summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-01-11 11:35:13 +0100
committerThomas Haller <thaller@redhat.com>2018-02-21 20:28:46 +0100
commit78ca2a70c719b255aa7de04cffaa264bb4d06b55 (patch)
tree2ecfa28940a289bd0c9c7af1c9c9d301a9429351
parentc7b3586b9db49fed8926d746ec24e3d21b542f42 (diff)
downloadNetworkManager-78ca2a70c719b255aa7de04cffaa264bb4d06b55.tar.gz
device: don't set invalid ip-iface
Now that every call to nm_device_set_ip_iface() and nm_device_set_ip_ifindex() is checked, and setting an interface that does not exist causes the device state to fail, we no longer need to allow setting an ip-iface if we are unable to retrieve the ip-ifindex.
-rw-r--r--src/devices/nm-device.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 084c3f7ae4..54b0097326 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1291,14 +1291,11 @@ _set_ip_ifindex (NMDevice *self,
NMPlatform *platform;
gboolean eq_name;
- /* we can set only the ifname without ifindex (to indicate that this
- * is an ip-interface, but lookup for the ifindex failed.
- * But we cannot just set ifindex > 0 without an ifname. */
- nm_assert (ifindex <= 0 || ifname);
-
- /* normalize ifindex */
- if (ifindex < 0)
+ /* normalize arguments */
+ if (ifindex <= 0) {
ifindex = 0;
+ ifname = NULL;
+ }
eq_name = nm_streq0 (priv->ip_iface, ifname);
@@ -1343,13 +1340,12 @@ nm_device_set_ip_ifindex (NMDevice *self, int ifindex)
const char *ifname = NULL;
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
+ g_return_val_if_fail (nm_device_is_activating (self), FALSE);
if (ifindex > 0) {
ifname = nm_platform_if_indextoname (nm_device_get_platform (self), ifindex, ifname_buf);
- if (!ifname) {
+ if (!ifname)
_LOGW (LOGD_DEVICE, "ip-ifindex: ifindex %d not found", ifindex);
- return FALSE;
- }
}
_set_ip_ifindex (self, ifindex, ifname);
@@ -1372,9 +1368,13 @@ nm_device_set_ip_iface (NMDevice *self, const char *ifname)
int ifindex = 0;
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
+ g_return_val_if_fail (nm_device_is_activating (self), FALSE);
- if (ifname)
+ if (ifname) {
ifindex = nm_platform_if_nametoindex (nm_device_get_platform (self), ifname);
+ if (ifindex <= 0)
+ _LOGW (LOGD_DEVICE, "ip-ifindex: ifname %s not found", ifname);
+ }
_set_ip_ifindex (self, ifindex, ifname);
return ifindex > 0;