tcp: do not use ipv6 header for ipv4 flow [Linux 3.16.72]

This Linux kernel change "tcp: do not use ipv6 header for ipv4 flow" is included in the Linux 3.16.72 release. This change is authored by Eric Dumazet <edumazet [at]> on Tue Mar 19 05:45:35 2019 -0700. The commit for this change in Linux stable tree is 169b154 (patch) which is from upstream commit 89e4130. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 89e4130.

tcp: do not use ipv6 header for ipv4 flow

commit 89e4130939a20304f4059ab72179da81f5347528 upstream.

When a dual stack tcp listener accepts an ipv4 flow,
it should not attempt to use an ipv6 header or tcp_v6_iif() helper.

Fixes: 1397ed35f22d ("ipv6: add flowinfo for tcp6 pkt_options for all cases")
Fixes: df3687ffc665 ("ipv6: add the IPV6_FL_F_REFLECT flag to IPV6_FL_A_GET")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <[email protected]>

There are 8 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 net/ipv6/tcp_ipv6.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 70a0f92..4370371 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1183,11 +1183,11 @@ static struct sock *tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
        newnp->ipv6_fl_list = NULL;
        newnp->pktoptions  = NULL;
        newnp->opt     = NULL;
-       newnp->mcast_oif   = inet6_iif(skb);
-       newnp->mcast_hops  = ipv6_hdr(skb)->hop_limit;
-       newnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb));
+       newnp->mcast_oif   = inet_iif(skb);
+       newnp->mcast_hops  = ip_hdr(skb)->ttl;
+       newnp->rcv_flowinfo = 0;
        if (np->repflow)
-           newnp->flow_label = ip6_flowlabel(ipv6_hdr(skb));
+           newnp->flow_label = 0;

         * No need to charge this sock to the relevant IPv6 refcnt debug socks count

Leave a Reply

Your email address will not be published. Required fields are marked *