mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 15:48:06 +02:00
core: don't flush routes/addresses on invalid interface indexes
The NM 'iface' isn't always the IP iface (like for modems) so to avoid a warning, only flush routes and addresses on deactivate when the iface can actually handle it.
This commit is contained in:
parent
f6f8ff1c33
commit
a868fd5a98
2 changed files with 10 additions and 6 deletions
|
|
@ -569,10 +569,12 @@ real_deactivate (NMModem *self, NMDevice *device)
|
|||
case MM_MODEM_IP_METHOD_STATIC:
|
||||
case MM_MODEM_IP_METHOD_DHCP:
|
||||
ifindex = nm_device_get_ip_ifindex (device);
|
||||
/* FIXME: use AF_UNSPEC here when we have IPv6 support */
|
||||
nm_system_iface_flush_routes (ifindex, AF_INET);
|
||||
nm_system_iface_flush_addresses (ifindex, AF_UNSPEC);
|
||||
nm_system_iface_set_up (ifindex, FALSE, NULL);
|
||||
if (ifindex >= 0) {
|
||||
/* FIXME: use AF_UNSPEC here when we have IPv6 support */
|
||||
nm_system_iface_flush_routes (ifindex, AF_INET);
|
||||
nm_system_iface_flush_addresses (ifindex, AF_UNSPEC);
|
||||
nm_system_iface_set_up (ifindex, FALSE, NULL);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
nm_log_err (LOGD_MB, "unknown IP method %d", priv->ip_method);
|
||||
|
|
|
|||
|
|
@ -3047,8 +3047,10 @@ nm_device_deactivate (NMDevice *self, NMDeviceStateReason reason)
|
|||
/* Take out any entries in the routing table and any IP address the device had. */
|
||||
ifindex = nm_device_get_ip_ifindex (self);
|
||||
family = tried_ipv6 ? AF_UNSPEC : AF_INET;
|
||||
nm_system_iface_flush_routes (ifindex, family);
|
||||
nm_system_iface_flush_addresses (ifindex, family);
|
||||
if (ifindex >= 0) {
|
||||
nm_system_iface_flush_routes (ifindex, family);
|
||||
nm_system_iface_flush_addresses (ifindex, family);
|
||||
}
|
||||
_update_ip4_address (self);
|
||||
|
||||
/* Clean up nameservers and addresses */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue