platform: let _lookup_cached_link() also return cached links that are not in netlink

The _lookup_cached_link() function, should not skip over links which are
currently in the cache, but not in netlink. Instead, let the callers
skip them, as they see fit.

No change in behavior, because the few callers now explicitly check
for this.
This commit is contained in:
Thomas Haller
2018-09-04 14:48:59 +02:00
parent 7042cd5e19
commit f99ee135d1

View File

@@ -812,19 +812,21 @@ _addrtime_get_lifetimes (guint32 timestamp,
/*****************************************************************************/ /*****************************************************************************/
static const NMPObject * static const NMPObject *
_lookup_cached_link (const NMPCache *cache, int ifindex, gboolean *completed_from_cache, const NMPObject **link_cached) _lookup_cached_link (const NMPCache *cache,
int ifindex,
gboolean *completed_from_cache,
const NMPObject **link_cached)
{ {
const NMPObject *obj; const NMPObject *obj;
nm_assert (completed_from_cache && link_cached); nm_assert (completed_from_cache && link_cached);
if (!*completed_from_cache) { if (!*completed_from_cache) {
obj = ifindex > 0 && cache ? nmp_cache_lookup_link (cache, ifindex) : NULL; obj = ifindex > 0 && cache
? nmp_cache_lookup_link (cache, ifindex)
: NULL;
if (obj && obj->_link.netlink.is_in_netlink) *link_cached = obj;
*link_cached = obj;
else
*link_cached = NULL;
*completed_from_cache = TRUE; *completed_from_cache = TRUE;
} }
return *link_cached; return *link_cached;
@@ -895,6 +897,7 @@ _linktype_get_type (NMPlatform *platform,
* when moving interfce to other netns). Thus here there is a tiny potential * when moving interfce to other netns). Thus here there is a tiny potential
* of messing stuff up. */ * of messing stuff up. */
if ( obj if ( obj
&& obj->_link.netlink.is_in_netlink
&& !NM_IN_SET (obj->link.type, NM_LINK_TYPE_UNKNOWN, NM_LINK_TYPE_NONE) && !NM_IN_SET (obj->link.type, NM_LINK_TYPE_UNKNOWN, NM_LINK_TYPE_NONE)
&& nm_streq (ifname, obj->link.name) && nm_streq (ifname, obj->link.name)
&& ( !kind && ( !kind
@@ -2240,7 +2243,8 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr
|| !af_inet6_addr_gen_mode_valid || !af_inet6_addr_gen_mode_valid
|| !tb[IFLA_STATS64])) { || !tb[IFLA_STATS64])) {
_lookup_cached_link (cache, obj->link.ifindex, completed_from_cache, &link_cached); _lookup_cached_link (cache, obj->link.ifindex, completed_from_cache, &link_cached);
if (link_cached) { if ( link_cached
&& link_cached->_link.netlink.is_in_netlink) {
if ( lnk_data_complete_from_cache if ( lnk_data_complete_from_cache
&& link_cached->link.type == obj->link.type && link_cached->link.type == obj->link.type
&& link_cached->_link.netlink.lnk && link_cached->_link.netlink.lnk