All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lahav Schlesinger <lschlesinger@drivenets.com>
To: netdev@vger.kernel.org
Cc: dsahern@kernel.org
Subject: [PATCH v2] ip: Support filter links/neighs with no master
Date: Thu,  9 Sep 2021 10:20:19 +0300	[thread overview]
Message-ID: <20210909072019.8220-1-lschlesinger@drivenets.com> (raw)

Commit d3432bf10f17 ("net: Support filtering interfaces on no master")
in the kernel added support for filtering interfaces/neighbours that
have no master interface.

This patch completes it and adds this support to iproute2:
1. ip link show nomaster
2. ip address show nomaster
3. ip neighbour {show | flush} nomaster

Signed-off-by: Lahav Schlesinger <lschlesinger@drivenets.com>
---
v1 -> v2
    Break long lines
---
 ip/ipaddress.c           | 3 +++
 ip/iplink.c              | 1 +
 ip/ipneigh.c             | 4 +++-
 man/man8/ip-address.8.in | 7 ++++++-
 man/man8/ip-link.8.in    | 7 ++++++-
 man/man8/ip-neighbour.8  | 7 ++++++-
 6 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 85534aaf..4109d8bd 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -60,6 +60,7 @@ static void usage(void)
 		"       ip address {save|flush} [ dev IFNAME ] [ scope SCOPE-ID ]\n"
 		"                            [ to PREFIX ] [ FLAG-LIST ] [ label LABEL ] [up]\n"
 		"       ip address [ show [ dev IFNAME ] [ scope SCOPE-ID ] [ master DEVICE ]\n"
+		"                         [ nomaster ]\n"
 		"                         [ type TYPE ] [ to PREFIX ] [ FLAG-LIST ]\n"
 		"                         [ label LABEL ] [up] [ vrf NAME ] ]\n"
 		"       ip address {showdump|restore}\n"
@@ -2123,6 +2124,8 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
 			if (!name_is_vrf(*argv))
 				invarg("Not a valid VRF name\n", *argv);
 			filter.master = ifindex;
+		} else if (strcmp(*argv, "nomaster") == 0) {
+			filter.master = -1;
 		} else if (strcmp(*argv, "type") == 0) {
 			int soff;

diff --git a/ip/iplink.c b/ip/iplink.c
index 18b2ea25..bce3da49 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -120,6 +120,7 @@ void iplink_usage(void)
 		"		[ gso_max_size BYTES ] | [ gso_max_segs PACKETS ]\n"
 		"\n"
 		"	ip link show [ DEVICE | group GROUP ] [up] [master DEV] [vrf NAME] [type TYPE]\n"
+ 		"		[nomaster]\n"
 		"\n"
 		"	ip link xstats type TYPE [ ARGS ]\n"
 		"\n"
diff --git a/ip/ipneigh.c b/ip/ipneigh.c
index b778de00..c29325e1 100644
--- a/ip/ipneigh.c
+++ b/ip/ipneigh.c
@@ -54,7 +54,7 @@ static void usage(void)
 		"		[ dev DEV ] [ router ] [ extern_learn ] [ protocol PROTO ]\n"
 		"\n"
 		"	ip neigh { show | flush } [ proxy ] [ to PREFIX ] [ dev DEV ] [ nud STATE ]\n"
-		"				  [ vrf NAME ]\n"
+		"				  [ vrf NAME ] [ nomaster ]\n"
 		"	ip neigh get { ADDR | proxy ADDR } dev DEV\n"
 		"\n"
 		"STATE := { delay | failed | incomplete | noarp | none |\n"
@@ -535,6 +535,8 @@ static int do_show_or_flush(int argc, char **argv, int flush)
 			if (!name_is_vrf(*argv))
 				invarg("Not a valid VRF name\n", *argv);
 			filter.master = ifindex;
+		} else if (strcmp(*argv, "nomaster") == 0) {
+			filter.master = -1;
 		} else if (strcmp(*argv, "unused") == 0) {
 			filter.unused_only = 1;
 		} else if (strcmp(*argv, "nud") == 0) {
diff --git a/man/man8/ip-address.8.in b/man/man8/ip-address.8.in
index fe773c91..65f67e06 100644
--- a/man/man8/ip-address.8.in
+++ b/man/man8/ip-address.8.in
@@ -49,7 +49,8 @@ ip-address \- protocol address management
 .IR TYPE " ] [ "
 .B vrf
 .IR NAME " ] [ "
-.BR up " ] ]"
+.BR up " ] ["
+.BR nomaster " ] ]"

 .ti -8
 .BR "ip address" " { " showdump " | " restore " }"
@@ -340,6 +341,10 @@ output.
 .B up
 only list running interfaces.

+.TP
+.B nomaster
+only list interfaces with no master.
+
 .TP
 .BR dynamic " and " permanent
 (IPv6 only) only list addresses installed due to stateless
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 41efc6d4..c0cbb5e8 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -179,7 +179,8 @@ ip-link \- network device configuration
 .B type
 .IR ETYPE " ] ["
 .B vrf
-.IR NAME " ]"
+.IR NAME " ] ["
+.BR nomaster " ]"

 .ti -8
 .B ip link xstats
@@ -2536,6 +2537,10 @@ interface list by comparing it with the relevant attribute in case the kernel
 didn't filter already. Therefore any string is accepted, but may lead to empty
 output.

+.TP
+.B nomaster
+only show devices with no master
+
 .SS  ip link xstats - display extended statistics

 .TP
diff --git a/man/man8/ip-neighbour.8 b/man/man8/ip-neighbour.8
index a27f9ef8..02862964 100644
--- a/man/man8/ip-neighbour.8
+++ b/man/man8/ip-neighbour.8
@@ -35,7 +35,8 @@ ip-neighbour \- neighbour/arp tables management.
 .B  nud
 .IR STATE " ] [ "
 .B  vrf
-.IR NAME " ] "
+.IR NAME " ] ["
+.BR nomaster " ]"

 .ti -8
 .B ip neigh get
@@ -191,6 +192,10 @@ only list the neighbours attached to this device.
 .BI vrf " NAME"
 only list the neighbours for given VRF.

+.TP
+.BI nomaster
+only list neighbours attached to an interface with no master.
+
 .TP
 .BI proxy
 list neighbour proxies.
--
2.17.1

             reply	other threads:[~2021-09-09  7:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  7:20 Lahav Schlesinger [this message]
2021-09-12 17:19 ` [PATCH v2] ip: Support filter links/neighs with no master David Ahern

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=20210909072019.8220-1-lschlesinger@drivenets.com \
    --to=lschlesinger@drivenets.com \
    --cc=dsahern@kernel.org \
    --cc=netdev@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.