From d41c35fbf8b772365fcaa60cbf5e56972be6d531 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 14 Jan 2010 14:15:18 -0800 Subject: [PATCH] netlink: work around kernel cache refill problems Sometimes cause the cache not to refill with all interfaces, meaning NM sometimes got the wrong carrier state from the kernel which prevented NM from taking over existing connections. --- src/nm-netlink-monitor.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/nm-netlink-monitor.c b/src/nm-netlink-monitor.c index e0bf397652..2c3987c3d5 100644 --- a/src/nm-netlink-monitor.c +++ b/src/nm-netlink-monitor.c @@ -560,6 +560,19 @@ nm_netlink_monitor_get_flags_sync (NMNetlinkMonitor *self, return FALSE; } + /* HACK: Apparently to get it working we have to refill the cache twice; + * otherwise some kernels (or maybe libnl?) only send a few of the + * interfaces in the refill request. + */ + if (nl_cache_refill (priv->nlh, priv->nlh_link_cache)) { + g_set_error (error, + NM_NETLINK_MONITOR_ERROR, + NM_NETLINK_MONITOR_ERROR_LINK_CACHE_UPDATE, + _("error updating link cache: %s"), + nl_geterror ()); + return FALSE; + } + /* Set up the filter */ filter = rtnl_link_alloc (); if (!filter) {