]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
bridge: vlan: add support for mcast_router option
authorNikolay Aleksandrov <nikolay@nvidia.com>
Wed, 1 Sep 2021 10:38:16 +0000 (13:38 +0300)
committerDavid Ahern <dsahern@kernel.org>
Mon, 6 Sep 2021 23:00:31 +0000 (17:00 -0600)
Add support for setting and dumping per-vlan/interface mcast_router
option. It controls the mcast router mode of a vlan/interface pair.
For bridge devices only modes 0 - 2 are allowed. The possible modes
are:
 0 - disabled
 1 - automatic router presence detection (default)
 2 - permanent router
 3 - temporary router (available only for ports)

Example:
 # mark port ens16 as a permanent mcast router for vlan 100
 $ bridge vlan set dev ens16 vid 100 mcast_router 2
 # disable mcast router for port ens16 and vlan 200
 $ bridge vlan set dev ens16 vid 200 mcast_router 0
 $ bridge -d vlan show
 port              vlan-id
 ens16             1 PVID Egress Untagged
                     state forwarding mcast_router 1
                   100
                     state forwarding mcast_router 2
                   200
                     state forwarding mcast_router 0

Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
bridge/vlan.c
man/man8/bridge.8

index 48365bca4c4af9848da1b788f7784433c0c7949f..8300f353f1a7b48d7f54572ea743e6be845f8df5 100644 (file)
@@ -36,6 +36,7 @@ static void usage(void)
                "                                                     [ pvid ] [ untagged ]\n"
                "                                                     [ self ] [ master ]\n"
                "       bridge vlan { set } vid VLAN_ID dev DEV [ state STP_STATE ]\n"
+               "                                               [ mcast_router MULTICAST_ROUTER ]\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"
@@ -334,6 +335,15 @@ static int vlan_option_set(int argc, char **argv)
                        }
                        addattr8(&req.n, sizeof(req), BRIDGE_VLANDB_ENTRY_STATE,
                                 state);
+               } else if (strcmp(*argv, "mcast_router") == 0) {
+                       __u8 mcast_router;
+
+                       NEXT_ARG();
+                       if (get_u8(&mcast_router, *argv, 0))
+                               invarg("invalid mcast_router", *argv);
+                       addattr8(&req.n, sizeof(req),
+                                BRIDGE_VLANDB_ENTRY_MCAST_ROUTER,
+                                mcast_router);
                } else {
                        if (matches(*argv, "help") == 0)
                                NEXT_ARG();
@@ -942,7 +952,7 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)
 
 static void print_vlan_opts(struct rtattr *a, int ifindex)
 {
-       struct rtattr *vtb[BRIDGE_VLANDB_ENTRY_MAX + 1];
+       struct rtattr *vtb[BRIDGE_VLANDB_ENTRY_MAX + 1], *vattr;
        struct bridge_vlan_xstats vstats;
        struct bridge_vlan_info *vinfo;
        __u16 vrange = 0;
@@ -1006,6 +1016,11 @@ static void print_vlan_opts(struct rtattr *a, int ifindex)
        print_nl();
        print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s    ", "");
        print_stp_state(state);
+       if (vtb[BRIDGE_VLANDB_ENTRY_MCAST_ROUTER]) {
+               vattr = vtb[BRIDGE_VLANDB_ENTRY_MCAST_ROUTER];
+               print_uint(PRINT_ANY, "mcast_router", "mcast_router %u ",
+                          rta_getattr_u8(vattr));
+       }
        print_nl();
        if (show_stats)
                __print_one_vlan_stats(&vstats);
index 76d2fa09d5bc0808c102e9dec6b0e66866805d28..c3c4ae48aaed3a80163b4b7a49396abf554b57da 100644 (file)
@@ -145,7 +145,9 @@ bridge \- show / manipulate bridge addresses and devices
 .B vid
 .IR VID " [ "
 .B state
-.IR STP_STATE " ] "
+.IR STP_STATE " ] [ "
+.B mcast_router
+.IR MULTICAST_ROUTER " ]"
 
 .ti -8
 .BR "bridge vlan" " [ " show " | " tunnelshow " ] [ "
@@ -915,6 +917,31 @@ is used during the STP election process. In this state, the vlan will only proce
 STP BPDUs.
 .sp
 
+.TP
+.BI mcast_router " MULTICAST_ROUTER "
+configure this vlan and interface's multicast router mode, note that only modes
+0 - 2 are available for bridge devices.
+A vlan and interface with a multicast router will receive all multicast traffic.
+.I MULTICAST_ROUTER
+may be either
+.sp
+.B 0
+- to disable multicast router.
+.sp
+
+.B 1
+- to let the system detect the presence of routers (default).
+.sp
+
+.B 2
+- to permanently enable multicast traffic forwarding on this vlan and interface.
+.sp
+
+.B 3
+- to temporarily mark this vlan and port as having a multicast router, i.e.
+enable multicast traffic forwarding. This mode is available only for ports.
+.sp
+
 .SS bridge vlan show - list vlan configuration.
 
 This command displays the current VLAN filter table.