diff options
author | Thomas Haller <thaller@redhat.com> | 2021-04-26 18:54:52 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-04-26 21:17:18 +0200 |
commit | 43a0c6c111d87ea18a3733b220817703a307389b (patch) | |
tree | 312c8fae3a51b6724c96ab59656d9ec6fb1e9a38 | |
parent | 23a200d19e25fb760a69dd818dad1b780352b8c4 (diff) | |
download | NetworkManager-43a0c6c111d87ea18a3733b220817703a307389b.tar.gz |
core: fix assertion failure in device's activate_stage2_device_config()
Fixes: d946aa0c503e ('wired-setting: add support to accept-all-mac-addresses')
-rw-r--r-- | src/core/devices/nm-device.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index d6ab3274b7..64ed4b3d7a 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -8502,18 +8502,20 @@ activate_stage2_device_config(NMDevice *self) accept_all_mac_addresses = s_wired ? nm_setting_wired_get_accept_all_mac_addresses(s_wired) : NM_TERNARY_DEFAULT; if (accept_all_mac_addresses != NM_TERNARY_DEFAULT) { - int ifi_flags; + int ifindex = nm_device_get_ip_ifindex(self); - ifi_flags = nm_platform_link_get_ifi_flags(nm_device_get_platform(self), - nm_device_get_ip_ifindex(self), - IFF_PROMISC); - if (ifi_flags >= 0 && ((!!ifi_flags) != (!!accept_all_mac_addresses))) { - nm_platform_link_change_flags(nm_device_get_platform(self), - nm_device_get_ip_ifindex(self), - IFF_PROMISC, - !!accept_all_mac_addresses); - if (priv->promisc_reset == NM_OPTION_BOOL_DEFAULT) - priv->promisc_reset = !accept_all_mac_addresses; + if (ifindex > 0) { + int ifi_flags = + nm_platform_link_get_ifi_flags(nm_device_get_platform(self), ifindex, IFF_PROMISC); + + if (ifi_flags >= 0 && ((!!ifi_flags) != (!!accept_all_mac_addresses))) { + nm_platform_link_change_flags(nm_device_get_platform(self), + ifindex, + IFF_PROMISC, + !!accept_all_mac_addresses); + if (priv->promisc_reset == NM_OPTION_BOOL_DEFAULT) + priv->promisc_reset = !accept_all_mac_addresses; + } } } |