Commit 2a617763 authored by Lorenz Bauer's avatar Lorenz Bauer Committed by Martin KaFai Lau
Browse files

net: document inet[6]_lookup_reuseport sk_state requirements



The current implementation was extracted from inet[6]_lhash2_lookup
in commit 80b373f7 ("inet: Extract helper for selecting socket
from reuseport group") and commit 5df65312 ("inet6: Extract helper
for selecting socket from reuseport group"). In the original context,
sk is always in TCP_LISTEN state and so did not have a separate check.

Add documentation that specifies which sk_state are valid to pass to
the function.

Reviewed-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: default avatarLorenz Bauer <lmb@isovalent.com>
Link: https://lore.kernel.org/r/20230720-so-reuseport-v6-5-7021b683cdae@isovalent.com


Signed-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
parent 0f495f76
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -335,6 +335,21 @@ static inline int compute_score(struct sock *sk, struct net *net,

INDIRECT_CALLABLE_DECLARE(inet_ehashfn_t udp_ehashfn);

/**
 * inet_lookup_reuseport() - execute reuseport logic on AF_INET socket if necessary.
 * @net: network namespace.
 * @sk: AF_INET socket, must be in TCP_LISTEN state for TCP or TCP_CLOSE for UDP.
 * @skb: context for a potential SK_REUSEPORT program.
 * @doff: header offset.
 * @saddr: source address.
 * @sport: source port.
 * @daddr: destination address.
 * @hnum: destination port in host byte order.
 * @ehashfn: hash function used to generate the fallback hash.
 *
 * Return: NULL if sk doesn't have SO_REUSEPORT set, otherwise a pointer to
 *         the selected sock or an error.
 */
struct sock *inet_lookup_reuseport(struct net *net, struct sock *sk,
				   struct sk_buff *skb, int doff,
				   __be32 saddr, __be16 sport,
+15 −0
Original line number Diff line number Diff line
@@ -114,6 +114,21 @@ static inline int compute_score(struct sock *sk, struct net *net,

INDIRECT_CALLABLE_DECLARE(inet6_ehashfn_t udp6_ehashfn);

/**
 * inet6_lookup_reuseport() - execute reuseport logic on AF_INET6 socket if necessary.
 * @net: network namespace.
 * @sk: AF_INET6 socket, must be in TCP_LISTEN state for TCP or TCP_CLOSE for UDP.
 * @skb: context for a potential SK_REUSEPORT program.
 * @doff: header offset.
 * @saddr: source address.
 * @sport: source port.
 * @daddr: destination address.
 * @hnum: destination port in host byte order.
 * @ehashfn: hash function used to generate the fallback hash.
 *
 * Return: NULL if sk doesn't have SO_REUSEPORT set, otherwise a pointer to
 *         the selected sock or an error.
 */
struct sock *inet6_lookup_reuseport(struct net *net, struct sock *sk,
				    struct sk_buff *skb, int doff,
				    const struct in6_addr *saddr,