diff options
Diffstat (limited to 'include/linux/ipv6.h')
-rw-r--r-- | include/linux/ipv6.h | 79 |
1 files changed, 59 insertions, 20 deletions
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index e0b922785d98..93bbed5c6cf4 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h | |||
@@ -171,12 +171,13 @@ enum { | |||
171 | }; | 171 | }; |
172 | 172 | ||
173 | #ifdef __KERNEL__ | 173 | #ifdef __KERNEL__ |
174 | #include <linux/in6.h> /* struct sockaddr_in6 */ | ||
175 | #include <linux/icmpv6.h> | 174 | #include <linux/icmpv6.h> |
176 | #include <net/if_inet6.h> /* struct ipv6_mc_socklist */ | ||
177 | #include <linux/tcp.h> | 175 | #include <linux/tcp.h> |
178 | #include <linux/udp.h> | 176 | #include <linux/udp.h> |
179 | 177 | ||
178 | #include <net/if_inet6.h> /* struct ipv6_mc_socklist */ | ||
179 | #include <net/inet_sock.h> | ||
180 | |||
180 | /* | 181 | /* |
181 | This structure contains results of exthdrs parsing | 182 | This structure contains results of exthdrs parsing |
182 | as offsets from skb->nh. | 183 | as offsets from skb->nh. |
@@ -199,18 +200,17 @@ static inline int inet6_iif(const struct sk_buff *skb) | |||
199 | return IP6CB(skb)->iif; | 200 | return IP6CB(skb)->iif; |
200 | } | 201 | } |
201 | 202 | ||
202 | struct tcp6_request_sock { | 203 | struct inet6_request_sock { |
203 | struct tcp_request_sock req; | ||
204 | struct in6_addr loc_addr; | 204 | struct in6_addr loc_addr; |
205 | struct in6_addr rmt_addr; | 205 | struct in6_addr rmt_addr; |
206 | struct sk_buff *pktopts; | 206 | struct sk_buff *pktopts; |
207 | int iif; | 207 | int iif; |
208 | }; | 208 | }; |
209 | 209 | ||
210 | static inline struct tcp6_request_sock *tcp6_rsk(const struct request_sock *sk) | 210 | struct tcp6_request_sock { |
211 | { | 211 | struct tcp_request_sock tcp6rsk_tcp; |
212 | return (struct tcp6_request_sock *)sk; | 212 | struct inet6_request_sock tcp6rsk_inet6; |
213 | } | 213 | }; |
214 | 214 | ||
215 | /** | 215 | /** |
216 | * struct ipv6_pinfo - ipv6 private area | 216 | * struct ipv6_pinfo - ipv6 private area |
@@ -298,12 +298,36 @@ struct tcp6_sock { | |||
298 | struct ipv6_pinfo inet6; | 298 | struct ipv6_pinfo inet6; |
299 | }; | 299 | }; |
300 | 300 | ||
301 | extern int inet6_sk_rebuild_header(struct sock *sk); | ||
302 | |||
301 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 303 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
302 | static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk) | 304 | static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk) |
303 | { | 305 | { |
304 | return inet_sk(__sk)->pinet6; | 306 | return inet_sk(__sk)->pinet6; |
305 | } | 307 | } |
306 | 308 | ||
309 | static inline struct inet6_request_sock * | ||
310 | inet6_rsk(const struct request_sock *rsk) | ||
311 | { | ||
312 | return (struct inet6_request_sock *)(((u8 *)rsk) + | ||
313 | inet_rsk(rsk)->inet6_rsk_offset); | ||
314 | } | ||
315 | |||
316 | static inline u32 inet6_rsk_offset(struct request_sock *rsk) | ||
317 | { | ||
318 | return rsk->rsk_ops->obj_size - sizeof(struct inet6_request_sock); | ||
319 | } | ||
320 | |||
321 | static inline struct request_sock *inet6_reqsk_alloc(struct request_sock_ops *ops) | ||
322 | { | ||
323 | struct request_sock *req = reqsk_alloc(ops); | ||
324 | |||
325 | if (req != NULL) | ||
326 | inet_rsk(req)->inet6_rsk_offset = inet6_rsk_offset(req); | ||
327 | |||
328 | return req; | ||
329 | } | ||
330 | |||
307 | static inline struct raw6_sock *raw6_sk(const struct sock *sk) | 331 | static inline struct raw6_sock *raw6_sk(const struct sock *sk) |
308 | { | 332 | { |
309 | return (struct raw6_sock *)sk; | 333 | return (struct raw6_sock *)sk; |
@@ -323,28 +347,37 @@ static inline void inet_sk_copy_descendant(struct sock *sk_to, | |||
323 | #define __ipv6_only_sock(sk) (inet6_sk(sk)->ipv6only) | 347 | #define __ipv6_only_sock(sk) (inet6_sk(sk)->ipv6only) |
324 | #define ipv6_only_sock(sk) ((sk)->sk_family == PF_INET6 && __ipv6_only_sock(sk)) | 348 | #define ipv6_only_sock(sk) ((sk)->sk_family == PF_INET6 && __ipv6_only_sock(sk)) |
325 | 349 | ||
326 | #include <linux/tcp.h> | 350 | struct inet6_timewait_sock { |
351 | struct in6_addr tw_v6_daddr; | ||
352 | struct in6_addr tw_v6_rcv_saddr; | ||
353 | }; | ||
327 | 354 | ||
328 | struct tcp6_timewait_sock { | 355 | struct tcp6_timewait_sock { |
329 | struct tcp_timewait_sock tw_v6_sk; | 356 | struct tcp_timewait_sock tcp6tw_tcp; |
330 | struct in6_addr tw_v6_daddr; | 357 | struct inet6_timewait_sock tcp6tw_inet6; |
331 | struct in6_addr tw_v6_rcv_saddr; | ||
332 | }; | 358 | }; |
333 | 359 | ||
334 | static inline struct tcp6_timewait_sock *tcp6_twsk(const struct sock *sk) | 360 | static inline u16 inet6_tw_offset(const struct proto *prot) |
335 | { | 361 | { |
336 | return (struct tcp6_timewait_sock *)sk; | 362 | return prot->twsk_prot->twsk_obj_size - |
363 | sizeof(struct inet6_timewait_sock); | ||
337 | } | 364 | } |
338 | 365 | ||
339 | static inline struct in6_addr *__tcp_v6_rcv_saddr(const struct sock *sk) | 366 | static inline struct inet6_timewait_sock *inet6_twsk(const struct sock *sk) |
367 | { | ||
368 | return (struct inet6_timewait_sock *)(((u8 *)sk) + | ||
369 | inet_twsk(sk)->tw_ipv6_offset); | ||
370 | } | ||
371 | |||
372 | static inline struct in6_addr *__inet6_rcv_saddr(const struct sock *sk) | ||
340 | { | 373 | { |
341 | return likely(sk->sk_state != TCP_TIME_WAIT) ? | 374 | return likely(sk->sk_state != TCP_TIME_WAIT) ? |
342 | &inet6_sk(sk)->rcv_saddr : &tcp6_twsk(sk)->tw_v6_rcv_saddr; | 375 | &inet6_sk(sk)->rcv_saddr : &inet6_twsk(sk)->tw_v6_rcv_saddr; |
343 | } | 376 | } |
344 | 377 | ||
345 | static inline struct in6_addr *tcp_v6_rcv_saddr(const struct sock *sk) | 378 | static inline struct in6_addr *inet6_rcv_saddr(const struct sock *sk) |
346 | { | 379 | { |
347 | return sk->sk_family == AF_INET6 ? __tcp_v6_rcv_saddr(sk) : NULL; | 380 | return sk->sk_family == AF_INET6 ? __inet6_rcv_saddr(sk) : NULL; |
348 | } | 381 | } |
349 | 382 | ||
350 | static inline int inet_v6_ipv6only(const struct sock *sk) | 383 | static inline int inet_v6_ipv6only(const struct sock *sk) |
@@ -361,13 +394,19 @@ static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk) | |||
361 | return NULL; | 394 | return NULL; |
362 | } | 395 | } |
363 | 396 | ||
397 | static inline struct inet6_request_sock * | ||
398 | inet6_rsk(const struct request_sock *rsk) | ||
399 | { | ||
400 | return NULL; | ||
401 | } | ||
402 | |||
364 | static inline struct raw6_sock *raw6_sk(const struct sock *sk) | 403 | static inline struct raw6_sock *raw6_sk(const struct sock *sk) |
365 | { | 404 | { |
366 | return NULL; | 405 | return NULL; |
367 | } | 406 | } |
368 | 407 | ||
369 | #define __tcp_v6_rcv_saddr(__sk) NULL | 408 | #define __inet6_rcv_saddr(__sk) NULL |
370 | #define tcp_v6_rcv_saddr(__sk) NULL | 409 | #define inet6_rcv_saddr(__sk) NULL |
371 | #define tcp_twsk_ipv6only(__sk) 0 | 410 | #define tcp_twsk_ipv6only(__sk) 0 |
372 | #define inet_v6_ipv6only(__sk) 0 | 411 | #define inet_v6_ipv6only(__sk) 0 |
373 | #endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ | 412 | #endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ |