Blame view

include/linux/ipv6.h 9.13 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
  #ifndef _IPV6_H
  #define _IPV6_H
607ca46e9   David Howells   UAPI: (Scripted) ...
4
  #include <uapi/linux/ipv6.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
6
  #define ipv6_optlen(p)  (((p)->hdrlen+1) << 3)
1431fb31e   Paul Durrant   xen-netback: fix ...
7
  #define ipv6_authlen(p) (((p)->hdrlen+2) << 2)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
9
10
11
12
13
14
15
16
17
18
19
20
  /*
   * This structure contains configuration options per IPv6 link.
   */
  struct ipv6_devconf {
  	__s32		forwarding;
  	__s32		hop_limit;
  	__s32		mtu6;
  	__s32		accept_ra;
  	__s32		accept_redirects;
  	__s32		autoconf;
  	__s32		dad_transmits;
  	__s32		rtr_solicits;
  	__s32		rtr_solicit_interval;
bd11f0741   Maciej Żenczykowski   ipv6 addrconf: im...
21
  	__s32		rtr_solicit_max_interval;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22
23
  	__s32		rtr_solicit_delay;
  	__s32		force_mld_version;
fc4eba58b   Hannes Frederic Sowa   ipv6: make unsoli...
24
25
  	__s32		mldv1_unsolicited_report_interval;
  	__s32		mldv2_unsolicited_report_interval;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
27
28
29
30
  	__s32		use_tempaddr;
  	__s32		temp_valid_lft;
  	__s32		temp_prefered_lft;
  	__s32		regen_max_retry;
  	__s32		max_desync_factor;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
  	__s32		max_addresses;
65f5c7c11   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
32
  	__s32		accept_ra_defrtr;
8013d1d7e   Hangbin Liu   net/ipv6: add sys...
33
  	__s32		accept_ra_min_hop_limit;
c4fd30eb1   YOSHIFUJI Hideaki   [IPV6]: ADDRCONF:...
34
  	__s32		accept_ra_pinfo;
35103d111   Andy Gospodarek   net: ipv6 sysctl ...
35
  	__s32		ignore_routes_with_linkdown;
930d6ff2e   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
36
37
  #ifdef CONFIG_IPV6_ROUTER_PREF
  	__s32		accept_ra_rtr_pref;
52e163563   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
38
  	__s32		rtr_probe_interval;
09c884d4c   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
39
  #ifdef CONFIG_IPV6_ROUTE_INFO
bbea124bc   Joel Scherpelz   net: ipv6: Add sy...
40
  	__s32		accept_ra_rt_info_min_plen;
09c884d4c   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
41
42
  	__s32		accept_ra_rt_info_max_plen;
  #endif
930d6ff2e   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
43
  #endif
fbea49e1e   YOSHIFUJI Hideaki   [IPV6] NDISC: Add...
44
  	__s32		proxy_ndp;
0bcbc9262   YOSHIFUJI Hideaki   [IPV6]: Disallow ...
45
  	__s32		accept_source_route;
d93331965   Ben Greear   ipv6: Allow accep...
46
  	__s32		accept_ra_from_local;
95c385b4d   Neil Horman   [IPV6] ADDRCONF: ...
47
48
  #ifdef CONFIG_IPV6_OPTIMISTIC_DAD
  	__s32		optimistic_dad;
7fd2561e4   Erik Kline   net: ipv6: Add a ...
49
  	__s32		use_optimistic;
95c385b4d   Neil Horman   [IPV6] ADDRCONF: ...
50
  #endif
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
51
52
53
  #ifdef CONFIG_IPV6_MROUTE
  	__s32		mc_forwarding;
  #endif
778d80be5   YOSHIFUJI Hideaki   ipv6: Add disable...
54
  	__s32		disable_ipv6;
abbc30436   Johannes Berg   ipv6: add option ...
55
  	__s32		drop_unicast_in_l2_multicast;
1b34be74c   YOSHIFUJI Hideaki   ipv6 addrconf: ad...
56
  	__s32		accept_dad;
f7734fdf6   Octavian Purdila   make TLLAO option...
57
  	__s32		force_tllao;
5cb04436e   Hannes Frederic Sowa   ipv6: add knob to...
58
  	__s32           ndisc_notify;
b800c3b96   Hannes Frederic Sowa   ipv6: drop fragme...
59
  	__s32		suppress_frag_ndisc;
c2943f145   Harout Hedeshian   net: ipv6: Add sy...
60
  	__s32		accept_ra_mtu;
7a02bf892   Johannes Berg   ipv6: add option ...
61
  	__s32		drop_unsolicited_na;
3d1bec993   Hannes Frederic Sowa   ipv6: introduce s...
62
63
64
65
  	struct ipv6_stable_secret {
  		bool initialized;
  		struct in6_addr secret;
  	} stable_secret;
3985e8a36   Erik Kline   ipv6: sysctl to r...
66
  	__s32		use_oif_addrs_only;
f1705ec19   David Ahern   net: ipv6: Make a...
67
  	__s32		keep_addr_on_down;
1ababeba4   David Lebrun   ipv6: implement d...
68
  	__s32		seg6_enabled;
bf355b8d2   David Lebrun   ipv6: sr: add cor...
69
70
71
  #ifdef CONFIG_IPV6_SEG6_HMAC
  	__s32		seg6_require_hmac;
  #endif
adc176c54   Erik Nordmark   ipv6 addrconf: Im...
72
  	__u32		enhanced_dad;
d35a00b8e   Felix Jia   net/ipv6: allow s...
73
  	__u32		addr_gen_mode;
df789fe75   David Forster   ipv6: Provide ipv...
74
  	__s32		disable_policy;
2210d6b2f   Maciej Żenczykowski   net: ipv6: sysctl...
75
  	__s32           ndisc_tclass;
607ea7cda   Konstantin Khlebnikov   net/ipv6/addrconf...
76
77
  
  	struct ctl_table_header *sysctl_header;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
78
  };
56d417b12   Brian Haley   IPv6: Add 'autoco...
79
80
81
82
83
84
  
  struct ipv6_params {
  	__s32 disable_ipv6;
  	__s32 autoconf;
  };
  extern struct ipv6_params ipv6_defaults;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
85
  #include <linux/icmpv6.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
86
87
  #include <linux/tcp.h>
  #include <linux/udp.h>
14c850212   Arnaldo Carvalho de Melo   [INET_SOCK]: Move...
88
  #include <net/inet_sock.h>
0660e03f6   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
89
90
91
92
  static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb)
  {
  	return (struct ipv6hdr *)skb_network_header(skb);
  }
6a674e9c7   Joseph Gasparakis   net: Add support ...
93
94
95
96
  static inline struct ipv6hdr *inner_ipv6_hdr(const struct sk_buff *skb)
  {
  	return (struct ipv6hdr *)skb_inner_network_header(skb);
  }
39b89160d   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
97
98
  static inline struct ipv6hdr *ipipv6_hdr(const struct sk_buff *skb)
  {
9c70220b7   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
99
  	return (struct ipv6hdr *)skb_transport_header(skb);
39b89160d   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
100
  }
ba5ea6146   Linus Lüssing   bridge: simplify ...
101
102
103
104
105
  static inline unsigned int ipv6_transport_len(const struct sk_buff *skb)
  {
  	return ntohs(ipv6_hdr(skb)->payload_len) + sizeof(struct ipv6hdr) -
  	       skb_network_header_len(skb);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106
107
108
109
110
111
112
  /* 
     This structure contains results of exthdrs parsing
     as offsets from skb->nh.
   */
  
  struct inet6_skb_parm {
  	int			iif;
dd3332bfc   YOSHIFUJI Hideaki / 吉藤英明   ipv6: Store Route...
113
  	__be16			ra;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
114
115
116
  	__u16			dst0;
  	__u16			srcrt;
  	__u16			dst1;
333fad536   YOSHIFUJI Hideaki   [IPV6]: Support s...
117
  	__u16			lastopt;
e7c38157c   David S. Miller   ipv6: Make IP6CB(...
118
  	__u16			nhoff;
3e3850e98   Patrick McHardy   [NETFILTER]: Fix ...
119
  	__u16			flags;
59fbb3a61   Masahide NAKAMURA   [IPV6] MIP6: Load...
120
  #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
8dd7368dd   David S. Miller   [IPV6]: Put dstha...
121
122
  	__u16			dsthao;
  #endif
4cdd34084   Patrick McHardy   netfilter: nf_con...
123
  	__u16			frag_max_size;
3e3850e98   Patrick McHardy   [NETFILTER]: Fix ...
124
125
  
  #define IP6SKB_XFRM_TRANSFORMED	1
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
126
  #define IP6SKB_FORWARDED	2
9c6eb28ac   Jan Engelhardt   netfilter: ipv6: ...
127
  #define IP6SKB_REROUTED		4
dd3332bfc   YOSHIFUJI Hideaki / 吉藤英明   ipv6: Store Route...
128
  #define IP6SKB_ROUTERALERT	8
f46078cfc   Hannes Frederic Sowa   ipv6: drop packet...
129
  #define IP6SKB_FRAGMENTED      16
8b58a3984   Florian Westphal   ipv6: use flag in...
130
  #define IP6SKB_HOPBYHOP        32
74b20582a   David Ahern   net: l3mdev: Add ...
131
  #define IP6SKB_L3SLAVE         64
cb891fa6a   Paolo Abeni   udp6: fix jumbogr...
132
  #define IP6SKB_JUMBOGRAM      128
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
133
  };
74b20582a   David Ahern   net: l3mdev: Add ...
134
  #if defined(CONFIG_NET_L3_MASTER_DEV)
a04a480d4   David Ahern   net: Require exac...
135
  static inline bool ipv6_l3mdev_skb(__u16 flags)
74b20582a   David Ahern   net: l3mdev: Add ...
136
137
138
139
  {
  	return flags & IP6SKB_L3SLAVE;
  }
  #else
a04a480d4   David Ahern   net: Require exac...
140
  static inline bool ipv6_l3mdev_skb(__u16 flags)
74b20582a   David Ahern   net: l3mdev: Add ...
141
142
143
144
  {
  	return false;
  }
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
145
  #define IP6CB(skb)	((struct inet6_skb_parm*)((skb)->cb))
4b340ae20   Brian Haley   IPv6: Complete IP...
146
  #define IP6CBMTU(skb)	((struct ip6_mtuinfo *)((skb)->cb))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
147

505cbfc57   Arnaldo Carvalho de Melo   [IPV6]: Generalis...
148
149
  static inline int inet6_iif(const struct sk_buff *skb)
  {
a04a480d4   David Ahern   net: Require exac...
150
  	bool l3_slave = ipv6_l3mdev_skb(IP6CB(skb)->flags);
74b20582a   David Ahern   net: l3mdev: Add ...
151
152
  
  	return l3_slave ? skb->skb_iif : IP6CB(skb)->iif;
505cbfc57   Arnaldo Carvalho de Melo   [IPV6]: Generalis...
153
  }
cb891fa6a   Paolo Abeni   udp6: fix jumbogr...
154
155
156
157
158
  
  static inline bool inet6_is_jumbogram(const struct sk_buff *skb)
  {
  	return !!(IP6CB(skb)->flags & IP6SKB_JUMBOGRAM);
  }
1801b570d   David Ahern   net: ipv6: add se...
159
160
161
162
163
164
165
166
167
168
  
  /* can not be used in TCP layer after tcp_v6_fill_cb */
  static inline int inet6_sdif(const struct sk_buff *skb)
  {
  #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
  	if (skb && ipv6_l3mdev_skb(IP6CB(skb)->flags))
  		return IP6CB(skb)->iif;
  #endif
  	return 0;
  }
505cbfc57   Arnaldo Carvalho de Melo   [IPV6]: Generalis...
169

a04a480d4   David Ahern   net: Require exac...
170
171
172
173
174
  /* can not be used in TCP layer after tcp_v6_fill_cb */
  static inline bool inet6_exact_dif_match(struct net *net, struct sk_buff *skb)
  {
  #if defined(CONFIG_NET_L3_MASTER_DEV)
  	if (!net->ipv4.sysctl_tcp_l3mdev_accept &&
da96786e2   David Ahern   net: tcp: check s...
175
  	    skb && ipv6_l3mdev_skb(IP6CB(skb)->flags))
a04a480d4   David Ahern   net: Require exac...
176
177
178
179
  		return true;
  #endif
  	return false;
  }
ca304b610   Arnaldo Carvalho de Melo   [IPV6]: Introduce...
180
181
  struct tcp6_request_sock {
  	struct tcp_request_sock	  tcp6rsk_tcp;
ca304b610   Arnaldo Carvalho de Melo   [IPV6]: Introduce...
182
  };
2e6599cb8   Arnaldo Carvalho de Melo   [NET] Generalise ...
183

20283d84c   Herbert Xu   [IPV6]: Remove ci...
184
185
186
  struct ipv6_mc_socklist;
  struct ipv6_ac_socklist;
  struct ipv6_fl_socklist;
366e41d97   Vlad Yasevich   ipv6: pull cork i...
187
188
189
190
191
  struct inet6_cork {
  	struct ipv6_txoptions *opt;
  	u8 hop_limit;
  	u8 tclass;
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
192
193
194
195
196
197
198
199
200
201
  /**
   * struct ipv6_pinfo - ipv6 private area
   *
   * In the struct sock hierarchy (tcp6_sock, upd6_sock, etc)
   * this _must_ be the last member, so that inet6_sk_generic
   * is able to calculate its offset from the base struct sock
   * by using the struct proto->slab_obj_size member. -acme
   */
  struct ipv6_pinfo {
  	struct in6_addr 	saddr;
b24a2516d   Yang Hongyang   ipv6: Add IPV6_PK...
202
  	struct in6_pktinfo	sticky_pktinfo;
d3818c92a   Eric Dumazet   ipv6: fix inet6_c...
203
  	const struct in6_addr		*daddr_cache;
8e1ef0a95   YOSHIFUJI Hideaki   [IPV6]: Cache sou...
204
  #ifdef CONFIG_IPV6_SUBTREES
d3818c92a   Eric Dumazet   ipv6: fix inet6_c...
205
  	const struct in6_addr		*saddr_cache;
8e1ef0a95   YOSHIFUJI Hideaki   [IPV6]: Cache sou...
206
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
207

90bcaf7b4   Al Viro   [IPV6]: flowlabel...
208
  	__be32			flow_label;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
209
  	__u32			frag_size;
1d5d236d3   YOSHIFUJI Hideaki   [IPV6]: Use bitfi...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
  
  	/*
  	 * Packed in 16bits.
  	 * Omit one shift by by putting the signed field at MSB.
  	 */
  #if defined(__BIG_ENDIAN_BITFIELD)
  	__s16			hop_limit:9;
  	__u16			__unused_1:7;
  #else
  	__u16			__unused_1:7;
  	__s16			hop_limit:9;
  #endif
  
  #if defined(__BIG_ENDIAN_BITFIELD)
  	/* Packed in 16bits. */
  	__s16			mcast_hops:9;
  	__u16			__unused_2:6,
  				mc_loop:1;
  #else
  	__u16			mc_loop:1,
  				__unused_2:6;
  	__s16			mcast_hops:9;
  #endif
c4062dfc4   Erich E. Hoover   ipv6: Implement I...
233
  	int			ucast_oif;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
234
235
236
237
238
  	int			mcast_oif;
  
  	/* pktoption flags */
  	union {
  		struct {
4c752098f   YOSHIFUJI Hideaki   [IPV6]: Make IPV6...
239
240
  			__u16	srcrt:1,
  				osrcrt:1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
241
  			        rxinfo:1,
333fad536   YOSHIFUJI Hideaki   [IPV6]: Support s...
242
  			        rxoinfo:1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
243
  				rxhlim:1,
333fad536   YOSHIFUJI Hideaki   [IPV6]: Support s...
244
  				rxohlim:1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
245
  				hopopts:1,
333fad536   YOSHIFUJI Hideaki   [IPV6]: Support s...
246
  				ohopopts:1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
247
  				dstopts:1,
333fad536   YOSHIFUJI Hideaki   [IPV6]: Support s...
248
  				odstopts:1,
41a1f8ea4   YOSHIFUJI Hideaki   [IPV6]: Support I...
249
                                  rxflow:1,
793b14731   Brian Haley   IPv6: data struct...
250
  				rxtclass:1,
6c4686228   Balazs Scheidler   tproxy: added tpr...
251
  				rxpmtu:1,
0cc0aa614   Willem de Bruijn   ipv6: add IPV6_RE...
252
253
254
  				rxorigdstaddr:1,
  				recvfragsize:1;
  				/* 1 bits hole */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
255
  		} bits;
333fad536   YOSHIFUJI Hideaki   [IPV6]: Support s...
256
  		__u16		all;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
257
258
259
  	} rxopt;
  
  	/* sockopt flags */
793b14731   Brian Haley   IPv6: data struct...
260
  	__u16			recverr:1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
261
  	                        sndflow:1,
df3687ffc   Florent Fourcot   ipv6: add the IPV...
262
  				repflow:1,
93b36cf34   Hannes Frederic Sowa   ipv6: support IPV...
263
  				pmtudisc:3,
9fe516ba3   Eric Dumazet   inet: move ipv6on...
264
  				padding:1,	/* 1 bit hole */
793b14731   Brian Haley   IPv6: data struct...
265
  				srcprefs:3,	/* 001: prefer temporary address
7cbca67c0   YOSHIFUJI Hideaki   [IPV6]: Support S...
266
267
268
  						 * 010: prefer public address
  						 * 100: prefer care-of address
  						 */
cb1ce2ef3   Tom Herbert   ipv6: Implement a...
269
  				dontfrag:1,
513674b5a   Shaohua Li   net: reevalulate ...
270
  				autoflowlabel:1,
15033f045   Andre Naujoks   ipv6: Add sockopt...
271
  				autoflowlabel_set:1,
9036b2fe0   Francesco Ruggeri   net: ipv6: add so...
272
273
  				mc_all:1,
  				rtalert_isolate:1;
e802af9ca   Stephen Hemminger   IPv6: Generic TTL...
274
  	__u8			min_hopcount;
41a1f8ea4   YOSHIFUJI Hideaki   [IPV6]: Support I...
275
  	__u8			tclass;
1397ed35f   Florent Fourcot   ipv6: add flowinf...
276
  	__be32			rcv_flowinfo;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
277
278
  
  	__u32			dst_cookie;
5d299f3d3   Eric Dumazet   net: ipv6: fix TC...
279
  	__u32			rx_dst_cookie;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
280

456b61bca   Eric Dumazet   ipv6: mcast: RCU ...
281
  	struct ipv6_mc_socklist	__rcu *ipv6_mc_list;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
282
  	struct ipv6_ac_socklist	*ipv6_ac_list;
18367681a   YOSHIFUJI Hideaki / 吉藤英明   ipv6 flowlabel: C...
283
  	struct ipv6_fl_socklist __rcu *ipv6_fl_list;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
284

45f6fad84   Eric Dumazet   ipv6: add complet...
285
  	struct ipv6_txoptions __rcu	*opt;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
286
  	struct sk_buff		*pktoptions;
4b340ae20   Brian Haley   IPv6: Complete IP...
287
  	struct sk_buff		*rxpmtu;
366e41d97   Vlad Yasevich   ipv6: pull cork i...
288
  	struct inet6_cork	cork;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
289
290
291
292
293
294
295
296
297
  };
  
  /* WARNING: don't change the layout of the members in {raw,udp,tcp}6_sock! */
  struct raw6_sock {
  	/* inet_sock has to be the first member of raw6_sock */
  	struct inet_sock	inet;
  	__u32			checksum;	/* perform checksum */
  	__u32			offset;		/* checksum offset  */
  	struct icmp6_filter	filter;
d1db275dd   Patrick McHardy   ipv6: ip6mr: supp...
298
  	__u32			ip6mr_table;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
  	/* ipv6_pinfo has to be the last member of raw6_sock, see inet6_sk_generic */
  	struct ipv6_pinfo	inet6;
  };
  
  struct udp6_sock {
  	struct udp_sock	  udp;
  	/* ipv6_pinfo has to be the last member of udp6_sock, see inet6_sk_generic */
  	struct ipv6_pinfo inet6;
  };
  
  struct tcp6_sock {
  	struct tcp_sock	  tcp;
  	/* ipv6_pinfo has to be the last member of tcp6_sock, see inet6_sk_generic */
  	struct ipv6_pinfo inet6;
  };
b9750ce13   Arnaldo Carvalho de Melo   [IPV6]: Generalis...
314
  extern int inet6_sk_rebuild_header(struct sock *sk);
48ee3569f   David S. Miller   ipv6: Move ipv6 t...
315
316
  struct tcp6_timewait_sock {
  	struct tcp_timewait_sock   tcp6tw_tcp;
48ee3569f   David S. Miller   ipv6: Move ipv6 t...
317
  };
dfd56b8b3   Eric Dumazet   net: use IS_ENABL...
318
  #if IS_ENABLED(CONFIG_IPV6)
e43486371   David Ahern   net: vrf: Fix cra...
319
  bool ipv6_mod_enabled(void);
e7eadb4de   Eric Dumazet   ipv6: inet6_sk() ...
320
  static inline struct ipv6_pinfo *inet6_sk(const struct sock *__sk)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
321
  {
e7eadb4de   Eric Dumazet   ipv6: inet6_sk() ...
322
  	return sk_fullsock(__sk) ? inet_sk(__sk)->pinet6 : NULL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
  }
  
  static inline struct raw6_sock *raw6_sk(const struct sock *sk)
  {
  	return (struct raw6_sock *)sk;
  }
  
  static inline void inet_sk_copy_descendant(struct sock *sk_to,
  					   const struct sock *sk_from)
  {
  	int ancestor_size = sizeof(struct inet_sock);
  
  	if (sk_from->sk_family == PF_INET6)
  		ancestor_size += sizeof(struct ipv6_pinfo);
  
  	__inet_sk_copy_descendant(sk_to, sk_from, ancestor_size);
  }
9fe516ba3   Eric Dumazet   inet: move ipv6on...
340
341
  #define __ipv6_only_sock(sk)	(sk->sk_ipv6only)
  #define ipv6_only_sock(sk)	(__ipv6_only_sock(sk))
4b261c75a   Hannes Frederic Sowa   ipv6: make IPV6_R...
342
343
  #define ipv6_sk_rxinfo(sk)	((sk)->sk_family == PF_INET6 && \
  				 inet6_sk(sk)->rxopt.bits.rxinfo)
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
344

efe4208f4   Eric Dumazet   ipv6: make lookup...
345
  static inline const struct in6_addr *inet6_rcv_saddr(const struct sock *sk)
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
346
  {
efe4208f4   Eric Dumazet   ipv6: make lookup...
347
348
349
  	if (sk->sk_family == AF_INET6)
  		return &sk->sk_v6_rcv_saddr;
  	return NULL;
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
350
  }
463c84b97   Arnaldo Carvalho de Melo   [NET]: Introduce ...
351
  static inline int inet_v6_ipv6only(const struct sock *sk)
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
352
  {
9fe516ba3   Eric Dumazet   inet: move ipv6on...
353
354
  	/* ipv6only field is at same position for timewait and other sockets */
  	return ipv6_only_sock(sk);
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
355
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
356
357
358
  #else
  #define __ipv6_only_sock(sk)	0
  #define ipv6_only_sock(sk)	0
4b261c75a   Hannes Frederic Sowa   ipv6: make IPV6_R...
359
  #define ipv6_sk_rxinfo(sk)	0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
360

e43486371   David Ahern   net: vrf: Fix cra...
361
362
363
364
  static inline bool ipv6_mod_enabled(void)
  {
  	return false;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
365
366
367
368
  static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk)
  {
  	return NULL;
  }
ca304b610   Arnaldo Carvalho de Melo   [IPV6]: Introduce...
369
370
371
372
373
  static inline struct inet6_request_sock *
  			inet6_rsk(const struct request_sock *rsk)
  {
  	return NULL;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
374
375
376
377
  static inline struct raw6_sock *raw6_sk(const struct sock *sk)
  {
  	return NULL;
  }
0fa1a53e1   Arnaldo Carvalho de Melo   [IPV6]: Introduce...
378
  #define inet6_rcv_saddr(__sk)	NULL
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
379
  #define tcp_twsk_ipv6only(__sk)		0
463c84b97   Arnaldo Carvalho de Melo   [NET]: Introduce ...
380
  #define inet_v6_ipv6only(__sk)		0
dfd56b8b3   Eric Dumazet   net: use IS_ENABL...
381
  #endif /* IS_ENABLED(CONFIG_IPV6) */
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
382
  #endif /* _IPV6_H */