diff options
-rw-r--r-- | include/linux/ipv6.h | 32 | ||||
-rw-r--r-- | include/net/inet6_hashtables.h | 6 | ||||
-rw-r--r-- | include/net/inet_timewait_sock.h | 3 | ||||
-rw-r--r-- | net/ipv4/inet_diag.c | 6 | ||||
-rw-r--r-- | net/ipv4/tcp_minisocks.c | 8 | ||||
-rw-r--r-- | net/ipv6/addrconf.c | 2 | ||||
-rw-r--r-- | net/ipv6/tcp_ipv6.c | 12 |
7 files changed, 41 insertions, 28 deletions
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 69a0decfbdf4..7d3908594fac 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h | |||
@@ -348,26 +348,36 @@ static inline void inet_sk_copy_descendant(struct sock *sk_to, | |||
348 | 348 | ||
349 | #include <linux/tcp.h> | 349 | #include <linux/tcp.h> |
350 | 350 | ||
351 | struct inet6_timewait_sock { | ||
352 | struct in6_addr tw_v6_daddr; | ||
353 | struct in6_addr tw_v6_rcv_saddr; | ||
354 | }; | ||
355 | |||
351 | struct tcp6_timewait_sock { | 356 | struct tcp6_timewait_sock { |
352 | struct tcp_timewait_sock tw_v6_sk; | 357 | struct tcp_timewait_sock tcp6tw_tcp; |
353 | struct in6_addr tw_v6_daddr; | 358 | struct inet6_timewait_sock tcp6tw_inet6; |
354 | struct in6_addr tw_v6_rcv_saddr; | ||
355 | }; | 359 | }; |
356 | 360 | ||
357 | static inline struct tcp6_timewait_sock *tcp6_twsk(const struct sock *sk) | 361 | static inline u16 inet6_tw_offset(const struct proto *prot) |
362 | { | ||
363 | return prot->twsk_obj_size - sizeof(struct inet6_timewait_sock); | ||
364 | } | ||
365 | |||
366 | static inline struct inet6_timewait_sock *inet6_twsk(const struct sock *sk) | ||
358 | { | 367 | { |
359 | return (struct tcp6_timewait_sock *)sk; | 368 | return (struct inet6_timewait_sock *)(((u8 *)sk) + |
369 | inet_twsk(sk)->tw_ipv6_offset); | ||
360 | } | 370 | } |
361 | 371 | ||
362 | static inline struct in6_addr *__tcp_v6_rcv_saddr(const struct sock *sk) | 372 | static inline struct in6_addr *__inet6_rcv_saddr(const struct sock *sk) |
363 | { | 373 | { |
364 | return likely(sk->sk_state != TCP_TIME_WAIT) ? | 374 | return likely(sk->sk_state != TCP_TIME_WAIT) ? |
365 | &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; |
366 | } | 376 | } |
367 | 377 | ||
368 | 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) |
369 | { | 379 | { |
370 | return sk->sk_family == AF_INET6 ? __tcp_v6_rcv_saddr(sk) : NULL; | 380 | return sk->sk_family == AF_INET6 ? __inet6_rcv_saddr(sk) : NULL; |
371 | } | 381 | } |
372 | 382 | ||
373 | static inline int inet_v6_ipv6only(const struct sock *sk) | 383 | static inline int inet_v6_ipv6only(const struct sock *sk) |
@@ -395,8 +405,8 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk) | |||
395 | return NULL; | 405 | return NULL; |
396 | } | 406 | } |
397 | 407 | ||
398 | #define __tcp_v6_rcv_saddr(__sk) NULL | 408 | #define __inet6_rcv_saddr(__sk) NULL |
399 | #define tcp_v6_rcv_saddr(__sk) NULL | 409 | #define inet6_rcv_saddr(__sk) NULL |
400 | #define tcp_twsk_ipv6only(__sk) 0 | 410 | #define tcp_twsk_ipv6only(__sk) 0 |
401 | #define inet_v6_ipv6only(__sk) 0 | 411 | #define inet_v6_ipv6only(__sk) 0 |
402 | #endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ | 412 | #endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ |
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index a4a204f99ea6..25f708ff020e 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h | |||
@@ -110,10 +110,10 @@ static inline struct sock * | |||
110 | 110 | ||
111 | if(*((__u32 *)&(tw->tw_dport)) == ports && | 111 | if(*((__u32 *)&(tw->tw_dport)) == ports && |
112 | sk->sk_family == PF_INET6) { | 112 | sk->sk_family == PF_INET6) { |
113 | const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk); | 113 | const struct inet6_timewait_sock *tw6 = inet6_twsk(sk); |
114 | 114 | ||
115 | if (ipv6_addr_equal(&tcp6tw->tw_v6_daddr, saddr) && | 115 | if (ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) && |
116 | ipv6_addr_equal(&tcp6tw->tw_v6_rcv_saddr, daddr) && | 116 | ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) && |
117 | (!sk->sk_bound_dev_if || sk->sk_bound_dev_if == dif)) | 117 | (!sk->sk_bound_dev_if || sk->sk_bound_dev_if == dif)) |
118 | goto hit; | 118 | goto hit; |
119 | } | 119 | } |
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index 28f7b2103505..ca240f856c46 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h | |||
@@ -127,7 +127,8 @@ struct inet_timewait_sock { | |||
127 | __u16 tw_num; | 127 | __u16 tw_num; |
128 | /* And these are ours. */ | 128 | /* And these are ours. */ |
129 | __u8 tw_ipv6only:1; | 129 | __u8 tw_ipv6only:1; |
130 | /* 31 bits hole, try to pack */ | 130 | /* 15 bits hole, try to pack */ |
131 | __u16 tw_ipv6_offset; | ||
131 | int tw_timeout; | 132 | int tw_timeout; |
132 | unsigned long tw_ttd; | 133 | unsigned long tw_ttd; |
133 | struct inet_bind_bucket *tw_tb; | 134 | struct inet_bind_bucket *tw_tb; |
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index 3ce73b141d7e..c49908192047 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c | |||
@@ -112,12 +112,12 @@ static int inet_diag_fill(struct sk_buff *skb, struct sock *sk, | |||
112 | r->idiag_inode = 0; | 112 | r->idiag_inode = 0; |
113 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 113 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
114 | if (r->idiag_family == AF_INET6) { | 114 | if (r->idiag_family == AF_INET6) { |
115 | const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk); | 115 | const struct inet6_timewait_sock *tw6 = inet6_twsk(sk); |
116 | 116 | ||
117 | ipv6_addr_copy((struct in6_addr *)r->id.idiag_src, | 117 | ipv6_addr_copy((struct in6_addr *)r->id.idiag_src, |
118 | &tcp6tw->tw_v6_rcv_saddr); | 118 | &tw6->tw_v6_rcv_saddr); |
119 | ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst, | 119 | ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst, |
120 | &tcp6tw->tw_v6_daddr); | 120 | &tw6->tw_v6_daddr); |
121 | } | 121 | } |
122 | #endif | 122 | #endif |
123 | nlh->nlmsg_len = skb->tail - b; | 123 | nlh->nlmsg_len = skb->tail - b; |
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 9c029683a626..2b9b7f6c7f7c 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
@@ -298,10 +298,12 @@ void tcp_time_wait(struct sock *sk, int state, int timeo) | |||
298 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 298 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
299 | if (tw->tw_family == PF_INET6) { | 299 | if (tw->tw_family == PF_INET6) { |
300 | struct ipv6_pinfo *np = inet6_sk(sk); | 300 | struct ipv6_pinfo *np = inet6_sk(sk); |
301 | struct tcp6_timewait_sock *tcp6tw = tcp6_twsk((struct sock *)tw); | 301 | struct inet6_timewait_sock *tw6; |
302 | 302 | ||
303 | ipv6_addr_copy(&tcp6tw->tw_v6_daddr, &np->daddr); | 303 | tw->tw_ipv6_offset = inet6_tw_offset(sk->sk_prot); |
304 | ipv6_addr_copy(&tcp6tw->tw_v6_rcv_saddr, &np->rcv_saddr); | 304 | tw6 = inet6_twsk((struct sock *)tw); |
305 | ipv6_addr_copy(&tw6->tw_v6_daddr, &np->daddr); | ||
306 | ipv6_addr_copy(&tw6->tw_v6_rcv_saddr, &np->rcv_saddr); | ||
305 | tw->tw_ipv6only = np->ipv6only; | 307 | tw->tw_ipv6only = np->ipv6only; |
306 | } | 308 | } |
307 | #endif | 309 | #endif |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index a60585fd85ad..704fb73e6c5f 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -1195,7 +1195,7 @@ struct inet6_ifaddr * ipv6_get_ifaddr(struct in6_addr *addr, struct net_device * | |||
1195 | int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2) | 1195 | int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2) |
1196 | { | 1196 | { |
1197 | const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr; | 1197 | const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr; |
1198 | const struct in6_addr *sk2_rcv_saddr6 = tcp_v6_rcv_saddr(sk2); | 1198 | const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2); |
1199 | u32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr; | 1199 | u32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr; |
1200 | u32 sk2_rcv_saddr = inet_rcv_saddr(sk2); | 1200 | u32 sk2_rcv_saddr = inet_rcv_saddr(sk2); |
1201 | int sk_ipv6only = ipv6_only_sock(sk); | 1201 | int sk_ipv6only = ipv6_only_sock(sk); |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 2f932ce72610..cb880079daf3 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -138,14 +138,14 @@ static int __tcp_v6_check_established(struct sock *sk, const __u16 lport, | |||
138 | 138 | ||
139 | /* Check TIME-WAIT sockets first. */ | 139 | /* Check TIME-WAIT sockets first. */ |
140 | sk_for_each(sk2, node, &(head + tcp_hashinfo.ehash_size)->chain) { | 140 | sk_for_each(sk2, node, &(head + tcp_hashinfo.ehash_size)->chain) { |
141 | const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk2); | 141 | const struct inet6_timewait_sock *tw6 = inet6_twsk(sk2); |
142 | 142 | ||
143 | tw = inet_twsk(sk2); | 143 | tw = inet_twsk(sk2); |
144 | 144 | ||
145 | if(*((__u32 *)&(tw->tw_dport)) == ports && | 145 | if(*((__u32 *)&(tw->tw_dport)) == ports && |
146 | sk2->sk_family == PF_INET6 && | 146 | sk2->sk_family == PF_INET6 && |
147 | ipv6_addr_equal(&tcp6tw->tw_v6_daddr, saddr) && | 147 | ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) && |
148 | ipv6_addr_equal(&tcp6tw->tw_v6_rcv_saddr, daddr) && | 148 | ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) && |
149 | sk2->sk_bound_dev_if == sk->sk_bound_dev_if) { | 149 | sk2->sk_bound_dev_if == sk->sk_bound_dev_if) { |
150 | const struct tcp_timewait_sock *tcptw = tcp_twsk(sk2); | 150 | const struct tcp_timewait_sock *tcptw = tcp_twsk(sk2); |
151 | struct tcp_sock *tp = tcp_sk(sk); | 151 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -1663,14 +1663,14 @@ static void get_timewait6_sock(struct seq_file *seq, | |||
1663 | { | 1663 | { |
1664 | struct in6_addr *dest, *src; | 1664 | struct in6_addr *dest, *src; |
1665 | __u16 destp, srcp; | 1665 | __u16 destp, srcp; |
1666 | struct tcp6_timewait_sock *tcp6tw = tcp6_twsk((struct sock *)tw); | 1666 | struct inet6_timewait_sock *tw6 = inet6_twsk((struct sock *)tw); |
1667 | int ttd = tw->tw_ttd - jiffies; | 1667 | int ttd = tw->tw_ttd - jiffies; |
1668 | 1668 | ||
1669 | if (ttd < 0) | 1669 | if (ttd < 0) |
1670 | ttd = 0; | 1670 | ttd = 0; |
1671 | 1671 | ||
1672 | dest = &tcp6tw->tw_v6_daddr; | 1672 | dest = &tw6->tw_v6_daddr; |
1673 | src = &tcp6tw->tw_v6_rcv_saddr; | 1673 | src = &tw6->tw_v6_rcv_saddr; |
1674 | destp = ntohs(tw->tw_dport); | 1674 | destp = ntohs(tw->tw_dport); |
1675 | srcp = ntohs(tw->tw_sport); | 1675 | srcp = ntohs(tw->tw_sport); |
1676 | 1676 | ||