netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Wang <weiwan@google.com>
To: "David S . Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
	Wei Wang <weiwan@google.com>
Subject: [PATCH] ipv6: Fix the pmtu path for connected UDP socket
Date: Wed,  2 Mar 2016 11:19:21 -0800	[thread overview]
Message-ID: <1456946361-9889-1-git-send-email-tracywwnj@gmail.com> (raw)

From: Wei Wang <weiwan@google.com>

When ICMPV6_PKT_TOOBIG message is received by a connected UDP socket,
the new mtu value is not properly updated in the dst_entry associated
with the socket.
This leads to the issue that the mtu value returned by getsockopt(sockfd,
IPPROTO_IPV6, IPV6_MTU, ...) is wrong.
The fix is to call the corresponding pmtu related function for connected
socket so that the dst_entry associated with the socket will get updated
with the new mtu value.
And before we call the above function to update mtu, we check to make
sure the source IP address, destination IP address, source port and
destination port are matching between the incoming flow and the socket.

Signed-off-by: Wei Wang <weiwan@google.com>
---
 net/ipv6/udp.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 0711f8f..5e6ba54 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -49,6 +49,7 @@
 #include <net/inet6_hashtables.h>
 #include <net/busy_poll.h>
 #include <net/sock_reuseport.h>
+#include <net/inet6_connection_sock.h>
 
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
@@ -566,7 +567,16 @@ void __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	if (type == ICMPV6_PKT_TOOBIG) {
 		if (!ip6_sk_accept_pmtu(sk))
 			goto out;
-		ip6_sk_update_pmtu(skb, sk, info);
+		bh_lock_sock(sk);
+		if (sk->sk_state == TCP_ESTABLISHED &&
+		    !sock_owned_by_user(sk) &&
+		    ipv6_addr_equal(saddr, &sk->sk_v6_rcv_saddr) &&
+		    ipv6_addr_equal(daddr, &sk->sk_v6_daddr) &&
+		    uh->dest == sk->sk_dport)
+			inet6_csk_update_pmtu(sk, ntohl(info));
+		else
+			ip6_sk_update_pmtu(skb, sk, info);
+		bh_unlock_sock(sk);
 		if (np->pmtudisc != IPV6_PMTUDISC_DONT)
 			harderr = 1;
 	}
-- 
2.7.0.rc3.207.g0ac5344

             reply	other threads:[~2016-03-02 19:19 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02 19:19 Wei Wang [this message]
2016-03-06  5:55 ` [PATCH] ipv6: Fix the pmtu path for connected UDP socket David Miller
2016-03-07 17:19   ` Eric Dumazet
2016-03-07 17:35     ` Eric Dumazet
2016-03-07 21:28 ` Martin KaFai Lau
  -- strict thread matches above, loose matches on Subject: below --
2016-03-14 20:59 Wei Wang
2016-03-16 23:53 ` David Miller
2016-03-17  0:22   ` Eric Dumazet
2016-03-17  2:38     ` David Miller
2016-03-17  3:34       ` Eric Dumazet
2016-03-18 17:19         ` Cong Wang
     [not found]           ` <CAEA6p_CfDYYLf-s0pUy7VNFH+46PDZSXNzUExXRAM_xv2w8tcw@mail.gmail.com>
2016-03-18 18:10             ` Cong Wang
2016-03-18 21:26               ` Wei Wang
2016-03-18 22:09                 ` Cong Wang
2016-03-21 17:13                   ` Wei Wang
2016-03-22  6:02                     ` Martin KaFai Lau
2016-03-22 16:53                       ` Cong Wang
2016-03-22 17:39                         ` Martin KaFai Lau
2016-03-22 18:03                           ` Wei Wang
2016-03-22 18:16                             ` Martin KaFai Lau
2016-03-22 20:13                             ` Cong Wang
2016-03-22 23:36                               ` Eric Dumazet
2016-03-23 23:57                                 ` Wei Wang
2016-03-24 18:32                                   ` Martin KaFai Lau
2016-03-24 19:45                                     ` Martin KaFai Lau
2016-03-25 23:55                                   ` Martin KaFai Lau
2016-03-26  0:16                                     ` Martin KaFai Lau
2016-03-28 22:39                                       ` Cong Wang
2016-03-28 23:44                                         ` Martin KaFai Lau
2016-03-24 19:23                                 ` Cong Wang
2016-03-22 18:19                           ` Cong Wang
2016-03-18  7:17 ` Martin KaFai Lau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1456946361-9889-1-git-send-email-tracywwnj@gmail.com \
    --to=weiwan@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).