Skip to content

Commit

Permalink
udp, bpf: Ignore connections in reuseport group after BPF sk lookup
Browse files Browse the repository at this point in the history
When BPF sk lookup invokes reuseport handling for the selected socket, it
should ignore the fact that reuseport group can contain connected UDP
sockets. With BPF sk lookup this is not relevant as we are not scoring
sockets to find the best match, which might be a connected UDP socket.

Fix it by unconditionally accepting the socket selected by reuseport.

This fixes the following two failures reported by test_progs.

  # ./test_progs -t sk_lookup
  ...
  torvalds#73/14 UDP IPv4 redir and reuseport with conns:FAIL
  ...
  torvalds#73/20 UDP IPv6 redir and reuseport with conns:FAIL
  ...

Fixes: a57066b ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net")
Reported-by: Alexei Starovoitov <[email protected]>
Signed-off-by: Jakub Sitnicki <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
jsitnicki authored and borkmann committed Jul 31, 2020
1 parent 50450fc commit c64c9c2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ static struct sock *udp4_lookup_run_bpf(struct net *net,
return sk;

reuse_sk = lookup_reuseport(net, sk, skb, saddr, sport, daddr, hnum);
if (reuse_sk && !reuseport_has_conns(sk, false))
if (reuse_sk)
sk = reuse_sk;
return sk;
}
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static inline struct sock *udp6_lookup_run_bpf(struct net *net,
return sk;

reuse_sk = lookup_reuseport(net, sk, skb, saddr, sport, daddr, hnum);
if (reuse_sk && !reuseport_has_conns(sk, false))
if (reuse_sk)
sk = reuse_sk;
return sk;
}
Expand Down

0 comments on commit c64c9c2

Please sign in to comment.