diff options
author | Thomas Haller <thaller@redhat.com> | 2020-09-16 13:24:07 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-09-24 09:43:54 +0200 |
commit | 62f2c5a879c70c5a9f28de9007c49aa5eeb24670 (patch) | |
tree | 55c810f39b6725f5eacebf57725d7e886871193e | |
parent | 1215b6cc30832dbb4f3b6ab4bd217f6dc88bc2ef (diff) | |
download | NetworkManager-62f2c5a879c70c5a9f28de9007c49aa5eeb24670.tar.gz |
platform: refactor nm_platform_ip6_address_get() function to accept pointer instead of "struct in6_addr"
While C is fine with accepting structs as function arguments,
we usually don't do that for IPv6 addresses. Accept a pointer
instead.
-rw-r--r-- | src/devices/nm-device.c | 2 | ||||
-rw-r--r-- | src/platform/nm-platform.c | 8 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 2 | ||||
-rw-r--r-- | src/platform/tests/test-address.c | 14 | ||||
-rw-r--r-- | src/platform/tests/test-common.c | 6 | ||||
-rw-r--r-- | src/platform/tests/test-route.c | 2 |
6 files changed, 18 insertions, 16 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index bb309e0372..254ef965ef 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -12107,7 +12107,7 @@ dad6_add_pending_address (NMDevice *self, pl_addr = nm_platform_ip6_address_get (platform, ifindex, - *address); + address); if ( pl_addr && NM_FLAGS_HAS (pl_addr->n_ifa_flags, IFA_F_TENTATIVE) && !NM_FLAGS_HAS (pl_addr->n_ifa_flags, IFA_F_DADFAILED) diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index d944a52d02..d3d5a4901b 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -3568,14 +3568,16 @@ nm_platform_ip4_address_get (NMPlatform *self, int ifindex, in_addr_t address, g } const NMPlatformIP6Address * -nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address) +nm_platform_ip6_address_get (NMPlatform *self, int ifindex, const struct in6_addr *address) { NMPObject obj_id; const NMPObject *obj; _CHECK_SELF (self, klass, NULL); - nmp_object_stackinit_id_ip6_address (&obj_id, ifindex, &address); + nm_assert (address); + + nmp_object_stackinit_id_ip6_address (&obj_id, ifindex, address); obj = nmp_cache_lookup_obj (nm_platform_get_cache (self), &obj_id); nm_assert (!obj || nmp_object_is_visible (obj)); return NMP_OBJECT_CAST_IP6_ADDRESS (obj); @@ -4186,7 +4188,7 @@ _err_inval_due_to_ipv6_tentative_pref_src (NMPlatform *self, const NMPObject *ob if (IN6_IS_ADDR_UNSPECIFIED (&r->pref_src)) return FALSE; - a = nm_platform_ip6_address_get (self, r->ifindex, r->pref_src); + a = nm_platform_ip6_address_get (self, r->ifindex, &r->pref_src); if (!a) return FALSE; if ( !NM_FLAGS_HAS (a->n_ifa_flags, IFA_F_TENTATIVE) diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index d0e9123619..2011617686 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -1863,7 +1863,7 @@ int nm_platform_link_wireguard_change (NMPlatform *self, guint peers_len, NMPlatformWireGuardChangeFlags change_flags); -const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address); +const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, const struct in6_addr *address); gboolean nm_platform_object_delete (NMPlatform *self, const NMPObject *route); diff --git a/src/platform/tests/test-address.c b/src/platform/tests/test-address.c index 26072400ef..b9421bf632 100644 --- a/src/platform/tests/test-address.c +++ b/src/platform/tests/test-address.c @@ -127,9 +127,9 @@ test_ip6_address_general (void) inet_pton (AF_INET6, IP6_ADDRESS, &addr); /* Add address */ - g_assert (!nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr)); + g_assert (!nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, &addr)); nmtstp_ip6_address_add (NULL, EX, ifindex, addr, IP6_PLEN, in6addr_any, lifetime, preferred, flags); - g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr)); + g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, &addr)); accept_signal (address_added); /* Add address again (aka update) */ @@ -148,7 +148,7 @@ test_ip6_address_general (void) /* Remove address */ nmtstp_ip6_address_del (NULL, EX, ifindex, addr, IP6_PLEN); - g_assert (!nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr)); + g_assert (!nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, &addr)); accept_signal (address_removed); /* Remove address again */ @@ -213,20 +213,20 @@ test_ip6_address_general_2 (void) /* Add/delete notification */ nmtstp_ip6_address_add (NULL, EX, ifindex, addr, IP6_PLEN, in6addr_any, lifetime, preferred, 0); accept_signal (address_added); - g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr)); + g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, &addr)); nmtstp_ip6_address_del (NULL, EX, ifindex, addr, IP6_PLEN); accept_signal (address_removed); - g_assert (!nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr)); + g_assert (!nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, &addr)); /* Add/delete conflict */ nmtstp_ip6_address_add (NULL, EX, ifindex, addr, IP6_PLEN, in6addr_any, lifetime, preferred, 0); accept_signal (address_added); - g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr)); + g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, &addr)); nmtstp_ip6_address_add (NULL, EX, ifindex, addr, IP6_PLEN, in6addr_any, lifetime, preferred, flags); ensure_no_signal (address_added); - g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr)); + g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, &addr)); free_signal (address_added); free_signal (address_removed); diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index 6452e9bd6e..91300408ca 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -915,7 +915,7 @@ _ip_address_add (NMPlatform *platform, g_assert (label == NULL); g_assert (flags == 0); - a = nm_platform_ip6_address_get (platform, ifindex, address->addr6); + a = nm_platform_ip6_address_get (platform, ifindex, &address->addr6); if ( a && !memcmp (nm_platform_ip6_address_get_peer (a), (IN6_IS_ADDR_UNSPECIFIED (&peer_address->addr6) || IN6_ARE_ADDR_EQUAL (&address->addr6, &peer_address->addr6)) @@ -1060,7 +1060,7 @@ _ip_address_del (NMPlatform *platform, if (is_v4) had_address = !!nm_platform_ip4_address_get (platform, ifindex, address->addr4, plen, peer_address->addr4); else - had_address = !!nm_platform_ip6_address_get (platform, ifindex, address->addr6); + had_address = !!nm_platform_ip6_address_get (platform, ifindex, &address->addr6); if (is_v4) { success = nmtstp_run_command ("ip address delete %s%s%s/%d dev %s", @@ -1112,7 +1112,7 @@ _ip_address_del (NMPlatform *platform, } else { const NMPlatformIP6Address *a; - a = nm_platform_ip6_address_get (platform, ifindex, address->addr6); + a = nm_platform_ip6_address_get (platform, ifindex, &address->addr6); if (!a) break; } diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c index 95556a64b2..b686cf5882 100644 --- a/src/platform/tests/test-route.c +++ b/src/platform/tests/test-route.c @@ -72,7 +72,7 @@ _wait_for_ipv6_addr_non_tentative (NMPlatform *platform, const NMPlatformIP6Address *plt_addr; for (i = 0; i < addr_n; i++) { - plt_addr = nm_platform_ip6_address_get (platform, ifindex, addrs[i]); + plt_addr = nm_platform_ip6_address_get (platform, ifindex, &addrs[i]); if ( !plt_addr || NM_FLAGS_HAS (plt_addr->n_ifa_flags, IFA_F_TENTATIVE)) { should_wait = TRUE; |