Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Lahav Schlesinger <lschlesinger@drivenets.com>
To: David Ahern <dsahern@gmail.com>
Cc: netdev@vger.kernel.org, dsahern@kernel.org, davem@davemloft.net,
	kuba@kernel.org
Subject: Re: [PATCH] net: Support filtering interfaces on no master
Date: Mon, 9 Aug 2021 09:54:32 +0300	[thread overview]
Message-ID: <20210809065432.lk2dx3abff4p6wmq@kgollan-pc> (raw)
In-Reply-To: <439cf1f8-78ad-2fec-8a43-a863ac34297b@gmail.com>

On Sun, Aug 08, 2021 at 02:02:36PM -0600, David Ahern wrote:
> On 8/8/21 7:28 AM, 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.
> >
> > I have a patch for iproute2 ready for adding this support in userspace.
> >
> > Signed-off-by: Lahav Schlesinger <lschlesinger@drivenets.com>
> > Cc: David Ahern <dsahern@kernel.org>
> > Cc: David S. Miller <davem@davemloft.net>
> > Cc: Jakub Kicinski <kuba@kernel.org>
> > ---
> >  net/core/neighbour.c | 7 +++++++
> >  net/core/rtnetlink.c | 7 +++++++
> >  2 files changed, 14 insertions(+)
> >
> > diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> > index 53e85c70c6e5..1b1e0ca70650 100644
> > --- a/net/core/neighbour.c
> > +++ b/net/core/neighbour.c
> > @@ -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
>
> > +
> >  	if (!master || master->ifindex != master_idx)
> >  		return true;
> >
> > diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> > index f6af3e74fc44..8ccc314744d4 100644
> > --- a/net/core/rtnetlink.c
> > +++ b/net/core/rtnetlink.c
> > @@ -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;
> >
> >
>


From 7908142b2d4799672a7f9dd27e848214e3c4a0a7 Mon Sep 17 00:00:00 2001
From: Lahav Schlesinger <lschlesinger@drivenets.com>
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.

Signed-off-by: Lahav Schlesinger <lschlesinger@drivenets.com>
Cc: David Ahern <dsahern@kernel.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
---
 net/core/neighbour.c | 7 +++++++
 net/core/rtnetlink.c | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 53e85c70c6e5..3aeefc48b96a 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -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;

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index f6af3e74fc44..bc4d62174ab0 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -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

  reply	other threads:[~2021-08-09  6:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-08 13:28 Lahav Schlesinger
2021-08-08 20:02 ` David Ahern
2021-08-09  6:54   ` Lahav Schlesinger [this message]
2021-08-09 20:32     ` Jakub Kicinski

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=20210809065432.lk2dx3abff4p6wmq@kgollan-pc \
    --to=lschlesinger@drivenets.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --subject='Re: [PATCH] net: Support filtering interfaces on no master' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).