Revert "platform: avoid storing unknown netlink object types (bgo #742928)"
This reverts commit 6c1a6d2d5f
.
Mistaken push; it'll get committed, just needs a slight fixup.
This commit is contained in:
@@ -1725,15 +1725,9 @@ refresh_object (NMPlatform *platform, struct nl_object *object, gboolean removed
|
|||||||
announce_object (platform, cached_object, NM_PLATFORM_SIGNAL_REMOVED, reason);
|
announce_object (platform, cached_object, NM_PLATFORM_SIGNAL_REMOVED, reason);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ObjectType type;
|
|
||||||
|
|
||||||
if (!kernel_object)
|
if (!kernel_object)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Unsupported object types should never have reached the caches */
|
|
||||||
type = object_type_from_nl_object (kernel_object);
|
|
||||||
g_assert (type != OBJECT_TYPE_UNKNOWN);
|
|
||||||
|
|
||||||
hack_empty_master_iff_lower_up (platform, kernel_object);
|
hack_empty_master_iff_lower_up (platform, kernel_object);
|
||||||
|
|
||||||
if (cached_object)
|
if (cached_object)
|
||||||
@@ -1747,7 +1741,7 @@ refresh_object (NMPlatform *platform, struct nl_object *object, gboolean removed
|
|||||||
announce_object (platform, kernel_object, cached_object ? NM_PLATFORM_SIGNAL_CHANGED : NM_PLATFORM_SIGNAL_ADDED, reason);
|
announce_object (platform, kernel_object, cached_object ? NM_PLATFORM_SIGNAL_CHANGED : NM_PLATFORM_SIGNAL_ADDED, reason);
|
||||||
|
|
||||||
/* Refresh the master device (even on enslave/release) */
|
/* Refresh the master device (even on enslave/release) */
|
||||||
if (type == OBJECT_TYPE_LINK) {
|
if (object_type_from_nl_object (kernel_object) == OBJECT_TYPE_LINK) {
|
||||||
int kernel_master = rtnl_link_get_master ((struct rtnl_link *) kernel_object);
|
int kernel_master = rtnl_link_get_master ((struct rtnl_link *) kernel_object);
|
||||||
int cached_master = cached_object ? rtnl_link_get_master ((struct rtnl_link *) cached_object) : 0;
|
int cached_master = cached_object ? rtnl_link_get_master ((struct rtnl_link *) cached_object) : 0;
|
||||||
struct nl_object *master_object;
|
struct nl_object *master_object;
|
||||||
@@ -2009,11 +2003,6 @@ event_notification (struct nl_msg *msg, gpointer user_data)
|
|||||||
*/
|
*/
|
||||||
if (!kernel_object)
|
if (!kernel_object)
|
||||||
return NL_OK;
|
return NL_OK;
|
||||||
|
|
||||||
/* Ignore unsupported object types (e.g. AF_PHONET family addresses) */
|
|
||||||
if (type == OBJECT_TYPE_UNKNOWN)
|
|
||||||
return NL_OK;
|
|
||||||
|
|
||||||
/* Handle external addition */
|
/* Handle external addition */
|
||||||
if (!cached_object) {
|
if (!cached_object) {
|
||||||
nle = nl_cache_add (cache, kernel_object);
|
nle = nl_cache_add (cache, kernel_object);
|
||||||
@@ -4104,34 +4093,6 @@ cache_announce_changes (NMPlatform *platform, struct nl_cache *new, struct nl_ca
|
|||||||
nl_cache_free (old);
|
nl_cache_free (old);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The cache should always avoid containing objects not handled by NM, like
|
|
||||||
* e.g. addresses of the AF_PHONET family. */
|
|
||||||
static void
|
|
||||||
cache_remove_unknown (NMPlatform *platform, struct nl_cache *cache)
|
|
||||||
{
|
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
|
||||||
GPtrArray *objects_to_remove = NULL;
|
|
||||||
struct nl_object *object;
|
|
||||||
|
|
||||||
for (object = nl_cache_get_first (priv->address_cache); object; object = nl_cache_get_next (object)) {
|
|
||||||
if (object_type_from_nl_object (object) == OBJECT_TYPE_UNKNOWN) {
|
|
||||||
if (!objects_to_remove)
|
|
||||||
objects_to_remove = g_ptr_array_new_with_free_func ((GDestroyNotify) nl_object_put);
|
|
||||||
nl_object_get (object);
|
|
||||||
g_ptr_array_add (objects_to_remove, object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (objects_to_remove) {
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
for (i = 0; i < objects_to_remove->len; i++)
|
|
||||||
nl_cache_remove (g_ptr_array_index (objects_to_remove, i));
|
|
||||||
|
|
||||||
g_ptr_array_free (objects_to_remove, TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Creates and populates the netlink object caches. Called upon platform init and
|
/* Creates and populates the netlink object caches. Called upon platform init and
|
||||||
* when we run out of sync (out of buffer space, netlink congestion control). In case
|
* when we run out of sync (out of buffer space, netlink congestion control). In case
|
||||||
* the caches already exist, it finds changed, added and removed objects, announces
|
* the caches already exist, it finds changed, added and removed objects, announces
|
||||||
@@ -4153,11 +4114,6 @@ cache_repopulate_all (NMPlatform *platform)
|
|||||||
rtnl_route_alloc_cache (priv->nlh, AF_UNSPEC, 0, &priv->route_cache);
|
rtnl_route_alloc_cache (priv->nlh, AF_UNSPEC, 0, &priv->route_cache);
|
||||||
g_assert (priv->link_cache && priv->address_cache && priv->route_cache);
|
g_assert (priv->link_cache && priv->address_cache && priv->route_cache);
|
||||||
|
|
||||||
/* Remove all unknown objects from the caches */
|
|
||||||
cache_remove_unknown (platform, priv->link_cache);
|
|
||||||
cache_remove_unknown (platform, priv->address_cache);
|
|
||||||
cache_remove_unknown (platform, priv->route_cache);
|
|
||||||
|
|
||||||
for (object = nl_cache_get_first (priv->address_cache); object; object = nl_cache_get_next (object)) {
|
for (object = nl_cache_get_first (priv->address_cache); object; object = nl_cache_get_next (object)) {
|
||||||
_rtnl_addr_hack_lifetimes_rel_to_abs ((struct rtnl_addr *) object);
|
_rtnl_addr_hack_lifetimes_rel_to_abs ((struct rtnl_addr *) object);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user