summaryrefslogtreecommitdiff
path: root/cloudinit/net/__init__.py
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2019-10-04 15:34:41 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-10-04 15:34:41 +0000
commita7d8d032a65e807007f1467a9220b7f161625668 (patch)
treef2116cab4c7905e7608eb9f807e5820ecd1b9f21 /cloudinit/net/__init__.py
parent5d5a32e039782ce3e1c0843082fe26260fa9273a (diff)
downloadvyos-cloud-init-a7d8d032a65e807007f1467a9220b7f161625668.tar.gz
vyos-cloud-init-a7d8d032a65e807007f1467a9220b7f161625668.zip
get_interfaces: don't exclude bridge and bond members
The change that introduced this issue was handling interfaces that are bonded in the kernel, in a way that doesn't present as "a bond" to userspace in the normal way. Both members of this "bond" will share a MAC address, so we filter one of them out to avoid incorrect MAC address collision warnings. Unfortunately, the matching condition was too broad, so that change also affected normal bonds and bridges. This change specifically excludes bonds and bridges from that determination, to address that regression. LP: #1846535
Diffstat (limited to 'cloudinit/net/__init__.py')
-rw-r--r--cloudinit/net/__init__.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py
index 5de5c6de..307da780 100644
--- a/cloudinit/net/__init__.py
+++ b/cloudinit/net/__init__.py
@@ -109,8 +109,22 @@ def is_bond(devname):
return os.path.exists(sys_dev_path(devname, "bonding"))
-def has_master(devname):
- return os.path.exists(sys_dev_path(devname, path="master"))
+def get_master(devname):
+ """Return the master path for devname, or None if no master"""
+ path = sys_dev_path(devname, path="master")
+ if os.path.exists(path):
+ return path
+ return None
+
+
+def master_is_bridge_or_bond(devname):
+ """Return a bool indicating if devname's master is a bridge or bond"""
+ master_path = get_master(devname)
+ if master_path is None:
+ return False
+ bonding_path = os.path.join(master_path, "bonding")
+ bridge_path = os.path.join(master_path, "bridge")
+ return (os.path.exists(bonding_path) or os.path.exists(bridge_path))
def is_netfailover(devname, driver=None):
@@ -158,7 +172,7 @@ def is_netfail_master(devname, driver=None):
Return True if all of the above is True.
"""
- if has_master(devname):
+ if get_master(devname) is not None:
return False
if driver is None:
@@ -215,7 +229,7 @@ def is_netfail_standby(devname, driver=None):
Return True if all of the above is True.
"""
- if not has_master(devname):
+ if get_master(devname) is None:
return False
if driver is None:
@@ -790,7 +804,7 @@ def get_interfaces():
continue
if is_bond(name):
continue
- if has_master(name):
+ if get_master(name) is not None and not master_is_bridge_or_bond(name):
continue
if is_netfailover(name):
continue