Commit ea7de52d authored by Thomas Haller's avatar Thomas Haller Committed by Lubomir Rintel

device: don't rely on nm_platform_link_get_ifindex() returning 0

While nm_platform_link_get_ifindex() is documented to return 0 if the device
is not found, don't rely on it. Instead, check that a valid(!) ifindex was
returned, and only then set the ifindex. Otherwise leave it at zero. There
is of course no difference in practice, but we generally treat invalid ifindexes
as <= 0, so it's not immediately clear what nm_platform_link_get_ifindex()
returns to signal no device.

(cherry picked from commit 9eefe27a)
parent a0161aa9
......@@ -6504,7 +6504,7 @@ tc_commit (NMDevice *self)
ip_ifindex = nm_device_get_ip_ifindex (self);
if (!ip_ifindex)
return s_tc == NULL;
return s_tc == NULL;
if (s_tc) {
nqdiscs = nm_setting_tc_config_get_num_qdiscs (s_tc);
......@@ -6591,9 +6591,12 @@ tc_commit (NMDevice *self)
var = nm_tc_action_get_attribute (action, "dev");
if (var && g_variant_is_of_type (var, G_VARIANT_TYPE_STRING)) {
int ifindex = nm_platform_link_get_ifindex (nm_device_get_platform (self),
g_variant_get_string (var, NULL));
tfilter->action.mirred.ifindex = ifindex;
int ifindex;
ifindex = nm_platform_link_get_ifindex (nm_device_get_platform (self),
g_variant_get_string (var, NULL));
if (ifindex > 0)
tfilter->action.mirred.ifindex = ifindex;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment