Skip to content

Commit

Permalink
l2tp: consider '::' as wildcard address in l2tp_ip6 socket lookup
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Guillaume Nault authored and davem330 committed Jan 2, 2017
1 parent 4200462 commit 97b84fd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/l2tp/l2tp_ip6.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ static struct sock *__l2tp_ip6_bind_lookup(struct net *net,
struct sock *sk;

sk_for_each_bound(sk, &l2tp_ip6_bind_table) {
const struct in6_addr *addr = inet6_rcv_saddr(sk);
const struct in6_addr *sk_laddr = inet6_rcv_saddr(sk);
struct l2tp_ip6_sock *l2tp = l2tp_ip6_sk(sk);

if (l2tp == NULL)
continue;

if ((l2tp->conn_id == tunnel_id) &&
net_eq(sock_net(sk), net) &&
(!addr || ipv6_addr_equal(addr, laddr)) &&
(!sk_laddr || ipv6_addr_any(sk_laddr) || ipv6_addr_equal(sk_laddr, laddr)) &&
(!sk->sk_bound_dev_if || !dif ||
sk->sk_bound_dev_if == dif))
goto found;
Expand Down

0 comments on commit 97b84fd

Please sign in to comment.