diff options
| author | Michael Biebl <biebl@debian.org> | 2016-04-25 15:06:28 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2016-04-25 15:06:28 +0200 |
| commit | ba829a4f45f619431fa823c39c19046957958dce (patch) | |
| tree | 450b967a7a247b05b794574fd9859fd987b014b2 /src/platform/nm-linux-platform.c | |
| parent | 7cba9af6f00e73f211ec9b6c88474044b421ba14 (diff) | |
| parent | 78c3b8801ecf4975e5da1af3b10ae20dd2d876de (diff) | |
Merge tag 'upstream/1.2.0'
Upstream version 1.2.0
Diffstat (limited to 'src/platform/nm-linux-platform.c')
| -rw-r--r-- | src/platform/nm-linux-platform.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index ded019e6..254f9c85 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1562,6 +1562,7 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr _lookup_cached_link (cache, obj->link.ifindex, completed_from_cache, &link_cached); if ( link_cached && link_cached->link.type == obj->link.type + && link_cached->_link.netlink.lnk && ( !lnk_data || nmp_object_equal (lnk_data, link_cached->_link.netlink.lnk))) { nmp_object_unref (lnk_data); @@ -5077,24 +5078,35 @@ link_release (NMPlatform *platform, int master, int slave) /******************************************************************/ static gboolean -infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link) +_infiniband_partition_action (NMPlatform *platform, int parent, int p_key, const char *action, char **ifname) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); const NMPObject *obj_parent; - const NMPObject *obj; gs_free char *path = NULL; gs_free char *id = NULL; - gs_free char *ifname = NULL; obj_parent = nmp_cache_lookup_link (priv->cache, parent); if (!obj_parent || !obj_parent->link.name[0]) g_return_val_if_reached (FALSE); - ifname = g_strdup_printf ("%s.%04x", obj_parent->link.name, p_key); + *ifname = g_strdup_printf ("%s.%04x", obj_parent->link.name, p_key); - path = g_strdup_printf ("/sys/class/net/%s/create_child", NM_ASSERT_VALID_PATH_COMPONENT (obj_parent->link.name)); + path = g_strdup_printf ("/sys/class/net/%s/%s", + NM_ASSERT_VALID_PATH_COMPONENT (obj_parent->link.name), + action); id = g_strdup_printf ("0x%04x", p_key); - if (!nm_platform_sysctl_set (platform, path, id)) + + return nm_platform_sysctl_set (platform, path, id); +} + + +static gboolean +infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link) +{ + const NMPObject *obj; + gs_free char *ifname = NULL; + + if (!_infiniband_partition_action (platform, parent, p_key, "create_child", &ifname)) return FALSE; do_request_link (platform, 0, ifname); @@ -5106,6 +5118,19 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMP return !!obj; } +static gboolean +infiniband_partition_delete (NMPlatform *platform, int parent, int p_key) +{ + gs_free char *ifname = NULL; + + if (!_infiniband_partition_action (platform, parent, p_key, "delete_child", &ifname)) { + if (errno != ENODEV) + return FALSE; + } + + return TRUE; +} + /******************************************************************/ static WifiData * @@ -6380,6 +6405,7 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass) platform_class->tun_add = tun_add; platform_class->infiniband_partition_add = infiniband_partition_add; + platform_class->infiniband_partition_delete = infiniband_partition_delete; platform_class->wifi_get_capabilities = wifi_get_capabilities; platform_class->wifi_get_bssid = wifi_get_bssid; |