4 #include <uapi/linux/ipv6.h>
6 #define ipv6_optlen(p) (((p)->hdrlen+1) << 3)
8 * This structure contains configuration options per IPv6 link.
15 __s32 accept_redirects;
19 __s32 rtr_solicit_interval;
20 __s32 rtr_solicit_delay;
21 __s32 force_mld_version;
22 __s32 mldv1_unsolicited_report_interval;
23 __s32 mldv2_unsolicited_report_interval;
26 __s32 temp_prefered_lft;
27 __s32 regen_max_retry;
28 __s32 max_desync_factor;
30 __s32 accept_ra_defrtr;
31 __s32 accept_ra_pinfo;
32 #ifdef CONFIG_IPV6_ROUTER_PREF
33 __s32 accept_ra_rtr_pref;
34 __s32 rtr_probe_interval;
35 #ifdef CONFIG_IPV6_ROUTE_INFO
36 __s32 accept_ra_rt_info_max_plen;
40 __s32 accept_source_route;
41 #ifdef CONFIG_IPV6_OPTIMISTIC_DAD
44 #ifdef CONFIG_IPV6_MROUTE
51 __s32 suppress_frag_ndisc;
59 extern struct ipv6_params ipv6_defaults;
60 #include <linux/icmpv6.h>
61 #include <linux/tcp.h>
62 #include <linux/udp.h>
64 #include <net/inet_sock.h>
66 static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb)
68 return (struct ipv6hdr *)skb_network_header(skb);
71 static inline struct ipv6hdr *inner_ipv6_hdr(const struct sk_buff *skb)
73 return (struct ipv6hdr *)skb_inner_network_header(skb);
76 static inline struct ipv6hdr *ipipv6_hdr(const struct sk_buff *skb)
78 return (struct ipv6hdr *)skb_transport_header(skb);
82 This structure contains results of exthdrs parsing
83 as offsets from skb->nh.
86 struct inet6_skb_parm {
96 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
101 #define IP6SKB_XFRM_TRANSFORMED 1
102 #define IP6SKB_FORWARDED 2
103 #define IP6SKB_REROUTED 4
104 #define IP6SKB_ROUTERALERT 8
105 #define IP6SKB_FRAGMENTED 16
108 #define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb))
109 #define IP6CBMTU(skb) ((struct ip6_mtuinfo *)((skb)->cb))
111 static inline int inet6_iif(const struct sk_buff *skb)
113 return IP6CB(skb)->iif;
116 struct tcp6_request_sock {
117 struct tcp_request_sock tcp6rsk_tcp;
120 struct ipv6_mc_socklist;
121 struct ipv6_ac_socklist;
122 struct ipv6_fl_socklist;
125 * struct ipv6_pinfo - ipv6 private area
127 * In the struct sock hierarchy (tcp6_sock, upd6_sock, etc)
128 * this _must_ be the last member, so that inet6_sk_generic
129 * is able to calculate its offset from the base struct sock
130 * by using the struct proto->slab_obj_size member. -acme
133 struct in6_addr saddr;
134 struct in6_pktinfo sticky_pktinfo;
135 const struct in6_addr *daddr_cache;
136 #ifdef CONFIG_IPV6_SUBTREES
137 const struct in6_addr *saddr_cache;
145 * Omit one shift by by putting the signed field at MSB.
147 #if defined(__BIG_ENDIAN_BITFIELD)
155 #if defined(__BIG_ENDIAN_BITFIELD)
156 /* Packed in 16bits. */
168 /* pktoption flags */
195 srcprefs:3, /* 001: prefer temporary address
196 * 010: prefer public address
197 * 100: prefer care-of address
207 struct ipv6_mc_socklist __rcu *ipv6_mc_list;
208 struct ipv6_ac_socklist *ipv6_ac_list;
209 struct ipv6_fl_socklist __rcu *ipv6_fl_list;
211 struct ipv6_txoptions *opt;
212 struct sk_buff *pktoptions;
213 struct sk_buff *rxpmtu;
215 struct ipv6_txoptions *opt;
221 /* WARNING: don't change the layout of the members in {raw,udp,tcp}6_sock! */
223 /* inet_sock has to be the first member of raw6_sock */
224 struct inet_sock inet;
225 __u32 checksum; /* perform checksum */
226 __u32 offset; /* checksum offset */
227 struct icmp6_filter filter;
229 /* ipv6_pinfo has to be the last member of raw6_sock, see inet6_sk_generic */
230 struct ipv6_pinfo inet6;
235 /* ipv6_pinfo has to be the last member of udp6_sock, see inet6_sk_generic */
236 struct ipv6_pinfo inet6;
241 /* ipv6_pinfo has to be the last member of tcp6_sock, see inet6_sk_generic */
242 struct ipv6_pinfo inet6;
245 extern int inet6_sk_rebuild_header(struct sock *sk);
247 struct tcp6_timewait_sock {
248 struct tcp_timewait_sock tcp6tw_tcp;
251 #if IS_ENABLED(CONFIG_IPV6)
252 static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk)
254 return inet_sk(__sk)->pinet6;
257 static inline struct request_sock *inet6_reqsk_alloc(struct request_sock_ops *ops)
259 struct request_sock *req = reqsk_alloc(ops);
262 inet_rsk(req)->pktopts = NULL;
267 static inline struct raw6_sock *raw6_sk(const struct sock *sk)
269 return (struct raw6_sock *)sk;
272 static inline void inet_sk_copy_descendant(struct sock *sk_to,
273 const struct sock *sk_from)
275 int ancestor_size = sizeof(struct inet_sock);
277 if (sk_from->sk_family == PF_INET6)
278 ancestor_size += sizeof(struct ipv6_pinfo);
280 __inet_sk_copy_descendant(sk_to, sk_from, ancestor_size);
283 #define __ipv6_only_sock(sk) (inet6_sk(sk)->ipv6only)
284 #define ipv6_only_sock(sk) ((sk)->sk_family == PF_INET6 && __ipv6_only_sock(sk))
286 static inline const struct in6_addr *inet6_rcv_saddr(const struct sock *sk)
288 if (sk->sk_family == AF_INET6)
289 return &sk->sk_v6_rcv_saddr;
293 static inline int inet_v6_ipv6only(const struct sock *sk)
295 return likely(sk->sk_state != TCP_TIME_WAIT) ?
296 ipv6_only_sock(sk) : inet_twsk(sk)->tw_ipv6only;
299 #define __ipv6_only_sock(sk) 0
300 #define ipv6_only_sock(sk) 0
302 static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk)
307 static inline struct inet6_request_sock *
308 inet6_rsk(const struct request_sock *rsk)
313 static inline struct raw6_sock *raw6_sk(const struct sock *sk)
318 #define inet6_rcv_saddr(__sk) NULL
319 #define tcp_twsk_ipv6only(__sk) 0
320 #define inet_v6_ipv6only(__sk) 0
321 #endif /* IS_ENABLED(CONFIG_IPV6) */
323 #define INET6_MATCH(__sk, __net, __saddr, __daddr, __ports, __dif) \
324 (((__sk)->sk_portpair == (__ports)) && \
325 ((__sk)->sk_family == AF_INET6) && \
326 ipv6_addr_equal(&(__sk)->sk_v6_daddr, (__saddr)) && \
327 ipv6_addr_equal(&(__sk)->sk_v6_rcv_saddr, (__daddr)) && \
328 (!(__sk)->sk_bound_dev_if || \
329 ((__sk)->sk_bound_dev_if == (__dif))) && \
330 net_eq(sock_net(__sk), (__net)))