]> git.proxmox.com Git - mirror_ifupdown2.git/blobdiff - ifupdown2/addons/bridge.py
addons: bridge: check kernel state for igmp snooping on vxlan brport
[mirror_ifupdown2.git] / ifupdown2 / addons / bridge.py
index fd2e28cce854ff08a14b70264ed30112e279bd56..9677b3bc1d2d08561bbec3206561daf0bb8ffa7b 100644 (file)
@@ -130,7 +130,7 @@ class bridge(moduleBase):
                           'example' : ['bridge-mclmc 2'],
                           'default' : '2'},
                     'bridge-mcrouter' :
-                        { 'help' : 'set multicast router',
+                        { 'help': 'Set bridge multicast routers: 0 - disabled - no, 1 - automatic (queried), 2 - permanently enabled - yes',
                           'validvals' : ['yes', 'no', '0', '1', '2'],
                           'example' : ['bridge-mcrouter 1'],
                           'default': 'yes'
@@ -203,7 +203,7 @@ class bridge(moduleBase):
                           'example' : ['bridge-mcqv4src 100=172.16.100.1 101=172.16.101.1']},
                      'bridge-portmcrouter':
                          {
-                             'help': 'set port multicast routers',
+                             'help': 'Set port multicast routers: 0 - disabled, 1 - automatic (queried), 2 - permanently enabled',
                              'validvals': ['<interface-disabled-automatic-enabled>'],
                              'example': [
                                  'under the port (for vlan aware bridge): bridge-portmcrouter 0',
@@ -220,7 +220,6 @@ class bridge(moduleBase):
                     'bridge-portmcfl' :
                         { 'help' : 'port multicast fast leave.',
                           'validvals': ['<interface-yes-no-0-1-list>'],
-                          'validrange' : ['yes', 'no', '0', '1'],
                           'default' : 'no',
                           'example' : ['under the port (for vlan aware bridge): bridge-portmcfl no',
                                        'under the bridge (for vlan unaware bridge): bridge-portmcfl swp1=no swp2=no']},
@@ -644,6 +643,14 @@ class bridge(moduleBase):
             )
         )
 
+        self.vxlan_bridge_igmp_snooping_enable_port_mcrouter = utils.get_boolean_from_string(
+            policymanager.policymanager_api.get_module_globals(
+                module_name=self.__class__.__name__,
+                attr="vxlan_bridge_igmp_snooping_enable_port_mcrouter"
+            ),
+            default=True
+        )
+
         self.l2protocol_tunnel_callback = {
             'all': self._l2protocol_tunnel_set_all,
             'stp': self._l2protocol_tunnel_set_stp,
@@ -1250,7 +1257,7 @@ class bridge(moduleBase):
             old_cache_key = self._ifla_br_attributes_old_cache_key_map.get(nl_attr)
             if old_cache_key and not link_just_created:
                 cached_value = self.brctlcmd.link_cache_get([ifname, 'linkinfo', old_cache_key])
-                if not cached_value:
+                if not cached_value or cached_value == "None":
                     # the link already exists but we don't have any value
                     # cached for this attr, it probably means that the
                     # capability is not available on this system (i.e old kernel)
@@ -1945,6 +1952,18 @@ class bridge(moduleBase):
                                                                                      brport_name,
                                                                                      brport_ifla_info_slave_data,
                                                                                      bridge_ports_learning.get(brport_name))
+
+                    cached_bridge_mcsnoop = self.brctlcmd.link_cache_get([ifname, 'linkinfo', Link.IFLA_BR_MCAST_SNOOPING])
+
+                    if (self.vxlan_bridge_igmp_snooping_enable_port_mcrouter and utils.get_boolean_from_string(
+                            self.get_bridge_mcsnoop_value(ifaceobj)
+                    )) or cached_bridge_mcsnoop:
+                        # if policy "vxlan_bridge_igmp_snooping_enable_port_mcrouter"
+                        # is on and mcsnoop is on (or mcsnoop is already enabled on the
+                        # bridge, set 'bridge-portmcrouter 2' on vxlan ports (if not set by the user)
+                        if not brport_ifla_info_slave_data.get(Link.IFLA_BRPORT_MULTICAST_ROUTER):
+                            brport_ifla_info_slave_data[Link.IFLA_BRPORT_MULTICAST_ROUTER] = 2
+                            self.logger.info("%s: %s: vxlan bridge igmp snooping: enable port multicast router" % (ifname, brport_name))
                 else:
                     kind = None
                     ifla_info_data = {}
@@ -2056,8 +2075,8 @@ class bridge(moduleBase):
         finally:
             if ifaceobj.link_type != ifaceLinkType.LINK_NA:
                 for p in running_ports:
-                    if (ifaceobj_getfunc(p)[0].link_privflags &
-                            ifaceLinkPrivFlags.KEEP_LINK_DOWN):
+                    ifaceobj_list = ifaceobj_getfunc(p)
+                    if (ifaceobj_list and ifaceobj_list[0].link_privflags & ifaceLinkPrivFlags.KEEP_LINK_DOWN):
                         netlink.link_set_updown(p, "down")
                         continue
                     try: