Skip to content

Commit e663809

Browse files
edumazetkuba-moo
authored andcommitted
tcp_metrics: fix addr_same() helper
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: d39d14f ("net: Add helper function to compare inetpeer addresses") Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: David Ahern <dsahern@kernel.org> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://lore.kernel.org/r/20230802131500.1478140-2-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent b755c25 commit e663809

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/ipv4/tcp_metrics.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void tcp_metric_set(struct tcp_metrics_block *tm,
7878
static bool addr_same(const struct inetpeer_addr *a,
7979
const struct inetpeer_addr *b)
8080
{
81-
return inetpeer_addr_cmp(a, b) == 0;
81+
return (a->family == b->family) && !inetpeer_addr_cmp(a, b);
8282
}
8383

8484
struct tcpm_hash_bucket {

0 commit comments

Comments
 (0)