Skip to contentSkip to conversation

net: make sure we never create ifindex = 0

PATCH Applied Jakub Kicinski 3 participants 3 messages Jul 31, 2023 – Aug 1, 2023

Subsystems (2)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH v2 1/1 net: make sure we never create ifindex = 0

Instead of allocating from 1 use proper xa_init flag, to protect ourselves from IDs wrapping back to 0.

Fixes 759ab1edb56c ("net: store netdevs in an xarray")

---
CC: [email protected]

---
 net/core/dev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/core/dev.c +1 -2
index b58674774a57..10e5a036c706 100644
@@ -11271,8 +11271,7 @@ static int __net_init netdev_init(struct net *net)
 	if (net->dev_index_head == NULL)
 		goto err_idx;
 
-	net->ifindex = 1;
-	xa_init_flags(&net->dev_by_index, XA_FLAGS_ALLOC);
+	xa_init_flags(&net->dev_by_index, XA_FLAGS_ALLOC1);
 
 	RAW_INIT_NOTIFIER_HEAD(&net->netdev_chain);
 
Signature · 1 line
2.41.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Jakub Kicinski

Instead of allocating from 1 use proper xa_init flag, to protect ourselves from IDs wrapping back to 0.

Fixes 759ab1edb56c ("net: store netdevs in an xarray")
Quoted 6 lines

---
CC: [email protected]

---
 net/core/dev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Thanks,

#2 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Mon, 31 Jul 2023 10:11:58 -0700 you wrote:

Instead of allocating from 1 use proper xa_init flag, to protect ourselves from IDs wrapping back to 0.

Fixes 759ab1edb56c ("net: store netdevs in an xarray")

[...]

Here is the summary with links:
- [net-next,v2] net: make sure we never create ifindex = 0

    https://git.kernel.org/netdev/net-next/c/ceaac91dcd06

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html