summaryrefslogtreecommitdiff
path: root/src/platform/nm-fake-platform.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-12-31 02:38:06 +0100
committerThomas Haller <thaller@redhat.com>2020-01-09 10:42:31 +0100
commit4a743aba651a2234c502d7d468413494e343d6e2 (patch)
treeb760187f86b978705b3fe21147667905fe633346 /src/platform/nm-fake-platform.c
parent6e8653eb5b45f284db8d35776b3ae35d7523aca8 (diff)
downloadNetworkManager-4a743aba651a2234c502d7d468413494e343d6e2.tar.gz
platform: extend nm_platform_link_add() to accept type specific extra parameter
This will be used to unify all link-add implementation.
Diffstat (limited to 'src/platform/nm-fake-platform.c')
-rw-r--r--src/platform/nm-fake-platform.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c
index 9fa2791fec..6271ee997c 100644
--- a/src/platform/nm-fake-platform.c
+++ b/src/platform/nm-fake-platform.c
@@ -276,11 +276,11 @@ link_add_pre (NMPlatform *platform,
static int
link_add (NMPlatform *platform,
- const char *name,
NMLinkType type,
- const char *veth_peer,
+ const char *name,
const void *address,
size_t address_len,
+ gconstpointer extra_data,
const NMPlatformLink **out_link)
{
NMFakePlatformLink *device;
@@ -291,14 +291,20 @@ link_add (NMPlatform *platform,
nm_auto_nmpobj const NMPObject *obj_new_veth = NULL;
NMPCacheOpsType cache_op;
NMPCacheOpsType cache_op_veth = NMP_CACHE_OPS_UNCHANGED;
+ const char *veth_peer = NULL;
device = link_add_pre (platform, name, type, address, address_len);
- if (veth_peer) {
- g_assert (type == NM_LINK_TYPE_VETH);
+ switch (type) {
+ case NM_LINK_TYPE_VETH:
+ veth_peer = extra_data;
+ g_assert (veth_peer);
device_veth = link_add_pre (platform, veth_peer, type, NULL, 0);
- } else
- g_assert (type != NM_LINK_TYPE_VETH);
+ break;
+ default:
+ g_assert (!extra_data);
+ break;
+ }
link_add_prepare (platform, device, (NMPObject *) device->obj);
cache_op = nmp_cache_update_netlink (nm_platform_get_cache (platform),
@@ -1355,12 +1361,12 @@ nm_fake_platform_setup (void)
nm_platform_setup (platform);
/* add loopback interface */
- link_add (platform, "lo", NM_LINK_TYPE_LOOPBACK, NULL, NULL, 0, NULL);
+ link_add (platform, NM_LINK_TYPE_LOOPBACK, "lo", NULL, 0, NULL, NULL);
/* add some ethernets */
- link_add (platform, "eth0", NM_LINK_TYPE_ETHERNET, NULL, NULL, 0, NULL);
- link_add (platform, "eth1", NM_LINK_TYPE_ETHERNET, NULL, NULL, 0, NULL);
- link_add (platform, "eth2", NM_LINK_TYPE_ETHERNET, NULL, NULL, 0, NULL);
+ link_add (platform, NM_LINK_TYPE_ETHERNET, "eth0", NULL, 0, NULL, NULL);
+ link_add (platform, NM_LINK_TYPE_ETHERNET, "eth1", NULL, 0, NULL, NULL);
+ link_add (platform, NM_LINK_TYPE_ETHERNET, "eth2", NULL, 0, NULL, NULL);
}
static void