summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-12-09 15:13:57 +0100
committerThomas Haller <thaller@redhat.com>2015-12-10 14:33:49 +0100
commita4de9187ff216a9281710261d122ad97c063322c (patch)
treeb81ce50cd7e5eb8b27525694e8d18a05eaa9df56 /src
parent2a14a28fe05ef4db30d03cd37dd03c143bf881fd (diff)
downloadNetworkManager-a4de9187ff216a9281710261d122ad97c063322c.tar.gz
platform: return pointer to NMPlatformLink object for add functions
Let the link-add functions return the internal pointer to the platform link object. Similar to link-get, which doesn't copy the link either. Also adjust the sole users of the add-functions (create-and-realize) to take the pointer. Eventually we still copy the returned data, because accessing platform can invalidate the returned pointer. Thus we don't actually safe any copying by this (at least every use of the function currently leads to the data being copied). Still change it, because I think the API of NMPlatform should look like that.
Diffstat (limited to 'src')
-rw-r--r--src/devices/nm-device-bond.c2
-rw-r--r--src/devices/nm-device-bridge.c3
-rw-r--r--src/devices/nm-device-infiniband.c4
-rw-r--r--src/devices/nm-device-ip-tunnel.c3
-rw-r--r--src/devices/nm-device-macvlan.c3
-rw-r--r--src/devices/nm-device-tun.c3
-rw-r--r--src/devices/nm-device-vlan.c4
-rw-r--r--src/devices/nm-device-vxlan.c3
-rw-r--r--src/devices/nm-device.c9
-rw-r--r--src/devices/nm-device.h6
-rw-r--r--src/devices/team/nm-device-team.c2
-rw-r--r--src/platform/nm-fake-platform.c20
-rw-r--r--src/platform/nm-linux-platform.c34
-rw-r--r--src/platform/nm-platform.c34
-rw-r--r--src/platform/nm-platform.h46
-rw-r--r--src/platform/tests/test-link.c6
16 files changed, 92 insertions, 90 deletions
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index 6471d3e4a2..72ded91f7d 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -448,7 +448,7 @@ static gboolean
create_and_realize (NMDevice *device,
NMConnection *connection,
NMDevice *parent,
- NMPlatformLink *out_plink,
+ const NMPlatformLink **out_plink,
GError **error)
{
const char *iface = nm_device_get_iface (device);
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index 39d41ae4d4..298a799024 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -377,7 +377,7 @@ static gboolean
create_and_realize (NMDevice *device,
NMConnection *connection,
NMDevice *parent,
- NMPlatformLink *out_plink,
+ const NMPlatformLink **out_plink,
GError **error)
{
NMSettingBridge *s_bridge;
@@ -387,7 +387,6 @@ create_and_realize (NMDevice *device,
NMPlatformError plerr;
g_assert (iface);
- g_assert (out_plink);
s_bridge = nm_connection_get_setting_bridge (connection);
g_assert (s_bridge);
diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c
index 50b7f1bb8f..792bdcd053 100644
--- a/src/devices/nm-device-infiniband.c
+++ b/src/devices/nm-device-infiniband.c
@@ -236,15 +236,13 @@ static gboolean
create_and_realize (NMDevice *device,
NMConnection *connection,
NMDevice *parent,
- NMPlatformLink *out_plink,
+ const NMPlatformLink **out_plink,
GError **error)
{
NMSettingInfiniband *s_infiniband;
int parent_ifindex, p_key;
NMPlatformError plerr;
- g_assert (out_plink);
-
if (!NM_IS_DEVICE_INFINIBAND (parent)) {
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
"Parent interface %s must be an InfiniBand interface",
diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c
index e0ccd6666e..bcb6dbf247 100644
--- a/src/devices/nm-device-ip-tunnel.c
+++ b/src/devices/nm-device-ip-tunnel.c
@@ -613,7 +613,7 @@ static gboolean
create_and_realize (NMDevice *device,
NMConnection *connection,
NMDevice *parent,
- NMPlatformLink *out_plink,
+ const NMPlatformLink **out_plink,
GError **error)
{
const char *iface = nm_device_get_iface (device);
@@ -628,7 +628,6 @@ create_and_realize (NMDevice *device,
s_ip_tunnel = nm_connection_get_setting_ip_tunnel (connection);
g_assert (s_ip_tunnel);
- g_assert (out_plink);
switch (nm_setting_ip_tunnel_get_mode (s_ip_tunnel)) {
case NM_IP_TUNNEL_MODE_GRE:
diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c
index c536fa136c..12cd95ba58 100644
--- a/src/devices/nm-device-macvlan.c
+++ b/src/devices/nm-device-macvlan.c
@@ -220,7 +220,7 @@ static gboolean
create_and_realize (NMDevice *device,
NMConnection *connection,
NMDevice *parent,
- NMPlatformLink *out_plink,
+ const NMPlatformLink **out_plink,
GError **error)
{
const char *iface = nm_device_get_iface (device);
@@ -231,7 +231,6 @@ create_and_realize (NMDevice *device,
s_macvlan = nm_connection_get_setting_macvlan (connection);
g_assert (s_macvlan);
- g_assert (out_plink);
parent_ifindex = nm_device_get_ifindex (parent);
g_warn_if_fail (parent_ifindex > 0);
diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c
index 045df73309..469d93cc1d 100644
--- a/src/devices/nm-device-tun.c
+++ b/src/devices/nm-device-tun.c
@@ -199,7 +199,7 @@ static gboolean
create_and_realize (NMDevice *device,
NMConnection *connection,
NMDevice *parent,
- NMPlatformLink *out_plink,
+ const NMPlatformLink **out_plink,
GError **error)
{
const char *iface = nm_device_get_iface (device);
@@ -209,7 +209,6 @@ create_and_realize (NMDevice *device,
s_tun = nm_connection_get_setting_tun (connection);
g_assert (s_tun);
- g_assert (out_plink);
user = _nm_utils_ascii_str_to_int64 (nm_setting_tun_get_owner (s_tun), 10, 0, G_MAXINT32, -1);
group = _nm_utils_ascii_str_to_int64 (nm_setting_tun_get_group (s_tun), 10, 0, G_MAXINT32, -1);
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index f276fa3869..4e5da03207 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -207,7 +207,7 @@ static gboolean
create_and_realize (NMDevice *device,
NMConnection *connection,
NMDevice *parent,
- NMPlatformLink *out_plink,
+ const NMPlatformLink **out_plink,
GError **error)
{
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
@@ -216,8 +216,6 @@ create_and_realize (NMDevice *device,
int parent_ifindex, vlan_id;
NMPlatformError plerr;
- g_assert (out_plink);
-
s_vlan = nm_connection_get_setting_vlan (connection);
g_assert (s_vlan);
diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c
index 3c96414008..514554c4c4 100644
--- a/src/devices/nm-device-vxlan.c
+++ b/src/devices/nm-device-vxlan.c
@@ -174,7 +174,7 @@ static gboolean
create_and_realize (NMDevice *device,
NMConnection *connection,
NMDevice *parent,
- NMPlatformLink *out_plink,
+ const NMPlatformLink **out_plink,
GError **error)
{
const char *iface = nm_device_get_iface (device);
@@ -186,7 +186,6 @@ create_and_realize (NMDevice *device,
s_vxlan = nm_connection_get_setting_vxlan (connection);
g_assert (s_vxlan);
- g_assert (out_plink);
if (parent)
props.parent_ifindex = nm_device_get_ifindex (parent);
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index ba2231768a..b993a063a5 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1761,7 +1761,8 @@ nm_device_create_and_realize (NMDevice *self,
GError **error)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
- NMPlatformLink plink = { .type = NM_LINK_TYPE_NONE };
+ NMPlatformLink plink_copy;
+ const NMPlatformLink *plink = NULL;
/* Must be set before device is realized */
priv->is_nm_owned = !nm_platform_link_get_by_ifname (NM_PLATFORM_GET, priv->iface);
@@ -1770,10 +1771,12 @@ nm_device_create_and_realize (NMDevice *self,
if (NM_DEVICE_GET_CLASS (self)->create_and_realize) {
if (!NM_DEVICE_GET_CLASS (self)->create_and_realize (self, connection, parent, &plink, error))
return FALSE;
+ plink_copy = *plink;
+ plink = &plink_copy;
}
- NM_DEVICE_GET_CLASS (self)->setup_start (self, (plink.type != NM_LINK_TYPE_NONE) ? &plink : NULL);
- nm_device_setup_finish (self, (plink.type != NM_LINK_TYPE_NONE) ? &plink : NULL);
+ NM_DEVICE_GET_CLASS (self)->setup_start (self, plink);
+ nm_device_setup_finish (self, plink);
g_return_val_if_fail (nm_device_check_connection_compatible (self, connection), TRUE);
return TRUE;
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 655f52d1f3..3ad900f385 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -170,7 +170,9 @@ typedef struct {
* @self: the #NMDevice
* @connection: the #NMConnection being activated
* @parent: the parent #NMDevice, if any
- * @out_plink: on success, a backing kernel network device if one exists
+ * @out_plink: on success, a backing kernel network device if one exists.
+ * The returned pointer is owned by platform and only valid until the
+ * next platform operation.
* @error: location to store error, or %NULL
*
* Create any backing resources (kernel devices, etc) required for this
@@ -183,7 +185,7 @@ typedef struct {
gboolean (*create_and_realize) (NMDevice *self,
NMConnection *connection,
NMDevice *parent,
- NMPlatformLink *out_plink,
+ const NMPlatformLink **out_plink,
GError **error);
/**
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
index c91e2c404b..74803225d8 100644
--- a/src/devices/team/nm-device-team.c
+++ b/src/devices/team/nm-device-team.c
@@ -673,7 +673,7 @@ static gboolean
create_and_realize (NMDevice *device,
NMConnection *connection,
NMDevice *parent,
- NMPlatformLink *out_plink,
+ const NMPlatformLink **out_plink,
GError **error)
{
const char *iface = nm_device_get_iface (device);
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c
index 09327a4d81..d6125aaaf3 100644
--- a/src/platform/nm-fake-platform.c
+++ b/src/platform/nm-fake-platform.c
@@ -292,10 +292,11 @@ link_add (NMPlatform *platform,
NMLinkType type,
const void *address,
size_t address_len,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
NMFakePlatformLink device;
+ NMFakePlatformLink *new_device;
link_init (&device, priv->links->len, type, name);
@@ -306,6 +307,7 @@ link_add (NMPlatform *platform,
}
g_array_append_val (priv->links, device);
+ new_device = &g_array_index (priv->links, NMFakePlatformLink, priv->links->len - 1);
if (device.link.ifindex) {
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, NMP_OBJECT_TYPE_LINK, device.link.ifindex, &device, NM_PLATFORM_SIGNAL_ADDED);
@@ -314,7 +316,7 @@ link_add (NMPlatform *platform,
}
if (out_link)
- *out_link = device.link;
+ *out_link = &new_device->link;
return TRUE;
}
@@ -672,11 +674,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, NMPlatformLink *out_link)
+vlan_add (NMPlatform *platform, const char *name, int parent, int vlan_id, guint32 vlan_flags, const NMPlatformLink **out_link)
{
NMFakePlatformLink *device;
- if (!link_add (platform, name, NM_LINK_TYPE_VLAN, NULL, 0, NULL))
+ if (!link_add (platform, name, NM_LINK_TYPE_VLAN, NULL, 0, out_link))
return FALSE;
device = link_get (platform, nm_platform_link_get_ifindex (platform, name));
@@ -689,7 +691,7 @@ vlan_add (NMPlatform *platform, const char *name, int parent, int vlan_id, guint
device->link.parent = parent;
if (out_link)
- *out_link = device->link;
+ *out_link = &device->link;
return TRUE;
}
@@ -712,11 +714,11 @@ static gboolean
link_vxlan_add (NMPlatform *platform,
const char *name,
NMPlatformLnkVxlan *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
NMFakePlatformLink *device;
- if (!link_add (platform, name, NM_LINK_TYPE_VXLAN, NULL, 0, NULL))
+ if (!link_add (platform, name, NM_LINK_TYPE_VXLAN, NULL, 0, out_link))
return FALSE;
device = link_get (platform, nm_platform_link_get_ifindex (platform, name));
@@ -729,12 +731,12 @@ link_vxlan_add (NMPlatform *platform,
device->link.parent = props->parent_ifindex;
if (out_link)
- *out_link = device->link;
+ *out_link = &device->link;
return TRUE;
}
static gboolean
-infiniband_partition_add (NMPlatform *platform, int parent, int p_key, NMPlatformLink *out_link)
+infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link)
{
NMFakePlatformLink *device, *parent_device;
gs_free char *name = NULL;
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 730f4b1c86..6d84d10450 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -3592,7 +3592,7 @@ do_add_link_with_lookup (NMPlatform *platform,
NMLinkType link_type,
const char *name,
struct nl_msg *nlmsg,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
const NMPObject *obj;
@@ -3600,8 +3600,8 @@ do_add_link_with_lookup (NMPlatform *platform,
obj = nmp_cache_lookup_link_full (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache,
0, name, FALSE, link_type, NULL, NULL);
- if (out_link && obj)
- *out_link = obj->link;
+ if (out_link)
+ *out_link = obj ? &obj->link : NULL;
return !!obj;
}
@@ -3801,7 +3801,7 @@ link_add (NMPlatform *platform,
NMLinkType type,
const void *address,
size_t address_len,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
@@ -4160,7 +4160,7 @@ vlan_add (NMPlatform *platform,
int parent,
int vlan_id,
guint32 vlan_flags,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
@@ -4204,7 +4204,7 @@ static int
link_gre_add (NMPlatform *platform,
const char *name,
NMPlatformLnkGre *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
struct nlattr *info;
@@ -4259,7 +4259,7 @@ static int
link_ip6tnl_add (NMPlatform *platform,
const char *name,
NMPlatformLnkIp6Tnl *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
struct nlattr *info;
@@ -4320,7 +4320,7 @@ static int
link_ipip_add (NMPlatform *platform,
const char *name,
NMPlatformLnkIpIp *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
struct nlattr *info;
@@ -4372,7 +4372,7 @@ link_macvlan_add (NMPlatform *platform,
const char *name,
int parent,
NMPlatformLnkMacvlan *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
struct nlattr *info;
@@ -4420,7 +4420,7 @@ static int
link_sit_add (NMPlatform *platform,
const char *name,
NMPlatformLnkSit *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
struct nlattr *info;
@@ -4471,7 +4471,7 @@ static gboolean
link_vxlan_add (NMPlatform *platform,
const char *name,
NMPlatformLnkVxlan *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
struct nlattr *info;
@@ -4714,7 +4714,7 @@ link_vlan_change (NMPlatform *platform,
static int
tun_add (NMPlatform *platform, const char *name, gboolean tap,
gint64 owner, gint64 group, gboolean pi, gboolean vnet_hdr,
- gboolean multi_queue, NMPlatformLink *out_link)
+ gboolean multi_queue, const NMPlatformLink **out_link)
{
const NMPObject *obj;
struct ifreq ifr = { };
@@ -4765,8 +4765,8 @@ tun_add (NMPlatform *platform, const char *name, gboolean tap,
0, name, FALSE,
tap ? NM_LINK_TYPE_TAP : NM_LINK_TYPE_TUN,
NULL, NULL);
- if (out_link && obj)
- *out_link = obj->link;
+ if (out_link)
+ *out_link = obj ? &obj->link : NULL;
return !!obj;
}
@@ -4887,7 +4887,7 @@ slave_get_option (NMPlatform *platform, int slave, const char *option)
/******************************************************************/
static gboolean
-infiniband_partition_add (NMPlatform *platform, int parent, int p_key, NMPlatformLink *out_link)
+infiniband_partition_add (NMPlatform *platform, int parent, int p_key, const NMPlatformLink **out_link)
{
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
const NMPObject *obj_parent;
@@ -4911,8 +4911,8 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key, NMPlatfor
obj = nmp_cache_lookup_link_full (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache,
0, ifname, FALSE, NM_LINK_TYPE_INFINIBAND, NULL, NULL);
- if (out_link && obj)
- *out_link = obj->link;
+ if (out_link)
+ *out_link = obj ? &obj->link : NULL;
return !!obj;
}
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index fe42465c77..cf58e9b252 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -571,7 +571,7 @@ nm_platform_link_get_by_address (NMPlatform *self,
}
static NMPlatformError
-_link_add_check_existing (NMPlatform *self, const char *name, NMLinkType type, NMPlatformLink *out_link)
+_link_add_check_existing (NMPlatform *self, const char *name, NMLinkType type, const NMPlatformLink **out_link)
{
const NMPlatformLink *pllink;
@@ -586,11 +586,13 @@ _link_add_check_existing (NMPlatform *self, const char *name, NMLinkType type, N
wrong_type ? ", expected " : "",
wrong_type ? nm_link_type_to_string (type) : "");
if (out_link)
- *out_link = *pllink;
+ *out_link = pllink;
if (wrong_type)
return NM_PLATFORM_ERROR_WRONG_TYPE;
return NM_PLATFORM_ERROR_EXISTS;
}
+ if (out_link)
+ *out_link = NULL;
return NM_PLATFORM_ERROR_SUCCESS;
}
@@ -619,7 +621,7 @@ nm_platform_link_add (NMPlatform *self,
NMLinkType type,
const void *address,
size_t address_len,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
NMPlatformError plerr;
@@ -648,7 +650,7 @@ nm_platform_link_add (NMPlatform *self,
* Create a software ethernet-like interface
*/
NMPlatformError
-nm_platform_dummy_add (NMPlatform *self, const char *name, NMPlatformLink *out_link)
+nm_platform_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link)
{
return nm_platform_link_add (self, name, NM_LINK_TYPE_DUMMY, NULL, 0, out_link);
}
@@ -1488,7 +1490,7 @@ nm_platform_bridge_add (NMPlatform *self,
const char *name,
const void *address,
size_t address_len,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
return nm_platform_link_add (self, name, NM_LINK_TYPE_BRIDGE, address, address_len, out_link);
}
@@ -1502,7 +1504,7 @@ nm_platform_bridge_add (NMPlatform *self,
* Create a software bonding device.
*/
NMPlatformError
-nm_platform_bond_add (NMPlatform *self, const char *name, NMPlatformLink *out_link)
+nm_platform_bond_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link)
{
return nm_platform_link_add (self, name, NM_LINK_TYPE_BOND, NULL, 0, out_link);
}
@@ -1516,7 +1518,7 @@ nm_platform_bond_add (NMPlatform *self, const char *name, NMPlatformLink *out_li
* Create a software teaming device.
*/
NMPlatformError
-nm_platform_team_add (NMPlatform *self, const char *name, NMPlatformLink *out_link)
+nm_platform_team_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link)
{
return nm_platform_link_add (self, name, NM_LINK_TYPE_TEAM, NULL, 0, out_link);
}
@@ -1537,7 +1539,7 @@ nm_platform_vlan_add (NMPlatform *self,
int parent,
int vlanid,
guint32 vlanflags,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
NMPlatformError plerr;
@@ -1572,7 +1574,7 @@ NMPlatformError
nm_platform_link_vxlan_add (NMPlatform *self,
const char *name,
NMPlatformLnkVxlan *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
NMPlatformError plerr;
@@ -1608,7 +1610,7 @@ nm_platform_link_vxlan_add (NMPlatform *self,
NMPlatformError
nm_platform_tun_add (NMPlatform *self, const char *name, gboolean tap,
gint64 owner, gint64 group, gboolean pi, gboolean vnet_hdr,
- gboolean multi_queue, NMPlatformLink *out_link)
+ gboolean multi_queue, const NMPlatformLink **out_link)
{
NMPlatformError plerr;
@@ -1779,7 +1781,7 @@ NMPlatformError
nm_platform_link_gre_add (NMPlatform *self,
const char *name,
NMPlatformLnkGre *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
NMPlatformError plerr;
char buffer[INET_ADDRSTRLEN];
@@ -1806,7 +1808,7 @@ nm_platform_link_gre_add (NMPlatform *self,
}
NMPlatformError
-nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, NMPlatformLink *out_link)
+nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, const NMPlatformLink **out_link)
{
gs_free char *parent_name = NULL;
gs_free char *name = NULL;
@@ -1915,7 +1917,7 @@ NMPlatformError
nm_platform_link_ip6tnl_add (NMPlatform *self,
const char *name,
NMPlatformLnkIp6Tnl *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
NMPlatformError plerr;
char buffer[INET6_ADDRSTRLEN];
@@ -1954,7 +1956,7 @@ NMPlatformError
nm_platform_link_ipip_add (NMPlatform *self,
const char *name,
NMPlatformLnkIpIp *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
NMPlatformError plerr;
char buffer[INET_ADDRSTRLEN];
@@ -1994,7 +1996,7 @@ nm_platform_link_macvlan_add (NMPlatform *self,
const char *name,
int parent,
NMPlatformLnkMacvlan *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
NMPlatformError plerr;
NMLinkType type;
@@ -2034,7 +2036,7 @@ NMPlatformError
nm_platform_link_sit_add (NMPlatform *self,
const char *name,
NMPlatformLnkSit *props,
- NMPlatformLink *out_link)
+ const NMPlatformLink **out_link)
{
NMPlatformError plerr;
char buffer[INET_ADDRSTRLEN];
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index cef962c29c..46d1312226 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -506,7 +506,7 @@ typedef struct {
NMLinkType type,
const void *address,
size_t address_len,
- NMPlatformLink *out_link);
+ const NMPlatformLink **out_link);
gboolean (*link_delete) (NMPlatform *, int ifindex);
const char *(*link_get_type_name) (NMPlatform *, int ifindex);
gboolean (*link_get_unmanaged) (NMPlatform *, int ifindex, gboolean *unmanaged);
@@ -550,7 +550,7 @@ 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, NMPlatformLink *out_link);
+ gboolean (*vlan_add) (NMPlatform *, const char *name, int parent, int vlanid, guint32 vlanflags, const NMPlatformLink **out_link);
gboolean (*link_vlan_change) (NMPlatform *self,
int ifindex,
NMVlanFlags flags_mask,
@@ -562,23 +562,23 @@ typedef struct {
const NMVlanQosMapping *egress_map,
gsize n_egress_map);
gboolean (*link_vxlan_add) (NMPlatform *, const char *name, NMPlatformLnkVxlan *props,
- NMPlatformLink *out_link);
+ const NMPlatformLink **out_link);
gboolean (*link_gre_add) (NMPlatform *, const char *name, NMPlatformLnkGre *props,
- NMPlatformLink *out_link);
+ const NMPlatformLink **out_link);
gboolean (*link_ip6tnl_add) (NMPlatform *, const char *name, NMPlatformLnkIp6Tnl *props,
- NMPlatformLink *out_link);
+ const NMPlatformLink **out_link);
gboolean (*link_ipip_add) (NMPlatform *, const char *name, NMPlatformLnkIpIp *props,
- NMPlatformLink *out_link);
+ const NMPlatformLink **out_link);
gboolean (*link_macvlan_add) (NMPlatform *, const char *name, int parent, NMPlatformLnkMacvlan *props,
- NMPlatformLink *out_link);
+ const NMPlatformLink **out_link);
gboolean (*link_sit_add) (NMPlatform *, const char *name, NMPlatformLnkSit *props,
- NMPlatformLink *out_link);
+ const NMPlatformLink **out_link);
- gboolean (*infiniband_partition_add) (NMPlatform *, int parent, int p_key, NMPlatformLink *out_link);
+ gboolean (*infiniband_partition_add) (NMPlatform *, int parent, int p_key, const NMPlatformLink **out_link);
gboolean (*tun_add) (NMPlatform *platform, const char *name, gboolean tap, gint64 owner, gint64 group, gboolean pi,
- gboolean vnet_hdr, gboolean multi_queue, NMPlatformLink *out_link);
+ gboolean vnet_hdr, gboolean multi_queue, const NMPlatformLink **out_link);
gboolean (*wifi_get_capabilities) (NMPlatform *, int ifindex, NMDeviceWifiCapabilities *caps);
gboolean (*wifi_get_bssid) (NMPlatform *, int ifindex, guint8 *bssid);
@@ -700,10 +700,10 @@ const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const ch
const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, gconstpointer address, size_t length);
GArray *nm_platform_link_get_all (NMPlatform *self);
-NMPlatformError nm_platform_dummy_add (NMPlatform *self, const char *name, NMPlatformLink *out_link);
-NMPlatformError nm_platform_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len, NMPlatformLink *out_link);
-NMPlatformError nm_platform_bond_add (NMPlatform *self, const char *name, NMPlatformLink *out_link);
-NMPlatformError nm_platform_team_add (NMPlatform *self, const char *name, NMPlatformLink *out_link);
+NMPlatformError nm_platform_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);
+NMPlatformError nm_platform_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len, const NMPlatformLink **out_link);
+NMPlatformError nm_platform_bond_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);
+NMPlatformError nm_platform_team_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);
gboolean nm_platform_link_delete (NMPlatform *self, int ifindex);
/* convienience methods to lookup the link and access fields of NMPlatformLink. */
@@ -773,7 +773,7 @@ const NMPlatformLnkSit *nm_platform_link_get_lnk_sit (NMPlatform *self, int ifin
const NMPlatformLnkVlan *nm_platform_link_get_lnk_vlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
const NMPlatformLnkVxlan *nm_platform_link_get_lnk_vxlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
-NMPlatformError nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags, NMPlatformLink *out_link);
+NMPlatformError nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags, const NMPlatformLink **out_link);
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_link_vlan_change (NMPlatform *self,
@@ -787,12 +787,12 @@ gboolean nm_platform_link_vlan_change (NMPlatform *self,
const NMVlanQosMapping *egress_map,
gsize n_egress_map);
-NMPlatformError nm_platform_link_vxlan_add (NMPlatform *self, const char *name, NMPlatformLnkVxlan *props, NMPlatformLink *out_link);
+NMPlatformError nm_platform_link_vxlan_add (NMPlatform *self, const char *name, NMPlatformLnkVxlan *props, const NMPlatformLink **out_link);
NMPlatformError nm_platform_tun_add (NMPlatform *self, const char *name, gboolean tap, gint64 owner, gint64 group, gboolean pi,
- gboolean vnet_hdr, gboolean multi_queue, NMPlatformLink *out_link);
+ gboolean vnet_hdr, gboolean multi_queue, const NMPlatformLink **out_link);
-NMPlatformError nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, NMPlatformLink *out_link);
+NMPlatformError nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, const NMPlatformLink **out_link);
gboolean nm_platform_infiniband_get_properties (NMPlatform *self, int ifindex, int *parent, int *p_key, const char **mode);
gboolean nm_platform_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex);
@@ -821,15 +821,15 @@ const struct in6_addr *nm_platform_ip6_address_get_peer (const NMPlatformIP6Addr
const NMPlatformIP4Address *nm_platform_ip4_address_get (NMPlatform *self, int ifindex, in_addr_t address, int plen, in_addr_t peer_address);
NMPlatformError nm_platform_link_gre_add (NMPlatform *self, const char *name, NMPlatformLnkGre *props,
- NMPlatformLink *out_link);
+ const NMPlatformLink **out_link);
NMPlatformError nm_platform_link_ip6tnl_add (NMPlatform *self, const char *name, NMPlatformLnkIp6Tnl *props,
- NMPlatformLink *out_link);
+ const NMPlatformLink **out_link);
NMPlatformError nm_platform_link_ipip_add (NMPlatform *self, const char *name, NMPlatformLnkIpIp *props,
- NMPlatformLink *out_link);
+ const NMPlatformLink **out_link);
NMPlatformError nm_platform_link_macvlan_add (NMPlatform *self, const char *name, int parent, NMPlatformLnkMacvlan *props,
- NMPlatformLink *out_link);
+ const NMPlatformLink **out_link);
NMPlatformError nm_platform_link_sit_add (NMPlatform *self, const char *name, NMPlatformLnkSit *props,
- NMPlatformLink *out_link);
+ const NMPlatformLink **out_link);
const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address, int plen);
GArray *nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex);
diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c
index 9da6bff7fa..8fb00f5bd6 100644
--- a/src/platform/tests/test-link.c
+++ b/src/platform/tests/test-link.c
@@ -462,11 +462,13 @@ test_bridge_addr (void)
{
char addr[ETH_ALEN];
NMPlatformLink link;
- const NMPlatformLink *plink;
+ const NMPlatformLink *plink = NULL;
nm_utils_hwaddr_aton ("de:ad:be:ef:00:11", addr, sizeof (addr));
- g_assert_cmpint (nm_platform_bridge_add (NM_PLATFORM_GET, DEVICE_NAME, addr, sizeof (addr), &link), ==, NM_PLATFORM_ERROR_SUCCESS);
+ g_assert_cmpint (nm_platform_bridge_add (NM_PLATFORM_GET, DEVICE_NAME, addr, sizeof (addr), &plink), ==, NM_PLATFORM_ERROR_SUCCESS);
+ g_assert (plink);
+ link = *plink;
g_assert_cmpstr (link.name, ==, DEVICE_NAME);
g_assert_cmpint (link.addr.len, ==, sizeof (addr));