summaryrefslogtreecommitdiffstats
path: root/net/ipv6/datagram.c
diff options
context:
space:
mode:
authorWei Wang <weiwan@google.com>2017-06-23 15:25:37 -0700
committerDavid S. Miller <davem@davemloft.net>2017-06-25 11:46:56 -0400
commit85cb73ff9b74785a7fc752875d7f0fe17ca3ea7c (patch)
tree00339cc580169297c2ae02f372d7f90cc0f7e652 /net/ipv6/datagram.c
parentd0c32a16235aeacd32c9de6ff90f9219614d7e4e (diff)
downloadblackbird-obmc-linux-85cb73ff9b74785a7fc752875d7f0fe17ca3ea7c.tar.gz
blackbird-obmc-linux-85cb73ff9b74785a7fc752875d7f0fe17ca3ea7c.zip
net: ipv6: reset daddr and dport in sk if connect() fails
In __ip6_datagram_connect(), reset sk->sk_v6_daddr and inet->dport if error occurs. In udp_v6_early_demux(), check for sk_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 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>
Diffstat (limited to 'net/ipv6/datagram.c')
-rw-r--r--net/ipv6/datagram.c8
1 files changed, 7 insertions, 1 deletions
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 @@ ipv4_connected:
*/
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);
OpenPOWER on IntegriCloud