Skip to content

Commit

Permalink
net: Support filtering interfaces on no master
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Lahav Schlesinger <[email protected]>
Reviewed-by: David Ahern <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
lschlesinger-dn authored and kuba-moo committed Aug 10, 2021
1 parent a5397d6 commit d3432bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions net/core/neighbour.c
Original file line number Diff line number Diff line change
Expand Up @@ -2528,6 +2528,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;

Expand Down
7 changes: 7 additions & 0 deletions net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,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;

Expand Down

0 comments on commit d3432bf

Please sign in to comment.