All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] inet: fix NLM_F_DUMP_INTR logic
@ 2024-02-15 17:21 Eric Dumazet
  2024-02-15 17:21 ` [PATCH net 1/2] ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Eric Dumazet @ 2024-02-15 17:21 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: David Ahern, Nicolas Dichtel, netdev, eric.dumazet, Eric Dumazet

Make sure NLM_F_DUMP_INTR is generated if dev_base_seq and
dev_addr_genid are changed by the same amount.

Eric Dumazet (2):
  ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid
  ipv6: properly combine dev_base_seq and ipv6.dev_addr_genid

 net/ipv4/devinet.c  | 21 +++++++++++++++++----
 net/ipv6/addrconf.c | 21 ++++++++++++++++++---
 2 files changed, 35 insertions(+), 7 deletions(-)

-- 
2.43.0.687.g38aa6559b0-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net 1/2] ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid
  2024-02-15 17:21 [PATCH net 0/2] inet: fix NLM_F_DUMP_INTR logic Eric Dumazet
@ 2024-02-15 17:21 ` Eric Dumazet
  2024-02-16  9:16   ` Nicolas Dichtel
  2024-02-15 17:21 ` [PATCH net 2/2] ipv6: properly combine dev_base_seq and ipv6.dev_addr_genid Eric Dumazet
  2024-02-18 10:30 ` [PATCH net 0/2] inet: fix NLM_F_DUMP_INTR logic patchwork-bot+netdevbpf
  2 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2024-02-15 17:21 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: David Ahern, Nicolas Dichtel, netdev, eric.dumazet, Eric Dumazet

net->dev_base_seq and ipv4.dev_addr_genid are monotonically increasing.

If we XOR their values, we could miss to detect if both values
were changed with the same amount.

Fixes: 0465277f6b3f ("ipv4: provide addr and netconf dump consistency info")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv4/devinet.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index ca0ff15dc8fa358b81a804eda7398ecd10f00743..bc74f131fe4dfad327e71c1a8f0a4b66cdc526e5 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1825,6 +1825,21 @@ static int in_dev_dump_addr(struct in_device *in_dev, struct sk_buff *skb,
 	return err;
 }
 
+/* Combine dev_addr_genid and dev_base_seq to detect changes.
+ */
+static u32 inet_base_seq(const struct net *net)
+{
+	u32 res = atomic_read(&net->ipv4.dev_addr_genid) +
+		  net->dev_base_seq;
+
+	/* Must not return 0 (see nl_dump_check_consistent()).
+	 * Chose a value far away from 0.
+	 */
+	if (!res)
+		res = 0x80000000;
+	return res;
+}
+
 static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	const struct nlmsghdr *nlh = cb->nlh;
@@ -1876,8 +1891,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
 		idx = 0;
 		head = &tgt_net->dev_index_head[h];
 		rcu_read_lock();
-		cb->seq = atomic_read(&tgt_net->ipv4.dev_addr_genid) ^
-			  tgt_net->dev_base_seq;
+		cb->seq = inet_base_seq(tgt_net);
 		hlist_for_each_entry_rcu(dev, head, index_hlist) {
 			if (idx < s_idx)
 				goto cont;
@@ -2278,8 +2292,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
 		idx = 0;
 		head = &net->dev_index_head[h];
 		rcu_read_lock();
-		cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
-			  net->dev_base_seq;
+		cb->seq = inet_base_seq(net);
 		hlist_for_each_entry_rcu(dev, head, index_hlist) {
 			if (idx < s_idx)
 				goto cont;
-- 
2.43.0.687.g38aa6559b0-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net 2/2] ipv6: properly combine dev_base_seq and ipv6.dev_addr_genid
  2024-02-15 17:21 [PATCH net 0/2] inet: fix NLM_F_DUMP_INTR logic Eric Dumazet
  2024-02-15 17:21 ` [PATCH net 1/2] ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid Eric Dumazet
@ 2024-02-15 17:21 ` Eric Dumazet
  2024-02-16  9:17   ` Nicolas Dichtel
  2024-02-18 10:30 ` [PATCH net 0/2] inet: fix NLM_F_DUMP_INTR logic patchwork-bot+netdevbpf
  2 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2024-02-15 17:21 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: David Ahern, Nicolas Dichtel, netdev, eric.dumazet, Eric Dumazet

net->dev_base_seq and ipv6.dev_addr_genid are monotonically increasing.

If we XOR their values, we could miss to detect if both values
were changed with the same amount.

Fixes: 63998ac24f83 ("ipv6: provide addr and netconf dump consistency info")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv6/addrconf.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 733ace18806c61f487d83081dc6d39d079959f77..5a839c5fb1a5aa55e5c7f2ad8081e401a76d5a93 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -708,6 +708,22 @@ static int inet6_netconf_get_devconf(struct sk_buff *in_skb,
 	return err;
 }
 
+/* Combine dev_addr_genid and dev_base_seq to detect changes.
+ */
+static u32 inet6_base_seq(const struct net *net)
+{
+	u32 res = atomic_read(&net->ipv6.dev_addr_genid) +
+		  net->dev_base_seq;
+
+	/* Must not return 0 (see nl_dump_check_consistent()).
+	 * Chose a value far away from 0.
+	 */
+	if (!res)
+		res = 0x80000000;
+	return res;
+}
+
+
 static int inet6_netconf_dump_devconf(struct sk_buff *skb,
 				      struct netlink_callback *cb)
 {
@@ -741,8 +757,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
 		idx = 0;
 		head = &net->dev_index_head[h];
 		rcu_read_lock();
-		cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
-			  net->dev_base_seq;
+		cb->seq = inet6_base_seq(net);
 		hlist_for_each_entry_rcu(dev, head, index_hlist) {
 			if (idx < s_idx)
 				goto cont;
@@ -5362,7 +5377,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
 	}
 
 	rcu_read_lock();
-	cb->seq = atomic_read(&tgt_net->ipv6.dev_addr_genid) ^ tgt_net->dev_base_seq;
+	cb->seq = inet6_base_seq(tgt_net);
 	for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
 		idx = 0;
 		head = &tgt_net->dev_index_head[h];
-- 
2.43.0.687.g38aa6559b0-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net 1/2] ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid
  2024-02-15 17:21 ` [PATCH net 1/2] ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid Eric Dumazet
@ 2024-02-16  9:16   ` Nicolas Dichtel
  0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Dichtel @ 2024-02-16  9:16 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: David Ahern, netdev, eric.dumazet

Le 15/02/2024 à 18:21, Eric Dumazet a écrit :
> net->dev_base_seq and ipv4.dev_addr_genid are monotonically increasing.
> 
> If we XOR their values, we could miss to detect if both values
> were changed with the same amount.
> 
> Fixes: 0465277f6b3f ("ipv4: provide addr and netconf dump consistency info")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Or if both values are equal :/

Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net 2/2] ipv6: properly combine dev_base_seq and ipv6.dev_addr_genid
  2024-02-15 17:21 ` [PATCH net 2/2] ipv6: properly combine dev_base_seq and ipv6.dev_addr_genid Eric Dumazet
@ 2024-02-16  9:17   ` Nicolas Dichtel
  2024-02-16  9:19     ` Eric Dumazet
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Dichtel @ 2024-02-16  9:17 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: David Ahern, netdev, eric.dumazet

Le 15/02/2024 à 18:21, Eric Dumazet a écrit :
> net->dev_base_seq and ipv6.dev_addr_genid are monotonically increasing.
> 
> If we XOR their values, we could miss to detect if both values
> were changed with the same amount.
> 
> Fixes: 63998ac24f83 ("ipv6: provide addr and netconf dump consistency info")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

The trailers are mangled, your sob is put twice.

Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net 2/2] ipv6: properly combine dev_base_seq and ipv6.dev_addr_genid
  2024-02-16  9:17   ` Nicolas Dichtel
@ 2024-02-16  9:19     ` Eric Dumazet
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2024-02-16  9:19 UTC (permalink / raw)
  To: nicolas.dichtel
  Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, David Ahern,
	netdev, eric.dumazet

On Fri, Feb 16, 2024 at 10:17 AM Nicolas Dichtel
<nicolas.dichtel@6wind.com> wrote:
>
> Le 15/02/2024 à 18:21, Eric Dumazet a écrit :
> > net->dev_base_seq and ipv6.dev_addr_genid are monotonically increasing.
> >
> > If we XOR their values, we could miss to detect if both values
> > were changed with the same amount.
> >
> > Fixes: 63998ac24f83 ("ipv6: provide addr and netconf dump consistency info")
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
> > Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> >
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
>
> The trailers are mangled, your sob is put twice.
>
> Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Oops, copy/paste error ;)

Thanks !

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net 0/2] inet: fix NLM_F_DUMP_INTR logic
  2024-02-15 17:21 [PATCH net 0/2] inet: fix NLM_F_DUMP_INTR logic Eric Dumazet
  2024-02-15 17:21 ` [PATCH net 1/2] ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid Eric Dumazet
  2024-02-15 17:21 ` [PATCH net 2/2] ipv6: properly combine dev_base_seq and ipv6.dev_addr_genid Eric Dumazet
@ 2024-02-18 10:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-18 10:30 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, dsahern, nicolas.dichtel, netdev, eric.dumazet

Hello:

This series was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Thu, 15 Feb 2024 17:21:05 +0000 you wrote:
> Make sure NLM_F_DUMP_INTR is generated if dev_base_seq and
> dev_addr_genid are changed by the same amount.
> 
> Eric Dumazet (2):
>   ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid
>   ipv6: properly combine dev_base_seq and ipv6.dev_addr_genid
> 
> [...]

Here is the summary with links:
  - [net,1/2] ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid
    https://git.kernel.org/netdev/net/c/081a0e3b0d4c
  - [net,2/2] ipv6: properly combine dev_base_seq and ipv6.dev_addr_genid
    https://git.kernel.org/netdev/net/c/e898e4cd1aab

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-02-18 10:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-15 17:21 [PATCH net 0/2] inet: fix NLM_F_DUMP_INTR logic Eric Dumazet
2024-02-15 17:21 ` [PATCH net 1/2] ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid Eric Dumazet
2024-02-16  9:16   ` Nicolas Dichtel
2024-02-15 17:21 ` [PATCH net 2/2] ipv6: properly combine dev_base_seq and ipv6.dev_addr_genid Eric Dumazet
2024-02-16  9:17   ` Nicolas Dichtel
2024-02-16  9:19     ` Eric Dumazet
2024-02-18 10:30 ` [PATCH net 0/2] inet: fix NLM_F_DUMP_INTR logic patchwork-bot+netdevbpf

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.