public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Wei Wang <tracywwnj@gmail.com>
To: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Cc: "Maciej Żenczykowski" <maze@google.com>,
	"Subash Abhinov Kasiviswanathan" <subashab@codeaurora.org>,
	"Wei Wang" <weiwan@google.com>
Subject: [PATCH v2 net] udpv6: reset daddr and dport in sk if connect() fails
Date: Thu, 22 Jun 2017 12:03:41 -0700	[thread overview]
Message-ID: <20170622190341.87998-1-tracywwnj@gmail.com> (raw)

From: Wei Wang <weiwan@google.com>

In __ip6_datagram_connect(), reset sk->sk_v6_daddr and inet->dport if
error occurs so that udp_v6_early_demux() won't consider this socket
as a valid candidate for early demux.

v2: fix compilation error

Signed-off-by: Wei Wang <weiwan@google.com>
Acked-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv6/datagram.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index e011122ebd43..5c786f5ab961 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -250,8 +250,14 @@ int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr,
 	 */
 
 	err = ip6_datagram_dst_update(sk, true);
-	if (err)
+	if (err) {
+		/* Reset daddr and dport so that udp_v6_early_demux()
+		 * fails to find this socket
+		 */
+		memset(&sk->sk_v6_daddr, 0, sizeof(sk->sk_v6_daddr));
+		inet->inet_dport = 0;
 		goto out;
+	}
 
 	sk->sk_state = TCP_ESTABLISHED;
 	sk_set_txhash(sk);
-- 
2.13.1.611.g7e3b11ae1-goog

             reply	other threads:[~2017-06-22 19:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-22 19:03 Wei Wang [this message]
2017-06-22 19:21 ` [PATCH v2 net] udpv6: reset daddr and dport in sk if connect() fails Maciej Żenczykowski
2017-06-23 18:03 ` David Miller

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=20170622190341.87998-1-tracywwnj@gmail.com \
    --to=tracywwnj@gmail.com \
    --cc=davem@davemloft.net \
    --cc=maze@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=subashab@codeaurora.org \
    --cc=weiwan@google.com \
    /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