Blame view
include/linux/ipv6.h
9.13 KB
b24413180
|
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4c
|
2 3 |
#ifndef _IPV6_H #define _IPV6_H |
607ca46e9
|
4 |
#include <uapi/linux/ipv6.h> |
1da177e4c
|
5 |
|
1da177e4c
|
6 |
#define ipv6_optlen(p) (((p)->hdrlen+1) << 3) |
1431fb31e
|
7 |
#define ipv6_authlen(p) (((p)->hdrlen+2) << 2) |
1da177e4c
|
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
|
21 |
__s32 rtr_solicit_max_interval; |
1da177e4c
|
22 23 |
__s32 rtr_solicit_delay; __s32 force_mld_version; |
fc4eba58b
|
24 25 |
__s32 mldv1_unsolicited_report_interval; __s32 mldv2_unsolicited_report_interval; |
1da177e4c
|
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
|
31 |
__s32 max_addresses; |
65f5c7c11
|
32 |
__s32 accept_ra_defrtr; |
8013d1d7e
|
33 |
__s32 accept_ra_min_hop_limit; |
c4fd30eb1
|
34 |
__s32 accept_ra_pinfo; |
35103d111
|
35 |
__s32 ignore_routes_with_linkdown; |
930d6ff2e
|
36 37 |
#ifdef CONFIG_IPV6_ROUTER_PREF __s32 accept_ra_rtr_pref; |
52e163563
|
38 |
__s32 rtr_probe_interval; |
09c884d4c
|
39 |
#ifdef CONFIG_IPV6_ROUTE_INFO |
bbea124bc
|
40 |
__s32 accept_ra_rt_info_min_plen; |
09c884d4c
|
41 42 |
__s32 accept_ra_rt_info_max_plen; #endif |
930d6ff2e
|
43 |
#endif |
fbea49e1e
|
44 |
__s32 proxy_ndp; |
0bcbc9262
|
45 |
__s32 accept_source_route; |
d93331965
|
46 |
__s32 accept_ra_from_local; |
95c385b4d
|
47 48 |
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD __s32 optimistic_dad; |
7fd2561e4
|
49 |
__s32 use_optimistic; |
95c385b4d
|
50 |
#endif |
7bc570c8b
|
51 52 53 |
#ifdef CONFIG_IPV6_MROUTE __s32 mc_forwarding; #endif |
778d80be5
|
54 |
__s32 disable_ipv6; |
abbc30436
|
55 |
__s32 drop_unicast_in_l2_multicast; |
1b34be74c
|
56 |
__s32 accept_dad; |
f7734fdf6
|
57 |
__s32 force_tllao; |
5cb04436e
|
58 |
__s32 ndisc_notify; |
b800c3b96
|
59 |
__s32 suppress_frag_ndisc; |
c2943f145
|
60 |
__s32 accept_ra_mtu; |
7a02bf892
|
61 |
__s32 drop_unsolicited_na; |
3d1bec993
|
62 63 64 65 |
struct ipv6_stable_secret { bool initialized; struct in6_addr secret; } stable_secret; |
3985e8a36
|
66 |
__s32 use_oif_addrs_only; |
f1705ec19
|
67 |
__s32 keep_addr_on_down; |
1ababeba4
|
68 |
__s32 seg6_enabled; |
bf355b8d2
|
69 70 71 |
#ifdef CONFIG_IPV6_SEG6_HMAC __s32 seg6_require_hmac; #endif |
adc176c54
|
72 |
__u32 enhanced_dad; |
d35a00b8e
|
73 |
__u32 addr_gen_mode; |
df789fe75
|
74 |
__s32 disable_policy; |
2210d6b2f
|
75 |
__s32 ndisc_tclass; |
607ea7cda
|
76 77 |
struct ctl_table_header *sysctl_header; |
1da177e4c
|
78 |
}; |
56d417b12
|
79 80 81 82 83 84 |
struct ipv6_params { __s32 disable_ipv6; __s32 autoconf; }; extern struct ipv6_params ipv6_defaults; |
1da177e4c
|
85 |
#include <linux/icmpv6.h> |
1da177e4c
|
86 87 |
#include <linux/tcp.h> #include <linux/udp.h> |
14c850212
|
88 |
#include <net/inet_sock.h> |
0660e03f6
|
89 90 91 92 |
static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb) { return (struct ipv6hdr *)skb_network_header(skb); } |
6a674e9c7
|
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
|
97 98 |
static inline struct ipv6hdr *ipipv6_hdr(const struct sk_buff *skb) { |
9c70220b7
|
99 |
return (struct ipv6hdr *)skb_transport_header(skb); |
39b89160d
|
100 |
} |
ba5ea6146
|
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
|
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
|
113 |
__be16 ra; |
1da177e4c
|
114 115 116 |
__u16 dst0; __u16 srcrt; __u16 dst1; |
333fad536
|
117 |
__u16 lastopt; |
e7c38157c
|
118 |
__u16 nhoff; |
3e3850e98
|
119 |
__u16 flags; |
59fbb3a61
|
120 |
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) |
8dd7368dd
|
121 122 |
__u16 dsthao; #endif |
4cdd34084
|
123 |
__u16 frag_max_size; |
3e3850e98
|
124 125 |
#define IP6SKB_XFRM_TRANSFORMED 1 |
7bc570c8b
|
126 |
#define IP6SKB_FORWARDED 2 |
9c6eb28ac
|
127 |
#define IP6SKB_REROUTED 4 |
dd3332bfc
|
128 |
#define IP6SKB_ROUTERALERT 8 |
f46078cfc
|
129 |
#define IP6SKB_FRAGMENTED 16 |
8b58a3984
|
130 |
#define IP6SKB_HOPBYHOP 32 |
74b20582a
|
131 |
#define IP6SKB_L3SLAVE 64 |
cb891fa6a
|
132 |
#define IP6SKB_JUMBOGRAM 128 |
1da177e4c
|
133 |
}; |
74b20582a
|
134 |
#if defined(CONFIG_NET_L3_MASTER_DEV) |
a04a480d4
|
135 |
static inline bool ipv6_l3mdev_skb(__u16 flags) |
74b20582a
|
136 137 138 139 |
{ return flags & IP6SKB_L3SLAVE; } #else |
a04a480d4
|
140 |
static inline bool ipv6_l3mdev_skb(__u16 flags) |
74b20582a
|
141 142 143 144 |
{ return false; } #endif |
1da177e4c
|
145 |
#define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb)) |
4b340ae20
|
146 |
#define IP6CBMTU(skb) ((struct ip6_mtuinfo *)((skb)->cb)) |
1da177e4c
|
147 |
|
505cbfc57
|
148 149 |
static inline int inet6_iif(const struct sk_buff *skb) { |
a04a480d4
|
150 |
bool l3_slave = ipv6_l3mdev_skb(IP6CB(skb)->flags); |
74b20582a
|
151 152 |
return l3_slave ? skb->skb_iif : IP6CB(skb)->iif; |
505cbfc57
|
153 |
} |
cb891fa6a
|
154 155 156 157 158 |
static inline bool inet6_is_jumbogram(const struct sk_buff *skb) { return !!(IP6CB(skb)->flags & IP6SKB_JUMBOGRAM); } |
1801b570d
|
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
|
169 |
|
a04a480d4
|
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
|
175 |
skb && ipv6_l3mdev_skb(IP6CB(skb)->flags)) |
a04a480d4
|
176 177 178 179 |
return true; #endif return false; } |
ca304b610
|
180 181 |
struct tcp6_request_sock { struct tcp_request_sock tcp6rsk_tcp; |
ca304b610
|
182 |
}; |
2e6599cb8
|
183 |
|
20283d84c
|
184 185 186 |
struct ipv6_mc_socklist; struct ipv6_ac_socklist; struct ipv6_fl_socklist; |
366e41d97
|
187 188 189 190 191 |
struct inet6_cork { struct ipv6_txoptions *opt; u8 hop_limit; u8 tclass; }; |
1da177e4c
|
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
|
202 |
struct in6_pktinfo sticky_pktinfo; |
d3818c92a
|
203 |
const struct in6_addr *daddr_cache; |
8e1ef0a95
|
204 |
#ifdef CONFIG_IPV6_SUBTREES |
d3818c92a
|
205 |
const struct in6_addr *saddr_cache; |
8e1ef0a95
|
206 |
#endif |
1da177e4c
|
207 |
|
90bcaf7b4
|
208 |
__be32 flow_label; |
1da177e4c
|
209 |
__u32 frag_size; |
1d5d236d3
|
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
|
233 |
int ucast_oif; |
1da177e4c
|
234 235 236 237 238 |
int mcast_oif; /* pktoption flags */ union { struct { |
4c752098f
|
239 240 |
__u16 srcrt:1, osrcrt:1, |
1da177e4c
|
241 |
rxinfo:1, |
333fad536
|
242 |
rxoinfo:1, |
1da177e4c
|
243 |
rxhlim:1, |
333fad536
|
244 |
rxohlim:1, |
1da177e4c
|
245 |
hopopts:1, |
333fad536
|
246 |
ohopopts:1, |
1da177e4c
|
247 |
dstopts:1, |
333fad536
|
248 |
odstopts:1, |
41a1f8ea4
|
249 |
rxflow:1, |
793b14731
|
250 |
rxtclass:1, |
6c4686228
|
251 |
rxpmtu:1, |
0cc0aa614
|
252 253 254 |
rxorigdstaddr:1, recvfragsize:1; /* 1 bits hole */ |
1da177e4c
|
255 |
} bits; |
333fad536
|
256 |
__u16 all; |
1da177e4c
|
257 258 259 |
} rxopt; /* sockopt flags */ |
793b14731
|
260 |
__u16 recverr:1, |
1da177e4c
|
261 |
sndflow:1, |
df3687ffc
|
262 |
repflow:1, |
93b36cf34
|
263 |
pmtudisc:3, |
9fe516ba3
|
264 |
padding:1, /* 1 bit hole */ |
793b14731
|
265 |
srcprefs:3, /* 001: prefer temporary address |
7cbca67c0
|
266 267 268 |
* 010: prefer public address * 100: prefer care-of address */ |
cb1ce2ef3
|
269 |
dontfrag:1, |
513674b5a
|
270 |
autoflowlabel:1, |
15033f045
|
271 |
autoflowlabel_set:1, |
9036b2fe0
|
272 273 |
mc_all:1, rtalert_isolate:1; |
e802af9ca
|
274 |
__u8 min_hopcount; |
41a1f8ea4
|
275 |
__u8 tclass; |
1397ed35f
|
276 |
__be32 rcv_flowinfo; |
1da177e4c
|
277 278 |
__u32 dst_cookie; |
5d299f3d3
|
279 |
__u32 rx_dst_cookie; |
1da177e4c
|
280 |
|
456b61bca
|
281 |
struct ipv6_mc_socklist __rcu *ipv6_mc_list; |
1da177e4c
|
282 |
struct ipv6_ac_socklist *ipv6_ac_list; |
18367681a
|
283 |
struct ipv6_fl_socklist __rcu *ipv6_fl_list; |
1da177e4c
|
284 |
|
45f6fad84
|
285 |
struct ipv6_txoptions __rcu *opt; |
1da177e4c
|
286 |
struct sk_buff *pktoptions; |
4b340ae20
|
287 |
struct sk_buff *rxpmtu; |
366e41d97
|
288 |
struct inet6_cork cork; |
1da177e4c
|
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
|
298 |
__u32 ip6mr_table; |
1da177e4c
|
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
|
314 |
extern int inet6_sk_rebuild_header(struct sock *sk); |
48ee3569f
|
315 316 |
struct tcp6_timewait_sock { struct tcp_timewait_sock tcp6tw_tcp; |
48ee3569f
|
317 |
}; |
dfd56b8b3
|
318 |
#if IS_ENABLED(CONFIG_IPV6) |
e43486371
|
319 |
bool ipv6_mod_enabled(void); |
e7eadb4de
|
320 |
static inline struct ipv6_pinfo *inet6_sk(const struct sock *__sk) |
1da177e4c
|
321 |
{ |
e7eadb4de
|
322 |
return sk_fullsock(__sk) ? inet_sk(__sk)->pinet6 : NULL; |
1da177e4c
|
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
|
340 341 |
#define __ipv6_only_sock(sk) (sk->sk_ipv6only) #define ipv6_only_sock(sk) (__ipv6_only_sock(sk)) |
4b261c75a
|
342 343 |
#define ipv6_sk_rxinfo(sk) ((sk)->sk_family == PF_INET6 && \ inet6_sk(sk)->rxopt.bits.rxinfo) |
8feaf0c0a
|
344 |
|
efe4208f4
|
345 |
static inline const struct in6_addr *inet6_rcv_saddr(const struct sock *sk) |
8feaf0c0a
|
346 |
{ |
efe4208f4
|
347 348 349 |
if (sk->sk_family == AF_INET6) return &sk->sk_v6_rcv_saddr; return NULL; |
8feaf0c0a
|
350 |
} |
463c84b97
|
351 |
static inline int inet_v6_ipv6only(const struct sock *sk) |
8feaf0c0a
|
352 |
{ |
9fe516ba3
|
353 354 |
/* ipv6only field is at same position for timewait and other sockets */ return ipv6_only_sock(sk); |
8feaf0c0a
|
355 |
} |
1da177e4c
|
356 357 358 |
#else #define __ipv6_only_sock(sk) 0 #define ipv6_only_sock(sk) 0 |
4b261c75a
|
359 |
#define ipv6_sk_rxinfo(sk) 0 |
1da177e4c
|
360 |
|
e43486371
|
361 362 363 364 |
static inline bool ipv6_mod_enabled(void) { return false; } |
1da177e4c
|
365 366 367 368 |
static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk) { return NULL; } |
ca304b610
|
369 370 371 372 373 |
static inline struct inet6_request_sock * inet6_rsk(const struct request_sock *rsk) { return NULL; } |
1da177e4c
|
374 375 376 377 |
static inline struct raw6_sock *raw6_sk(const struct sock *sk) { return NULL; } |
0fa1a53e1
|
378 |
#define inet6_rcv_saddr(__sk) NULL |
8feaf0c0a
|
379 |
#define tcp_twsk_ipv6only(__sk) 0 |
463c84b97
|
380 |
#define inet_v6_ipv6only(__sk) 0 |
dfd56b8b3
|
381 |
#endif /* IS_ENABLED(CONFIG_IPV6) */ |
8feaf0c0a
|
382 |
#endif /* _IPV6_H */ |