]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _IPV6_H |
2 | #define _IPV6_H | |
3 | ||
607ca46e | 4 | #include <uapi/linux/ipv6.h> |
1da177e4 | 5 | |
1da177e4 | 6 | #define ipv6_optlen(p) (((p)->hdrlen+1) << 3) |
1431fb31 | 7 | #define ipv6_authlen(p) (((p)->hdrlen+2) << 2) |
1da177e4 LT |
8 | /* |
9 | * This structure contains configuration options per IPv6 link. | |
10 | */ | |
11 | struct ipv6_devconf { | |
12 | __s32 forwarding; | |
13 | __s32 hop_limit; | |
14 | __s32 mtu6; | |
15 | __s32 accept_ra; | |
16 | __s32 accept_redirects; | |
17 | __s32 autoconf; | |
18 | __s32 dad_transmits; | |
19 | __s32 rtr_solicits; | |
20 | __s32 rtr_solicit_interval; | |
bd11f074 | 21 | __s32 rtr_solicit_max_interval; |
1da177e4 LT |
22 | __s32 rtr_solicit_delay; |
23 | __s32 force_mld_version; | |
fc4eba58 HFS |
24 | __s32 mldv1_unsolicited_report_interval; |
25 | __s32 mldv2_unsolicited_report_interval; | |
1da177e4 LT |
26 | __s32 use_tempaddr; |
27 | __s32 temp_valid_lft; | |
28 | __s32 temp_prefered_lft; | |
29 | __s32 regen_max_retry; | |
30 | __s32 max_desync_factor; | |
1da177e4 | 31 | __s32 max_addresses; |
65f5c7c1 | 32 | __s32 accept_ra_defrtr; |
8013d1d7 | 33 | __s32 accept_ra_min_hop_limit; |
c4fd30eb | 34 | __s32 accept_ra_pinfo; |
35103d11 | 35 | __s32 ignore_routes_with_linkdown; |
930d6ff2 YH |
36 | #ifdef CONFIG_IPV6_ROUTER_PREF |
37 | __s32 accept_ra_rtr_pref; | |
52e16356 | 38 | __s32 rtr_probe_interval; |
09c884d4 YH |
39 | #ifdef CONFIG_IPV6_ROUTE_INFO |
40 | __s32 accept_ra_rt_info_max_plen; | |
41 | #endif | |
930d6ff2 | 42 | #endif |
fbea49e1 | 43 | __s32 proxy_ndp; |
0bcbc926 | 44 | __s32 accept_source_route; |
d9333196 | 45 | __s32 accept_ra_from_local; |
95c385b4 NH |
46 | #ifdef CONFIG_IPV6_OPTIMISTIC_DAD |
47 | __s32 optimistic_dad; | |
7fd2561e | 48 | __s32 use_optimistic; |
7bc570c8 YH |
49 | #endif |
50 | #ifdef CONFIG_IPV6_MROUTE | |
51 | __s32 mc_forwarding; | |
95c385b4 | 52 | #endif |
778d80be | 53 | __s32 disable_ipv6; |
abbc3043 | 54 | __s32 drop_unicast_in_l2_multicast; |
1b34be74 | 55 | __s32 accept_dad; |
f7734fdf | 56 | __s32 force_tllao; |
5cb04436 | 57 | __s32 ndisc_notify; |
b800c3b9 | 58 | __s32 suppress_frag_ndisc; |
c2943f14 | 59 | __s32 accept_ra_mtu; |
7a02bf89 | 60 | __s32 drop_unsolicited_na; |
3d1bec99 HFS |
61 | struct ipv6_stable_secret { |
62 | bool initialized; | |
63 | struct in6_addr secret; | |
64 | } stable_secret; | |
3985e8a3 | 65 | __s32 use_oif_addrs_only; |
f1705ec1 | 66 | __s32 keep_addr_on_down; |
1ababeba | 67 | __s32 seg6_enabled; |
bf355b8d DL |
68 | #ifdef CONFIG_IPV6_SEG6_HMAC |
69 | __s32 seg6_require_hmac; | |
70 | #endif | |
607ea7cd KK |
71 | |
72 | struct ctl_table_header *sysctl_header; | |
1da177e4 | 73 | }; |
56d417b1 BH |
74 | |
75 | struct ipv6_params { | |
76 | __s32 disable_ipv6; | |
77 | __s32 autoconf; | |
78 | }; | |
79 | extern struct ipv6_params ipv6_defaults; | |
1da177e4 | 80 | #include <linux/icmpv6.h> |
1da177e4 LT |
81 | #include <linux/tcp.h> |
82 | #include <linux/udp.h> | |
83 | ||
14c85021 ACM |
84 | #include <net/inet_sock.h> |
85 | ||
0660e03f ACM |
86 | static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb) |
87 | { | |
88 | return (struct ipv6hdr *)skb_network_header(skb); | |
89 | } | |
90 | ||
6a674e9c JG |
91 | static inline struct ipv6hdr *inner_ipv6_hdr(const struct sk_buff *skb) |
92 | { | |
93 | return (struct ipv6hdr *)skb_inner_network_header(skb); | |
94 | } | |
95 | ||
39b89160 ACM |
96 | static inline struct ipv6hdr *ipipv6_hdr(const struct sk_buff *skb) |
97 | { | |
9c70220b | 98 | return (struct ipv6hdr *)skb_transport_header(skb); |
39b89160 ACM |
99 | } |
100 | ||
1da177e4 LT |
101 | /* |
102 | This structure contains results of exthdrs parsing | |
103 | as offsets from skb->nh. | |
104 | */ | |
105 | ||
106 | struct inet6_skb_parm { | |
107 | int iif; | |
dd3332bf | 108 | __be16 ra; |
1da177e4 LT |
109 | __u16 dst0; |
110 | __u16 srcrt; | |
111 | __u16 dst1; | |
333fad53 | 112 | __u16 lastopt; |
e7c38157 | 113 | __u16 nhoff; |
3e3850e9 | 114 | __u16 flags; |
59fbb3a6 | 115 | #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) |
8dd7368d DM |
116 | __u16 dsthao; |
117 | #endif | |
4cdd3408 | 118 | __u16 frag_max_size; |
3e3850e9 PM |
119 | |
120 | #define IP6SKB_XFRM_TRANSFORMED 1 | |
7bc570c8 | 121 | #define IP6SKB_FORWARDED 2 |
9c6eb28a | 122 | #define IP6SKB_REROUTED 4 |
dd3332bf | 123 | #define IP6SKB_ROUTERALERT 8 |
f46078cf | 124 | #define IP6SKB_FRAGMENTED 16 |
8b58a398 | 125 | #define IP6SKB_HOPBYHOP 32 |
74b20582 | 126 | #define IP6SKB_L3SLAVE 64 |
1da177e4 LT |
127 | }; |
128 | ||
74b20582 | 129 | #if defined(CONFIG_NET_L3_MASTER_DEV) |
a04a480d | 130 | static inline bool ipv6_l3mdev_skb(__u16 flags) |
74b20582 DA |
131 | { |
132 | return flags & IP6SKB_L3SLAVE; | |
133 | } | |
134 | #else | |
a04a480d | 135 | static inline bool ipv6_l3mdev_skb(__u16 flags) |
74b20582 DA |
136 | { |
137 | return false; | |
138 | } | |
139 | #endif | |
140 | ||
1da177e4 | 141 | #define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb)) |
4b340ae2 | 142 | #define IP6CBMTU(skb) ((struct ip6_mtuinfo *)((skb)->cb)) |
1da177e4 | 143 | |
505cbfc5 ACM |
144 | static inline int inet6_iif(const struct sk_buff *skb) |
145 | { | |
a04a480d | 146 | bool l3_slave = ipv6_l3mdev_skb(IP6CB(skb)->flags); |
74b20582 DA |
147 | |
148 | return l3_slave ? skb->skb_iif : IP6CB(skb)->iif; | |
505cbfc5 ACM |
149 | } |
150 | ||
a04a480d DA |
151 | /* can not be used in TCP layer after tcp_v6_fill_cb */ |
152 | static inline bool inet6_exact_dif_match(struct net *net, struct sk_buff *skb) | |
153 | { | |
154 | #if defined(CONFIG_NET_L3_MASTER_DEV) | |
155 | if (!net->ipv4.sysctl_tcp_l3mdev_accept && | |
da96786e | 156 | skb && ipv6_l3mdev_skb(IP6CB(skb)->flags)) |
a04a480d DA |
157 | return true; |
158 | #endif | |
159 | return false; | |
160 | } | |
161 | ||
ca304b61 ACM |
162 | struct tcp6_request_sock { |
163 | struct tcp_request_sock tcp6rsk_tcp; | |
ca304b61 | 164 | }; |
2e6599cb | 165 | |
20283d84 HX |
166 | struct ipv6_mc_socklist; |
167 | struct ipv6_ac_socklist; | |
168 | struct ipv6_fl_socklist; | |
169 | ||
366e41d9 VY |
170 | struct inet6_cork { |
171 | struct ipv6_txoptions *opt; | |
172 | u8 hop_limit; | |
173 | u8 tclass; | |
174 | }; | |
175 | ||
1da177e4 LT |
176 | /** |
177 | * struct ipv6_pinfo - ipv6 private area | |
178 | * | |
179 | * In the struct sock hierarchy (tcp6_sock, upd6_sock, etc) | |
180 | * this _must_ be the last member, so that inet6_sk_generic | |
181 | * is able to calculate its offset from the base struct sock | |
182 | * by using the struct proto->slab_obj_size member. -acme | |
183 | */ | |
184 | struct ipv6_pinfo { | |
185 | struct in6_addr saddr; | |
b24a2516 | 186 | struct in6_pktinfo sticky_pktinfo; |
d3818c92 | 187 | const struct in6_addr *daddr_cache; |
8e1ef0a9 | 188 | #ifdef CONFIG_IPV6_SUBTREES |
d3818c92 | 189 | const struct in6_addr *saddr_cache; |
8e1ef0a9 | 190 | #endif |
1da177e4 | 191 | |
90bcaf7b | 192 | __be32 flow_label; |
1da177e4 | 193 | __u32 frag_size; |
1d5d236d YH |
194 | |
195 | /* | |
196 | * Packed in 16bits. | |
197 | * Omit one shift by by putting the signed field at MSB. | |
198 | */ | |
199 | #if defined(__BIG_ENDIAN_BITFIELD) | |
200 | __s16 hop_limit:9; | |
201 | __u16 __unused_1:7; | |
202 | #else | |
203 | __u16 __unused_1:7; | |
204 | __s16 hop_limit:9; | |
205 | #endif | |
206 | ||
207 | #if defined(__BIG_ENDIAN_BITFIELD) | |
208 | /* Packed in 16bits. */ | |
209 | __s16 mcast_hops:9; | |
210 | __u16 __unused_2:6, | |
211 | mc_loop:1; | |
212 | #else | |
213 | __u16 mc_loop:1, | |
214 | __unused_2:6; | |
215 | __s16 mcast_hops:9; | |
216 | #endif | |
c4062dfc | 217 | int ucast_oif; |
1da177e4 LT |
218 | int mcast_oif; |
219 | ||
220 | /* pktoption flags */ | |
221 | union { | |
222 | struct { | |
4c752098 YH |
223 | __u16 srcrt:1, |
224 | osrcrt:1, | |
1da177e4 | 225 | rxinfo:1, |
333fad53 | 226 | rxoinfo:1, |
1da177e4 | 227 | rxhlim:1, |
333fad53 | 228 | rxohlim:1, |
1da177e4 | 229 | hopopts:1, |
333fad53 | 230 | ohopopts:1, |
1da177e4 | 231 | dstopts:1, |
333fad53 | 232 | odstopts:1, |
41a1f8ea | 233 | rxflow:1, |
793b1473 | 234 | rxtclass:1, |
6c468622 | 235 | rxpmtu:1, |
0cc0aa61 WB |
236 | rxorigdstaddr:1, |
237 | recvfragsize:1; | |
238 | /* 1 bits hole */ | |
1da177e4 | 239 | } bits; |
333fad53 | 240 | __u16 all; |
1da177e4 LT |
241 | } rxopt; |
242 | ||
243 | /* sockopt flags */ | |
793b1473 | 244 | __u16 recverr:1, |
1da177e4 | 245 | sndflow:1, |
df3687ff | 246 | repflow:1, |
93b36cf3 | 247 | pmtudisc:3, |
9fe516ba | 248 | padding:1, /* 1 bit hole */ |
793b1473 | 249 | srcprefs:3, /* 001: prefer temporary address |
7cbca67c YH |
250 | * 010: prefer public address |
251 | * 100: prefer care-of address | |
252 | */ | |
cb1ce2ef TH |
253 | dontfrag:1, |
254 | autoflowlabel:1; | |
e802af9c | 255 | __u8 min_hopcount; |
41a1f8ea | 256 | __u8 tclass; |
1397ed35 | 257 | __be32 rcv_flowinfo; |
1da177e4 LT |
258 | |
259 | __u32 dst_cookie; | |
5d299f3d | 260 | __u32 rx_dst_cookie; |
1da177e4 | 261 | |
456b61bc | 262 | struct ipv6_mc_socklist __rcu *ipv6_mc_list; |
1da177e4 | 263 | struct ipv6_ac_socklist *ipv6_ac_list; |
18367681 | 264 | struct ipv6_fl_socklist __rcu *ipv6_fl_list; |
1da177e4 | 265 | |
45f6fad8 | 266 | struct ipv6_txoptions __rcu *opt; |
1da177e4 | 267 | struct sk_buff *pktoptions; |
4b340ae2 | 268 | struct sk_buff *rxpmtu; |
366e41d9 | 269 | struct inet6_cork cork; |
1da177e4 LT |
270 | }; |
271 | ||
272 | /* WARNING: don't change the layout of the members in {raw,udp,tcp}6_sock! */ | |
273 | struct raw6_sock { | |
274 | /* inet_sock has to be the first member of raw6_sock */ | |
275 | struct inet_sock inet; | |
276 | __u32 checksum; /* perform checksum */ | |
277 | __u32 offset; /* checksum offset */ | |
278 | struct icmp6_filter filter; | |
d1db275d | 279 | __u32 ip6mr_table; |
1da177e4 LT |
280 | /* ipv6_pinfo has to be the last member of raw6_sock, see inet6_sk_generic */ |
281 | struct ipv6_pinfo inet6; | |
282 | }; | |
283 | ||
284 | struct udp6_sock { | |
285 | struct udp_sock udp; | |
286 | /* ipv6_pinfo has to be the last member of udp6_sock, see inet6_sk_generic */ | |
287 | struct ipv6_pinfo inet6; | |
288 | }; | |
289 | ||
290 | struct tcp6_sock { | |
291 | struct tcp_sock tcp; | |
292 | /* ipv6_pinfo has to be the last member of tcp6_sock, see inet6_sk_generic */ | |
293 | struct ipv6_pinfo inet6; | |
294 | }; | |
295 | ||
b9750ce1 ACM |
296 | extern int inet6_sk_rebuild_header(struct sock *sk); |
297 | ||
48ee3569 DM |
298 | struct tcp6_timewait_sock { |
299 | struct tcp_timewait_sock tcp6tw_tcp; | |
48ee3569 DM |
300 | }; |
301 | ||
dfd56b8b | 302 | #if IS_ENABLED(CONFIG_IPV6) |
e4348637 DA |
303 | bool ipv6_mod_enabled(void); |
304 | ||
e7eadb4d | 305 | static inline struct ipv6_pinfo *inet6_sk(const struct sock *__sk) |
1da177e4 | 306 | { |
e7eadb4d | 307 | return sk_fullsock(__sk) ? inet_sk(__sk)->pinet6 : NULL; |
1da177e4 LT |
308 | } |
309 | ||
310 | static inline struct raw6_sock *raw6_sk(const struct sock *sk) | |
311 | { | |
312 | return (struct raw6_sock *)sk; | |
313 | } | |
314 | ||
315 | static inline void inet_sk_copy_descendant(struct sock *sk_to, | |
316 | const struct sock *sk_from) | |
317 | { | |
318 | int ancestor_size = sizeof(struct inet_sock); | |
319 | ||
320 | if (sk_from->sk_family == PF_INET6) | |
321 | ancestor_size += sizeof(struct ipv6_pinfo); | |
322 | ||
323 | __inet_sk_copy_descendant(sk_to, sk_from, ancestor_size); | |
324 | } | |
325 | ||
9fe516ba ED |
326 | #define __ipv6_only_sock(sk) (sk->sk_ipv6only) |
327 | #define ipv6_only_sock(sk) (__ipv6_only_sock(sk)) | |
4b261c75 HFS |
328 | #define ipv6_sk_rxinfo(sk) ((sk)->sk_family == PF_INET6 && \ |
329 | inet6_sk(sk)->rxopt.bits.rxinfo) | |
8feaf0c0 | 330 | |
efe4208f | 331 | static inline const struct in6_addr *inet6_rcv_saddr(const struct sock *sk) |
8feaf0c0 | 332 | { |
efe4208f ED |
333 | if (sk->sk_family == AF_INET6) |
334 | return &sk->sk_v6_rcv_saddr; | |
335 | return NULL; | |
8feaf0c0 ACM |
336 | } |
337 | ||
463c84b9 | 338 | static inline int inet_v6_ipv6only(const struct sock *sk) |
8feaf0c0 | 339 | { |
9fe516ba ED |
340 | /* ipv6only field is at same position for timewait and other sockets */ |
341 | return ipv6_only_sock(sk); | |
8feaf0c0 | 342 | } |
1da177e4 LT |
343 | #else |
344 | #define __ipv6_only_sock(sk) 0 | |
345 | #define ipv6_only_sock(sk) 0 | |
4b261c75 | 346 | #define ipv6_sk_rxinfo(sk) 0 |
1da177e4 | 347 | |
e4348637 DA |
348 | static inline bool ipv6_mod_enabled(void) |
349 | { | |
350 | return false; | |
351 | } | |
352 | ||
1da177e4 LT |
353 | static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk) |
354 | { | |
355 | return NULL; | |
356 | } | |
357 | ||
ca304b61 ACM |
358 | static inline struct inet6_request_sock * |
359 | inet6_rsk(const struct request_sock *rsk) | |
360 | { | |
361 | return NULL; | |
362 | } | |
363 | ||
1da177e4 LT |
364 | static inline struct raw6_sock *raw6_sk(const struct sock *sk) |
365 | { | |
366 | return NULL; | |
367 | } | |
368 | ||
0fa1a53e | 369 | #define inet6_rcv_saddr(__sk) NULL |
8feaf0c0 | 370 | #define tcp_twsk_ipv6only(__sk) 0 |
463c84b9 | 371 | #define inet_v6_ipv6only(__sk) 0 |
dfd56b8b | 372 | #endif /* IS_ENABLED(CONFIG_IPV6) */ |
8feaf0c0 | 373 | #endif /* _IPV6_H */ |