summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-10-10 19:58:59 +0200
committerThomas Haller <thaller@redhat.com>2015-10-14 12:52:07 +0200
commitf193d98ced90b0fd1317e03a5e89b369002c4376 (patch)
tree1afdc79fd00cf73a854be20a64b0bfc3a3f0dba9
parentd1c528e64c198e5833c6bf3538404a388ec408b4 (diff)
downloadNetworkManager-f193d98ced90b0fd1317e03a5e89b369002c4376.tar.gz
platform: refactor order of peer-address argument in ip_address_add() function
The peer-address seems less important then the prefix-length. Also, nm_platform_ip4_address_delete() has the peer-address argument as last. Soon ip4_address_get() also receives a peer-address argument, so get the order right first.
-rw-r--r--src/devices/nm-device.c2
-rw-r--r--src/platform/nm-fake-platform.c33
-rw-r--r--src/platform/nm-linux-platform.c4
-rw-r--r--src/platform/nm-platform.c12
-rw-r--r--src/platform/nm-platform.h42
-rw-r--r--src/platform/tests/platform.c4
-rw-r--r--src/platform/tests/test-address.c12
-rw-r--r--src/platform/tests/test-cleanup.c4
-rw-r--r--src/tests/test-route-manager.c4
9 files changed, 74 insertions, 43 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index eaf9695fe7..f86e751684 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -4862,8 +4862,8 @@ check_and_add_ipv6ll_addr (NMDevice *self)
if (!nm_platform_ip6_address_add (NM_PLATFORM_GET,
ip_ifindex,
lladdr,
- in6addr_any,
64,
+ in6addr_any,
NM_PLATFORM_LIFETIME_PERMANENT,
NM_PLATFORM_LIFETIME_PERMANENT,
0)) {
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c
index 8259eac6b5..800425ace7 100644
--- a/src/platform/nm-fake-platform.c
+++ b/src/platform/nm-fake-platform.c
@@ -87,9 +87,14 @@ G_DEFINE_TYPE (NMFakePlatform, nm_fake_platform, NM_TYPE_PLATFORM)
static void link_changed (NMPlatform *platform, NMFakePlatformLink *device, gboolean raise_signal);
-static gboolean ip6_address_add (NMPlatform *platform, int ifindex,
- struct in6_addr addr, struct in6_addr peer_addr,
- int plen, guint32 lifetime, guint32 preferred, guint flags);
+static gboolean ip6_address_add (NMPlatform *platform,
+ int ifindex,
+ struct in6_addr addr,
+ int plen,
+ struct in6_addr peer_addr,
+ guint32 lifetime,
+ guint32 preferred,
+ guint flags);
static gboolean ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int plen);
/******************************************************************/
@@ -335,7 +340,7 @@ link_changed (NMPlatform *platform, NMFakePlatformLink *device, gboolean raise_s
if (device->link.ifindex && !IN6_IS_ADDR_UNSPECIFIED (&device->ip6_lladdr)) {
if (device->link.connected)
- ip6_address_add (platform, device->link.ifindex, device->ip6_lladdr, in6addr_any, 64, NM_PLATFORM_LIFETIME_PERMANENT, NM_PLATFORM_LIFETIME_PERMANENT, 0);
+ ip6_address_add (platform, device->link.ifindex, in6addr_any, 64, device->ip6_lladdr, NM_PLATFORM_LIFETIME_PERMANENT, NM_PLATFORM_LIFETIME_PERMANENT, 0);
else
ip6_address_delete (platform, device->link.ifindex, device->ip6_lladdr, 64);
}
@@ -886,9 +891,13 @@ ip6_address_get_all (NMPlatform *platform, int ifindex)
}
static gboolean
-ip4_address_add (NMPlatform *platform, int ifindex,
- in_addr_t addr, in_addr_t peer_addr,
- int plen, guint32 lifetime, guint32 preferred,
+ip4_address_add (NMPlatform *platform,
+ int ifindex,
+ in_addr_t addr,
+ int plen,
+ in_addr_t peer_addr,
+ guint32 lifetime,
+ guint32 preferred,
const char *label)
{
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
@@ -929,9 +938,13 @@ ip4_address_add (NMPlatform *platform, int ifindex,
}
static gboolean
-ip6_address_add (NMPlatform *platform, int ifindex,
- struct in6_addr addr, struct in6_addr peer_addr,
- int plen, guint32 lifetime, guint32 preferred, guint flags)
+ip6_address_add (NMPlatform *platform,
+ int ifindex,
+ struct in6_addr addr,
+ int plen,
+ struct in6_addr peer_addr,
+ guint32 lifetime,
+ guint32 preferred, guint flags)
{
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
NMPlatformIP6Address address;
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index bf0df38d8b..1f6b1e22fe 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -4238,8 +4238,8 @@ static gboolean
ip4_address_add (NMPlatform *platform,
int ifindex,
in_addr_t addr,
- in_addr_t peer_addr,
int plen,
+ in_addr_t peer_addr,
guint32 lifetime,
guint32 preferred,
const char *label)
@@ -4260,8 +4260,8 @@ static gboolean
ip6_address_add (NMPlatform *platform,
int ifindex,
struct in6_addr addr,
- struct in6_addr peer_addr,
int plen,
+ struct in6_addr peer_addr,
guint32 lifetime,
guint32 preferred,
guint flags)
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index 9007fb4384..32c103a123 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -1849,8 +1849,8 @@ gboolean
nm_platform_ip4_address_add (NMPlatform *self,
int ifindex,
in_addr_t address,
- in_addr_t peer_address,
int plen,
+ in_addr_t peer_address,
guint32 lifetime,
guint32 preferred,
const char *label)
@@ -1879,15 +1879,15 @@ nm_platform_ip4_address_add (NMPlatform *self,
_LOGD ("address: adding or updating IPv4 address: %s", nm_platform_ip4_address_to_string (&addr));
}
- return klass->ip4_address_add (self, ifindex, address, peer_address, plen, lifetime, preferred, label);
+ return klass->ip4_address_add (self, ifindex, address, plen, peer_address, lifetime, preferred, label);
}
gboolean
nm_platform_ip6_address_add (NMPlatform *self,
int ifindex,
struct in6_addr address,
- struct in6_addr peer_address,
int plen,
+ struct in6_addr peer_address,
guint32 lifetime,
guint32 preferred,
guint flags)
@@ -1914,7 +1914,7 @@ nm_platform_ip6_address_add (NMPlatform *self,
_LOGD ("address: adding or updating IPv6 address: %s", nm_platform_ip6_address_to_string (&addr));
}
- return klass->ip6_address_add (self, ifindex, address, peer_address, plen, lifetime, preferred, flags);
+ return klass->ip6_address_add (self, ifindex, address, plen, peer_address, lifetime, preferred, flags);
}
gboolean
@@ -2069,7 +2069,7 @@ nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known
now, ADDRESS_LIFETIME_PADDING, &lifetime, &preferred))
continue;
- if (!nm_platform_ip4_address_add (self, ifindex, known_address->address, known_address->peer_address, known_address->plen, lifetime, preferred, known_address->label))
+ if (!nm_platform_ip4_address_add (self, ifindex, known_address->address, known_address->plen, known_address->peer_address, lifetime, preferred, known_address->label))
return FALSE;
if (out_added_addresses) {
@@ -2130,7 +2130,7 @@ nm_platform_ip6_address_sync (NMPlatform *self, int ifindex, const GArray *known
continue;
if (!nm_platform_ip6_address_add (self, ifindex, known_address->address,
- known_address->peer_address, known_address->plen,
+ known_address->plen, known_address->peer_address,
lifetime, preferred, known_address->flags))
return FALSE;
}
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index 756101c8fc..d68be070d2 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -513,13 +513,22 @@ typedef struct {
GArray * (*ip4_address_get_all) (NMPlatform *, int ifindex);
GArray * (*ip6_address_get_all) (NMPlatform *, int ifindex);
- gboolean (*ip4_address_add) (NMPlatform *, int ifindex,
- in_addr_t address, in_addr_t peer_address, int plen,
- guint32 lifetime, guint32 preferred_lft,
+ gboolean (*ip4_address_add) (NMPlatform *,
+ int ifindex,
+ in_addr_t address,
+ int plen,
+ in_addr_t peer_address,
+ guint32 lifetime,
+ guint32 preferred_lft,
const char *label);
- gboolean (*ip6_address_add) (NMPlatform *, int ifindex,
- struct in6_addr address, struct in6_addr peer_address, int plen,
- guint32 lifetime, guint32 preferred_lft, guint flags);
+ gboolean (*ip6_address_add) (NMPlatform *,
+ int ifindex,
+ struct in6_addr address,
+ int plen,
+ struct in6_addr peer_address,
+ guint32 lifetime,
+ guint32 preferred_lft,
+ guint flags);
gboolean (*ip4_address_delete) (NMPlatform *, int ifindex, in_addr_t address, int plen, in_addr_t peer_address);
gboolean (*ip6_address_delete) (NMPlatform *, int ifindex, struct in6_addr address, int plen);
const NMPlatformIP4Address *(*ip4_address_get) (NMPlatform *, int ifindex, in_addr_t address, int plen);
@@ -700,13 +709,22 @@ const NMPlatformIP4Address *nm_platform_ip4_address_get (NMPlatform *self, int i
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);
GArray *nm_platform_ip6_address_get_all (NMPlatform *self, int ifindex);
-gboolean nm_platform_ip4_address_add (NMPlatform *self, int ifindex,
- in_addr_t address, in_addr_t peer_address, int plen,
- guint32 lifetime, guint32 preferred_lft,
+gboolean nm_platform_ip4_address_add (NMPlatform *self,
+ int ifindex,
+ in_addr_t address,
+ int plen,
+ in_addr_t peer_address,
+ guint32 lifetime,
+ guint32 preferred_lft,
const char *label);
-gboolean nm_platform_ip6_address_add (NMPlatform *self, int ifindex,
- struct in6_addr address, struct in6_addr peer_address, int plen,
- guint32 lifetime, guint32 preferred_lft, guint flags);
+gboolean nm_platform_ip6_address_add (NMPlatform *self,
+ int ifindex,
+ struct in6_addr address,
+ int plen,
+ struct in6_addr peer_address,
+ guint32 lifetime,
+ guint32 preferred_lft,
+ guint flags);
gboolean nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address, int plen, in_addr_t peer_address);
gboolean nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr address, int plen);
gboolean nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, GPtrArray **out_added_addresses);
diff --git a/src/platform/tests/platform.c b/src/platform/tests/platform.c
index 31f36351f1..ec671eaa28 100644
--- a/src/platform/tests/platform.c
+++ b/src/platform/tests/platform.c
@@ -583,7 +583,7 @@ do_ip4_address_add (char **argv)
guint32 lifetime = strtol (*argv++, NULL, 10);
guint32 preferred = strtol (*argv++, NULL, 10);
- gboolean value = nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, address, 0, plen, lifetime, preferred, NULL);
+ gboolean value = nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, address, plen, 0, lifetime, preferred, NULL);
return value;
} else
return FALSE;
@@ -601,7 +601,7 @@ do_ip6_address_add (char **argv)
guint32 preferred = strtol (*argv++, NULL, 10);
guint flags = (*argv) ? rtnl_addr_str2flags (*argv++) : 0;
- gboolean value = nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, address, in6addr_any, plen, lifetime, preferred, flags);
+ gboolean value = nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, address, plen, in6addr_any, lifetime, preferred, flags);
return value;
} else
return FALSE;
diff --git a/src/platform/tests/test-address.c b/src/platform/tests/test-address.c
index 639fa0c80e..14cd9efdf2 100644
--- a/src/platform/tests/test-address.c
+++ b/src/platform/tests/test-address.c
@@ -65,12 +65,12 @@ test_ip4_address (void)
/* Add address */
g_assert (!nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
- g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
+ g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0, lifetime, preferred, NULL));
g_assert (nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
accept_signal (address_added);
/* Add address again (aka update) */
- g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
+ g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0, lifetime, preferred, NULL));
accept_signals (address_changed, 0, 1);
/* Test address listing */
@@ -114,12 +114,12 @@ test_ip6_address (void)
/* Add address */
g_assert (!nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
- g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
+ g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN, in6addr_any, lifetime, preferred, flags));
g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
accept_signal (address_added);
/* Add address again (aka update) */
- g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
+ g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN, in6addr_any, lifetime, preferred, flags));
accept_signals (address_changed, 0, 1);
/* Test address listing */
@@ -175,7 +175,7 @@ test_ip4_address_external (void)
/* Add/delete conflict */
run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d",
IP4_ADDRESS, IP4_PLEN, DEVICE_NAME, lifetime, preferred);
- g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
+ g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0, lifetime, preferred, NULL));
g_assert (nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
accept_signal (address_added);
/*run_command ("ip address delete %s/%d dev %s", IP4_ADDRESS, IP4_PLEN, DEVICE_NAME);
@@ -212,7 +212,7 @@ test_ip6_address_external (void)
/* Add/delete conflict */
run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d",
IP6_ADDRESS, IP6_PLEN, DEVICE_NAME, lifetime, preferred);
- g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
+ g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN, in6addr_any, lifetime, preferred, flags));
g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
accept_signal (address_added);
/*run_command ("ip address delete %s/%d dev %s", IP6_ADDRESS, IP6_PLEN, DEVICE_NAME);
diff --git a/src/platform/tests/test-cleanup.c b/src/platform/tests/test-cleanup.c
index 0b825114aa..4ef6908588 100644
--- a/src/platform/tests/test-cleanup.c
+++ b/src/platform/tests/test-cleanup.c
@@ -43,8 +43,8 @@ test_cleanup_internal (void)
g_assert (ifindex > 0);
/* Add routes and addresses */
- g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr4, 0, plen4, lifetime, preferred, NULL));
- g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr6, in6addr_any, plen6, lifetime, preferred, flags));
+ g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr4, plen4, 0, lifetime, preferred, NULL));
+ g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr6, plen6, in6addr_any, lifetime, preferred, flags));
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway4, 32, INADDR_ANY, 0, metric, mss));
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network4, plen4, gateway4, 0, metric, mss));
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway4, 0, metric, mss));
diff --git a/src/tests/test-route-manager.c b/src/tests/test-route-manager.c
index 86d52dff89..d5902af4bc 100644
--- a/src/tests/test-route-manager.c
+++ b/src/tests/test-route-manager.c
@@ -377,8 +377,8 @@ setup_dev0_ip6 (int ifindex)
nm_platform_ip6_address_add (NM_PLATFORM_GET,
ifindex,
*nmtst_inet6_from_string ("2001:db8:8086::666"),
- in6addr_any,
64,
+ in6addr_any,
3600,
3600,
0);
@@ -481,8 +481,8 @@ update_dev0_ip6 (int ifindex)
nm_platform_ip6_address_add (NM_PLATFORM_GET,
ifindex,
*nmtst_inet6_from_string ("2001:db8:8086::2"),
- in6addr_any,
64,
+ in6addr_any,
3600,
3600,
0);