diff mbox series

[iproute2-next,v2,07/19] bridge: vlan: add global mcast_snooping option

Message ID 20210828110805.463429-8-razor@blackwall.org (mailing list archive)
State Accepted
Delegated to: David Ahern
Headers show
Series bridge: vlan: add global multicast options | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Nikolay Aleksandrov Aug. 28, 2021, 11:07 a.m. UTC
From: Nikolay Aleksandrov <nikolay@nvidia.com>

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

Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
---
v2: adjust help msg alignment to fit in 100 columns

 bridge/vlan.c     | 18 +++++++++++++++++-
 man/man8/bridge.8 | 11 ++++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

Comments

David Ahern Sept. 1, 2021, 3:36 a.m. UTC | #1
On 8/28/21 4:07 AM, Nikolay Aleksandrov wrote:
> @@ -397,6 +400,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();

How did you redo this patch set where 06 uses strcmp for the help line
and yet patches 7-17 all have matches?

Fixed those up given where we are with 5.14 cycle and applied to
iproute2-next.
Nikolay Aleksandrov Sept. 1, 2021, 8:07 a.m. UTC | #2
On 01/09/2021 06:36, David Ahern wrote:
> On 8/28/21 4:07 AM, Nikolay Aleksandrov wrote:
>> @@ -397,6 +400,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();
> 
> How did you redo this patch set where 06 uses strcmp for the help line
> and yet patches 7-17 all have matches?
> 
> Fixed those up given where we are with 5.14 cycle and applied to
> iproute2-next.
> 

Oh wtf, looks like rebasing gone wrong, I'll have to fix up my scripts.
Apologies about that and thanks for taking care of the matches -> strcmp.
diff mbox series

Patch

diff --git a/bridge/vlan.c b/bridge/vlan.c
index 34fba0a5bdfb..b1a8cfc4a362 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -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"
@@ -38,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\n"
+		"                      [ mcast_snooping MULTICAST_SNOOPING ]\n"
 		"       bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");
 	exit(-1);
 }
@@ -355,6 +357,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 +400,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 +711,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 +738,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();
 }
 
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 796d20b662ab..d894289b2dc2 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -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.