Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH iproute2] bridge: fdb: the 'dynamic' option in the show/get commands
@ 2020-07-27 13:26 Anton Danilov
  2020-07-27 23:44 ` Stephen Hemminger
  2021-08-09 21:11 ` Vladimir Oltean
  0 siblings, 2 replies; 3+ messages in thread
From: Anton Danilov @ 2020-07-27 13:26 UTC (permalink / raw)
  To: netdev; +Cc: stephen, Anton Danilov

In most of cases a user wants to see only the dynamic mac addresses
in the fdb output. But currently the 'fdb show' displays tons of
various self entries, those only waste the output without any useful
goal.

New option 'dynamic' for 'show' and 'get' commands forces display
only relevant records.

Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
---
 bridge/fdb.c      | 17 +++++++++++++----
 man/man8/bridge.8 | 30 ++++++++++++++++++------------
 2 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/bridge/fdb.c b/bridge/fdb.c
index 710dfc99..78aaaa5a 100644
--- a/bridge/fdb.c
+++ b/bridge/fdb.c
@@ -30,7 +30,8 @@
 #include "rt_names.h"
 #include "utils.h"
 
-static unsigned int filter_index, filter_vlan, filter_state, filter_master;
+static unsigned int filter_index, filter_dynamic, filter_master,
+	filter_state, filter_vlan;
 
 static void usage(void)
 {
@@ -40,9 +41,10 @@ static void usage(void)
 		"              [ sticky ] [ local | static | dynamic ] [ dst IPADDR ]\n"
 		"              [ vlan VID ] [ port PORT] [ vni VNI ] [ via DEV ]\n"
 		"              [ src_vni VNI ]\n"
-		"       bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ] [ state STATE ] ]\n"
-		"       bridge fdb get ADDR [ br BRDEV ] { brport |dev }  DEV [ vlan VID ]\n"
-		"              [ vni VNI ]\n");
+		"       bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ]\n"
+		"              [ state STATE ] [ dynamic ] ]\n"
+		"       bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n"
+		"              [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n");
 	exit(-1);
 }
 
@@ -167,6 +169,9 @@ int print_fdb(struct nlmsghdr *n, void *arg)
 	if (filter_vlan && filter_vlan != vid)
 		return 0;
 
+	if (filter_dynamic && (r->ndm_state & NUD_PERMANENT))
+		return 0;
+
 	open_json_object(NULL);
 	if (n->nlmsg_type == RTM_DELNEIGH)
 		print_bool(PRINT_ANY, "deleted", "Deleted ", true);
@@ -322,6 +327,8 @@ static int fdb_show(int argc, char **argv)
 			if (state_a2n(&state, *argv))
 				invarg("invalid state", *argv);
 			filter_state |= state;
+		} else if (strcmp(*argv, "dynamic") == 0) {
+			filter_dynamic = 1;
 		} else {
 			if (matches(*argv, "help") == 0)
 				usage();
@@ -566,6 +573,8 @@ static int fdb_get(int argc, char **argv)
 				duparg2("vlan", *argv);
 			NEXT_ARG();
 			vlan = atoi(*argv);
+		} else if (matches(*argv, "dynamic") == 0) {
+			filter_dynamic = 1;
 		} else {
 			if (strcmp(*argv, "to") == 0)
 				NEXT_ARG();
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 71f2e890..5aa83e15 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -77,12 +77,12 @@ bridge \- show / manipulate bridge addresses and devices
 .B port
 .IR PORT " ] ["
 .B via
-.IR DEVICE " ]"
+.IR DEVICE " ] ["
+.B src_vni
+.IR VNI " ]"
 
 .ti -8
-.BR "bridge fdb" " [ " show " ] [ "
-.B dev
-.IR DEV " ] [ "
+.BR "bridge fdb" " [ [ " show " ] [ "
 .B br
 .IR BRDEV " ] [ "
 .B brport
@@ -90,18 +90,24 @@ bridge \- show / manipulate bridge addresses and devices
 .B vlan
 .IR VID " ] [ "
 .B state
-.IR STATE " ]"
+.IR STATE " ] ["
+.B dynamic
+.IR "] ]"
 
 .ti -8
-.B bridge fdb get
-.I LLADDR " [ "
-.B dev
-.IR DEV " ] [ "
+.BR "bridge fdb get" " ["
+.B to
+.IR "]"
+.I LLADDR "[ "
 .B br
-.IR BRDEV " ] [ "
+.IR BRDEV " ]"
+.B { brport | dev }
+.IR DEV " [ "
 .B vlan
-.IR VID  " ] ["
-.BR self " ] [ " master " ]"
+.IR VID  " ] [ "
+.B vni
+.IR VNI " ] ["
+.BR self " ] [ " master " ] [ " dynamic " ]"
 
 .ti -8
 .BR "bridge mdb" " { " add " | " del " } "
-- 
2.27.0


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

* Re: [PATCH iproute2] bridge: fdb: the 'dynamic' option in the show/get commands
  2020-07-27 13:26 [PATCH iproute2] bridge: fdb: the 'dynamic' option in the show/get commands Anton Danilov
@ 2020-07-27 23:44 ` Stephen Hemminger
  2021-08-09 21:11 ` Vladimir Oltean
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2020-07-27 23:44 UTC (permalink / raw)
  To: Anton Danilov; +Cc: netdev

On Mon, 27 Jul 2020 16:26:07 +0300
Anton Danilov <littlesmilingcloud@gmail.com> wrote:

> In most of cases a user wants to see only the dynamic mac addresses
> in the fdb output. But currently the 'fdb show' displays tons of
> various self entries, those only waste the output without any useful
> goal.
> 
> New option 'dynamic' for 'show' and 'get' commands forces display
> only relevant records.
> 
> Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>

Looks like a good solution.
Applied

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

* Re: [PATCH iproute2] bridge: fdb: the 'dynamic' option in the show/get commands
  2020-07-27 13:26 [PATCH iproute2] bridge: fdb: the 'dynamic' option in the show/get commands Anton Danilov
  2020-07-27 23:44 ` Stephen Hemminger
@ 2021-08-09 21:11 ` Vladimir Oltean
  1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Oltean @ 2021-08-09 21:11 UTC (permalink / raw)
  To: Anton Danilov; +Cc: netdev, stephen

Hello Anton,

On Mon, Jul 27, 2020 at 04:26:07PM +0300, Anton Danilov wrote:
> In most of cases a user wants to see only the dynamic mac addresses
> in the fdb output. But currently the 'fdb show' displays tons of
> various self entries, those only waste the output without any useful
> goal.
> 
> New option 'dynamic' for 'show' and 'get' commands forces display
> only relevant records.
> 
> Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
> ---
>  bridge/fdb.c      | 17 +++++++++++++----
>  man/man8/bridge.8 | 30 ++++++++++++++++++------------
>  2 files changed, 31 insertions(+), 16 deletions(-)
> 
> diff --git a/bridge/fdb.c b/bridge/fdb.c
> index 710dfc99..78aaaa5a 100644
> --- a/bridge/fdb.c
> +++ b/bridge/fdb.c
> @@ -30,7 +30,8 @@
>  #include "rt_names.h"
>  #include "utils.h"
>  
> -static unsigned int filter_index, filter_vlan, filter_state, filter_master;
> +static unsigned int filter_index, filter_dynamic, filter_master,
> +	filter_state, filter_vlan;
>  
>  static void usage(void)
>  {
> @@ -40,9 +41,10 @@ static void usage(void)
>  		"              [ sticky ] [ local | static | dynamic ] [ dst IPADDR ]\n"
>  		"              [ vlan VID ] [ port PORT] [ vni VNI ] [ via DEV ]\n"
>  		"              [ src_vni VNI ]\n"
> -		"       bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ] [ state STATE ] ]\n"
> -		"       bridge fdb get ADDR [ br BRDEV ] { brport |dev }  DEV [ vlan VID ]\n"
> -		"              [ vni VNI ]\n");
> +		"       bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ]\n"
> +		"              [ state STATE ] [ dynamic ] ]\n"
> +		"       bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n"
> +		"              [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n");
>  	exit(-1);
>  }
>  
> @@ -167,6 +169,9 @@ int print_fdb(struct nlmsghdr *n, void *arg)
>  	if (filter_vlan && filter_vlan != vid)
>  		return 0;
>  
> +	if (filter_dynamic && (r->ndm_state & NUD_PERMANENT))
> +		return 0;
> +
>  	open_json_object(NULL);
>  	if (n->nlmsg_type == RTM_DELNEIGH)
>  		print_bool(PRINT_ANY, "deleted", "Deleted ", true);
> @@ -322,6 +327,8 @@ static int fdb_show(int argc, char **argv)
>  			if (state_a2n(&state, *argv))
>  				invarg("invalid state", *argv);
>  			filter_state |= state;
> +		} else if (strcmp(*argv, "dynamic") == 0) {
> +			filter_dynamic = 1;
>  		} else {
>  			if (matches(*argv, "help") == 0)
>  				usage();
> @@ -566,6 +573,8 @@ static int fdb_get(int argc, char **argv)
>  				duparg2("vlan", *argv);
>  			NEXT_ARG();
>  			vlan = atoi(*argv);
> +		} else if (matches(*argv, "dynamic") == 0) {
> +			filter_dynamic = 1;
>  		} else {
>  			if (strcmp(*argv, "to") == 0)
>  				NEXT_ARG();
> diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
> index 71f2e890..5aa83e15 100644
> --- a/man/man8/bridge.8
> +++ b/man/man8/bridge.8
> @@ -77,12 +77,12 @@ bridge \- show / manipulate bridge addresses and devices
>  .B port
>  .IR PORT " ] ["
>  .B via
> -.IR DEVICE " ]"
> +.IR DEVICE " ] ["
> +.B src_vni
> +.IR VNI " ]"
>  
>  .ti -8
> -.BR "bridge fdb" " [ " show " ] [ "
> -.B dev
> -.IR DEV " ] [ "
> +.BR "bridge fdb" " [ [ " show " ] [ "
>  .B br
>  .IR BRDEV " ] [ "
>  .B brport
> @@ -90,18 +90,24 @@ bridge \- show / manipulate bridge addresses and devices
>  .B vlan
>  .IR VID " ] [ "
>  .B state
> -.IR STATE " ]"
> +.IR STATE " ] ["
> +.B dynamic
> +.IR "] ]"
>  
>  .ti -8
> -.B bridge fdb get
> -.I LLADDR " [ "
> -.B dev
> -.IR DEV " ] [ "
> +.BR "bridge fdb get" " ["
> +.B to
> +.IR "]"
> +.I LLADDR "[ "
>  .B br
> -.IR BRDEV " ] [ "
> +.IR BRDEV " ]"
> +.B { brport | dev }
> +.IR DEV " [ "
>  .B vlan
> -.IR VID  " ] ["
> -.BR self " ] [ " master " ]"
> +.IR VID  " ] [ "
> +.B vni
> +.IR VNI " ] ["
> +.BR self " ] [ " master " ] [ " dynamic " ]"
>  
>  .ti -8
>  .BR "bridge mdb" " { " add " | " del " } "
> -- 
> 2.27.0
> 

Are the 'static' entries 'dynamic'?

bridge fdb add dev sw0p2 00:01:02:03:04:05 master static
bridge fdb show dev sw0p2 dynamic | grep 00:01:02:03:04:05
00:01:02:03:04:05 vlan 1 offload master br0 static
00:01:02:03:04:05 offload master br0 static

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

end of thread, other threads:[~2021-08-09 21:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27 13:26 [PATCH iproute2] bridge: fdb: the 'dynamic' option in the show/get commands Anton Danilov
2020-07-27 23:44 ` Stephen Hemminger
2021-08-09 21:11 ` Vladimir Oltean

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