Skip to content

Commit

Permalink
Update behavior of base bond interface with NetworkManager (canonical…
Browse files Browse the repository at this point in the history
…#5385)

When using NetworkManager, if the base bond interface does not have
subnet information configured, ensure it is disabled with respect to
ipv4 and ipv6. Otherwise, the base bond interface defaults to 'auto'
and will try to configure itself via DHCP. This is problematic when
using a tagged VLAN interface on top of the bond as the base
interface will try to configure itself via DHCP on the untagged VLAN.
  • Loading branch information
jcmoore3 authored Aug 14, 2024
1 parent e1845be commit 90a3190
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
19 changes: 16 additions & 3 deletions cloudinit/net/network_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,13 @@ def _set_ip_method(self, family, subnet_type):
"dhcp": "auto",
}

# Ensure we got an [ipvX] section
self._set_default(family, "method", "disabled")
# Ensure we have an [ipvX] section, default to disabled
method = "disabled"
self._set_default(family, "method", method)

try:
method = method_map[subnet_type]
if subnet_type:
method = method_map[subnet_type]
except KeyError:
# What else can we do
method = "auto"
Expand Down Expand Up @@ -360,6 +362,17 @@ def render_interface(self, iface, network_state, renderer):
found_dns_search = []

# Deal with Layer 3 configuration
if if_type == "bond" and not iface["subnets"]:
# If there is no L3 subnet config for a given connection,
# ensure it is disabled. Without this, the interface
# defaults to 'auto' which implies DHCP. This is problematic
# for certain configurations such as bonds where the root
# device itself may not have a subnet config and should be
# disabled while a separate VLAN interface on the bond holds
# the subnet information.
for family in ["ipv4", "ipv6"]:
self._set_ip_method(family, None)

for subnet in iface["subnets"]:
family = "ipv6" if subnet_is_ipv6(subnet) else "ipv4"

Expand Down
16 changes: 16 additions & 0 deletions tests/unittests/net/test_network_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ def test_bond_dns_baseline(self, tmpdir):
[bond]
mode=802.3ad
[ipv4]
method=disabled
may-fail=false
[ipv6]
method=disabled
may-fail=false
[ethernet]
mtu=9000
Expand Down Expand Up @@ -279,6 +287,14 @@ def test_bond_dns_redacted_with_method_disabled(self, tmpdir):
[bond]
mode=802.3ad
[ipv4]
method=disabled
may-fail=false
[ipv6]
method=disabled
may-fail=false
[ethernet]
mtu=9000
Expand Down

0 comments on commit 90a3190

Please sign in to comment.