netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] ip nexthop: Allow flush|list operations to specify a specific protocol
@ 2019-08-10  0:18 Donald Sharp
  2019-08-18 18:31 ` David Ahern
  2019-09-04 14:59 ` David Ahern
  0 siblings, 2 replies; 3+ messages in thread
From: Donald Sharp @ 2019-08-10  0:18 UTC (permalink / raw)
  To: netdev, dsahern

In the case where we have a large number of nexthops from a specific
protocol, allow the flush and list operations to take a protocol
to limit the commands scopes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
---
 ip/ipnexthop.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/ip/ipnexthop.c b/ip/ipnexthop.c
index f35aab52..bc8ab431 100644
--- a/ip/ipnexthop.c
+++ b/ip/ipnexthop.c
@@ -19,6 +19,7 @@ static struct {
 	unsigned int groups;
 	unsigned int ifindex;
 	unsigned int master;
+	unsigned int proto;
 } filter;
 
 enum {
@@ -34,7 +35,7 @@ static void usage(void) __attribute__((noreturn));
 static void usage(void)
 {
 	fprintf(stderr,
-		"Usage: ip nexthop { list | flush } SELECTOR\n"
+		"Usage: ip nexthop { list | flush } [ protocol ID ] SELECTOR\n"
 		"       ip nexthop { add | replace } id ID NH [ protocol ID ]\n"
 		"       ip nexthop { get| del } id ID\n"
 		"SELECTOR := [ id ID ] [ dev DEV ] [ vrf NAME ] [ master DEV ]\n"
@@ -109,6 +110,9 @@ static int flush_nexthop(struct nlmsghdr *nlh, void *arg)
 		return -1;
 	}
 
+	if (filter.proto && nhm->nh_protocol != filter.proto)
+		return 0;
+
 	parse_rtattr(tb, NHA_MAX, RTM_NHA(nhm), len);
 	if (tb[NHA_ID])
 		id = rta_getattr_u32(tb[NHA_ID]);
@@ -213,6 +217,9 @@ int print_nexthop(struct nlmsghdr *n, void *arg)
 		return -1;
 	}
 
+	if (filter.proto && filter.proto != nhm->nh_protocol)
+		return 0;
+
 	parse_rtattr(tb, NHA_MAX, RTM_NHA(nhm), len);
 
 	open_json_object(NULL);
@@ -473,6 +480,13 @@ static int ipnh_list_flush(int argc, char **argv, int action)
 			if (get_unsigned(&id, *argv, 0))
 				invarg("invalid id value", *argv);
 			return ipnh_get_id(id);
+		} else if (!matches(*argv, "protocol")) {
+			__u32 proto;
+
+			NEXT_ARG();
+			if (get_unsigned(&proto, *argv, 0))
+				invarg("invalid protocol value", *argv);
+			filter.proto = proto;
 		} else if (matches(*argv, "help") == 0) {
 			usage();
 		} else {
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] ip nexthop: Allow flush|list operations to specify a specific protocol
  2019-08-10  0:18 [PATCH 2/2] ip nexthop: Allow flush|list operations to specify a specific protocol Donald Sharp
@ 2019-08-18 18:31 ` David Ahern
  2019-09-04 14:59 ` David Ahern
  1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2019-08-18 18:31 UTC (permalink / raw)
  To: Donald Sharp, netdev

On 8/9/19 6:18 PM, Donald Sharp wrote:
> In the case where we have a large number of nexthops from a specific
> protocol, allow the flush and list operations to take a protocol
> to limit the commands scopes.
> 
> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
> ---
>  ip/ipnexthop.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 

Donald: This looks correct to me. Before applying I want to add test
cases to tools/testing/selftests/net/fib_nexthops.sh in the kernel repo
to just to run through different options. Hopefully, I can do that this
week.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] ip nexthop: Allow flush|list operations to specify a specific protocol
  2019-08-10  0:18 [PATCH 2/2] ip nexthop: Allow flush|list operations to specify a specific protocol Donald Sharp
  2019-08-18 18:31 ` David Ahern
@ 2019-09-04 14:59 ` David Ahern
  1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2019-09-04 14:59 UTC (permalink / raw)
  To: Donald Sharp, netdev

On 8/9/19 6:18 PM, Donald Sharp wrote:
> In the case where we have a large number of nexthops from a specific
> protocol, allow the flush and list operations to take a protocol
> to limit the commands scopes.
> 
> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
> ---
>  ip/ipnexthop.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 

applied to iproute2-next. Thanks for the test cases.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-04 14:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-10  0:18 [PATCH 2/2] ip nexthop: Allow flush|list operations to specify a specific protocol Donald Sharp
2019-08-18 18:31 ` David Ahern
2019-09-04 14:59 ` David Ahern

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).