Message ID | 20230726072507.4104996-1-nico.escande@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 13a5d8fcb41bbc5875c0a6c150236208eadd3936 |
Delegated to: | Stephen Hemminger |
Headers | show |
Series | [iproute2,v2] bridge: link: allow filtering on bridge name | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
Hello: This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <stephen@networkplumber.org>: On Wed, 26 Jul 2023 09:25:07 +0200 you wrote: > When using 'brige link show' we can either dump all links enslaved to any bridge > (called without arg ) or display a single link (called with dev arg). > However there is no way to dummp all links of a single bridge. > > To do so, this adds new optional 'master XXX' arg to 'bridge link show' command. > usage: bridge link show master br0 > > [...] Here is the summary with links: - [iproute2,v2] bridge: link: allow filtering on bridge name https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=13a5d8fcb41b You are awesome, thank you!
On Wed, Jul 26, 2023 at 09:25:07AM +0200, Nicolas Escande wrote: > When using 'brige link show' we can either dump all links enslaved to any bridge > (called without arg ) or display a single link (called with dev arg). > However there is no way to dummp all links of a single bridge. > > To do so, this adds new optional 'master XXX' arg to 'bridge link show' command. > usage: bridge link show master br0 > > Signed-off-by: Nicolas Escande <nico.escande@gmail.com> > --- > bridge/link.c | 27 ++++++++++++++++++++++----- > 1 file changed, 22 insertions(+), 5 deletions(-) Please update the man page as well
On Thu Jul 27, 2023 at 3:22 PM CEST, Ido Schimmel wrote: > On Wed, Jul 26, 2023 at 09:25:07AM +0200, Nicolas Escande wrote: > > When using 'brige link show' we can either dump all links enslaved to any bridge > > (called without arg ) or display a single link (called with dev arg). > > However there is no way to dummp all links of a single bridge. > > > > To do so, this adds new optional 'master XXX' arg to 'bridge link show' command. > > usage: bridge link show master br0 > > > > Signed-off-by: Nicolas Escande <nico.escande@gmail.com> > > --- > > bridge/link.c | 27 ++++++++++++++++++++++----- > > 1 file changed, 22 insertions(+), 5 deletions(-) > > Please update the man page as well I sure as hell forgot about man pages, sorry. As the patch already got picked up in git I just sent a new patch for this.
diff --git a/bridge/link.c b/bridge/link.c index b3542986..af0457b6 100644 --- a/bridge/link.c +++ b/bridge/link.c @@ -17,7 +17,8 @@ #include "utils.h" #include "br_common.h" -static unsigned int filter_index; +static unsigned int filter_dev_index; +static unsigned int filter_master_index; static const char *stp_states[] = { [BR_STATE_DISABLED] = "disabled", @@ -244,11 +245,15 @@ int print_linkinfo(struct nlmsghdr *n, void *arg) if (!(ifi->ifi_family == AF_BRIDGE || ifi->ifi_family == AF_UNSPEC)) return 0; - if (filter_index && filter_index != ifi->ifi_index) + if (filter_dev_index && filter_dev_index != ifi->ifi_index) return 0; parse_rtattr_flags(tb, IFLA_MAX, IFLA_RTA(ifi), len, NLA_F_NESTED); + if (filter_master_index && tb[IFLA_MASTER] && + filter_master_index != rta_getattr_u32(tb[IFLA_MASTER])) + return 0; + name = get_ifname_rta(ifi->ifi_index, tb[IFLA_IFNAME]); if (!name) return -1; @@ -312,7 +317,7 @@ static void usage(void) " [ hwmode {vepa | veb} ]\n" " [ backup_port DEVICE ] [ nobackup_port ]\n" " [ self ] [ master ]\n" - " bridge link show [dev DEV]\n"); + " bridge link show [dev DEV] [master DEVICE]\n"); exit(-1); } @@ -607,6 +612,7 @@ static int brlink_modify(int argc, char **argv) static int brlink_show(int argc, char **argv) { char *filter_dev = NULL; + char *filter_master = NULL; while (argc > 0) { if (strcmp(*argv, "dev") == 0) { @@ -615,14 +621,25 @@ static int brlink_show(int argc, char **argv) duparg("dev", *argv); filter_dev = *argv; } + if (strcmp(*argv, "master") == 0) { + NEXT_ARG(); + if (filter_master) + duparg("master", *argv); + filter_master = *argv; + } argc--; argv++; } if (filter_dev) { - filter_index = ll_name_to_index(filter_dev); - if (!filter_index) + filter_dev_index = ll_name_to_index(filter_dev); + if (!filter_dev_index) return nodev(filter_dev); } + if (filter_master) { + filter_master_index = ll_name_to_index(filter_master); + if (!filter_master_index) + return nodev(filter_master); + } if (rtnl_linkdump_req(&rth, PF_BRIDGE) < 0) { perror("Cannot send dump request");
When using 'brige link show' we can either dump all links enslaved to any bridge (called without arg ) or display a single link (called with dev arg). However there is no way to dummp all links of a single bridge. To do so, this adds new optional 'master XXX' arg to 'bridge link show' command. usage: bridge link show master br0 Signed-off-by: Nicolas Escande <nico.escande@gmail.com> --- bridge/link.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)