All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com,
	 David Ahern <dsahern@kernel.org>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	 Eric Dumazet <edumazet@google.com>
Subject: [PATCH net 1/6] tcp_metrics: fix addr_same() helper
Date: Wed,  2 Aug 2023 13:14:55 +0000	[thread overview]
Message-ID: <20230802131500.1478140-2-edumazet@google.com> (raw)
In-Reply-To: <20230802131500.1478140-1-edumazet@google.com>

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@google.com>
Cc: David Ahern <dsahern@kernel.org>
---
 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


  reply	other threads:[~2023-08-02 13:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-02 13:14 [PATCH net 0/6] tcp_metrics: series of fixes Eric Dumazet
2023-08-02 13:14 ` Eric Dumazet [this message]
2023-08-02 15:04   ` [PATCH net 1/6] tcp_metrics: fix addr_same() helper David Ahern
2023-08-02 17:26   ` Kuniyuki Iwashima
2023-08-02 13:14 ` [PATCH net 2/6] tcp_metrics: annotate data-races around tm->tcpm_stamp Eric Dumazet
2023-08-02 15:06   ` David Ahern
2023-08-02 17:30   ` Kuniyuki Iwashima
2023-08-02 13:14 ` [PATCH net 3/6] tcp_metrics: annotate data-races around tm->tcpm_lock Eric Dumazet
2023-08-02 15:07   ` David Ahern
2023-08-02 17:35   ` Kuniyuki Iwashima
2023-08-02 13:14 ` [PATCH net 4/6] tcp_metrics: annotate data-races around tm->tcpm_vals[] Eric Dumazet
2023-08-02 15:09   ` David Ahern
2023-08-02 17:37   ` Kuniyuki Iwashima
2023-08-02 13:14 ` [PATCH net 5/6] tcp_metrics: annotate data-races around tm->tcpm_net Eric Dumazet
2023-08-02 15:12   ` David Ahern
2023-08-02 17:42   ` Kuniyuki Iwashima
2023-08-02 13:15 ` [PATCH net 6/6] tcp_metrics: fix data-race in tcpm_suck_dst() vs fastopen Eric Dumazet
2023-08-02 17:47   ` Kuniyuki Iwashima
2023-08-03 18:10 ` [PATCH net 0/6] tcp_metrics: series of fixes patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230802131500.1478140-2-edumazet@google.com \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=eric.dumazet@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.