From: Julien Fortin Date: Tue, 26 Feb 2019 17:58:22 +0000 (+0100) Subject: addons: addressvirtual: create VRRP macvlans in bridge mode X-Git-Tag: 1.2.8-1~35 X-Git-Url: https://git.proxmox.com/?p=mirror_ifupdown2.git;a=commitdiff_plain;h=e588acb7d88c794d6b789ca7d355bf76336a953f addons: addressvirtual: create VRRP macvlans in bridge mode Signed-off-by: Julien Fortin --- diff --git a/ifupdown2/addons/addressvirtual.py b/ifupdown2/addons/addressvirtual.py index 4fa042e..7a2eb00 100644 --- a/ifupdown2/addons/addressvirtual.py +++ b/ifupdown2/addons/addressvirtual.py @@ -402,10 +402,11 @@ class addressvirtual(moduleBase): link_created = False macvlan_ifname = intf_config_dict.get("ifname") macvlan_hwaddr = intf_config_dict.get("hwaddress") + macvlan_mode = intf_config_dict.get("mode") ips = intf_config_dict.get("ips") if not self.ipcmd.link_exists(macvlan_ifname): - self.ipcmd.link_add_macvlan(ifname, macvlan_ifname) + self.ipcmd.link_add_macvlan(ifname, macvlan_ifname, macvlan_mode) link_created = True # first thing we need to handle vrf enslavement @@ -546,6 +547,7 @@ class addressvirtual(moduleBase): # { # "ifname": "macvlan_ifname", # "hwaddress": "macvlan_hwaddress", + # "mode": "macvlan_mode", # "ips": [str(IPNetwork), ] # }, # ] @@ -595,6 +597,7 @@ class addressvirtual(moduleBase): "ifname": macvlan_ip4_ifname, "hwaddress": macvlan_ip4_mac, "hwaddress_int": self.mac_str_to_int(macvlan_ip4_mac), + "mode": "bridge", "ips": ip4, "id": vrrp_id }) @@ -606,6 +609,7 @@ class addressvirtual(moduleBase): "ifname": macvlan_ip6_ifname, "hwaddress": macvlan_ip6_mac, "hwaddress_int": self.mac_str_to_int(macvlan_ip6_mac), + "mode": "bridge", "ips": ip6, "id": vrrp_id }) @@ -648,7 +652,10 @@ class addressvirtual(moduleBase): if not self.check_mac_address(ifaceobj, mac): continue - config = {"ifname": "%s%d" % (macvlan_prefix, index)} + config = { + "ifname": "%s%d" % (macvlan_prefix, index), + "mode": "private" + } if mac != "none": config["hwaddress"] = mac diff --git a/ifupdown2/ifupdownaddons/LinkUtils.py b/ifupdown2/ifupdownaddons/LinkUtils.py index 7abc1df..69ffd9e 100644 --- a/ifupdown2/ifupdownaddons/LinkUtils.py +++ b/ifupdown2/ifupdownaddons/LinkUtils.py @@ -1373,8 +1373,8 @@ class LinkUtils(utilsBase): return False @staticmethod - def link_add_macvlan(ifname, macvlan_ifacename): - utils.exec_commandl(['ip', 'link', 'add', 'link', ifname, 'name', macvlan_ifacename, 'type', 'macvlan', 'mode', 'private']) + def link_add_macvlan(ifname, macvlan_ifacename, mode): + utils.exec_commandl(['ip', 'link', 'add', 'link', ifname, 'name', macvlan_ifacename, 'type', 'macvlan', 'mode', mode]) @staticmethod def route_add(route):