[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230802172645.50191-1-kuniyu@amazon.com>
Date: Wed, 2 Aug 2023 10:26:45 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <edumazet@...gle.com>
CC: <davem@...emloft.net>, <dsahern@...nel.org>, <eric.dumazet@...il.com>,
<kuba@...nel.org>, <kuniyu@...zon.com>, <netdev@...r.kernel.org>,
<pabeni@...hat.com>
Subject: Re: [PATCH net 1/6] tcp_metrics: fix addr_same() helper
From: Eric Dumazet <edumazet@...gle.com>
Date: Wed, 2 Aug 2023 13:14:55 +0000
> Because v4 and v6 families use separate inetpeer trees (respectively
> net->ipv4.peers and net->ipv6.peers), inetpeer_addr_cmp(a, b) assumes
> a & b share the same family.
>
> tcp_metrics use a common hash table, where entries can have different
> families.
>
> We must therefore make sure to not call inetpeer_addr_cmp()
> if the families do not match.
>
> Fixes: d39d14ffa24c ("net: Add helper function to compare inetpeer addresses")
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> Cc: David Ahern <dsahern@...nel.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu@...zon.com>
> ---
> net/ipv4/tcp_metrics.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
> index 82f4575f9cd90049a5ad4c7329ad1ddc28fc1aa0..c4daf0aa2d4d9695e128b67df571d91d647a254d 100644
> --- a/net/ipv4/tcp_metrics.c
> +++ b/net/ipv4/tcp_metrics.c
> @@ -78,7 +78,7 @@ static void tcp_metric_set(struct tcp_metrics_block *tm,
> static bool addr_same(const struct inetpeer_addr *a,
> const struct inetpeer_addr *b)
> {
> - return inetpeer_addr_cmp(a, b) == 0;
> + return (a->family == b->family) && !inetpeer_addr_cmp(a, b);
> }
>
> struct tcpm_hash_bucket {
> --
> 2.41.0.640.ga95def55d0-goog
Powered by blists - more mailing lists