diff options
author | Dan Williams <dcbw@redhat.com> | 2014-09-18 12:53:19 -0500 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-04-29 11:07:11 +0200 |
commit | f70b9f675b5009db09b35e1d8cad0c26936dba3d (patch) | |
tree | cd3161a531e89d3e83dc095be45ec5ef486fbf40 | |
parent | 235dee9c4394a184ed37f8938db8ead2ba357fe2 (diff) | |
download | NetworkManager-f70b9f675b5009db09b35e1d8cad0c26936dba3d.tar.gz |
platform: return link objects from add functions
-rw-r--r-- | src/devices/nm-device-bond.c | 2 | ||||
-rw-r--r-- | src/devices/nm-device-bridge.c | 3 | ||||
-rw-r--r-- | src/devices/nm-device-infiniband.c | 2 | ||||
-rw-r--r-- | src/devices/nm-device-vlan.c | 3 | ||||
-rw-r--r-- | src/devices/team/nm-device-team.c | 2 | ||||
-rw-r--r-- | src/platform/nm-fake-platform.c | 31 | ||||
-rw-r--r-- | src/platform/nm-linux-platform.c | 46 | ||||
-rw-r--r-- | src/platform/nm-platform.c | 70 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 23 | ||||
-rw-r--r-- | src/platform/tests/platform.c | 10 | ||||
-rw-r--r-- | src/platform/tests/test-address.c | 2 | ||||
-rw-r--r-- | src/platform/tests/test-cleanup.c | 2 | ||||
-rw-r--r-- | src/platform/tests/test-link.c | 16 | ||||
-rw-r--r-- | src/platform/tests/test-route.c | 2 | ||||
-rw-r--r-- | src/tests/test-route-manager.c | 4 |
15 files changed, 149 insertions, 69 deletions
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 3356125b7c..951954ba6e 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -574,7 +574,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, g_assert (iface); - if ( !nm_platform_bond_add (NM_PLATFORM_GET, iface) + if ( !nm_platform_bond_add (NM_PLATFORM_GET, iface, NULL) && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "Failed to create bond interface '%s' for '%s': %s", diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index f5219b02dd..ffec9764dd 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -513,7 +513,8 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, if ( !nm_platform_bridge_add (NM_PLATFORM_GET, iface, mac_address_str ? mac_address : NULL, - mac_address_str ? ETH_ALEN : 0) + mac_address_str ? ETH_ALEN : 0, + NULL) && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "Failed to create bridge interface '%s' for '%s': %s", diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index c7b8787c45..f9cd946d44 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -327,7 +327,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, parent_ifindex = nm_device_get_ifindex (parent); p_key = nm_setting_infiniband_get_p_key (s_infiniband); - if ( !nm_platform_infiniband_partition_add (NM_PLATFORM_GET, parent_ifindex, p_key) + if ( !nm_platform_infiniband_partition_add (NM_PLATFORM_GET, parent_ifindex, p_key, NULL) && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "Failed to create InfiniBand P_Key interface '%s' for '%s': %s", diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index d3000b9364..19c20b8bbc 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -718,7 +718,8 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, iface, nm_device_get_ifindex (parent), nm_setting_vlan_get_id (s_vlan), - nm_setting_vlan_get_flags (s_vlan)) + nm_setting_vlan_get_flags (s_vlan), + NULL) && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "Failed to create VLAN interface '%s' for '%s': %s", diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 5cefde770c..1f80d543c4 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -692,7 +692,7 @@ nm_device_team_new_for_connection (NMConnection *connection, GError **error) g_assert (iface); - if ( !nm_platform_team_add (NM_PLATFORM_GET, iface) + if ( !nm_platform_team_add (NM_PLATFORM_GET, iface, NULL) && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "Failed to create team master interface '%s' for '%s': %s", diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c index c9785b0035..3fa13a6f38 100644 --- a/src/platform/nm-fake-platform.c +++ b/src/platform/nm-fake-platform.c @@ -166,7 +166,7 @@ _nm_platform_link_get (NMPlatform *platform, int ifindex, NMPlatformLink *l) { NMFakePlatformLink *device = link_get (platform, ifindex); - if (device) + if (device && l) *l = device->link; return !!device; } @@ -189,7 +189,12 @@ _link_announce (NMFakePlatformLinkData *data) } static gboolean -link_add (NMPlatform *platform, const char *name, NMLinkType type, const void *address, size_t address_len) +link_add (NMPlatform *platform, + const char *name, + NMLinkType type, + const void *address, + size_t address_len, + NMPlatformLink *out_link) { NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform); NMFakePlatformLink device; @@ -205,6 +210,8 @@ link_add (NMPlatform *platform, const char *name, NMLinkType type, const void *a g_idle_add ((GSourceFunc) _link_announce, data); } + if (out_link) + *out_link = device.link; return TRUE; } @@ -609,11 +616,11 @@ slave_get_option (NMPlatform *platform, int slave, const char *option) } static gboolean -vlan_add (NMPlatform *platform, const char *name, int parent, int vlan_id, guint32 vlan_flags) +vlan_add (NMPlatform *platform, const char *name, int parent, int vlan_id, guint32 vlan_flags, NMPlatformLink *out_link) { NMFakePlatformLink *device; - if (!link_add (platform, name, NM_LINK_TYPE_VLAN, NULL, 0)) + if (!link_add (platform, name, NM_LINK_TYPE_VLAN, NULL, 0, NULL)) return FALSE; device = link_get (platform, link_get_ifindex (platform, name)); @@ -623,6 +630,8 @@ vlan_add (NMPlatform *platform, const char *name, int parent, int vlan_id, guint device->vlan_id = vlan_id; device->link.parent = parent; + if (out_link) + *out_link = device->link; return TRUE; } @@ -654,7 +663,7 @@ vlan_set_egress_map (NMPlatform *platform, int ifindex, int from, int to) } static gboolean -infiniband_partition_add (NMPlatform *platform, int parent, int p_key) +infiniband_partition_add (NMPlatform *platform, int parent, int p_key, NMPlatformLink *out_link) { NMFakePlatformLink *parent_device; char *name; @@ -664,7 +673,7 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key) g_return_val_if_fail (parent_device != NULL, FALSE); name = g_strdup_printf ("%s.%04x", parent_device->link.name, p_key); - success = link_add (platform, name, NM_LINK_TYPE_INFINIBAND, NULL, 0); + success = link_add (platform, name, NM_LINK_TYPE_INFINIBAND, NULL, 0, out_link); g_free (name); return success; @@ -1338,15 +1347,15 @@ nm_fake_platform_setup (void) nm_platform_setup (platform); /* skip zero element */ - link_add (platform, NULL, NM_LINK_TYPE_NONE, NULL, 0); + link_add (platform, NULL, NM_LINK_TYPE_NONE, NULL, 0, NULL); /* add loopback interface */ - link_add (platform, "lo", NM_LINK_TYPE_LOOPBACK, NULL, 0); + link_add (platform, "lo", NM_LINK_TYPE_LOOPBACK, NULL, 0, NULL); /* add some ethernets */ - link_add (platform, "eth0", NM_LINK_TYPE_ETHERNET, NULL, 0); - link_add (platform, "eth1", NM_LINK_TYPE_ETHERNET, NULL, 0); - link_add (platform, "eth2", NM_LINK_TYPE_ETHERNET, NULL, 0); + link_add (platform, "eth0", NM_LINK_TYPE_ETHERNET, NULL, 0, NULL); + link_add (platform, "eth1", NM_LINK_TYPE_ETHERNET, NULL, 0, NULL); + link_add (platform, "eth2", NM_LINK_TYPE_ETHERNET, NULL, 0, NULL); } static void diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 65dd60f569..4e6e65f8e6 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -2315,7 +2315,9 @@ _nm_platform_link_get (NMPlatform *platform, int ifindex, NMPlatformLink *l) rtnllink = rtnl_link_get (priv->link_cache, ifindex); if (rtnllink) { if (link_is_announceable (platform, rtnllink)) { - if (init_link (platform, l, rtnllink)) + NMPlatformLink tmp = { 0 }; + + if (init_link (platform, l ? l : &tmp, rtnllink)) return TRUE; } } @@ -2337,7 +2339,25 @@ build_rtnl_link (int ifindex, const char *name, NMLinkType type) } static gboolean -link_add (NMPlatform *platform, const char *name, NMLinkType type, const void *address, size_t address_len) +link_get_by_name (NMPlatform *platform, const char *name, NMPlatformLink *out_link) +{ + int ifindex; + + if (out_link) { + ifindex = nm_platform_link_get_ifindex (platform, name); + g_return_val_if_fail (ifindex > 0, FALSE); + return _nm_platform_link_get (platform, ifindex, out_link); + } + return TRUE; +} + +static gboolean +link_add (NMPlatform *platform, + const char *name, + NMLinkType type, + const void *address, + size_t address_len, + NMPlatformLink *out_link) { struct nl_object *l; @@ -2364,7 +2384,11 @@ link_add (NMPlatform *platform, const char *name, NMLinkType type, const void *a rtnl_link_set_addr ((struct rtnl_link *) l, nladdr); } - return add_object (platform, l); + + if (!add_object (platform, l)) + return FALSE; + + return link_get_by_name (platform, name, out_link); } static struct rtnl_link * @@ -2846,7 +2870,12 @@ link_get_dev_id (NMPlatform *platform, int ifindex) } static int -vlan_add (NMPlatform *platform, const char *name, int parent, int vlan_id, guint32 vlan_flags) +vlan_add (NMPlatform *platform, + const char *name, + int parent, + int vlan_id, + guint32 vlan_flags, + NMPlatformLink *out_link) { struct nl_object *object = build_rtnl_link (0, name, NM_LINK_TYPE_VLAN); struct rtnl_link *rtnllink = (struct rtnl_link *) object; @@ -2867,7 +2896,10 @@ vlan_add (NMPlatform *platform, const char *name, int parent, int vlan_id, guint debug ("link: add vlan '%s', parent %d, vlan id %d, flags %X (native: %X)", name, parent, vlan_id, (unsigned int) vlan_flags, kernel_flags); - return add_object (platform, object); + if (!add_object (platform, object)) + return FALSE; + + return link_get_by_name (platform, name, out_link); } static gboolean @@ -3028,7 +3060,7 @@ slave_get_option (NMPlatform *platform, int slave, const char *option) } static gboolean -infiniband_partition_add (NMPlatform *platform, int parent, int p_key) +infiniband_partition_add (NMPlatform *platform, int parent, int p_key, NMPlatformLink *out_link) { const char *parent_name; char *path, *id; @@ -3048,6 +3080,8 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key) auto_nl_object struct rtnl_link *rtnllink = _nm_rtnl_link_alloc (0, ifname); success = refresh_object (platform, (struct nl_object *) rtnllink, FALSE, NM_PLATFORM_REASON_INTERNAL); + if (success) + success = link_get_by_name (platform, ifname, out_link); } return success; diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 1a7b9bc182..04300772d7 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -500,7 +500,6 @@ nm_platform_link_get (NMPlatform *self, int ifindex, NMPlatformLink *link) _CHECK_SELF (self, klass, FALSE); g_return_val_if_fail (ifindex > 0, FALSE); - g_return_val_if_fail (link, FALSE); g_return_val_if_fail (klass->link_get, FALSE); return !!klass->link_get (self, ifindex, link); @@ -513,14 +512,24 @@ nm_platform_link_get (NMPlatform *self, int ifindex, NMPlatformLink *link) * @type: Interface type * @address: (allow-none): set the mac address of the link * @address_len: the length of the @address + * @out_link: on success, the link object * - * Add a software interface. Sets self->error to NM_PLATFORM_ERROR_EXISTS - * if interface is already already exists. Any link-changed ADDED signal will be - * emitted directly, before this function finishes. + * Add a software interface. If the interface already exists and is of type + * @type, sets platform->error to NM_PLATFORM_ERROR_EXISTS and returns the link + * in @out_link. If the interface already exists and is not of type @type, + * sets platform->error to NM_PLATFORM_ERROR_WRONG_TYPE. Any link-changed ADDED + * signal will be emitted directly, before this function finishes. */ static gboolean -nm_platform_link_add (NMPlatform *self, const char *name, NMLinkType type, const void *address, size_t address_len) +nm_platform_link_add (NMPlatform *self, + const char *name, + NMLinkType type, + const void *address, + size_t address_len, + NMPlatformLink *out_link) { + int ifindex; + _CHECK_SELF (self, klass, FALSE); reset_error (self); @@ -528,29 +537,37 @@ nm_platform_link_add (NMPlatform *self, const char *name, NMLinkType type, const g_return_val_if_fail (klass->link_add, FALSE); g_return_val_if_fail ( (address != NULL) ^ (address_len == 0) , FALSE); - if (nm_platform_link_exists (self, name)) { + ifindex = nm_platform_link_get_ifindex (self, name); + if (ifindex > 0) { debug ("link: already exists"); - self->error = NM_PLATFORM_ERROR_EXISTS; + if (nm_platform_link_get_type (self, ifindex) != type) + self->error = NM_PLATFORM_ERROR_WRONG_TYPE; + else { + self->error = NM_PLATFORM_ERROR_EXISTS; + (void) nm_platform_link_get (self, ifindex, out_link); + } return FALSE; } - return klass->link_add (self, name, type, address, address_len); + reset_error(self); + return klass->link_add (self, name, type, address, address_len, out_link); } /** * nm_platform_dummy_add: * @self: platform instance * @name: New interface name + * @out_link: on success, the link object * * Create a software ethernet-like interface */ gboolean -nm_platform_dummy_add (NMPlatform *self, const char *name) +nm_platform_dummy_add (NMPlatform *self, const char *name, NMPlatformLink *out_link) { g_return_val_if_fail (name, FALSE); debug ("link: adding dummy '%s'", name); - return nm_platform_link_add (self, name, NM_LINK_TYPE_DUMMY, NULL, 0); + return nm_platform_link_add (self, name, NM_LINK_TYPE_DUMMY, NULL, 0, out_link); } /** @@ -1241,42 +1258,49 @@ nm_platform_link_get_master (NMPlatform *self, int slave) * @name: New interface name * @address: (allow-none): set the mac address of the new bridge * @address_len: the length of the @address + * @out_link: on success, the link object * * Create a software bridge. */ gboolean -nm_platform_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len) +nm_platform_bridge_add (NMPlatform *self, + const char *name, + const void *address, + size_t address_len, + NMPlatformLink *out_link) { debug ("link: adding bridge '%s'", name); - return nm_platform_link_add (self, name, NM_LINK_TYPE_BRIDGE, address, address_len); + return nm_platform_link_add (self, name, NM_LINK_TYPE_BRIDGE, address, address_len, out_link); } /** * nm_platform_bond_add: * @self: platform instance * @name: New interface name + * @out_link: on success, the link object * * Create a software bonding device. */ gboolean -nm_platform_bond_add (NMPlatform *self, const char *name) +nm_platform_bond_add (NMPlatform *self, const char *name, NMPlatformLink *out_link) { debug ("link: adding bond '%s'", name); - return nm_platform_link_add (self, name, NM_LINK_TYPE_BOND, NULL, 0); + return nm_platform_link_add (self, name, NM_LINK_TYPE_BOND, NULL, 0, out_link); } /** * nm_platform_team_add: * @self: platform instance * @name: New interface name + * @out_link: on success, the link object * * Create a software teaming device. */ gboolean -nm_platform_team_add (NMPlatform *self, const char *name) +nm_platform_team_add (NMPlatform *self, const char *name, NMPlatformLink *out_link) { debug ("link: adding team '%s'", name); - return nm_platform_link_add (self, name, NM_LINK_TYPE_TEAM, NULL, 0); + return nm_platform_link_add (self, name, NM_LINK_TYPE_TEAM, NULL, 0, out_link); } /** @@ -1285,11 +1309,17 @@ nm_platform_team_add (NMPlatform *self, const char *name) * @name: New interface name * @vlanid: VLAN identifier * @vlanflags: VLAN flags from libnm + * @out_link: on success, the link object * * Create a software VLAN device. */ gboolean -nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags) +nm_platform_vlan_add (NMPlatform *self, + const char *name, + int parent, + int vlanid, + guint32 vlanflags, + NMPlatformLink *out_link) { _CHECK_SELF (self, klass, FALSE); reset_error (self); @@ -1307,7 +1337,7 @@ nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid debug ("link: adding vlan '%s' parent %d vlanid %d vlanflags %x", name, parent, vlanid, vlanflags); - return klass->vlan_add (self, name, parent, vlanid, vlanflags); + return klass->vlan_add (self, name, parent, vlanid, vlanflags, out_link); } gboolean @@ -1408,7 +1438,7 @@ nm_platform_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to } gboolean -nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key) +nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, NMPlatformLink *out_link) { const char *parent_name; char *name; @@ -1435,7 +1465,7 @@ nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key) } g_free (name); - return klass->infiniband_partition_add (self, parent, p_key); + return klass->infiniband_partition_add (self, parent, p_key, out_link); } gboolean diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 5cd5ae8e0c..342950610d 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -363,7 +363,12 @@ typedef struct { gboolean (*link_get) (NMPlatform *platform, int ifindex, NMPlatformLink *link); GArray *(*link_get_all) (NMPlatform *); - gboolean (*link_add) (NMPlatform *, const char *name, NMLinkType type, const void *address, size_t address_len); + gboolean (*link_add) (NMPlatform *, + const char *name, + NMLinkType type, + const void *address, + size_t address_len, + NMPlatformLink *out_link); gboolean (*link_delete) (NMPlatform *, int ifindex); int (*link_get_ifindex) (NMPlatform *, const char *name); const char *(*link_get_name) (NMPlatform *, int ifindex); @@ -406,12 +411,12 @@ typedef struct { gboolean (*slave_set_option) (NMPlatform *, int ifindex, const char *option, const char *value); char * (*slave_get_option) (NMPlatform *, int ifindex, const char *option); - gboolean (*vlan_add) (NMPlatform *, const char *name, int parent, int vlanid, guint32 vlanflags); + gboolean (*vlan_add) (NMPlatform *, const char *name, int parent, int vlanid, guint32 vlanflags, NMPlatformLink *out_link); gboolean (*vlan_get_info) (NMPlatform *, int ifindex, int *parent, int *vlan_id); gboolean (*vlan_set_ingress_map) (NMPlatform *, int ifindex, int from, int to); gboolean (*vlan_set_egress_map) (NMPlatform *, int ifindex, int from, int to); - gboolean (*infiniband_partition_add) (NMPlatform *, int parent, int p_key); + gboolean (*infiniband_partition_add) (NMPlatform *, int parent, int p_key, NMPlatformLink *out_link); gboolean (*veth_get_properties) (NMPlatform *, int ifindex, NMPlatformVethProperties *properties); gboolean (*tun_get_properties) (NMPlatform *, int ifindex, NMPlatformTunProperties *properties); @@ -510,10 +515,10 @@ gint64 nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *path, g gboolean nm_platform_link_get (NMPlatform *self, int ifindex, NMPlatformLink *link); GArray *nm_platform_link_get_all (NMPlatform *self); -gboolean nm_platform_dummy_add (NMPlatform *self, const char *name); -gboolean nm_platform_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len); -gboolean nm_platform_bond_add (NMPlatform *self, const char *name); -gboolean nm_platform_team_add (NMPlatform *self, const char *name); +gboolean nm_platform_dummy_add (NMPlatform *self, const char *name, NMPlatformLink *out_link); +gboolean nm_platform_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len, NMPlatformLink *out_link); +gboolean nm_platform_bond_add (NMPlatform *self, const char *name, NMPlatformLink *out_link); +gboolean nm_platform_team_add (NMPlatform *self, const char *name, NMPlatformLink *out_link); gboolean nm_platform_link_exists (NMPlatform *self, const char *name); gboolean nm_platform_link_delete (NMPlatform *self, int ifindex); int nm_platform_link_get_ifindex (NMPlatform *self, const char *name); @@ -559,12 +564,12 @@ char *nm_platform_master_get_option (NMPlatform *self, int ifindex, const char * gboolean nm_platform_slave_set_option (NMPlatform *self, int ifindex, const char *option, const char *value); char *nm_platform_slave_get_option (NMPlatform *self, int ifindex, const char *option); -gboolean nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags); +gboolean nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags, NMPlatformLink *out_link); gboolean nm_platform_vlan_get_info (NMPlatform *self, int ifindex, int *parent, int *vlanid); gboolean nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to); gboolean nm_platform_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to); -gboolean nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key); +gboolean nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, NMPlatformLink *out_link); gboolean nm_platform_veth_get_properties (NMPlatform *self, int ifindex, NMPlatformVethProperties *properties); gboolean nm_platform_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *properties); diff --git a/src/platform/tests/platform.c b/src/platform/tests/platform.c index 07ca8f9108..d46d140abd 100644 --- a/src/platform/tests/platform.c +++ b/src/platform/tests/platform.c @@ -93,25 +93,25 @@ do_link_get_all (char **argv) static gboolean do_dummy_add (char **argv) { - return nm_platform_dummy_add (NM_PLATFORM_GET, argv[0]); + return nm_platform_dummy_add (NM_PLATFORM_GET, argv[0], NULL); } static gboolean do_bridge_add (char **argv) { - return nm_platform_bridge_add (NM_PLATFORM_GET, argv[0], NULL, 0); + return nm_platform_bridge_add (NM_PLATFORM_GET, argv[0], NULL, 0, NULL); } static gboolean do_bond_add (char **argv) { - return nm_platform_bond_add (NM_PLATFORM_GET, argv[0]); + return nm_platform_bond_add (NM_PLATFORM_GET, argv[0], NULL); } static gboolean do_team_add (char **argv) { - return nm_platform_team_add (NM_PLATFORM_GET, argv[0]); + return nm_platform_team_add (NM_PLATFORM_GET, argv[0], NULL); } static gboolean @@ -122,7 +122,7 @@ do_vlan_add (char **argv) int vlanid = strtol (*argv++, NULL, 10); guint32 vlan_flags = strtol (*argv++, NULL, 10); - return nm_platform_vlan_add (NM_PLATFORM_GET, name, parent, vlanid, vlan_flags); + return nm_platform_vlan_add (NM_PLATFORM_GET, name, parent, vlanid, vlan_flags, NULL); } static gboolean diff --git a/src/platform/tests/test-address.c b/src/platform/tests/test-address.c index 9463ae4e9f..f6deafebff 100644 --- a/src/platform/tests/test-address.c +++ b/src/platform/tests/test-address.c @@ -259,7 +259,7 @@ setup_tests (void) nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)); g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); - g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME)); + g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL)); wait_signal (link_added); free_signal (link_added); diff --git a/src/platform/tests/test-cleanup.c b/src/platform/tests/test-cleanup.c index 29892c9c83..a7f5f82e74 100644 --- a/src/platform/tests/test-cleanup.c +++ b/src/platform/tests/test-cleanup.c @@ -35,7 +35,7 @@ test_cleanup_internal (void) inet_pton (AF_INET6, "2001:db8:e:f:1:2:3:4", &gateway6); /* Create and set up device */ - g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME)); + g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL)); wait_signal (link_added); free_signal (link_added); g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME))); diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index 6dddfc0d59..50f179dbfc 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -90,13 +90,13 @@ software_add (NMLinkType link_type, const char *name) { switch (link_type) { case NM_LINK_TYPE_DUMMY: - return nm_platform_dummy_add (NM_PLATFORM_GET, name); + return nm_platform_dummy_add (NM_PLATFORM_GET, name, NULL); case NM_LINK_TYPE_BRIDGE: - return nm_platform_bridge_add (NM_PLATFORM_GET, name, NULL, 0); + return nm_platform_bridge_add (NM_PLATFORM_GET, name, NULL, 0, NULL); case NM_LINK_TYPE_BOND: { gboolean bond0_exists = nm_platform_link_exists (NM_PLATFORM_GET, "bond0"); - gboolean result = nm_platform_bond_add (NM_PLATFORM_GET, name); + gboolean result = nm_platform_bond_add (NM_PLATFORM_GET, name, NULL); NMPlatformError error = nm_platform_get_error (NM_PLATFORM_GET); /* Check that bond0 is *not* automatically created. */ @@ -107,14 +107,14 @@ software_add (NMLinkType link_type, const char *name) return result; } case NM_LINK_TYPE_TEAM: - return nm_platform_team_add (NM_PLATFORM_GET, name); + return nm_platform_team_add (NM_PLATFORM_GET, name, NULL); case NM_LINK_TYPE_VLAN: { SignalData *parent_added; SignalData *parent_changed; /* Don't call link_callback for the bridge interface */ parent_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, PARENT_NAME); - if (nm_platform_bridge_add (NM_PLATFORM_GET, PARENT_NAME, NULL, 0)) + if (nm_platform_bridge_add (NM_PLATFORM_GET, PARENT_NAME, NULL, 0, NULL)) wait_signal (parent_added); free_signal (parent_added); @@ -126,7 +126,7 @@ software_add (NMLinkType link_type, const char *name) accept_signal (parent_changed); free_signal (parent_changed); - return nm_platform_vlan_add (NM_PLATFORM_GET, name, parent_ifindex, VLAN_ID, 0); + return nm_platform_vlan_add (NM_PLATFORM_GET, name, parent_ifindex, VLAN_ID, 0, NULL); } } default: @@ -403,12 +403,12 @@ test_internal (void) error (NM_PLATFORM_ERROR_NOT_FOUND); /* Add device */ - g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME)); + g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL)); no_error (); wait_signal (link_added); /* Try to add again */ - g_assert (!nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME)); + g_assert (!nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL)); error (NM_PLATFORM_ERROR_EXISTS); /* Check device index, name and type */ diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c index 85a119ddd0..33e639ba04 100644 --- a/src/platform/tests/test-route.c +++ b/src/platform/tests/test-route.c @@ -324,7 +324,7 @@ setup_tests (void) nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)); g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); - g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME)); + g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL)); wait_signal (link_added); free_signal (link_added); diff --git a/src/tests/test-route-manager.c b/src/tests/test-route-manager.c index 4b12950fd7..1dd2e8cb9d 100644 --- a/src/tests/test-route-manager.c +++ b/src/tests/test-route-manager.c @@ -639,7 +639,7 @@ fixture_setup (test_fixture *fixture, gconstpointer user_data) "nm-test-device0"); nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device0")); g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, "nm-test-device0")); - g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, "nm-test-device0")); + g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, "nm-test-device0", NULL)); wait_signal (link_added); free_signal (link_added); fixture->ifindex0 = nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device0"); @@ -651,7 +651,7 @@ fixture_setup (test_fixture *fixture, gconstpointer user_data) "nm-test-device1"); nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device1")); g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, "nm-test-device1")); - g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, "nm-test-device1")); + g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, "nm-test-device1", NULL)); wait_signal (link_added); free_signal (link_added); fixture->ifindex1 = nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device1"); |