bridge: vlan: add global multicast options
Subsystems (2)
cover bridge: vlan: add global multicast options
From: Nikolay Aleksandrov <[email protected]>
Hi all,
This set adds support for vlan multicast options. The feature is globally controlled by a new bridge option called mcast_vlan_snooping which is added by patch 01. Then patches 2 and 3 add support for dumping global vlan options and filtering on vlan id. Patch 04 adds support for setting global vlan options and then patches 05-16 add all the new global vlan options, finally patch 17 adds support for dumping vlan multicast router ports. These options are identical in meaning, names and functionality as the bridge-wide ones.
All the new vlan global commands are under the global keyword:
$ bridge vlan global show [ vid VID dev DEVICE ] $ bridge vlan global set vid VID dev DEVICE ...
I've added command examples in each commit message. The patch-set is a bit bigger but the global options follow the same pattern so I don't see a point in breaking them. All man page descriptions have been taken from the same current bridge-wide mcast options. The only additional iproute2 change which is left to do is the per-vlan mcast router control which I'll send separately. Note to properly use this set you'll need the updated kernel headers where mcast router was moved from a global option to per-vlan/per-device one (changed uapi enum which was in net-next).
Example:
# enable vlan mcast snooping globally
$ ip link set dev bridge type bridge mcast_vlan_snooping 1
# enable mcast querier on vlan 100
$ bridge vlan global set dev bridge vid 100 mcast_querier 1
# show vlan 100's global options
$ bridge -s vlan global show vid 100
port vlan-id
bridge 100
mcast_snooping 1 mcast_querier 1 mcast_igmp_version 2 mcast_mld_version 1 mcast_last_member_count 2 mcast_last_member_interval 100 mcast_startup_query_count 2 mcast_startup_query_interval 3125 mcast_membership_interval 26000 mcast_querier_interval 25500 mcast_query_interval 12500 mcast_query_response_interval 1000A following kernel patch-set will add selftests which use these commands.
Thanks,
Nik
Nikolay Aleksandrov (17):
ip: bridge: add support for mcast_vlan_snooping
bridge: vlan: add support to show global vlan options
bridge: vlan: add support for vlan filtering when dumping options
bridge: vlan: add support to set global vlan options
bridge: vlan: add global mcast_snooping option
bridge: vlan: add global mcast_igmp_version option
bridge: vlan: add global mcast_mld_version option
bridge: vlan: add global mcast_last_member_count option
bridge: vlan: add global mcast_startup_query_count option
bridge: vlan: add global mcast_last_member_interval option
bridge: vlan: add global mcast_membership_interval option
bridge: vlan: add global mcast_querier_interval option
bridge: vlan: add global mcast_query_interval option
bridge: vlan: add global mcast_query_response_interval option
bridge: vlan: add global mcast_startup_query_interval option
bridge: vlan: add global mcast_querier option
bridge: vlan: add support for dumping router ports
bridge/br_common.h | 4 +- bridge/mdb.c | 6 +- bridge/monitor.c | 2 +- bridge/vlan.c | 546 +++++++++++++++++++++++++++++++++++++----- ip/iplink_bridge.c | 29 +++ man/man8/bridge.8 | 130 ++++++++++ man/man8/ip-link.8.in | 8 + 7 files changed, 659 insertions(+), 66 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/17 ip: bridge: add support for mcast_vlan_snooping
From: Nikolay Aleksandrov <[email protected]>
Add support for mcast_vlan_snooping option which controls per-vlan multicast snooping, also update the man page.
Syntax: $ ip link set dev bridge type bridge mcast_vlan_snooping 0/1
--- ip/iplink_bridge.c | 29 +++++++++++++++++++++++++++++ man/man8/ip-link.8.in | 8 ++++++++ 2 files changed, 37 insertions(+)
ip/iplink_bridge.c +29 -0
@@ -43,6 +43,7 @@ static void print_explain(FILE *f)" [ vlan_stats_enabled VLAN_STATS_ENABLED ]\n" " [ vlan_stats_per_port VLAN_STATS_PER_PORT ]\n" " [ mcast_snooping MULTICAST_SNOOPING ]\n" +" [ mcast_vlan_snooping MULTICAST_VLAN_SNOOPING ]\n" " [ mcast_router MULTICAST_ROUTER ]\n" " [ mcast_query_use_ifaddr MCAST_QUERY_USE_IFADDR ]\n" " [ mcast_querier MULTICAST_QUERIER ]\n"
@@ -83,6 +84,7 @@ void br_dump_bridge_id(const struct ifla_bridge_id *id, char *buf, size_t len)static int bridge_parse_opt (struct link_util *lu,int argc,char **argv,struct nlmsghdr *n) { +struct br_boolopt_multi bm = {};__u32 val;while (argc >0 ) {
@@ -200,6 +202,18 @@ static int bridge_parse_opt(struct link_util *lu, int argc, char **argv,invarg ("invalid mcast_snooping" , *argv);addattr8 (n,1024 ,IFLA_BR_MCAST_SNOOPING , mcast_snoop); + }else if (matches (*argv,"mcast_vlan_snooping" ) ==0 ) { +__u32 mcvl_bit =1 <<BR_BOOLOPT_MCAST_VLAN_SNOOPING ; +__u8 mcast_vlan_snooping; + +NEXT_ARG (); +if (get_u8 (&mcast_vlan_snooping, *argv,0 )) +invarg ("invalid mcast_vlan_snooping" , *argv); + bm.optmask |=1 <<BR_BOOLOPT_MCAST_VLAN_SNOOPING ; +if (mcast_vlan_snooping) + bm.optval |= mcvl_bit; +else + bm.optval &= ~mcvl_bit; }else if (matches (*argv,"mcast_query_use_ifaddr" ) ==0 ) {__u8 mcast_qui;
@@ -379,6 +393,9 @@ static int bridge_parse_opt(struct link_util *lu, int argc, char **argv, argc--, argv++; } +if (bm.optmask) +addattr_l (n,1024 ,IFLA_BR_MULTI_BOOLOPT , + &bm,sizeof (bm));return 0 ; }
@@ -559,6 +576,18 @@ static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])"mcast_snooping %u " , rta_getattr_u8(tb[IFLA_BR_MCAST_SNOOPING])); +if (tb[IFLA_BR_MULTI_BOOLOPT ]) { +__u32 mcvl_bit =1 <<BR_BOOLOPT_MCAST_VLAN_SNOOPING ; +struct br_boolopt_multi *bm; + + bm =RTA_DATA (tb[IFLA_BR_MULTI_BOOLOPT ]); +if (bm->optmask & mcvl_bit) +print_uint (PRINT_ANY , +"mcast_vlan_snooping" , +"mcast_vlan_snooping %u " , + !!(bm->optval & mcvl_bit)); + } +if (tb[IFLA_BR_MCAST_ROUTER ]) print_uint(PRINT_ANY, "mcast_router",
man/man8/ip-link.8.in +8 -0
@@ -1492,6 +1492,8 @@ the following additional arguments are supported: ] [ .BI mcast_snooping " MULTICAST_SNOOPING " ] [ +.BI mcast_vlan_snooping " MULTICAST_VLAN_SNOOPING " +] [ .BI mcast_router " MULTICAST_ROUTER " ] [ .BI mcast_query_use_ifaddr " MCAST_QUERY_USE_IFADDR "
@@ -1614,6 +1616,12 @@ per-VLAN per-port stats accounting. Can be changed only when there are no port V or off .RI ( MULTICAST_SNOOPING " == 0). " +.BI mcast_vlan_snooping " MULTICAST_VLAN_SNOOPING " +- turn multicast VLAN snooping on +.RI ( MULTICAST_VLAN_SNOOPING " > 0) " +or off +.RI ( MULTICAST_VLAN_SNOOPING " == 0). " + .BI mcast_router " MULTICAST_ROUTER " - set bridge's multicast router if IGMP snooping is enabled. .I MULTICAST_ROUTER
Signature · 1 line
2.31.1
PATCH 2/17 bridge: vlan: add support to show global vlan options
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add support for new bridge vlan command grouping called global which operates on global options. The first command it supports is "show". Man page and help are also updated with the new command.
Syntax is: $ bridge vlan global show [ vid VID ] [ dev DEV ]
--- bridge/br_common.h | 3 +- bridge/monitor.c | 2 +- bridge/vlan.c | 229 ++++++++++++++++++++++++++++++++++----------- man/man8/bridge.8 | 21 +++++ 4 files changed, 200 insertions(+), 55 deletions(-)
bridge/br_common.h +2 -1
@@ -12,7 +12,8 @@ int print_mdb_mon(struct nlmsghdr *n, void *arg);int print_fdb (struct nlmsghdr *n,void *arg);void print_stp_state (__u8 state);int parse_stp_state (const char *arg); -int print_vlan_rtm (struct nlmsghdr *n,void *arg,bool monitor); +int print_vlan_rtm (struct nlmsghdr *n,void *arg,bool monitor, +bool global_only);int do_fdb (int argc,char **argv);int do_mdb (int argc,char **argv);
bridge/monitor.c +1 -1
@@ -71,7 +71,7 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl,case RTM_DELVLAN :if (prefix_banner)fprintf (fp,"[VLAN]" ); -return print_vlan_rtm (n, arg, true); +return print_vlan_rtm (n, arg, true, false);default :return 0 ;
bridge/vlan.c +176 -53
282 lines not on this page · raw message
man/man8/bridge.8 +21 -0
@@ -152,6 +152,13 @@ bridge \- show / manipulate bridge addresses and devices .B dev .IR DEV " ]" +.ti -8 +.BR "bridge vlan global" " [ " show " ] [ " +.B dev +.IR DEV " ] [ " +.B vid +.IR VID " ]" + .ti -8 .BR "bridge monitor" " [ " all " | " neigh " | " link " | " mdb " | " vlan " ]"
@@ -895,6 +902,20 @@ option, the command displays per-vlan traffic statistics. This command displays the current vlan tunnel info mapping. +.SS bridge vlan global show - list global vlan options. + +This command displays the global VLAN options for each VLAN entry. + +.TP +.BI dev " DEV" +the interface only whose VLAN global options should be listed. Default is to list +all bridge interfaces. + +.TP +.BI vid " VID" +the VLAN ID only whose global options should be listed. Default is to list +all vlans. + .SH bridge monitor - state monitoring The
Signature · 1 line
2.31.1
PATCH 4/17 bridge: vlan: add support to set global vlan options
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add support to change global vlan options via a new vlan global set subcommand similar to the current vlan set subcommand. The man page and help are updated accordingly. The command works only with bridge devices. It doesn't support any options yet.
Syntax: $ bridge vlan global set vid VID dev DEV
--- bridge/vlan.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++ man/man8/bridge.8 | 20 ++++++++++++ 2 files changed, 100 insertions(+)
bridge/vlan.c +80 -0
@@ -37,6 +37,7 @@ static void usage(void)" bridge vlan { set } vid VLAN_ID dev DEV [ state STP_STATE ]\n" " bridge vlan { show } [ dev DEV ] [ vid VLAN_ID ]\n" " bridge vlan { tunnelshow } [ dev DEV ] [ vid VLAN_ID ]\n" +" bridge vlan global { set } vid VLAN_ID dev DEV\n" " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 ); }
@@ -338,6 +339,83 @@ static int vlan_option_set(int argc, char **argv)return 0 ; } +static int vlan_global_option_set (int argc,char **argv) +{ +struct { +struct nlmsghdr n; +struct br_vlan_msg bvm; +char buf[1024 ]; + } req = { + .n.nlmsg_len =NLMSG_LENGTH (sizeof (struct br_vlan_msg )), + .n.nlmsg_flags =NLM_F_REQUEST , + .n.nlmsg_type =RTM_NEWVLAN , + .bvm.family =PF_BRIDGE , + }; +struct rtattr *afspec; +short vid_end =-1 ; +char *d =NULL ; +short vid =-1 ; + + afspec =addattr_nest (&req.n,sizeof (req), +BRIDGE_VLANDB_GLOBAL_OPTIONS ); + afspec->rta_type |=NLA_F_NESTED ; +while (argc >0 ) { +if (strcmp (*argv,"dev" ) ==0 ) { +NEXT_ARG (); + d = *argv; + req.bvm.ifindex =ll_name_to_index (d); +if (req.bvm.ifindex ==0 ) { +fprintf (stderr,"Cannot find network device \"%s\"\n" , + d); +return -1 ; + } + }else if (strcmp (*argv,"vid" ) ==0 ) { +char *p; + +NEXT_ARG (); + p =strchr (*argv,'-' ); +if (p) { + *p ='\0' ; + p++; + vid =atoi (*argv); + vid_end =atoi (p); +if (vid >= vid_end || vid_end >=4096 ) { +fprintf (stderr,"Invalid VLAN range \"%hu-%hu\"\n" , + vid, vid_end); +return -1 ; + } + }else { + vid =atoi (*argv); + } +if (vid >=4096 ) { +fprintf (stderr,"Invalid VLAN ID \"%hu\"\n" , + vid); +return -1 ; + } +addattr16 (&req.n,sizeof (req),BRIDGE_VLANDB_GOPTS_ID , + vid); +if (vid_end !=-1 ) +addattr16 (&req.n,sizeof (req), +BRIDGE_VLANDB_GOPTS_RANGE , vid_end); + }else { +if (matches (*argv,"help" ) ==0 ) +NEXT_ARG (); + } + argc--; argv++; + } +addattr_nest_end (&req.n, afspec); + +if (d ==NULL || vid ==-1 ) { +fprintf (stderr,"Device and VLAN ID are required arguments.\n" ); +return -1 ; + } + +if (rtnl_talk (&rth, &req.n,NULL ) <0 ) +return -1 ; + +return 0 ; +} +/* In order to use this function for both filtering and non-filtering cases * we need to make it a tristate: * return -1 - if filtering we've gone over so don't continue
@@ -1016,6 +1094,8 @@ static int vlan_global(int argc, char **argv) matches(*argv, "lst") == 0 || matches(*argv, "list") == 0)return vlan_global_show (argc-1 , argv+1 ); + else if (matches(*argv, "set") == 0) + return vlan_global_option_set(argc-1, argv+1); elseusage (); }else {
man/man8/bridge.8 +20 -0
@@ -152,6 +152,13 @@ bridge \- show / manipulate bridge addresses and devices .B dev .IR DEV " ]" +.ti -8 +.BR "bridge vlan global set" +.B dev +.I DEV +.B vid +.IR VID " [ ]" + .ti -8 .BR "bridge vlan global" " [ " show " ] [ " .B dev
@@ -902,6 +909,19 @@ option, the command displays per-vlan traffic statistics. This command displays the current vlan tunnel info mapping. +.SS bridge vlan global set - change vlan filter entry's global options + +This command changes vlan filter entry's global options. + +.TP +.BI dev " NAME" +the interface with which this vlan is associated. Only bridge devices are +supported for global options. + +.TP +.BI vid " VID" +the VLAN ID that identifies the vlan. + .SS bridge vlan global show - list global vlan options. This command displays the global VLAN options for each VLAN entry.
Signature · 1 line
2.31.1
PATCH 3/17 bridge: vlan: add support for vlan filtering when dumping options
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
In order to allow vlan filtering when dumping options we need to move all print operations into the option dumping functions and add the filtering after we've parsed the nested attributes so we can extract the start and end vlan ids.
--- bridge/vlan.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-)
bridge/vlan.c +30 -15
@@ -622,7 +622,7 @@ static int print_vlan_stats(struct nlmsghdr *n, void *arg)return 0 ; } -static void print_vlan_global_opts (struct rtattr *a) +static void print_vlan_global_opts (struct rtattr *a,int ifindex) {struct rtattr *vtb[BRIDGE_VLANDB_GOPTS_MAX +1 ];__u16 vid, vrange =0 ;
@@ -637,11 +637,24 @@ static void print_vlan_global_opts(struct rtattr *a) vrange =rta_getattr_u16 (vtb[BRIDGE_VLANDB_GOPTS_RANGE ]); else vrange = vid; + +if (filter_vlan && (filter_vlan < vid || filter_vlan > vrange)) +return ; + +if (vlan_rtm_cur_ifidx != ifindex) { +open_vlan_port (ifindex,VLAN_SHOW_VLAN ); +open_json_object (NULL ); + vlan_rtm_cur_ifidx = ifindex; + }else { +open_json_object (NULL ); + print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", ""); + }print_range ("vlan" , vid, vrange);print_nl (); +close_json_object (); } -static void print_vlan_opts (struct rtattr *a) +static void print_vlan_opts (struct rtattr *a,int ifindex) {struct rtattr *vtb[BRIDGE_VLANDB_ENTRY_MAX +1 ];struct bridge_vlan_xstats vstats;
@@ -662,6 +675,9 @@ static void print_vlan_opts(struct rtattr *a)else vrange = vinfo->vid; +if (filter_vlan && (filter_vlan < vinfo->vid || filter_vlan > vrange)) +return ; +if (vtb[BRIDGE_VLANDB_ENTRY_STATE ]) state =rta_getattr_u8 (vtb[BRIDGE_VLANDB_ENTRY_STATE ]);
@@ -690,6 +706,15 @@ static void print_vlan_opts(struct rtattr *a) vstats.tx_bytes =rta_getattr_u64 (attr); } } + +if (vlan_rtm_cur_ifidx != ifindex) { +open_vlan_port (ifindex,VLAN_SHOW_VLAN ); +open_json_object (NULL ); + vlan_rtm_cur_ifidx = ifindex; + }else { +open_json_object (NULL ); + print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", ""); + }print_range ("vlan" , vinfo->vid, vrange);print_vlan_flags (vinfo->flags);print_nl ();
@@ -698,6 +723,7 @@ static void print_vlan_opts(struct rtattr *a)print_nl ();if (show_stats)__print_one_vlan_stats (&vstats); +close_json_object (); }int print_vlan_rtm (struct nlmsghdr *n,void *arg,bool monitor,bool global_only)
@@ -746,25 +772,14 @@ int print_vlan_rtm(struct nlmsghdr *n, void *arg, bool monitor, bool global_only (global_only && rta_type != BRIDGE_VLANDB_GLOBAL_OPTIONS)) continue; -if (vlan_rtm_cur_ifidx != bvm->ifindex) { -open_vlan_port (bvm->ifindex,VLAN_SHOW_VLAN ); -open_json_object (NULL ); - vlan_rtm_cur_ifidx = bvm->ifindex; - }else { -open_json_object (NULL ); - print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", ""); - } -switch (rta_type) {case BRIDGE_VLANDB_ENTRY : -print_vlan_opts (a); +print_vlan_opts (a, bvm->ifindex);break ;case BRIDGE_VLANDB_GLOBAL_OPTIONS : -print_vlan_global_opts (a); +print_vlan_global_opts (a, bvm->ifindex);break ; } - -close_json_object (); }return 0 ;
Signature · 1 line
2.31.1
PATCH 6/17 bridge: vlan: add global mcast_igmp_version option
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add control and dump support for the global mcast_igmp_version option which controls the IGMP version on the vlan (default 2).
Syntax: $ bridge vlan global set dev bridge vid 1 mcast_igmp_version 3
--- bridge/vlan.c | 12 ++++++++++++ man/man8/bridge.8 | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
bridge/vlan.c +12 -0
@@ -39,6 +39,7 @@ static void usage(void)" bridge vlan { show } [ dev DEV ] [ vid VLAN_ID ]\n" " bridge vlan { tunnelshow } [ dev DEV ] [ vid VLAN_ID ]\n" " bridge vlan global { set } vid VLAN_ID dev DEV [ mcast_snooping MULTICAST_SNOOPING ]\n" +" [ mcast_igmp_version IGMP_VERSION ]\n" " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 ); }
@@ -405,6 +406,12 @@ static int vlan_global_option_set(int argc, char **argv)invarg ("invalid mcast_snooping" , *argv);addattr8 (&req.n,1024 ,BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING , val8); + }else if (strcmp (*argv,"mcast_igmp_version" ) ==0 ) { +NEXT_ARG (); +if (get_u8 (&val8, *argv,0 )) +invarg ("invalid mcast_igmp_version" , *argv); +addattr8 (&req.n,1024 , +BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION , val8); }else {if (matches (*argv,"help" ) ==0 )NEXT_ARG ();
@@ -743,6 +750,11 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)print_uint (PRINT_ANY ,"mcast_snooping" ,"mcast_snooping %u " ,rta_getattr_u8 (vattr)); } +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION ]) { + vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION ]; +print_uint (PRINT_ANY ,"mcast_igmp_version" , +"mcast_igmp_version %u " ,rta_getattr_u8 (vattr)); + }print_nl ();close_json_object (); }
man/man8/bridge.8 +7 -1
@@ -159,7 +159,9 @@ bridge \- show / manipulate bridge addresses and devices .B vid .IR VID " [ " .B mcast_snooping -.IR MULTICAST_SNOOPING " ]" +.IR MULTICAST_SNOOPING " ] [ " +.B mcast_igmp_version +.IR IGMP_VERSION " ]" .ti -8 .BR "bridge vlan global" " [ " show " ] [ "
@@ -931,6 +933,10 @@ turn multicast snooping for VLAN entry with VLAN ID on or off .RI ( MULTICAST_SNOOPING " == 0). Default is on. " +.TP +.BI mcast_igmp_version " IGMP_VERSION " +set the IGMP version. Default is 2. + .SS bridge vlan global show - list global vlan options. This command displays the global VLAN options for each VLAN entry.
Signature · 1 line
2.31.1
PATCH 5/17 bridge: vlan: add global mcast_snooping option
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add control and dump support for the global mcast_snooping option which controls if multicast snooping is enabled or disabled for a single vlan.
Syntax: $ bridge vlan global set dev bridge vid 1 mcast_snooping 1
--- bridge/vlan.c | 19 +++++++++++++++++-- man/man8/bridge.8 | 11 ++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-)
bridge/vlan.c +17 -2
@@ -9,6 +9,7 @@#include <linux/if_bridge.h> #include <linux/if_ether.h> #include <string.h> +#include <errno.h> #include "json_print.h" #include "libnetlink.h"
@@ -37,7 +38,7 @@ static void usage(void)" bridge vlan { set } vid VLAN_ID dev DEV [ state STP_STATE ]\n" " bridge vlan { show } [ dev DEV ] [ vid VLAN_ID ]\n" " bridge vlan { tunnelshow } [ dev DEV ] [ vid VLAN_ID ]\n" -" bridge vlan global { set } vid VLAN_ID dev DEV\n" +" bridge vlan global { set } vid VLAN_ID dev DEV [ mcast_snooping MULTICAST_SNOOPING ]\n" " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 ); }
@@ -355,6 +356,7 @@ static int vlan_global_option_set(int argc, char **argv)short vid_end =-1 ;char *d =NULL ;short vid =-1 ; +__u8 val8; afspec =addattr_nest (&req.n,sizeof (req),BRIDGE_VLANDB_GLOBAL_OPTIONS );
@@ -397,6 +399,12 @@ static int vlan_global_option_set(int argc, char **argv)if (vid_end !=-1 )addattr16 (&req.n,sizeof (req),BRIDGE_VLANDB_GOPTS_RANGE , vid_end); + }else if (strcmp (*argv,"mcast_snooping" ) ==0 ) { +NEXT_ARG (); +if (get_u8 (&val8, *argv,0 )) +invarg ("invalid mcast_snooping" , *argv); +addattr8 (&req.n,1024 , +BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING , val8); }else {if (matches (*argv,"help" ) ==0 )NEXT_ARG ();
@@ -702,7 +710,7 @@ static int print_vlan_stats(struct nlmsghdr *n, void *arg)static void print_vlan_global_opts (struct rtattr *a,int ifindex) { -struct rtattr *vtb[BRIDGE_VLANDB_GOPTS_MAX +1 ]; +struct rtattr *vtb[BRIDGE_VLANDB_GOPTS_MAX +1 ], *vattr;__u16 vid, vrange =0 ;if ((a->rta_type &NLA_TYPE_MASK ) !=BRIDGE_VLANDB_GLOBAL_OPTIONS )
@@ -729,6 +737,13 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex) }print_range ("vlan" , vid, vrange);print_nl (); + print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", ""); +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING ]) { + vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING ]; +print_uint (PRINT_ANY ,"mcast_snooping" ,"mcast_snooping %u " , +rta_getattr_u8 (vattr)); + } +print_nl ();close_json_object (); }
man/man8/bridge.8 +10 -1
@@ -157,7 +157,9 @@ bridge \- show / manipulate bridge addresses and devices .B dev .I DEV .B vid -.IR VID " [ ]" +.IR VID " [ " +.B mcast_snooping +.IR MULTICAST_SNOOPING " ]" .ti -8 .BR "bridge vlan global" " [ " show " ] [ "
@@ -922,6 +924,13 @@ supported for global options. .BI vid " VID" the VLAN ID that identifies the vlan. +.TP +.BI mcast_snooping " MULTICAST_SNOOPING " +turn multicast snooping for VLAN entry with VLAN ID on +.RI ( MULTICAST_SNOOPING " > 0) " +or off +.RI ( MULTICAST_SNOOPING " == 0). Default is on. " + .SS bridge vlan global show - list global vlan options. This command displays the global VLAN options for each VLAN entry.
Signature · 1 line
2.31.1
PATCH 7/17 bridge: vlan: add global mcast_mld_version option
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add control and dump support for the global mcast_mld_version option which controls the MLD version on the vlan (default 1).
Syntax: $ bridge vlan global set dev bridge vid 1 mcast_mld_version 2
--- bridge/vlan.c | 12 ++++++++++++ man/man8/bridge.8 | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
bridge/vlan.c +12 -0
@@ -40,6 +40,7 @@ static void usage(void)" bridge vlan { tunnelshow } [ dev DEV ] [ vid VLAN_ID ]\n" " bridge vlan global { set } vid VLAN_ID dev DEV [ mcast_snooping MULTICAST_SNOOPING ]\n" " [ mcast_igmp_version IGMP_VERSION ]\n" +" [ mcast_mld_version MLD_VERSION ]\n" " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 ); }
@@ -412,6 +413,12 @@ static int vlan_global_option_set(int argc, char **argv)invarg ("invalid mcast_igmp_version" , *argv);addattr8 (&req.n,1024 ,BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION , val8); + }else if (strcmp (*argv,"mcast_mld_version" ) ==0 ) { +NEXT_ARG (); +if (get_u8 (&val8, *argv,0 )) +invarg ("invalid mcast_mld_version" , *argv); +addattr8 (&req.n,1024 , +BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION , val8); }else {if (matches (*argv,"help" ) ==0 )NEXT_ARG ();
@@ -755,6 +762,11 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)print_uint (PRINT_ANY ,"mcast_igmp_version" ,"mcast_igmp_version %u " ,rta_getattr_u8 (vattr)); } +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION ]) { + vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION ]; +print_uint (PRINT_ANY ,"mcast_mld_version" , +"mcast_mld_version %u " ,rta_getattr_u8 (vattr)); + }print_nl ();close_json_object (); }
man/man8/bridge.8 +7 -1
@@ -161,7 +161,9 @@ bridge \- show / manipulate bridge addresses and devices .B mcast_snooping .IR MULTICAST_SNOOPING " ] [ " .B mcast_igmp_version -.IR IGMP_VERSION " ]" +.IR IGMP_VERSION " ] [ " +.B mcast_mld_version +.IR MLD_VERSION " ]" .ti -8 .BR "bridge vlan global" " [ " show " ] [ "
@@ -937,6 +939,10 @@ or off .BI mcast_igmp_version " IGMP_VERSION " set the IGMP version. Default is 2. +.TP +.BI mcast_mld_version " MLD_VERSION " +set the MLD version. Default is 1. + .SS bridge vlan global show - list global vlan options. This command displays the global VLAN options for each VLAN entry.
Signature · 1 line
2.31.1
PATCH 8/17 bridge: vlan: add global mcast_last_member_count option
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add control and dump support for the global mcast_last_member_count option which controls the number of queries the bridge will send on the vlan after a leave is received (default 2).
Syntax:
$ bridge vlan global set dev bridge vid 1 mcast_last_member_count 10
--- bridge/vlan.c | 15 +++++++++++++++ man/man8/bridge.8 | 10 +++++++++- 2 files changed, 24 insertions(+), 1 deletion(-)
bridge/vlan.c +15 -0
@@ -41,6 +41,7 @@ static void usage(void)" bridge vlan global { set } vid VLAN_ID dev DEV [ mcast_snooping MULTICAST_SNOOPING ]\n" " [ mcast_igmp_version IGMP_VERSION ]\n" " [ mcast_mld_version MLD_VERSION ]\n" +" [ mcast_last_member_count LAST_MEMBER_COUNT ]\n" " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 ); }
@@ -358,6 +359,7 @@ static int vlan_global_option_set(int argc, char **argv)short vid_end =-1 ;char *d =NULL ;short vid =-1 ; +__u32 val32;__u8 val8; afspec = addattr_nest(&req.n, sizeof(req),
@@ -419,6 +421,13 @@ static int vlan_global_option_set(int argc, char **argv)invarg ("invalid mcast_mld_version" , *argv);addattr8 (&req.n,1024 ,BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION , val8); + }else if (strcmp (*argv,"mcast_last_member_count" ) ==0 ) { +NEXT_ARG (); +if (get_u32 (&val32, *argv,0 )) +invarg ("invalid mcast_last_member_count" , *argv); +addattr32 (&req.n,1024 , +BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_CNT , + val32); }else {if (matches (*argv,"help" ) ==0 )NEXT_ARG ();
@@ -767,6 +776,12 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)print_uint (PRINT_ANY ,"mcast_mld_version" ,"mcast_mld_version %u " ,rta_getattr_u8 (vattr)); } +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION ]) { + vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_CNT ]; +print_uint (PRINT_ANY ,"mcast_last_member_count" , +"mcast_last_member_count %u " , +rta_getattr_u32 (vattr)); + }print_nl ();close_json_object (); }
man/man8/bridge.8 +9 -1
@@ -163,7 +163,9 @@ bridge \- show / manipulate bridge addresses and devices .B mcast_igmp_version .IR IGMP_VERSION " ] [ " .B mcast_mld_version -.IR MLD_VERSION " ]" +.IR MLD_VERSION " ] [ " +.B mcast_last_member_count +.IR LAST_MEMBER_COUNT " ]" .ti -8 .BR "bridge vlan global" " [ " show " ] [ "
@@ -943,6 +945,12 @@ set the IGMP version. Default is 2. .BI mcast_mld_version " MLD_VERSION " set the MLD version. Default is 1. +.TP +.BI mcast_last_member_count " LAST_MEMBER_COUNT " +set multicast last member count, ie the number of queries the bridge +will send before stopping forwarding a multicast group after a "leave" +message has been received. Default is 2. + .SS bridge vlan global show - list global vlan options. This command displays the global VLAN options for each VLAN entry.
Signature · 1 line
2.31.1
PATCH 9/17 bridge: vlan: add global mcast_startup_query_count option
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add control and dump support for the global mcast_startup_query_count option which controls the number of queries the bridge will send on the vlan during startup phase (default 2).
Syntax:
$ bridge vlan global set dev bridge vid 1 mcast_startup_query_count 5
--- bridge/vlan.c | 15 +++++++++++++++ man/man8/bridge.8 | 8 +++++++- 2 files changed, 22 insertions(+), 1 deletion(-)
bridge/vlan.c +15 -0
@@ -42,6 +42,7 @@ static void usage(void)" [ mcast_igmp_version IGMP_VERSION ]\n" " [ mcast_mld_version MLD_VERSION ]\n" " [ mcast_last_member_count LAST_MEMBER_COUNT ]\n" +" [ mcast_startup_query_count STARTUP_QUERY_COUNT ]\n" " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 ); }
@@ -428,6 +429,14 @@ static int vlan_global_option_set(int argc, char **argv)addattr32 (&req.n,1024 ,BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_CNT , val32); + }else if (strcmp (*argv,"mcast_startup_query_count" ) ==0 ) { +NEXT_ARG (); +if (get_u32 (&val32, *argv,0 )) +invarg ("invalid mcast_startup_query_count" , + *argv); +addattr32 (&req.n,1024 , +BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT , + val32); }else {if (matches (*argv,"help" ) ==0 )NEXT_ARG ();
@@ -782,6 +791,12 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)"mcast_last_member_count %u " , rta_getattr_u32(vattr)); } +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT ]) { + vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT ]; +print_uint (PRINT_ANY ,"mcast_startup_query_count" , +"mcast_startup_query_count %u " , +rta_getattr_u32 (vattr)); + }print_nl ();close_json_object (); }
man/man8/bridge.8 +7 -1
@@ -165,7 +165,9 @@ bridge \- show / manipulate bridge addresses and devices .B mcast_mld_version .IR MLD_VERSION " ] [ " .B mcast_last_member_count -.IR LAST_MEMBER_COUNT " ]" +.IR LAST_MEMBER_COUNT " ] [ " +.B mcast_startup_query_count +.IR STARTUP_QUERY_COUNT " ]" .ti -8 .BR "bridge vlan global" " [ " show " ] [ "
@@ -951,6 +953,10 @@ set multicast last member count, ie the number of queries the bridge will send before stopping forwarding a multicast group after a "leave" message has been received. Default is 2. +.TP +.BI mcast_startup_query_count " STARTUP_QUERY_COUNT " +set the number of queries to send during startup phase. Default is 2. + .SS bridge vlan global show - list global vlan options. This command displays the global VLAN options for each VLAN entry.
Signature · 1 line
2.31.1
PATCH 10/17 bridge: vlan: add global mcast_last_member_interval option
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add control and dump support for the global mcast_last_member_interval option which controls the interval between queries to find remaining members of a group after a leave message. To be consistent with the same bridge-wide option the value is reported with USER_HZ granularity and the same granularity is expected when setting it.
The default is 100 (1 second).
Syntax:
$ bridge vlan global set dev bridge vid 1 mcast_last_member_interval 200
--- bridge/vlan.c | 16 ++++++++++++++++ man/man8/bridge.8 | 7 +++++++ 2 files changed, 23 insertions(+)
bridge/vlan.c +16 -0
@@ -42,6 +42,7 @@ static void usage(void)" [ mcast_igmp_version IGMP_VERSION ]\n" " [ mcast_mld_version MLD_VERSION ]\n" " [ mcast_last_member_count LAST_MEMBER_COUNT ]\n" +" [ mcast_last_member_interval LAST_MEMBER_INTERVAL ]\n" " [ mcast_startup_query_count STARTUP_QUERY_COUNT ]\n" " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 );
@@ -360,6 +361,7 @@ static int vlan_global_option_set(int argc, char **argv)short vid_end =-1 ;char *d =NULL ;short vid =-1 ; +__u64 val64;__u32 val32;__u8 val8;
@@ -437,6 +439,14 @@ static int vlan_global_option_set(int argc, char **argv)addattr32 (&req.n,1024 ,BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT , val32); + }else if (strcmp (*argv,"mcast_last_member_interval" ) ==0 ) { +NEXT_ARG (); +if (get_u64 (&val64, *argv,0 )) +invarg ("invalid mcast_last_member_interval" , + *argv); +addattr64 (&req.n,1024 , +BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_INTVL , + val64); }else {if (matches (*argv,"help" ) ==0 )NEXT_ARG ();
@@ -791,6 +801,12 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)"mcast_last_member_count %u " , rta_getattr_u32(vattr)); } +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_INTVL ]) { + vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_INTVL ]; +print_lluint (PRINT_ANY ,"mcast_last_member_interval" , +"mcast_last_member_interval %llu " , +rta_getattr_u64 (vattr)); + }if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT ]) { vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT ]; print_uint(PRINT_ANY, "mcast_startup_query_count",
man/man8/bridge.8 +7 -0
@@ -166,6 +166,8 @@ bridge \- show / manipulate bridge addresses and devices .IR MLD_VERSION " ] [ " .B mcast_last_member_count .IR LAST_MEMBER_COUNT " ] [ " +.B mcast_last_member_interval +.IR LAST_MEMBER_INTERVAL " ] [ " .B mcast_startup_query_count .IR STARTUP_QUERY_COUNT " ]"
@@ -953,6 +955,11 @@ set multicast last member count, ie the number of queries the bridge will send before stopping forwarding a multicast group after a "leave" message has been received. Default is 2. +.TP +.BI mcast_last_member_interval " LAST_MEMBER_INTERVAL " +interval between queries to find remaining members of a group, +after a "leave" message is received. + .TP .BI mcast_startup_query_count " STARTUP_QUERY_COUNT " set the number of queries to send during startup phase. Default is 2.
Signature · 1 line
2.31.1
PATCH 11/17 bridge: vlan: add global mcast_membership_interval option
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add control and dump support for the global mcast_membership_interval option which controls the interval after which the bridge will leave a group if no reports have been received for it. To be consistent with the same bridge-wide option the value is reported with USER_HZ granularity and the same granularity is expected when setting it.
The default is 26000 (260 seconds).
Syntax:
$ bridge vlan global set dev bridge vid 1 mcast_membership_interval 13000
--- bridge/vlan.c | 15 +++++++++++++++ man/man8/bridge.8 | 9 ++++++++- 2 files changed, 23 insertions(+), 1 deletion(-)
bridge/vlan.c +15 -0
@@ -44,6 +44,7 @@ static void usage(void)" [ mcast_last_member_count LAST_MEMBER_COUNT ]\n" " [ mcast_last_member_interval LAST_MEMBER_INTERVAL ]\n" " [ mcast_startup_query_count STARTUP_QUERY_COUNT ]\n" +" [ mcast_membership_interval MEMBERSHIP_INTERVAL ]\n" " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 ); }
@@ -447,6 +448,14 @@ static int vlan_global_option_set(int argc, char **argv)addattr64 (&req.n,1024 ,BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_INTVL , val64); + }else if (strcmp (*argv,"mcast_membership_interval" ) ==0 ) { +NEXT_ARG (); +if (get_u64 (&val64, *argv,0 )) +invarg ("invalid mcast_membership_interval" , + *argv); +addattr64 (&req.n,1024 , +BRIDGE_VLANDB_GOPTS_MCAST_MEMBERSHIP_INTVL , + val64); }else {if (matches (*argv,"help" ) ==0 )NEXT_ARG ();
@@ -813,6 +822,12 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)"mcast_startup_query_count %u " , rta_getattr_u32(vattr)); } +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_MEMBERSHIP_INTVL ]) { + vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_MEMBERSHIP_INTVL ]; +print_lluint (PRINT_ANY ,"mcast_membership_interval" , +"mcast_membership_interval %llu " , +rta_getattr_u64 (vattr)); + }print_nl ();close_json_object (); }
man/man8/bridge.8 +8 -1
@@ -169,7 +169,9 @@ bridge \- show / manipulate bridge addresses and devices .B mcast_last_member_interval .IR LAST_MEMBER_INTERVAL " ] [ " .B mcast_startup_query_count -.IR STARTUP_QUERY_COUNT " ]" +.IR STARTUP_QUERY_COUNT " ] [ " +.B mcast_membership_interval +.IR MEMBERSHIP_INTERVAL " ]" .ti -8 .BR "bridge vlan global" " [ " show " ] [ "
@@ -964,6 +966,11 @@ after a "leave" message is received. .BI mcast_startup_query_count " STARTUP_QUERY_COUNT " set the number of queries to send during startup phase. Default is 2. +.TP +.BI mcast_membership_interval " MEMBERSHIP_INTERVAL " +delay after which the bridge will leave a group, +if no membership reports for this group are received. + .SS bridge vlan global show - list global vlan options. This command displays the global VLAN options for each VLAN entry.
Signature · 1 line
2.31.1
PATCH 12/17 bridge: vlan: add global mcast_querier_interval option
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add control and dump support for the global mcast_querier_interval option which controls the interval after which if no other router queries are seen the bridge will start sending its own queries. To be consistent with the same bridge-wide option the value is reported with USER_HZ granularity and the same granularity is expected when setting it.
Syntax:
$ bridge vlan global set dev bridge vid 1 mcast_querier_interval 13000
--- bridge/vlan.c | 15 +++++++++++++++ man/man8/bridge.8 | 12 +++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
bridge/vlan.c +15 -0
@@ -45,6 +45,7 @@ static void usage(void)" [ mcast_last_member_interval LAST_MEMBER_INTERVAL ]\n" " [ mcast_startup_query_count STARTUP_QUERY_COUNT ]\n" " [ mcast_membership_interval MEMBERSHIP_INTERVAL ]\n" +" [ mcast_querier_interval QUERIER_INTERVAL ]\n" " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 ); }
@@ -456,6 +457,14 @@ static int vlan_global_option_set(int argc, char **argv)addattr64 (&req.n,1024 ,BRIDGE_VLANDB_GOPTS_MCAST_MEMBERSHIP_INTVL , val64); + }else if (strcmp (*argv,"mcast_querier_interval" ) ==0 ) { +NEXT_ARG (); +if (get_u64 (&val64, *argv,0 )) +invarg ("invalid mcast_querier_interval" , + *argv); +addattr64 (&req.n,1024 , +BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_INTVL , + val64); }else {if (matches (*argv,"help" ) ==0 )NEXT_ARG ();
@@ -828,6 +837,12 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)"mcast_membership_interval %llu " , rta_getattr_u64(vattr)); } +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_INTVL ]) { + vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_INTVL ]; +print_lluint (PRINT_ANY ,"mcast_querier_interval" , +"mcast_querier_interval %llu " , +rta_getattr_u64 (vattr)); + }print_nl ();close_json_object (); }
man/man8/bridge.8 +11 -1
@@ -171,7 +171,9 @@ bridge \- show / manipulate bridge addresses and devices .B mcast_startup_query_count .IR STARTUP_QUERY_COUNT " ] [ " .B mcast_membership_interval -.IR MEMBERSHIP_INTERVAL " ]" +.IR MEMBERSHIP_INTERVAL " ] [ " +.B mcast_querier_interval +.IR QUERIER_INTERVAL " ]" .ti -8 .BR "bridge vlan global" " [ " show " ] [ "
@@ -971,6 +973,14 @@ set the number of queries to send during startup phase. Default is 2. delay after which the bridge will leave a group, if no membership reports for this group are received. +.TP +.BI mcast_querier_interval " QUERIER_INTERVAL " +interval between queries sent by other routers. If no queries are seen +after this delay has passed, the bridge will start to send its own queries +(as if +.BI mcast_querier +was enabled). + .SS bridge vlan global show - list global vlan options. This command displays the global VLAN options for each VLAN entry.
Signature · 1 line
2.31.1
PATCH 13/17 bridge: vlan: add global mcast_query_interval option
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add control and dump support for the global mcast_query_interval option which controls the interval between queries sent by the bridge after the end of the startup phase. To be consistent with the same bridge-wide option the value is reported with USER_HZ granularity and the same granularity is expected when setting it.
Syntax:
$ bridge vlan global set dev bridge vid 1 mcast_query_interval 13000
--- bridge/vlan.c | 15 +++++++++++++++ man/man8/bridge.8 | 9 ++++++++- 2 files changed, 23 insertions(+), 1 deletion(-)
bridge/vlan.c +15 -0
@@ -46,6 +46,7 @@ static void usage(void)" [ mcast_startup_query_count STARTUP_QUERY_COUNT ]\n" " [ mcast_membership_interval MEMBERSHIP_INTERVAL ]\n" " [ mcast_querier_interval QUERIER_INTERVAL ]\n" +" [ mcast_query_interval QUERY_INTERVAL ]\n" " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 ); }
@@ -465,6 +466,14 @@ static int vlan_global_option_set(int argc, char **argv)addattr64 (&req.n,1024 ,BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_INTVL , val64); + }else if (strcmp (*argv,"mcast_query_interval" ) ==0 ) { +NEXT_ARG (); +if (get_u64 (&val64, *argv,0 )) +invarg ("invalid mcast_query_interval" , + *argv); +addattr64 (&req.n,1024 , +BRIDGE_VLANDB_GOPTS_MCAST_QUERY_INTVL , + val64); }else {if (matches (*argv,"help" ) ==0 )NEXT_ARG ();
@@ -843,6 +852,12 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)"mcast_querier_interval %llu " , rta_getattr_u64(vattr)); } +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERY_INTVL ]) { + vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERY_INTVL ]; +print_lluint (PRINT_ANY ,"mcast_query_interval" , +"mcast_query_interval %llu " , +rta_getattr_u64 (vattr)); + }print_nl ();close_json_object (); }
man/man8/bridge.8 +8 -1
@@ -173,7 +173,9 @@ bridge \- show / manipulate bridge addresses and devices .B mcast_membership_interval .IR MEMBERSHIP_INTERVAL " ] [ " .B mcast_querier_interval -.IR QUERIER_INTERVAL " ]" +.IR QUERIER_INTERVAL " ] [ " +.B mcast_query_interval +.IR QUERY_INTERVAL " ]" .ti -8 .BR "bridge vlan global" " [ " show " ] [ "
@@ -981,6 +983,11 @@ after this delay has passed, the bridge will start to send its own queries .BI mcast_querier was enabled). +.TP +.BI mcast_query_interval " QUERY_INTERVAL " +interval between queries sent by the bridge after the end of the +startup phase. + .SS bridge vlan global show - list global vlan options. This command displays the global VLAN options for each VLAN entry.
Signature · 1 line
2.31.1
PATCH 14/17 bridge: vlan: add global mcast_query_response_interval option
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add control and dump support for the global mcast_query_response_interval option which sets the Max Response Time/Maximum Response Delay for IGMP/MLD queries sent by the bridge. To be consistent with the same bridge-wide option the value is reported with USER_HZ granularity and the same granularity is expected when setting it.
Syntax:
$ bridge vlan global set dev bridge vid 1 mcast_query_response_interval 13000
--- bridge/vlan.c | 15 +++++++++++++++ man/man8/bridge.8 | 9 ++++++++- 2 files changed, 23 insertions(+), 1 deletion(-)
bridge/vlan.c +15 -0
@@ -47,6 +47,7 @@ static void usage(void)" [ mcast_membership_interval MEMBERSHIP_INTERVAL ]\n" " [ mcast_querier_interval QUERIER_INTERVAL ]\n" " [ mcast_query_interval QUERY_INTERVAL ]\n" +" [ mcast_query_response_interval QUERY_RESPONSE_INTERVAL ]\n" " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 ); }
@@ -474,6 +475,14 @@ static int vlan_global_option_set(int argc, char **argv)addattr64 (&req.n,1024 ,BRIDGE_VLANDB_GOPTS_MCAST_QUERY_INTVL , val64); + }else if (strcmp (*argv,"mcast_query_response_interval" ) ==0 ) { +NEXT_ARG (); +if (get_u64 (&val64, *argv,0 )) +invarg ("invalid mcast_query_response_interval" , + *argv); +addattr64 (&req.n,1024 , +BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL , + val64); }else {if (matches (*argv,"help" ) ==0 )NEXT_ARG ();
@@ -858,6 +867,12 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)"mcast_query_interval %llu " , rta_getattr_u64(vattr)); } +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL ]) { + vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL ]; +print_lluint (PRINT_ANY ,"mcast_query_response_interval" , +"mcast_query_response_interval %llu " , +rta_getattr_u64 (vattr)); + }print_nl ();close_json_object (); }
man/man8/bridge.8 +8 -1
@@ -175,7 +175,9 @@ bridge \- show / manipulate bridge addresses and devices .B mcast_querier_interval .IR QUERIER_INTERVAL " ] [ " .B mcast_query_interval -.IR QUERY_INTERVAL " ]" +.IR QUERY_INTERVAL " ] [ " +.B mcast_query_response_interval +.IR QUERY_RESPONSE_INTERVAL " ]" .ti -8 .BR "bridge vlan global" " [ " show " ] [ "
@@ -988,6 +990,11 @@ was enabled). interval between queries sent by the bridge after the end of the startup phase. +.TP +.BI mcast_query_response_interval " QUERY_RESPONSE_INTERVAL " +set the Max Response Time/Maximum Response Delay for IGMP/MLD +queries sent by the bridge. + .SS bridge vlan global show - list global vlan options. This command displays the global VLAN options for each VLAN entry.
Signature · 1 line
2.31.1
PATCH 16/17 bridge: vlan: add global mcast_querier option
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add control and dump support for the global mcast_querier option which controls if the bridge will act as a multicast querier for that vlan.
Syntax: $ bridge vlan global set dev bridge vid 1 mcast_querier 1
--- bridge/vlan.c | 12 ++++++++++++ man/man8/bridge.8 | 10 ++++++++++ 2 files changed, 22 insertions(+)
bridge/vlan.c +12 -0
@@ -39,6 +39,7 @@ static void usage(void)" bridge vlan { show } [ dev DEV ] [ vid VLAN_ID ]\n" " bridge vlan { tunnelshow } [ dev DEV ] [ vid VLAN_ID ]\n" " bridge vlan global { set } vid VLAN_ID dev DEV [ mcast_snooping MULTICAST_SNOOPING ]\n" +" [ mcast_querier MULTICAST_QUERIER ]\n" " [ mcast_igmp_version IGMP_VERSION ]\n" " [ mcast_mld_version MLD_VERSION ]\n" " [ mcast_last_member_count LAST_MEMBER_COUNT ]\n"
@@ -417,6 +418,12 @@ static int vlan_global_option_set(int argc, char **argv)invarg ("invalid mcast_snooping" , *argv);addattr8 (&req.n,1024 ,BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING , val8); + }else if (strcmp (*argv,"mcast_querier" ) ==0 ) { +NEXT_ARG (); +if (get_u8 (&val8, *argv,0 )) +invarg ("invalid mcast_querier" , *argv); +addattr8 (&req.n,1024 , +BRIDGE_VLANDB_GOPTS_MCAST_QUERIER , val8); }else if (strcmp (*argv,"mcast_igmp_version" ) ==0 ) {NEXT_ARG ();if (get_u8 (&val8, *argv,0 ))
@@ -830,6 +837,11 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)print_uint (PRINT_ANY ,"mcast_snooping" ,"mcast_snooping %u " ,rta_getattr_u8 (vattr)); } +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERIER ]) { + vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERIER ]; +print_uint (PRINT_ANY ,"mcast_querier" ,"mcast_querier %u " , +rta_getattr_u8 (vattr)); + }if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION ]) { vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION ]; print_uint(PRINT_ANY, "mcast_igmp_version",
man/man8/bridge.8 +10 -0
@@ -160,6 +160,8 @@ bridge \- show / manipulate bridge addresses and devices .IR VID " [ " .B mcast_snooping .IR MULTICAST_SNOOPING " ] [ " +.B mcast_querier +.IR MULTICAST_QUERIER " ] [ " .B mcast_igmp_version .IR IGMP_VERSION " ] [ " .B mcast_mld_version
@@ -951,6 +953,14 @@ turn multicast snooping for VLAN entry with VLAN ID on or off .RI ( MULTICAST_SNOOPING " == 0). Default is on. " +.TP +.BI mcast_querier " MULTICAST_QUERIER " +enable +.RI ( MULTICAST_QUERIER " > 0) " +or disable +.RI ( MULTICAST_QUERIER " == 0) " +IGMP/MLD querier, ie sending of multicast queries by the bridge. Default is disabled. + .TP .BI mcast_igmp_version " IGMP_VERSION " set the IGMP version. Default is 2.
Signature · 1 line
2.31.1
PATCH 15/17 bridge: vlan: add global mcast_startup_query_interval option
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add control and dump support for the global mcast_startup_query_interval option which controls the interval between queries in the startup phase. To be consistent with the same bridge-wide option the value is reported with USER_HZ granularity and the same granularity is expected when setting it.
Syntax:
$ bridge vlan global set dev bridge vid 1 mcast_startup_query_interval 15000
--- bridge/vlan.c | 15 +++++++++++++++ man/man8/bridge.8 | 6 ++++++ 2 files changed, 21 insertions(+)
bridge/vlan.c +15 -0
@@ -44,6 +44,7 @@ static void usage(void)" [ mcast_last_member_count LAST_MEMBER_COUNT ]\n" " [ mcast_last_member_interval LAST_MEMBER_INTERVAL ]\n" " [ mcast_startup_query_count STARTUP_QUERY_COUNT ]\n" +" [ mcast_startup_query_interval STARTUP_QUERY_INTERVAL ]\n" " [ mcast_membership_interval MEMBERSHIP_INTERVAL ]\n" " [ mcast_querier_interval QUERIER_INTERVAL ]\n" " [ mcast_query_interval QUERY_INTERVAL ]\n"
@@ -483,6 +484,14 @@ static int vlan_global_option_set(int argc, char **argv)addattr64 (&req.n,1024 ,BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL , val64); + }else if (strcmp (*argv,"mcast_startup_query_interval" ) ==0 ) { +NEXT_ARG (); +if (get_u64 (&val64, *argv,0 )) +invarg ("invalid mcast_startup_query_interval" , + *argv); +addattr64 (&req.n,1024 , +BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL , + val64); }else {if (matches (*argv,"help" ) ==0 )NEXT_ARG ();
@@ -849,6 +858,12 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)"mcast_startup_query_count %u " , rta_getattr_u32(vattr)); } +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL ]) { + vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL ]; +print_lluint (PRINT_ANY ,"mcast_startup_query_interval" , +"mcast_startup_query_interval %llu " , +rta_getattr_u64 (vattr)); + }if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_MEMBERSHIP_INTVL ]) { vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_MEMBERSHIP_INTVL ]; print_lluint(PRINT_ANY, "mcast_membership_interval",
man/man8/bridge.8 +6 -0
@@ -170,6 +170,8 @@ bridge \- show / manipulate bridge addresses and devices .IR LAST_MEMBER_INTERVAL " ] [ " .B mcast_startup_query_count .IR STARTUP_QUERY_COUNT " ] [ " +.B mcast_startup_query_interval +.IR STARTUP_QUERY_INTERVAL " ] [ " .B mcast_membership_interval .IR MEMBERSHIP_INTERVAL " ] [ " .B mcast_querier_interval
@@ -972,6 +974,10 @@ after a "leave" message is received. .BI mcast_startup_query_count " STARTUP_QUERY_COUNT " set the number of queries to send during startup phase. Default is 2. +.TP +.BI mcast_startup_query_interval " STARTUP_QUERY_INTERVAL " +interval between queries in the startup phase. + .TP .BI mcast_membership_interval " MEMBERSHIP_INTERVAL " delay after which the bridge will leave a group,
Signature · 1 line
2.31.1
PATCH 17/17 bridge: vlan: add support for dumping router ports
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add dump support for vlan multicast router ports and their details if requested. If details are requested we print 1 entry per line, otherwise we print all router ports on a single line similar to how mdb prints them.
Looks like:
$ bridge vlan global show vid 100
port vlan-id
bridge 100
mcast_snooping 1 mcast_querier 0 mcast_igmp_version 2 mcast_mld_version 1 mcast_last_member_count 2 mcast_last_member_interval 100 mcast_startup_query_count 2 mcast_startup_query_interval 3125 mcast_membership_interval 26000 mcast_querier_interval 25500 mcast_query_interval 12500 mcast_query_response_interval 1000
router ports: ens20 ens16Looks like (with -s):
$ bridge -s vlan global show vid 100
port vlan-id
bridge 100
mcast_snooping 1 mcast_querier 0 mcast_igmp_version 2 mcast_mld_version 1 mcast_last_member_count 2 mcast_last_member_interval 100 mcast_startup_query_count 2 mcast_startup_query_interval 3125 mcast_membership_interval 26000 mcast_querier_interval 25500 mcast_query_interval 12500 mcast_query_response_interval 1000
router ports: ens20 187.57 temp
ens16 118.27 temp--- bridge/br_common.h | 1 + bridge/mdb.c | 6 +++--- bridge/vlan.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-)
bridge/br_common.h +1 -0
@@ -14,6 +14,7 @@ void print_stp_state(__u8 state);int parse_stp_state (const char *arg);int print_vlan_rtm (struct nlmsghdr *n,void *arg,bool monitor,bool global_only); +void br_print_router_port_stats (struct rtattr *pattr);int do_fdb (int argc,char **argv);int do_mdb (int argc,char **argv);
bridge/mdb.c +3 -3
@@ -59,7 +59,7 @@ static const char *format_timer(__u32 ticks, int align)return tbuf; } -static void __print_router_port_stats (FILE *f,struct rtattr *pattr) +void br_print_router_port_stats (struct rtattr *pattr) {struct rtattr *tb[MDBA_ROUTER_PATTR_MAX +1 ];
@@ -101,13 +101,13 @@ static void br_print_router_ports(FILE *f, struct rtattr *attr,print_string (PRINT_JSON ,"port" ,NULL , port_ifname);if (show_stats) -__print_router_port_stats (f, i); +br_print_router_port_stats (i);close_json_object (); }else if (show_stats) {fprintf (f,"router ports on %s: %s" , brifname, port_ifname); -__print_router_port_stats (f, i); +br_print_router_port_stats (i);fprintf (f,"\n" ); }else {fprintf (f,"%s " , port_ifname);
bridge/vlan.c +34 -0
@@ -802,6 +802,36 @@ static int print_vlan_stats(struct nlmsghdr *n, void *arg)return 0 ; } +static void print_vlan_router_ports (struct rtattr *rattr) +{ +int rem =RTA_PAYLOAD (rattr); +struct rtattr *i; + + print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", ""); +open_json_array (PRINT_ANY ,is_json_context () ?"router_ports" : +"router ports: " ); +for (i =RTA_DATA (rattr);RTA_OK (i, rem); i =RTA_NEXT (i, rem)) { +uint32_t *port_ifindex =RTA_DATA (i); +const char *port_ifname =ll_index_to_name (*port_ifindex); + +open_json_object (NULL ); +if (show_stats && i !=RTA_DATA (rattr)) { +print_nl (); +/* start: IFNAMSIZ + 4 + strlen("router ports: ") */ +print_string (PRINT_FP ,NULL , + "%-" __stringify(IFNAMSIZ) "s " +" " , +"" ); + } +print_string (PRINT_ANY ,"port" ,"%s " , port_ifname); +if (show_stats) +br_print_router_port_stats (i); +close_json_object (); + } +close_json_array (PRINT_JSON ,NULL ); +print_nl (); +} +static void print_vlan_global_opts (struct rtattr *a,int ifindex) {struct rtattr *vtb[BRIDGE_VLANDB_GOPTS_MAX +1 ], *vattr;
@@ -901,6 +931,10 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex) rta_getattr_u64(vattr)); }print_nl (); +if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS ]) { + vattr =RTA_DATA (vtb[BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS ]); +print_vlan_router_ports (vattr); + }close_json_object (); }
Signature · 1 line
2.31.1
Re: [PATCH iproute2-next 01/17] ip: bridge: add support for mcast_vlan_snooping
In reply to Nikolay Aleksandrovip/iplink_bridge.c static int bridge_parse_opt(struct link_util *lu, int argc, char **argv, · line 206
Quoted 2 lines · On Thu, 26 Aug 2021 16:05:17 +0300 Nikolay Aleksandrov <[email protected]>…
ip/iplink_bridge.c +2
-0+ }else if (matches (*argv,"mcast_vlan_snooping" ) ==0 ) { +__u32 mcvl_bit =1 <<BR_BOOLOPT_MCAST_VLAN_SNOOPING ;
Using matches() is problematic. since it will change how 'mcast' is handled.
Overall, bridge command (and rest of iproute2) needs to move away from matches
Re: [PATCH iproute2-next 01/17] ip: bridge: add support for mcast_vlan_snooping
Quoted 12 lines · Stephen Hemminger
ip/iplink_bridge.c static int bridge_parse_opt(struct link_util *lu, int argc, char **argv, · line 206
Quoted 2 lines · On Thu, 26 Aug 2021 16:05:17 +0300 Nikolay Aleksandrov <[email protected]>…
ip/iplink_bridge.c +2
-0+ }else if (matches (*argv,"mcast_vlan_snooping" ) ==0 ) { +__u32 mcvl_bit =1 <<BR_BOOLOPT_MCAST_VLAN_SNOOPING ;Using
matches()is problematic. since it will change how 'mcast' is handled.Overall, bridge command (and rest of iproute2) needs to move away from matches
Sure, I can send a follow up if you don't mind to switch all matches calls. I used it to be in line with the current code.
Re: [PATCH iproute2-next 01/17] ip: bridge: add support for mcast_vlan_snooping
Quoted 10 lines · Nikolay Aleksandrov
Quoted 9 lines · Stephen Hemminger
ip/iplink_bridge.c static int bridge_parse_opt(struct link_util *lu, int argc, char **argv, · line 206
Quoted 2 lines · On Thu, 26 Aug 2021 16:05:17 +0300 Nikolay Aleksandrov <[email protected]>…
ip/iplink_bridge.c +2
-0+ }else if (matches (*argv,"mcast_vlan_snooping" ) ==0 ) { +__u32 mcvl_bit =1 <<BR_BOOLOPT_MCAST_VLAN_SNOOPING ;Using
matches()is problematic. since it will change how 'mcast' is handled.
Quoted 7 lines
Quoted 3 lines
Overall, bridge command (and rest of iproute2) needs to move away from matches
Sure, I can send a follow up if you don't mind to switch all matches calls. I used it to be in line with the current code.
existing options need to stay using matches(); new options need to use full strcmp().
Re: [PATCH iproute2-next 02/17] bridge: vlan: add support to show global vlan options
In reply to Nikolay AleksandrovQuoted 194 lines · Nikolay Aleksandrov
From: Nikolay Aleksandrov <[email protected]>
Add support for new bridge vlan command grouping called global which operates on global options. The first command it supports is "show". Man page and help are also updated with the new command.
Syntax is: $ bridge vlan global show [ vid VID ] [ dev DEV ]
Signed-off-by Nikolay Aleksandrov <[email protected]>--- bridge/br_common.h | 3 +- bridge/monitor.c | 2 +- bridge/vlan.c | 229 ++++++++++++++++++++++++++++++++++----------- man/man8/bridge.8 | 21 +++++ 4 files changed, 200 insertions(+), 55 deletions(-)bridge/br_common.h +2
-1@@ -12,7 +12,8 @@ int print_mdb_mon(struct nlmsghdr *n, void *arg);int print_fdb (struct nlmsghdr *n,void *arg);void print_stp_state (__u8 state);int parse_stp_state (const char *arg); -int print_vlan_rtm (struct nlmsghdr *n,void *arg,bool monitor); +int print_vlan_rtm (struct nlmsghdr *n,void *arg,bool monitor, +bool global_only);int do_fdb (int argc,char **argv);int do_mdb (int argc,char **argv);bridge/monitor.c +1
-1@@ -71,7 +71,7 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl,case RTM_DELVLAN :if (prefix_banner)fprintf (fp,"[VLAN]" ); -return print_vlan_rtm (n, arg, true); +return print_vlan_rtm (n, arg, true, false);default :return 0 ;bridge/vlan.c +87
-37@@ -36,7 +36,8 @@ static void usage(void)" [ self ] [ master ]\n" " bridge vlan { set } vid VLAN_ID dev DEV [ state STP_STATE ]\n" " bridge vlan { show } [ dev DEV ] [ vid VLAN_ID ]\n" - " bridge vlan { tunnelshow } [ dev DEV ] [ vid VLAN_ID ]\n"); +" bridge vlan { tunnelshow } [ dev DEV ] [ vid VLAN_ID ]\n" + " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 ); }@@ -621,11 +622,89 @@ static int print_vlan_stats(struct nlmsghdr *n, void *arg)return 0 ; } -int print_vlan_rtm (struct nlmsghdr *n,void *arg,bool monitor) +static void print_vlan_global_opts (struct rtattr *a) +{ +struct rtattr *vtb[BRIDGE_VLANDB_GOPTS_MAX +1 ]; +__u16 vid, vrange =0 ; + +if ((a->rta_type &NLA_TYPE_MASK ) !=BRIDGE_VLANDB_GLOBAL_OPTIONS ) +return ; + +parse_rtattr_flags (vtb,BRIDGE_VLANDB_GOPTS_MAX ,RTA_DATA (a), +RTA_PAYLOAD (a),NLA_F_NESTED ); + vid =rta_getattr_u16 (vtb[BRIDGE_VLANDB_GOPTS_ID ]); +if (vtb[BRIDGE_VLANDB_GOPTS_RANGE ]) + vrange =rta_getattr_u16 (vtb[BRIDGE_VLANDB_GOPTS_RANGE ]); +else + vrange = vid; +print_range ("vlan" , vid, vrange); +print_nl (); +} + +static void print_vlan_opts (struct rtattr *a) +{ +struct rtattr *vtb[BRIDGE_VLANDB_ENTRY_MAX +1 ]; +struct bridge_vlan_xstats vstats; +struct bridge_vlan_info *vinfo; +__u16 vrange =0 ; +__u8 state =0 ; + +if ((a->rta_type &NLA_TYPE_MASK ) !=BRIDGE_VLANDB_ENTRY ) +return ; + +parse_rtattr_flags (vtb,BRIDGE_VLANDB_ENTRY_MAX ,RTA_DATA (a), +RTA_PAYLOAD (a),NLA_F_NESTED ); + vinfo =RTA_DATA (vtb[BRIDGE_VLANDB_ENTRY_INFO ]); + +memset (&vstats,0 ,sizeof (vstats)); +if (vtb[BRIDGE_VLANDB_ENTRY_RANGE ]) + vrange =rta_getattr_u16 (vtb[BRIDGE_VLANDB_ENTRY_RANGE ]); +else + vrange = vinfo->vid; + +if (vtb[BRIDGE_VLANDB_ENTRY_STATE ]) + state =rta_getattr_u8 (vtb[BRIDGE_VLANDB_ENTRY_STATE ]); + +if (vtb[BRIDGE_VLANDB_ENTRY_STATS ]) { +struct rtattr *stb[BRIDGE_VLANDB_STATS_MAX +1 ]; +struct rtattr *attr; + + attr = vtb[BRIDGE_VLANDB_ENTRY_STATS ]; +parse_rtattr (stb,BRIDGE_VLANDB_STATS_MAX ,RTA_DATA (attr), +RTA_PAYLOAD (attr)); + +if (stb[BRIDGE_VLANDB_STATS_RX_BYTES ]) { + attr = stb[BRIDGE_VLANDB_STATS_RX_BYTES ]; + vstats.rx_bytes =rta_getattr_u64 (attr); + } +if (stb[BRIDGE_VLANDB_STATS_RX_PACKETS ]) { + attr = stb[BRIDGE_VLANDB_STATS_RX_PACKETS ]; + vstats.rx_packets =rta_getattr_u64 (attr); + } +if (stb[BRIDGE_VLANDB_STATS_TX_PACKETS ]) { + attr = stb[BRIDGE_VLANDB_STATS_TX_PACKETS ]; + vstats.tx_packets =rta_getattr_u64 (attr); + } +if (stb[BRIDGE_VLANDB_STATS_TX_BYTES ]) { + attr = stb[BRIDGE_VLANDB_STATS_TX_BYTES ]; + vstats.tx_bytes =rta_getattr_u64 (attr); + } + } +print_range ("vlan" , vinfo->vid, vrange); +print_vlan_flags (vinfo->flags); +print_nl (); + print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", ""); +print_stp_state (state); +print_nl (); +if (show_stats) +__print_one_vlan_stats (&vstats); +} + +int print_vlan_rtm (struct nlmsghdr *n,void *arg,bool monitor,bool global_only) { -struct rtattr *vtb[BRIDGE_VLANDB_ENTRY_MAX +1 ], *a;struct br_vlan_msg *bvm =NLMSG_DATA (n);int len = n->nlmsg_len; +struct rtattr *a;int rem; if (n->nlmsg_type != RTM_NEWVLAN && n->nlmsg_type != RTM_DELVLAN &&@@ -660,49 +739,13 @@ int print_vlan_rtm(struct nlmsghdr *n, void *arg, bool monitor) rem = len;for (a =BRVLAN_RTA (bvm);RTA_OK (a, rem); a =RTA_NEXT (a, rem)) { -struct bridge_vlan_xstats vstats; -struct bridge_vlan_info *vinfo; -__u32 vrange =0 ; -__u8 state =0 ; - -parse_rtattr_flags (vtb,BRIDGE_VLANDB_ENTRY_MAX ,RTA_DATA (a), -RTA_PAYLOAD (a),NLA_F_NESTED ); - vinfo =RTA_DATA (vtb[BRIDGE_VLANDB_ENTRY_INFO ]); - -memset (&vstats,0 ,sizeof (vstats)); -if (vtb[BRIDGE_VLANDB_ENTRY_RANGE ]) - vrange =rta_getattr_u16 (vtb[BRIDGE_VLANDB_ENTRY_RANGE ]); -else - vrange = vinfo->vid; - -if (vtb[BRIDGE_VLANDB_ENTRY_STATE ]) - state =rta_getattr_u8 (vtb[BRIDGE_VLANDB_ENTRY_STATE ]); +unsigned short rta_type = a->rta_type &NLA_TYPE_MASK ; -if (vtb[BRIDGE_VLANDB_ENTRY_STATS ]) { -struct rtattr *stb[BRIDGE_VLANDB_STATS_MAX +1 ]; -struct rtattr *attr; - - attr = vtb[BRIDGE_VLANDB_ENTRY_STATS ]; -parse_rtattr (stb,BRIDGE_VLANDB_STATS_MAX ,RTA_DATA (attr), -RTA_PAYLOAD (attr)); +/* skip unknown attributes */ +if (rta_type >BRIDGE_VLANDB_MAX || + (global_only && rta_type !=BRIDGE_VLANDB_GLOBAL_OPTIONS )) +continue ; -if (stb[BRIDGE_VLANDB_STATS_RX_BYTES ]) { - attr = stb[BRIDGE_VLANDB_STATS_RX_BYTES ]; - vstats.rx_bytes =rta_getattr_u64 (attr); - } -if (stb[BRIDGE_VLANDB_STATS_RX_PACKETS ]) { - attr = stb[BRIDGE_VLANDB_STATS_RX_PACKETS ]; - vstats.rx_packets =rta_getattr_u64 (attr); - } -if (stb[BRIDGE_VLANDB_STATS_TX_PACKETS ]) { - attr = stb[BRIDGE_VLANDB_STATS_TX_PACKETS ];
bridge/vlan.c int print_vlan_rtm(struct nlmsghdr *n, void *arg, bool monitor) · line 751
Quoted 10 lines
bridge/vlan.c +0
-7- vstats.tx_packets =rta_getattr_u64 (attr); - } -if (stb[BRIDGE_VLANDB_STATS_TX_BYTES ]) { - attr = stb[BRIDGE_VLANDB_STATS_TX_BYTES ]; - vstats.tx_bytes =rta_getattr_u64 (attr); - } - }if (vlan_rtm_cur_ifidx != bvm->ifindex) {open_vlan_port (bvm->ifindex,VLAN_SHOW_VLAN );open_json_object (NULL );
Split the refactoring of this code into a separate patch that only does the refactoring.
Re: [PATCH iproute2-next 10/17] bridge: vlan: add global mcast_last_member_interval option
In reply to Nikolay Aleksandrovbridge/vlan.c static void usage(void) · line 48
Quoted 8 lines · Nikolay Aleksandrov
bridge/vlan.c +1
-0@@ -42,6 +42,7 @@ static void usage(void)" [ mcast_igmp_version IGMP_VERSION ]\n" " [ mcast_mld_version MLD_VERSION ]\n" " [ mcast_last_member_count LAST_MEMBER_COUNT ]\n" +" [ mcast_last_member_interval LAST_MEMBER_INTERVAL ]\n" " [ mcast_startup_query_count STARTUP_QUERY_COUNT ]\n" " bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");exit (-1 );
line lengths are too long. The LAST_MEMBER_INTERVAL is at 107 characters wide just in what is displayed to the user. Let's keep those under 100.
Re: [PATCH iproute2-next 10/17] bridge: vlan: add global mcast_last_member_interval option
In reply to a message not in the archiveQuoted 25 lines · Nikolay Aleksandrov
------------------------------------------------------------------------
*From:* David Ahern <[email protected]>
*Sent:* Friday, 27 August 2021, 20:15
*To:* Nikolay Aleksandrov; [email protected]
*Cc:* Roopa Prabhu; Joachim Wiberg; Nikolay Aleksandrov *Subject:* Re: [PATCH iproute2-next 10/17] bridge: vlan: add globalmcast_last_member_intervaloptionQuoted 8 lines · Nikolay Aleksandrov
(quoted diff) +0
-0@@ -42,6 +42,7 @@ static void usage(void)" [
mcast_igmp_versionIGMP_VERSION]\n" " [mcast_mld_versionMLD_VERSION]\n" " [mcast_last_member_countLAST_MEMBER_COUNT]\n" + " [mcast_last_member_intervalLAST_MEMBER_INTERVAL]\n" " [mcast_startup_query_countSTARTUP_QUERY_COUNT]\n" " bridge vlan global { show } [ dev DEV ] [ vidVLAN_ID]\n");
exit(-1);line lengths are too long. The
LAST_MEMBER_INTERVALis at 107 characters wide just in what is displayed to the user. Let's keep those under 100.Quoted 1 line
Quoted 1 line
Quoted 5 lines
To be clear do you want me to break the help line or use a format string to print it?
Something like this:
" bridge vlan global { set } vid VLAN_ID dev DEV\n"
" [ mcast_snooping MULTICAST_SNOOPING ]\n" " [ mcast_igmp_version IGMP_VERSION ]\n" " [ mcast_mld_version MLD_VERSION ]\n" " [ mcast_last_member_count LAST_MEMBER_COUNT ]\n"
(email line lengths are too short forcing wrapping too early, but that is the intent with line lengths in the 80-90 range
Re: [PATCH iproute2-next 06/17] bridge: vlan: add global mcast_igmp_version option
In reply to Nikolay AleksandrovHi Nik,
awesome to see this patchset! :-) I've begun setting things up here for testing. Just have a question about this:
Quoted 2 lines · Nikolay Aleksandrov
Add control and dump support for the global
mcast_igmp_versionoption which controls the IGMP version on the vlan (default 2).
Why is the default IGMPv2? Since we support IGMPv3, surely that should be the default, with fallback to IGMPv2 when we detect end devices that don't support v3?
The snooping RFC refers back to the IGMPv3 RFC
https://datatracker.ietf.org/doc/html/rfc3376#section-7
I noticed the default for MLD is also set to the older version v1, and I'm guessing there's a reasoning behind both that I haven't yet grasped.
Best regards
/Joachim
Re: [PATCH iproute2-next 06/17] bridge: vlan: add global mcast_igmp_version option
Quoted 16 lines · Joachim Wiberg
Hi Nik,
awesome to see this patchset! :-) I've begun setting things up here for testing. Just have a question about this:
Quoted 2 lines · Nikolay Aleksandrov
Add control and dump support for the global
mcast_igmp_versionoption which controls the IGMP version on the vlan (default 2).Why is the default IGMPv2? Since we support IGMPv3, surely that should be the default, with fallback to IGMPv2 when we detect end devices that don't support v3?
The snooping RFC refers back to the IGMPv3 RFC
Quoted 8 lines
https://datatracker.ietf.org/doc/html/rfc3376#section-7
I noticed the default for MLD is also set to the older version v1, and I'm guessing there's a reasoning behind both that I haven't yet grasped.
Best regards
/Joachim
Hi,
The reason is to be consistent with the bridge config. It already has IGMPv2 as default. I added IGMPv3 support much later and we couldn't change the default.
I'd prefer not to surprise users and have different behaviour when they switch snooping from bridge-wide to per-vlan. It is a config option after all, distributions can choose to change their default when they create devices. :)
Cheers,
Nik
Re: [PATCH iproute2-next 06/17] bridge: vlan: add global mcast_igmp_version option
Quoted 33 lines · Nikolay Aleksandrov
Quoted 16 lines · Joachim Wiberg
Hi Nik,
awesome to see this patchset! :-) I've begun setting things up here for testing. Just have a question about this:
Quoted 2 lines · Nikolay Aleksandrov
Add control and dump support for the global
mcast_igmp_versionoption which controls the IGMP version on the vlan (default 2).Why is the default IGMPv2? Since we support IGMPv3, surely that should be the default, with fallback to IGMPv2 when we detect end devices that don't support v3?
The snooping RFC refers back to the IGMPv3 RFC
Quoted 8 lines
https://datatracker.ietf.org/doc/html/rfc3376#section-7
I noticed the default for MLD is also set to the older version v1, and I'm guessing there's a reasoning behind both that I haven't yet grasped.
Best regards
/JoachimHi,
The reason is to be consistent with the bridge config. It already has IGMPv2 as default. I added IGMPv3 support much later and we couldn't change the default.
I'd prefer not to surprise users and have different behaviour when they switch snooping from bridge-wide to per-vlan. It is a config option after all, distributions can choose to change their default when they create devices. :)
Quoted 3 lines
Cheers,
Nik
Forgot to mention - the RFC fallback and compatibility logic is not implemented yet, so if we set v3 we'll be stuck with it even if there are v2 participants. In fact it's a bit of a mess when mixing v2 and v3 right now, their interop needs more work.