~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/net/inet_sock.h

Version: ~ [ linux-5.2-rc1 ] ~ [ linux-5.1.2 ] ~ [ linux-5.0.16 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.43 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.119 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.176 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.179 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.139 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.67 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * INET         An implementation of the TCP/IP protocol suite for the LINUX
  3  *              operating system.  INET is implemented using the  BSD Socket
  4  *              interface as the means of communication with the user level.
  5  *
  6  *              Definitions for inet_sock
  7  *
  8  * Authors:     Many, reorganised here by
  9  *              Arnaldo Carvalho de Melo <acme@mandriva.com>
 10  *
 11  *              This program is free software; you can redistribute it and/or
 12  *              modify it under the terms of the GNU General Public License
 13  *              as published by the Free Software Foundation; either version
 14  *              2 of the License, or (at your option) any later version.
 15  */
 16 #ifndef _INET_SOCK_H
 17 #define _INET_SOCK_H
 18 
 19 
 20 #include <linux/kmemcheck.h>
 21 #include <linux/string.h>
 22 #include <linux/types.h>
 23 #include <linux/jhash.h>
 24 
 25 #include <net/flow.h>
 26 #include <net/sock.h>
 27 #include <net/request_sock.h>
 28 #include <net/netns/hash.h>
 29 
 30 /** struct ip_options - IP Options
 31  *
 32  * @faddr - Saved first hop address
 33  * @is_data - Options in __data, rather than skb
 34  * @is_strictroute - Strict source route
 35  * @srr_is_hit - Packet destination addr was our one
 36  * @is_changed - IP checksum more not valid
 37  * @rr_needaddr - Need to record addr of outgoing dev
 38  * @ts_needtime - Need to record timestamp
 39  * @ts_needaddr - Need to record addr of outgoing dev
 40  */
 41 struct ip_options {
 42         __be32          faddr;
 43         unsigned char   optlen;
 44         unsigned char   srr;
 45         unsigned char   rr;
 46         unsigned char   ts;
 47         unsigned char   is_strictroute:1,
 48                         srr_is_hit:1,
 49                         is_changed:1,
 50                         rr_needaddr:1,
 51                         ts_needtime:1,
 52                         ts_needaddr:1;
 53         unsigned char   router_alert;
 54         unsigned char   cipso;
 55         unsigned char   __pad2;
 56         unsigned char   __data[0];
 57 };
 58 
 59 struct ip_options_rcu {
 60         struct rcu_head rcu;
 61         struct ip_options opt;
 62 };
 63 
 64 struct ip_options_data {
 65         struct ip_options_rcu   opt;
 66         char                    data[40];
 67 };
 68 
 69 struct inet_request_sock {
 70         struct request_sock     req;
 71 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
 72         u16                     inet6_rsk_offset;
 73 #endif
 74         __be16                  loc_port;
 75         __be32                  loc_addr;
 76         __be32                  rmt_addr;
 77         __be16                  rmt_port;
 78         kmemcheck_bitfield_begin(flags);
 79         u16                     snd_wscale : 4,
 80                                 rcv_wscale : 4,
 81                                 tstamp_ok  : 1,
 82                                 sack_ok    : 1,
 83                                 wscale_ok  : 1,
 84                                 ecn_ok     : 1,
 85                                 acked      : 1,
 86                                 no_srccheck: 1;
 87         kmemcheck_bitfield_end(flags);
 88         struct ip_options_rcu   *opt;
 89 };
 90 
 91 static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk)
 92 {
 93         return (struct inet_request_sock *)sk;
 94 }
 95 
 96 struct ip_mc_socklist;
 97 struct ipv6_pinfo;
 98 struct rtable;
 99 
100 /** struct inet_sock - representation of INET sockets
101  *
102  * @sk - ancestor class
103  * @pinet6 - pointer to IPv6 control block
104  * @daddr - Foreign IPv4 addr
105  * @rcv_saddr - Bound local IPv4 addr
106  * @dport - Destination port
107  * @num - Local port
108  * @saddr - Sending source
109  * @uc_ttl - Unicast TTL
110  * @sport - Source port
111  * @id - ID counter for DF pkts
112  * @tos - TOS
113  * @mc_ttl - Multicasting TTL
114  * @is_icsk - is this an inet_connection_sock?
115  * @mc_index - Multicast device index
116  * @mc_list - Group array
117  * @cork - info to build ip hdr on each ip frag while socket is corked
118  */
119 struct inet_sock {
120         /* sk and pinet6 has to be the first two members of inet_sock */
121         struct sock             sk;
122 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
123         struct ipv6_pinfo       *pinet6;
124 #endif
125         /* Socket demultiplex comparisons on incoming packets. */
126         __be32                  daddr;
127         __be32                  rcv_saddr;
128         __be16                  dport;
129         __u16                   num;
130         __be32                  saddr;
131         __s16                   uc_ttl;
132         __u16                   cmsg_flags;
133         struct ip_options_rcu   *inet_opt;
134         __be16                  sport;
135         __u16                   id;
136         __u8                    tos;
137         __u8                    mc_ttl;
138         __u8                    pmtudisc;
139         __u8                    recverr:1,
140                                 is_icsk:1,
141                                 freebind:1,
142                                 hdrincl:1,
143                                 mc_loop:1,
144                                 transparent:1,
145                                 mc_all:1;
146         int                     mc_index;
147         __be32                  mc_addr;
148         struct ip_mc_socklist   *mc_list;
149         struct {
150                 unsigned int            flags;
151                 unsigned int            fragsize;
152                 struct ip_options       *opt;
153                 struct dst_entry        *dst;
154                 int                     length; /* Total length of all frames */
155                 __be32                  addr;
156                 struct flowi            fl;
157         } cork;
158 };
159 
160 #define IPCORK_OPT      1       /* ip-options has been held in ipcork.opt */
161 #define IPCORK_ALLFRAG  2       /* always fragment (for ipv6 for now) */
162 
163 static inline struct inet_sock *inet_sk(const struct sock *sk)
164 {
165         return (struct inet_sock *)sk;
166 }
167 
168 static inline void __inet_sk_copy_descendant(struct sock *sk_to,
169                                              const struct sock *sk_from,
170                                              const int ancestor_size)
171 {
172         memcpy(inet_sk(sk_to) + 1, inet_sk(sk_from) + 1,
173                sk_from->sk_prot->obj_size - ancestor_size);
174 }
175 #if !(defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE))
176 static inline void inet_sk_copy_descendant(struct sock *sk_to,
177                                            const struct sock *sk_from)
178 {
179         __inet_sk_copy_descendant(sk_to, sk_from, sizeof(struct inet_sock));
180 }
181 #endif
182 
183 extern int inet_sk_rebuild_header(struct sock *sk);
184 
185 extern u32 inet_ehash_secret;
186 extern void build_ehash_secret(void);
187 
188 static inline unsigned int inet_ehashfn(struct net *net,
189                                         const __be32 laddr, const __u16 lport,
190                                         const __be32 faddr, const __be16 fport)
191 {
192         return jhash_3words((__force __u32) laddr,
193                             (__force __u32) faddr,
194                             ((__u32) lport) << 16 | (__force __u32)fport,
195                             inet_ehash_secret + net_hash_mix(net));
196 }
197 
198 static inline int inet_sk_ehashfn(const struct sock *sk)
199 {
200         const struct inet_sock *inet = inet_sk(sk);
201         const __be32 laddr = inet->rcv_saddr;
202         const __u16 lport = inet->num;
203         const __be32 faddr = inet->daddr;
204         const __be16 fport = inet->dport;
205         struct net *net = sock_net(sk);
206 
207         return inet_ehashfn(net, laddr, lport, faddr, fport);
208 }
209 
210 static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops)
211 {
212         struct request_sock *req = reqsk_alloc(ops);
213         struct inet_request_sock *ireq = inet_rsk(req);
214 
215         if (req != NULL) {
216                 kmemcheck_annotate_bitfield(ireq, flags);
217                 ireq->opt = NULL;
218         }
219 
220         return req;
221 }
222 
223 static inline __u8 inet_sk_flowi_flags(const struct sock *sk)
224 {
225         return inet_sk(sk)->transparent ? FLOWI_FLAG_ANYSRC : 0;
226 }
227 
228 #endif  /* _INET_SOCK_H */
229 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp