net: remove duplicate reuseport_lookup functions
authorLorenz Bauer <lmb@isovalent.com>
Thu, 20 Jul 2023 15:30:08 +0000 (17:30 +0200)
committerMartin KaFai Lau <martin.lau@kernel.org>
Tue, 25 Jul 2023 20:51:44 +0000 (13:51 -0700)
commit0f495f7617229772403e683033abc473f0f0553c
tree14162556d8b75af77a81d29a147babdbbf9c8735
parentce796e60b3b196b61fcc565df195443cbb846ef0
net: remove duplicate reuseport_lookup functions

There are currently four copies of reuseport_lookup: one each for
(TCP, UDP)x(IPv4, IPv6). This forces us to duplicate all callers of
those functions as well. This is already the case for sk_lookup
helpers (inet,inet6,udp4,udp6)_lookup_run_bpf.

There are two differences between the reuseport_lookup helpers:

1. They call different hash functions depending on protocol
2. UDP reuseport_lookup checks that sk_state != TCP_ESTABLISHED

Move the check for sk_state into the caller and use the INDIRECT_CALL
infrastructure to cut down the helpers to one per IP version.

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Link: https://lore.kernel.org/r/20230720-so-reuseport-v6-4-7021b683cdae@isovalent.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
include/net/inet6_hashtables.h
include/net/inet_hashtables.h
net/ipv4/inet_hashtables.c
net/ipv4/udp.c
net/ipv6/inet6_hashtables.c
net/ipv6/udp.c