diff options
author | Dan Williams <dcbw@redhat.com> | 2014-09-18 12:53:19 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2015-05-06 16:14:25 -0500 |
commit | 2abda4bfa59bfd6de8da69741f2c5f3304e46617 (patch) | |
tree | fd7cf0a2e49444835e74c1d8aff1518bff04b082 | |
parent | 179d56c73c35e83368589b40a8a2d429b41a4dbf (diff) | |
download | NetworkManager-2abda4bfa59bfd6de8da69741f2c5f3304e46617.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 | 45 | ||||
-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, 148 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 ba79a6ccb1..7d374348e7 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -715,7 +715,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 0da6590ffb..2969e37b6b 100644 --- a/src/platform/nm-fake-platform.c +++ b/src/platform/nm-fake-platform.c @@ -162,13 +162,18 @@ _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; } 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; @@ -180,6 +185,8 @@ link_add (NMPlatform *platform, const char *name, NMLinkType type, const void *a if (device.link.ifindex) g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, device.link.ifindex, &device, NM_PLATFORM_SIGNAL_ADDED, NM_PLATFORM_REASON_INTERNAL); + if (out_link) + *out_link = device.link; return TRUE; } @@ -584,11 +591,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)); @@ -598,6 +605,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; } @@ -629,7 +638,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; @@ -639,7 +648,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; @@ -1313,15 +1322,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 532fa4de4e..68688280d9 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -2304,9 +2304,10 @@ _nm_platform_link_get (NMPlatform *platform, int ifindex, NMPlatformLink *l) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); auto_nl_object struct rtnl_link *rtnllink = NULL; + NMPlatformLink tmp = { 0 }; rtnllink = rtnl_link_get (priv->link_cache, ifindex); - return (rtnllink && init_link (platform, l, rtnllink)); + return (rtnllink && init_link (platform, l ? l : &tmp, rtnllink)); } static struct nl_object * @@ -2324,7 +2325,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; @@ -2351,7 +2370,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 * @@ -2842,7 +2865,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; @@ -2863,7 +2891,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 @@ -3024,7 +3055,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; @@ -3044,6 +3075,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 844ad32cda..0b51614e2f 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -536,7 +536,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); @@ -549,14 +548,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); @@ -564,29 +573,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); } /** @@ -1277,42 +1294,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); } /** @@ -1321,11 +1345,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); @@ -1343,7 +1373,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 @@ -1444,7 +1474,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; @@ -1471,7 +1501,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 1de8747a59..ea8d82994f 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -375,7 +375,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); @@ -418,12 +423,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); @@ -526,10 +531,10 @@ gboolean nm_platform_sysctl_set_ip6_hop_limit_safe (NMPlatform *self, const char 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); @@ -575,12 +580,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 0547261551..e7b0a47388 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)); accept_signal (link_added); free_signal (link_added); diff --git a/src/platform/tests/test-cleanup.c b/src/platform/tests/test-cleanup.c index 473489da81..962730463f 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)); accept_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 d82d0165e6..bbd42946af 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)) accept_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 (); accept_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 c22ce51571..dcc74d9621 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)); accept_signal (link_added); free_signal (link_added); diff --git a/src/tests/test-route-manager.c b/src/tests/test-route-manager.c index 17bcb454c1..f7b37a3b4a 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)); accept_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)); accept_signal (link_added); free_signal (link_added); fixture->ifindex1 = nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device1"); |