[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230628183950.75449-1-kuniyu@amazon.com>
Date: Wed, 28 Jun 2023 11:39:50 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <lmb@...valent.com>
CC: <andrii@...nel.org>, <ast@...nel.org>, <bpf@...r.kernel.org>,
<daniel@...earbox.net>, <davem@...emloft.net>,
<dsahern@...nel.org>, <edumazet@...gle.com>, <haoluo@...gle.com>,
<hemanthmalla@...il.com>, <joe@...d.net.nz>,
<john.fastabend@...il.com>, <jolsa@...nel.org>,
<kpsingh@...nel.org>, <kuba@...nel.org>, <kuniyu@...zon.com>,
<linux-kernel@...r.kernel.org>, <linux-kselftest@...r.kernel.org>,
<martin.lau@...ux.dev>, <mykolal@...com>, <netdev@...r.kernel.org>,
<pabeni@...hat.com>, <sdf@...gle.com>, <shuah@...nel.org>,
<song@...nel.org>, <willemdebruijn.kernel@...il.com>, <yhs@...com>
Subject: Re: [PATCH bpf-next v4 4/7] net: document inet[6]_lookup_reuseport sk_state requirements
From: Lorenz Bauer <lmb@...valent.com>
Date: Wed, 28 Jun 2023 10:48:19 +0100
> The current implementation was extracted from inet[6]_lhash2_lookup
> in commit 80b373f74f9e ("inet: Extract helper for selecting socket
> from reuseport group") and commit 5df6531292b5 ("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.
>
> Signed-off-by: Lorenz Bauer <lmb@...valent.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@...zon.com>
2 nit below.
> ---
> net/ipv4/inet_hashtables.c | 14 ++++++++++++++
> net/ipv6/inet6_hashtables.c | 14 ++++++++++++++
> 2 files changed, 28 insertions(+)
>
> diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
> index 352eb371c93b..ac927a635a6f 100644
> --- a/net/ipv4/inet_hashtables.c
> +++ b/net/ipv4/inet_hashtables.c
> @@ -335,6 +335,20 @@ 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.
It seems you forgot to copy-and-paste the ehashfn description.
---8<---
+ * @ehashfn: hash function used to generate the fallback hash.
---8<---
https://lore.kernel.org/all/20230613-so-reuseport-v3-4-907b4cbb7b99@isovalent.com/
> + *
> + * 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,
> diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
> index 3616225c89ef..d37602fabc00 100644
> --- a/net/ipv6/inet6_hashtables.c
> +++ b/net/ipv6/inet6_hashtables.c
> @@ -114,6 +114,20 @@ 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.
Same here.
> + *
> + * 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,
>
> --
> 2.40.1
Powered by blists - more mailing lists