Commit 000224c1106c2abc21a376c5bb851b1ffe4b4458

Authored by Guillaume Nault
Committed by Greg Kroah-Hartman
1 parent c2804b21f2

l2tp: consider '::' as wildcard address in l2tp_ip6 socket lookup

[ Upstream commit 97b84fd6d91766ea57dcc350d78f42639e011c30 ]

An L2TP socket bound to the unspecified address should match with any
address. If not, it can't receive any packet and __l2tp_ip6_bind_lookup()
can't prevent another socket from binding on the same device/tunnel ID.

While there, rename the 'addr' variable to 'sk_laddr' (local addr), to
make following patch clearer.

Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff

... ... @@ -64,7 +64,7 @@
64 64 struct sock *sk;
65 65  
66 66 sk_for_each_bound(sk, &l2tp_ip6_bind_table) {
67   - const struct in6_addr *addr = inet6_rcv_saddr(sk);
  67 + const struct in6_addr *sk_laddr = inet6_rcv_saddr(sk);
68 68 struct l2tp_ip6_sock *l2tp = l2tp_ip6_sk(sk);
69 69  
70 70 if (l2tp == NULL)
... ... @@ -72,7 +72,7 @@
72 72  
73 73 if ((l2tp->conn_id == tunnel_id) &&
74 74 net_eq(sock_net(sk), net) &&
75   - (!addr || ipv6_addr_equal(addr, laddr)) &&
  75 + (!sk_laddr || ipv6_addr_any(sk_laddr) || ipv6_addr_equal(sk_laddr, laddr)) &&
76 76 (!sk->sk_bound_dev_if || !dif ||
77 77 sk->sk_bound_dev_if == dif))
78 78 goto found;