mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 19:00:11 +01:00
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.
This commit is contained in:
parent
9399297a82
commit
9eefe27a1c
1 changed files with 7 additions and 4 deletions
|
|
@ -6508,7 +6508,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);
|
||||
|
|
@ -6595,9 +6595,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue