summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-02-11 13:58:00 +0100
committerThomas Haller <thaller@redhat.com>2014-02-23 22:31:42 +0100
commit66f5256b94dc26c782266e1ecc8288811398aa31 (patch)
tree1b53fbcccdae08680d4b0f1bcc7c1e40d20b9327
parenteac0573d5e67e4377e4efda57db655ef8e9cec58 (diff)
downloadNetworkManager-66f5256b94dc26c782266e1ecc8288811398aa31.tar.gz
core: add nm_platform_link_refresh() function to refresh the libnl cache for links
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/platform/nm-linux-platform.c16
-rw-r--r--src/platform/nm-platform.c19
-rw-r--r--src/platform/nm-platform.h4
3 files changed, 39 insertions, 0 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index b47ee7481b..96274353bc 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -1669,6 +1669,20 @@ link_get_flags (NMPlatform *platform, int ifindex)
}
static gboolean
+link_refresh (NMPlatform *platform, int ifindex)
+{
+ auto_nl_object struct rtnl_link *rtnllink = rtnl_link_alloc ();
+
+ if (rtnllink) {
+ rtnl_link_set_ifindex (rtnllink, ifindex);
+ return refresh_object (platform, (struct nl_object *) rtnllink, FALSE, NM_PLATFORM_REASON_EXTERNAL);
+ } else
+ error ("link_refresh failed with out of memory");
+
+ return FALSE;
+}
+
+static gboolean
link_is_up (NMPlatform *platform, int ifindex)
{
return !!(link_get_flags (platform, ifindex) & IFF_UP);
@@ -3026,6 +3040,8 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
platform_class->link_get_type = link_get_type;
platform_class->link_get_type_name = link_get_type_name;
+ platform_class->link_refresh = link_refresh;
+
platform_class->link_set_up = link_set_up;
platform_class->link_set_down = link_set_down;
platform_class->link_set_arp = link_set_arp;
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index fcd4b192c5..eb84b6d7fe 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -640,6 +640,25 @@ nm_platform_link_supports_slaves (int ifindex)
}
/**
+ * nm_platform_link_refresh:
+ * @ifindex: Interface index
+ *
+ * Reload the cache for ifindex synchronously.
+ */
+gboolean
+nm_platform_link_refresh (int ifindex)
+{
+ reset_error ();
+
+ g_return_val_if_fail (ifindex > 0, FALSE);
+
+ if (klass->link_refresh)
+ return klass->link_refresh (platform, ifindex);
+
+ return TRUE;
+}
+
+/**
* nm_platform_link_is_up:
* @ifindex: Interface index
*
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index 465a64ab7c..bdf82b39fd 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -271,6 +271,8 @@ typedef struct {
NMLinkType (*link_get_type) (NMPlatform *, int ifindex);
const char *(*link_get_type_name) (NMPlatform *, int ifindex);
+ gboolean (*link_refresh) (NMPlatform *, int ifindex);
+
gboolean (*link_set_up) (NMPlatform *, int ifindex);
gboolean (*link_set_down) (NMPlatform *, int ifindex);
gboolean (*link_set_arp) (NMPlatform *, int ifindex);
@@ -397,6 +399,8 @@ const char *nm_platform_link_get_type_name (int ifindex);
gboolean nm_platform_link_is_software (int ifindex);
gboolean nm_platform_link_supports_slaves (int ifindex);
+gboolean nm_platform_link_refresh (int ifindex);
+
gboolean nm_platform_link_set_up (int ifindex);
gboolean nm_platform_link_set_down (int ifindex);
gboolean nm_platform_link_set_arp (int ifindex);