Merge "net: ipv6: reset daddr and dport in socket if connect() fails"
This commit is contained in:
commit
b971eaa3a0
2 changed files with 21 additions and 8 deletions
|
@ -184,6 +184,11 @@ ipv4_connected:
|
||||||
err = 0;
|
err = 0;
|
||||||
if (IS_ERR(dst)) {
|
if (IS_ERR(dst)) {
|
||||||
err = PTR_ERR(dst);
|
err = PTR_ERR(dst);
|
||||||
|
/* 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;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include <net/tcp_states.h>
|
#include <net/tcp_states.h>
|
||||||
#include <net/ip6_checksum.h>
|
#include <net/ip6_checksum.h>
|
||||||
#include <net/xfrm.h>
|
#include <net/xfrm.h>
|
||||||
|
#include <net/inet_hashtables.h>
|
||||||
#include <net/inet6_hashtables.h>
|
#include <net/inet6_hashtables.h>
|
||||||
#include <net/busy_poll.h>
|
#include <net/busy_poll.h>
|
||||||
|
|
||||||
|
@ -964,15 +965,22 @@ static struct sock *__udp6_lib_demux_lookup(struct net *net,
|
||||||
int dif)
|
int dif)
|
||||||
{
|
{
|
||||||
struct sock *sk;
|
struct sock *sk;
|
||||||
|
struct hlist_nulls_node *hnode;
|
||||||
|
unsigned short hnum = ntohs(loc_port);
|
||||||
|
unsigned int hash2 = udp6_portaddr_hash(net, loc_addr, hnum);
|
||||||
|
unsigned int slot2 = hash2 & udp_table.mask;
|
||||||
|
struct udp_hslot *hslot2 = &udp_table.hash2[slot2];
|
||||||
|
|
||||||
rcu_read_lock();
|
const __portpair ports = INET_COMBINED_PORTS(rmt_port, hnum);
|
||||||
sk = __udp6_lib_lookup(net, rmt_addr, rmt_port, loc_addr, loc_port,
|
|
||||||
dif, &udp_table);
|
|
||||||
if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
|
|
||||||
sk = NULL;
|
|
||||||
rcu_read_unlock();
|
|
||||||
|
|
||||||
|
udp_portaddr_for_each_entry_rcu(sk, hnode, &hslot2->head) {
|
||||||
|
if (sk->sk_state == TCP_ESTABLISHED &&
|
||||||
|
INET6_MATCH(sk, net, rmt_addr, loc_addr, ports, dif))
|
||||||
return sk;
|
return sk;
|
||||||
|
/* Only check first socket in chain */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void udp_v6_early_demux(struct sk_buff *skb)
|
static void udp_v6_early_demux(struct sk_buff *skb)
|
||||||
|
@ -997,7 +1005,7 @@ static void udp_v6_early_demux(struct sk_buff *skb)
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!sk)
|
if (!sk || !atomic_inc_not_zero_hint(&sk->sk_refcnt, 2))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
skb->sk = sk;
|
skb->sk = sk;
|
||||||
|
|
Loading…
Add table
Reference in a new issue