Skip to content

Commit

Permalink
nm: Handle ipv6.method: ignore
Browse files Browse the repository at this point in the history
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 <fge@redhat.com>
  • Loading branch information
cathay4t committed Sep 26, 2024
1 parent a44f555 commit 3456e97
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
11 changes: 10 additions & 1 deletion rust/src/lib/nm/query_apply/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 33 additions & 0 deletions tests/integration/nm/ip_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]

0 comments on commit 3456e97

Please sign in to comment.