[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200727132606.251041-1-littlesmilingcloud@gmail.com>
Date: Mon, 27 Jul 2020 16:26:07 +0300
From: Anton Danilov <littlesmilingcloud@...il.com>
To: netdev@...r.kernel.org
Cc: stephen@...workplumber.org,
Anton Danilov <littlesmilingcloud@...il.com>
Subject: [PATCH iproute2] bridge: fdb: the 'dynamic' option in the show/get commands
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@...il.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
Powered by blists - more mailing lists