mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-09 00:40:19 +01:00
platform: let nmp_cache_lookup_link_full() prefer visible links
In nmp_cache_lookup_link_full(), we may have multiple candidates that match. Continue searching, until we find a visible one. That way, visible results are preferred. Note that for links, nmp_object_is_visible() checks whether the link is visible in netlink (instead of only udev).
This commit is contained in:
parent
f411dea585
commit
f47f9e3956
1 changed files with 11 additions and 4 deletions
|
|
@ -1976,6 +1976,8 @@ nmp_cache_lookup_link_full (const NMPCache *cache,
|
|||
} else if (!ifname && !match_fn)
|
||||
return NULL;
|
||||
else {
|
||||
const NMPObject *obj_best = NULL;
|
||||
|
||||
if (ifname) {
|
||||
if (strlen (ifname) >= IFNAMSIZ)
|
||||
return NULL;
|
||||
|
|
@ -1987,16 +1989,21 @@ nmp_cache_lookup_link_full (const NMPCache *cache,
|
|||
nmp_cache_iter_for_each_link (&iter, head_entry, &link) {
|
||||
obj = NMP_OBJECT_UP_CAST (link);
|
||||
|
||||
if (visible_only && !nmp_object_is_visible (obj))
|
||||
continue;
|
||||
if (link_type != NM_LINK_TYPE_NONE && obj->link.type != link_type)
|
||||
continue;
|
||||
if (visible_only && !nmp_object_is_visible (obj))
|
||||
continue;
|
||||
if (match_fn && !match_fn (obj, user_data))
|
||||
continue;
|
||||
|
||||
return obj;
|
||||
/* if there are multiple candidates, prefer the visible ones. */
|
||||
if ( visible_only
|
||||
|| nmp_object_is_visible (obj))
|
||||
return obj;
|
||||
if (!obj_best)
|
||||
obj_best = obj;
|
||||
}
|
||||
return NULL;
|
||||
return obj_best;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue