summaryrefslogtreecommitdiff
path: root/net/ipv6/udp.c
diff options
context:
space:
mode:
authorWei Wang <weiwan@google.com>2017-07-06 20:04:39 -0600
committerSubash Abhinov Kasiviswanathan <subashab@codeaurora.org>2017-07-12 15:09:29 -0600
commita0271af20883c5d00bc208ef2adc19e59004ed18 (patch)
tree53ff33a6acebbb3d27b844e05873b796ea3973f9 /net/ipv6/udp.c
parentc4a69905373742f0e5b1a26fdabe5899055aa3db (diff)
net: ipv6: reset daddr and dport in socket if connect() fails
In __ip6_datagram_connect(), reset socket->socket_v6_daddr and inet->dport if error occurs. In udp_v6_early_demux(), check for socket_state to make sure it is in TCP_ESTABLISHED state. Together, it makes sure unconnected UDP socket won't be considered as a valid candidate for early demux. v3: add TCP_ESTABLISHED state check in udp_v6_early_demux() v2: fix compilation error CRs-Fixed: 2057820 Change-Id: Ifa9c2ddfaa5b51d4082b7b1dd8a5d03b3c290705 Fixes: 5425077d73e0 ("net: ipv6: Add early demux handler for UDP unicast") Signed-off-by: Wei Wang <weiwan@google.com> Acked-by: Maciej Żenczykowski <maze@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Git-commit: 85cb73ff9b74785a7fc752875d7f0fe17ca3ea7c Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git [subashab@codeaurora.org: resolve trivial merge conflicts] Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
Diffstat (limited to 'net/ipv6/udp.c')
-rw-r--r--net/ipv6/udp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index a48a8faa401c..a8cabc876348 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -974,7 +974,8 @@ static struct sock *__udp6_lib_demux_lookup(struct net *net,
const __portpair ports = INET_COMBINED_PORTS(rmt_port, hnum);
udp_portaddr_for_each_entry_rcu(sk, hnode, &hslot2->head) {
- if (INET6_MATCH(sk, net, rmt_addr, loc_addr, ports, dif))
+ if (sk->sk_state == TCP_ESTABLISHED &&
+ INET6_MATCH(sk, net, rmt_addr, loc_addr, ports, dif))
return sk;
/* Only check first socket in chain */
break;