Skip to contentSkip to conversation

net: Support filtering interfaces on no master

PATCH Superseded Lahav Schlesinger 3 participants 4 messages Aug 8, 2021 – Aug 9, 2021

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: Support filtering interfaces on no master

Currently there's support for filtering neighbours/links for interfaces which have a specific master device (using the IFLA_MASTER/NDA_MASTER attributes).

This patch adds support for filtering interfaces/neighbours dump for interfaces that *don't* have a master.

I have a patch for iproute2 ready for adding this support in userspace.

Cc David Ahern <[email protected]>
Cc David S. Miller <[email protected]>
Cc Jakub Kicinski <[email protected]>
---
 net/core/neighbour.c | 7 +++++++
 net/core/rtnetlink.c | 7 +++++++
 2 files changed, 14 insertions(+)
net/core/neighbour.c +7 -0
index 53e85c70c6e5..1b1e0ca70650 100644
@@ -2533,6 +2533,13 @@ static bool neigh_master_filtered(struct net_device *dev, int master_idx)
 		return false;
 
 	master = dev ? netdev_master_upper_dev_get(dev) : NULL;
+
+	/* 0 is already used to denote NDA_MASTER wasn't passed, therefore need another
+	 * invalid value for ifindex to denote "no master".
+	 */
+	if (master_idx == -1)
+                return (bool)master;
+
 	if (!master || master->ifindex != master_idx)
 		return true;
 
net/core/rtnetlink.c +7 -0
index f6af3e74fc44..8ccc314744d4 100644
@@ -1970,6 +1970,13 @@ static bool link_master_filtered(struct net_device *dev, int master_idx)
 		return false;
 
 	master = netdev_master_upper_dev_get(dev);
+
+	/* 0 is already used to denote IFLA_MASTER wasn't passed, therefore need
+	 * another invalid value for ifindex to denote "no master".
+	 */
+	if (master_idx == -1)
+                return (bool)master;
+
 	if (!master || master->ifindex != master_idx)
 		return true;
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 23 lines · Lahav Schlesinger

Currently there's support for filtering neighbours/links for interfaces which have a specific master device (using the IFLA_MASTER/NDA_MASTER attributes).

This patch adds support for filtering interfaces/neighbours dump for interfaces that *don't* have a master.

I have a patch for iproute2 ready for adding this support in userspace.

Cc David Ahern <[email protected]>
Cc David S. Miller <[email protected]>
Cc Jakub Kicinski <[email protected]>
---
 net/core/neighbour.c | 7 +++++++
 net/core/rtnetlink.c | 7 +++++++
 2 files changed, 14 insertions(+)
net/core/neighbour.c +0 -0
index 53e85c70c6e5..1b1e0ca70650 100644

net/core/neighbour.c static bool neigh_master_filtered(struct net_device *dev, int master_idx) · line 2541

Quoted 9 lines
net/core/neighbour.c +6 -0
@@ -2533,6 +2533,13 @@ static bool neigh_master_filtered(struct net_device *dev, int master_idx)
 		return false;
 
 	master = dev ? netdev_master_upper_dev_get(dev) : NULL;
+
+	/* 0 is already used to denote NDA_MASTER wasn't passed, therefore need another
+	 * invalid value for ifindex to denote "no master".
+	 */
+	if (master_idx == -1)
+                return (bool)master;

return !!master;

same below

Quoted 23 lines
net/core/neighbour.c +1 -0
+
 	if (!master || master->ifindex != master_idx)
 		return true;
 
net/core/rtnetlink.c +7 -0
index f6af3e74fc44..8ccc314744d4 100644
@@ -1970,6 +1970,13 @@ static bool link_master_filtered(struct net_device *dev, int master_idx)
 		return false;
 
 	master = netdev_master_upper_dev_get(dev);
+
+	/* 0 is already used to denote IFLA_MASTER wasn't passed, therefore need
+	 * another invalid value for ifindex to denote "no master".
+	 */
+	if (master_idx == -1)
+                return (bool)master;
+
 	if (!master || master->ifindex != master_idx)
 		return true;
 
#2 lore raw
Quoted 49 lines · David Ahern
Quoted 23 lines · Lahav Schlesinger

Currently there's support for filtering neighbours/links for interfaces which have a specific master device (using the IFLA_MASTER/NDA_MASTER attributes).

This patch adds support for filtering interfaces/neighbours dump for interfaces that *don't* have a master.

I have a patch for iproute2 ready for adding this support in userspace.

Cc David Ahern <[email protected]>
Cc David S. Miller <[email protected]>
Cc Jakub Kicinski <[email protected]>
---
 net/core/neighbour.c | 7 +++++++
 net/core/rtnetlink.c | 7 +++++++
 2 files changed, 14 insertions(+)
net/core/neighbour.c +0 -0
index 53e85c70c6e5..1b1e0ca70650 100644

net/core/neighbour.c static bool neigh_master_filtered(struct net_device *dev, int master_idx) · line 2541

Quoted 9 lines
net/core/neighbour.c +6 -0
@@ -2533,6 +2533,13 @@ static bool neigh_master_filtered(struct net_device *dev, int master_idx)
 		return false;
 
 	master = dev ? netdev_master_upper_dev_get(dev) : NULL;
+
+	/* 0 is already used to denote NDA_MASTER wasn't passed, therefore need another
+	 * invalid value for ifindex to denote "no master".
+	 */
+	if (master_idx == -1)
+                return (bool)master;

return !!master;

same below

Quoted 11 lines
net/core/neighbour.c +1 -0
+
 	if (!master || master->ifindex != master_idx)
 		return true;
 
net/core/rtnetlink.c +0 -0
index f6af3e74fc44..8ccc314744d4 100644
@@ -1970,6 +1970,13 @@ static bool link_master_filtered(struct net_device *dev, int master_idx)
 		return false;
 
Quoted 13 lines

net/core/rtnetlink.c static bool link_master_filtered(struct net_device *dev, int master_idx) · line 1982

Quoted 12 lines
net/core/rtnetlink.c +7 -0
 	master = netdev_master_upper_dev_get(dev);
+
+	/* 0 is already used to denote IFLA_MASTER wasn't passed, therefore need
+	 * another invalid value for ifindex to denote "no master".
+	 */
+	if (master_idx == -1)
+                return (bool)master;
+
 	if (!master || master->ifindex != master_idx)
 		return true;
 

From 7908142b2d4799672a7f9dd27e848214e3c4a0a7 Mon Sep 17 00:00:00 2001
From: Lahav Schlesinger <[email protected]>
Date: Sun, 8 Aug 2021 13:16:44 +0000
Subject: [PATCH] net: Support filtering interfaces on no master

Currently there's support for filtering neighbours/links for interfaces which have a specific master device (using the IFLA_MASTER/NDA_MASTER attributes).

This patch adds support for filtering interfaces/neighbours dump for interfaces that *don't* have a master.

I have a patch for iproute2 ready for adding this support in userspace.

Cc David Ahern <[email protected]>
Cc David S. Miller <[email protected]>
Cc Jakub Kicinski <[email protected]>
---
 net/core/neighbour.c | 7 +++++++
 net/core/rtnetlink.c | 7 +++++++
 2 files changed, 14 insertions(+)
net/core/neighbour.c +7 -0
index 53e85c70c6e5..3aeefc48b96a 100644
@@ -2533,6 +2533,13 @@ static bool neigh_master_filtered(struct net_device *dev, int master_idx)
 		return false;
 
 	master = dev ? netdev_master_upper_dev_get(dev) : NULL;
+
+	/* 0 is already used to denote NDA_MASTER wasn't passed, therefore need another
+	 * invalid value for ifindex to denote "no master".
+	 */
+	if (master_idx == -1)
+		return !!master;
+
 	if (!master || master->ifindex != master_idx)
 		return true;
 
net/core/rtnetlink.c +7 -0
index f6af3e74fc44..bc4d62174ab0 100644
@@ -1970,6 +1970,13 @@ static bool link_master_filtered(struct net_device *dev, int master_idx)
 		return false;
 
 	master = netdev_master_upper_dev_get(dev);
+
+	/* 0 is already used to denote IFLA_MASTER wasn't passed, therefore need
+	 * another invalid value for ifindex to denote "no master".
+	 */
+	if (master_idx == -1)
+		return !!master;
+
 	if (!master || master->ifindex != master_idx)
 		return true;
 

--
2.25.1

maintainer
#3 lore raw
Quoted 7 lines · On Mon, 9 Aug 2021 09:54:32 +0300 Lahav Schlesinger wrote:

Currently there's support for filtering neighbours/links for interfaces which have a specific master device (using the IFLA_MASTER/NDA_MASTER attributes).

This patch adds support for filtering interfaces/neighbours dump for interfaces that *don't* have a master.

Quoted 6 lines

I have a patch for iproute2 ready for adding this support in userspace.

Cc David Ahern <[email protected]>
Cc David S. Miller <[email protected]>
Cc Jakub Kicinski <[email protected]>

Please make a fresh posting with [PATCH net-next v2] as the subject tag.