mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 07:38:20 +02:00
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.
This commit is contained in:
parent
d1c528e64c
commit
f193d98ced
9 changed files with 74 additions and 43 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue