Skip to content

Commit e504799

Browse files
Daniel Lezcanodavem330
authored andcommitted
[NETNS][IPV6] tcp6 - handle several network namespace
We have the right network namespace at the right place now. So make use of this information to make tcp6 per network namespace Signed-off-by: Daniel Lezcano <[email protected]> Signed-off-by: Benjamin Thery <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 93ec926 commit e504799

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

net/ipv6/tcp_ipv6.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,8 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
988988
struct tcphdr *th = tcp_hdr(skb), *t1;
989989
struct sk_buff *buff;
990990
struct flowi fl;
991+
struct net *net = skb->dst->dev->nd_net;
992+
struct sock *ctl_sk = net->ipv6.tcp_sk;
991993
unsigned int tot_len = sizeof(*th);
992994
#ifdef CONFIG_TCP_MD5SIG
993995
struct tcp_md5sig_key *key;
@@ -1072,11 +1074,10 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
10721074
* Underlying function will use this to retrieve the network
10731075
* namespace
10741076
*/
1075-
if (!ip6_dst_lookup(init_net.ipv6.tcp_sk, &buff->dst, &fl)) {
1077+
if (!ip6_dst_lookup(ctl_sk, &buff->dst, &fl)) {
10761078

10771079
if (xfrm_lookup(&buff->dst, &fl, NULL, 0) >= 0) {
1078-
ip6_xmit(init_net.ipv6.tcp_sk,
1079-
buff, &fl, NULL, 0);
1080+
ip6_xmit(ctl_sk, buff, &fl, NULL, 0);
10801081
TCP_INC_STATS_BH(TCP_MIB_OUTSEGS);
10811082
TCP_INC_STATS_BH(TCP_MIB_OUTRSTS);
10821083
return;
@@ -1092,6 +1093,8 @@ static void tcp_v6_send_ack(struct tcp_timewait_sock *tw,
10921093
struct tcphdr *th = tcp_hdr(skb), *t1;
10931094
struct sk_buff *buff;
10941095
struct flowi fl;
1096+
struct net *net = skb->dev->nd_net;
1097+
struct sock *ctl_sk = net->ipv6.tcp_sk;
10951098
unsigned int tot_len = sizeof(struct tcphdr);
10961099
__be32 *topt;
10971100
#ifdef CONFIG_TCP_MD5SIG
@@ -1173,10 +1176,9 @@ static void tcp_v6_send_ack(struct tcp_timewait_sock *tw,
11731176
fl.fl_ip_sport = t1->source;
11741177
security_skb_classify_flow(skb, &fl);
11751178

1176-
if (!ip6_dst_lookup(init_net.ipv6.tcp_sk, &buff->dst, &fl)) {
1179+
if (!ip6_dst_lookup(ctl_sk, &buff->dst, &fl)) {
11771180
if (xfrm_lookup(&buff->dst, &fl, NULL, 0) >= 0) {
1178-
ip6_xmit(init_net.ipv6.tcp_sk,
1179-
buff, &fl, NULL, 0);
1181+
ip6_xmit(ctl_sk, buff, &fl, NULL, 0);
11801182
TCP_INC_STATS_BH(TCP_MIB_OUTSEGS);
11811183
return;
11821184
}

0 commit comments

Comments
 (0)