From 3456e97ba02fd9529e01b67052045d45ab443704 Mon Sep 17 00:00:00 2001 From: Gris Ge Date: Thu, 26 Sep 2024 17:37:58 +0800 Subject: [PATCH] nm: Handle `ipv6.method: ignore` With NetworkManager holding `ipv6.method: ignore`, we should trust nispor on querying the correct ipv6 status. Current code is blindly treat it as ipv6.enabled, this fix is only use nispor information for ipv6 status if NetworkManager found `ipv6.method: ignore` Integration test case included. Resolves: https://issues.redhat.com/browse/RHEL-58406 Signed-off-by: Gris Ge --- rust/src/lib/nm/query_apply/ip.rs | 11 ++++++++++- tests/integration/nm/ip_test.py | 33 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/rust/src/lib/nm/query_apply/ip.rs b/rust/src/lib/nm/query_apply/ip.rs index 095dfb279e..c7eafd08fd 100644 --- a/rust/src/lib/nm/query_apply/ip.rs +++ b/rust/src/lib/nm/query_apply/ip.rs @@ -93,7 +93,16 @@ pub(crate) fn nm_ip_setting_to_nmstate6( | NmSettingIpMethod::Shared => (true, Some(false), Some(false)), NmSettingIpMethod::Auto => (true, Some(true), Some(true)), NmSettingIpMethod::Dhcp => (true, Some(true), Some(false)), - NmSettingIpMethod::Ignore => (true, Some(false), Some(false)), + NmSettingIpMethod::Ignore => { + log::debug!( + "Found NmSettingIpMethod::Ignore for ipv6, \ + reply on nispor for setting IPv6 query" + ); + return InterfaceIpv6 { + enabled_defined: false, + ..Default::default() + }; + } }; let (auto_dns, auto_gateway, auto_routes, auto_table_id) = parse_dhcp_opts(nm_ip_setting); diff --git a/tests/integration/nm/ip_test.py b/tests/integration/nm/ip_test.py index dd742d4e6a..9aebba4533 100644 --- a/tests/integration/nm/ip_test.py +++ b/tests/integration/nm/ip_test.py @@ -6,10 +6,12 @@ from libnmstate.schema import Interface from libnmstate.schema import InterfaceIPv4 from libnmstate.schema import InterfaceIPv6 +from libnmstate.schema import InterfaceState from libnmstate.schema import InterfaceType from ..testlib import cmdlib from ..testlib import assertlib +from ..testlib.statelib import show_only IPV4_ADDRESS1 = "192.0.2.251" @@ -223,3 +225,34 @@ def test_fix_dhcp_timeout_even_not_desired(dummy1_with_small_dhcp_timeout): ) == I32_MAX ) + + +@pytest.fixture +def eth1_up_ipv6_flushed_with_method_ignore(eth1_up): + libnmstate.apply( + { + Interface.KEY: [ + { + Interface.NAME: "eth1", + Interface.STATE: InterfaceState.UP, + Interface.IPV6: { + InterfaceIPv6.ENABLED: False, + }, + } + ], + } + ) + + cmdlib.exec_cmd( + "nmcli c modify eth1 ipv6.method ignore".split(), check=True + ) + cmdlib.exec_cmd("nmcli c up eth1".split(), check=True) + cmdlib.exec_cmd("ip -6 addr flush dev eth1".split(), check=True) + + +def test_delegate_nm_ipv6_method_ignore_to_nispor( + eth1_up_ipv6_flushed_with_method_ignore, +): + state = show_only(("eth1",)) + + assert not state[Interface.KEY][0][Interface.IPV6][InterfaceIPv6.ENABLED]