aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/tcp_ipv6.c
diff options
context:
space:
mode:
authorJon Maxwell <jmaxwell37@gmail.com>2018-05-10 02:53:51 -0400
committerDavid S. Miller <davem@davemloft.net>2018-05-10 17:44:52 -0400
commit00483690552c5fb6aa30bf3acb75b0ee89b4c0fd (patch)
tree6946a9497933df7fe6ae0f54729ee84b04e1ca1e /net/ipv6/tcp_ipv6.c
parent03bdfc001c951cb04ad3d28aecee4ec0e18e9664 (diff)
tcp: Add mark for TIMEWAIT sockets
This version has some suggestions by Eric Dumazet: - Use a local variable for the mark in IPv6 instead of ctl_sk to avoid SMP races. - Use the more elegant "IP4_REPLY_MARK(net, skb->mark) ?: sk->sk_mark" statement. - Factorize code as sk_fullsock() check is not necessary. Aidan McGurn from Openwave Mobility systems reported the following bug: "Marked routing is broken on customer deployment. Its effects are large increase in Uplink retransmissions caused by the client never receiving the final ACK to their FINACK - this ACK misses the mark and routes out of the incorrect route." Currently marks are added to sk_buffs for replies when the "fwmark_reflect" sysctl is enabled. But not for TW sockets that had sk->sk_mark set via setsockopt(SO_MARK..). Fix this in IPv4/v6 by adding tw->tw_mark for TIME_WAIT sockets. Copy the the original sk->sk_mark in __inet_twsk_hashdance() to the new tw->tw_mark location. Then progate this so that the skb gets sent with the correct mark. Do the same for resets. Give the "fwmark_reflect" sysctl precedence over sk->sk_mark so that netfilter rules are still honored. Signed-off-by: Jon Maxwell <jmaxwell37@gmail.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/tcp_ipv6.c')
-rw-r--r--net/ipv6/tcp_ipv6.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 6d664d83cd16..7d47c2b550a9 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -803,6 +803,7 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32
803 unsigned int tot_len = sizeof(struct tcphdr); 803 unsigned int tot_len = sizeof(struct tcphdr);
804 struct dst_entry *dst; 804 struct dst_entry *dst;
805 __be32 *topt; 805 __be32 *topt;
806 __u32 mark = 0;
806 807
807 if (tsecr) 808 if (tsecr)
808 tot_len += TCPOLEN_TSTAMP_ALIGNED; 809 tot_len += TCPOLEN_TSTAMP_ALIGNED;
@@ -871,7 +872,10 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32
871 fl6.flowi6_oif = oif; 872 fl6.flowi6_oif = oif;
872 } 873 }
873 874
874 fl6.flowi6_mark = IP6_REPLY_MARK(net, skb->mark); 875 if (sk)
876 mark = (sk->sk_state == TCP_TIME_WAIT) ?
877 inet_twsk(sk)->tw_mark : sk->sk_mark;
878 fl6.flowi6_mark = IP6_REPLY_MARK(net, skb->mark) ?: mark;
875 fl6.fl6_dport = t1->dest; 879 fl6.fl6_dport = t1->dest;
876 fl6.fl6_sport = t1->source; 880 fl6.fl6_sport = t1->source;
877 fl6.flowi6_uid = sock_net_uid(net, sk && sk_fullsock(sk) ? sk : NULL); 881 fl6.flowi6_uid = sock_net_uid(net, sk && sk_fullsock(sk) ? sk : NULL);