platform: remove plen argument for IPv6 address ID

The prefix length is not part of the ID for IPv6 address. Remove
it from nmp_object_stackinit_id_ip6_address().
This commit is contained in:
Thomas Haller
2017-05-26 21:49:00 +02:00
parent 59e31ab6ea
commit d1b951a7e5
10 changed files with 24 additions and 29 deletions

View File

@@ -8399,8 +8399,7 @@ dad6_get_pending_addresses (NMDevice *self)
addr = nm_ip6_config_get_address (confs[i], j); addr = nm_ip6_config_get_address (confs[i], j);
pl_addr = nm_platform_ip6_address_get (nm_device_get_platform (self), pl_addr = nm_platform_ip6_address_get (nm_device_get_platform (self),
ifindex, ifindex,
addr->address, addr->address);
addr->plen);
if ( pl_addr if ( pl_addr
&& NM_FLAGS_HAS (pl_addr->n_ifa_flags, IFA_F_TENTATIVE) && NM_FLAGS_HAS (pl_addr->n_ifa_flags, IFA_F_TENTATIVE)
&& !NM_FLAGS_HAS (pl_addr->n_ifa_flags, IFA_F_DADFAILED) && !NM_FLAGS_HAS (pl_addr->n_ifa_flags, IFA_F_DADFAILED)

View File

@@ -1117,7 +1117,7 @@ ip4_address_get (NMPlatform *platform, int ifindex, in_addr_t addr, guint8 plen,
} }
static const NMPlatformIP6Address * static const NMPlatformIP6Address *
ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen) ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr)
{ {
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform); NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE ((NMFakePlatform *) platform);
int i; int i;
@@ -1126,7 +1126,6 @@ ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8
NMPlatformIP6Address *address = &g_array_index (priv->ip6_addresses, NMPlatformIP6Address, i); NMPlatformIP6Address *address = &g_array_index (priv->ip6_addresses, NMPlatformIP6Address, i);
if ( address->ifindex == ifindex if ( address->ifindex == ifindex
&& address->plen == plen
&& IN6_ARE_ADDR_EQUAL (&address->address, &addr)) && IN6_ARE_ADDR_EQUAL (&address->address, &addr))
return address; return address;
} }

View File

@@ -5906,7 +5906,7 @@ ip6_address_add (NMPlatform *platform,
preferred, preferred,
NULL); NULL);
nmp_object_stackinit_id_ip6_address (&obj_id, ifindex, &addr, plen); nmp_object_stackinit_id_ip6_address (&obj_id, ifindex, &addr);
return do_add_addrroute (platform, &obj_id, nlmsg); return do_add_addrroute (platform, &obj_id, nlmsg);
} }
@@ -5956,7 +5956,7 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, gui
if (!nlmsg) if (!nlmsg)
g_return_val_if_reached (FALSE); g_return_val_if_reached (FALSE);
nmp_object_stackinit_id_ip6_address (&obj_id, ifindex, &addr, plen); nmp_object_stackinit_id_ip6_address (&obj_id, ifindex, &addr);
return do_delete_object (platform, &obj_id, nlmsg); return do_delete_object (platform, &obj_id, nlmsg);
} }
@@ -5974,12 +5974,12 @@ ip4_address_get (NMPlatform *platform, int ifindex, in_addr_t addr, guint8 plen,
} }
static const NMPlatformIP6Address * static const NMPlatformIP6Address *
ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr, guint8 plen) ip6_address_get (NMPlatform *platform, int ifindex, struct in6_addr addr)
{ {
NMPObject obj_id; NMPObject obj_id;
const NMPObject *obj; const NMPObject *obj;
nmp_object_stackinit_id_ip6_address (&obj_id, ifindex, &addr, plen); nmp_object_stackinit_id_ip6_address (&obj_id, ifindex, &addr);
obj = nmp_cache_lookup_obj (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, &obj_id); obj = nmp_cache_lookup_obj (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, &obj_id);
if (nmp_object_is_visible (obj)) if (nmp_object_is_visible (obj))
return &obj->ip6_address; return &obj->ip6_address;

View File

@@ -2776,13 +2776,11 @@ nm_platform_ip4_address_get (NMPlatform *self, int ifindex, in_addr_t address, g
} }
const NMPlatformIP6Address * const NMPlatformIP6Address *
nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address, guint8 plen) nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address)
{ {
_CHECK_SELF (self, klass, NULL); _CHECK_SELF (self, klass, NULL);
g_return_val_if_fail (plen <= 128, NULL); return klass->ip6_address_get (self, ifindex, address);
return klass->ip6_address_get (self, ifindex, address, plen);
} }
static const NMPlatformIP4Address * static const NMPlatformIP4Address *

View File

@@ -663,7 +663,7 @@ typedef struct {
gboolean (*ip4_address_delete) (NMPlatform *, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address); gboolean (*ip4_address_delete) (NMPlatform *, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address);
gboolean (*ip6_address_delete) (NMPlatform *, int ifindex, struct in6_addr address, guint8 plen); gboolean (*ip6_address_delete) (NMPlatform *, int ifindex, struct in6_addr address, guint8 plen);
const NMPlatformIP4Address *(*ip4_address_get) (NMPlatform *, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address); const NMPlatformIP4Address *(*ip4_address_get) (NMPlatform *, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address);
const NMPlatformIP6Address *(*ip6_address_get) (NMPlatform *, int ifindex, struct in6_addr address, guint8 plen); const NMPlatformIP6Address *(*ip6_address_get) (NMPlatform *, int ifindex, struct in6_addr address);
GArray * (*ip4_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteFlags flags); GArray * (*ip4_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteFlags flags);
GArray * (*ip6_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteFlags flags); GArray * (*ip6_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteFlags flags);
@@ -938,7 +938,7 @@ NMPlatformError nm_platform_link_sit_add (NMPlatform *self,
const NMPlatformLnkSit *props, const NMPlatformLnkSit *props,
const NMPlatformLink **out_link); const NMPlatformLink **out_link);
const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address, guint8 plen); const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address);
GArray *nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex); GArray *nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex);
GArray *nm_platform_ip6_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, gboolean nm_platform_ip4_address_add (NMPlatform *self,

View File

@@ -357,20 +357,19 @@ _vt_cmd_obj_stackinit_id_ip4_address (NMPObject *obj, const NMPObject *src)
} }
const NMPObject * const NMPObject *
nmp_object_stackinit_id_ip6_address (NMPObject *obj, int ifindex, const struct in6_addr *address, guint8 plen) nmp_object_stackinit_id_ip6_address (NMPObject *obj, int ifindex, const struct in6_addr *address)
{ {
nmp_object_stackinit (obj, NMP_OBJECT_TYPE_IP6_ADDRESS, NULL); nmp_object_stackinit (obj, NMP_OBJECT_TYPE_IP6_ADDRESS, NULL);
obj->ip4_address.ifindex = ifindex; obj->ip4_address.ifindex = ifindex;
if (address) if (address)
obj->ip6_address.address = *address; obj->ip6_address.address = *address;
obj->ip6_address.plen = plen;
return obj; return obj;
} }
static void static void
_vt_cmd_obj_stackinit_id_ip6_address (NMPObject *obj, const NMPObject *src) _vt_cmd_obj_stackinit_id_ip6_address (NMPObject *obj, const NMPObject *src)
{ {
nmp_object_stackinit_id_ip6_address (obj, src->ip_address.ifindex, &src->ip6_address.address, src->ip_address.plen); nmp_object_stackinit_id_ip6_address (obj, src->ip_address.ifindex, &src->ip6_address.address);
} }
const NMPObject * const NMPObject *

View File

@@ -390,7 +390,7 @@ const NMPObject *nmp_object_stackinit (NMPObject *obj, NMPObjectType obj_type, c
const NMPObject *nmp_object_stackinit_id (NMPObject *obj, const NMPObject *src); const NMPObject *nmp_object_stackinit_id (NMPObject *obj, const NMPObject *src);
const NMPObject *nmp_object_stackinit_id_link (NMPObject *obj, int ifindex); const NMPObject *nmp_object_stackinit_id_link (NMPObject *obj, int ifindex);
const NMPObject *nmp_object_stackinit_id_ip4_address (NMPObject *obj, int ifindex, guint32 address, guint8 plen, guint32 peer_address); const NMPObject *nmp_object_stackinit_id_ip4_address (NMPObject *obj, int ifindex, guint32 address, guint8 plen, guint32 peer_address);
const NMPObject *nmp_object_stackinit_id_ip6_address (NMPObject *obj, int ifindex, const struct in6_addr *address, guint8 plen); const NMPObject *nmp_object_stackinit_id_ip6_address (NMPObject *obj, int ifindex, const struct in6_addr *address);
const NMPObject *nmp_object_stackinit_id_ip4_route (NMPObject *obj, int ifindex, guint32 network, guint8 plen, guint32 metric); const NMPObject *nmp_object_stackinit_id_ip4_route (NMPObject *obj, int ifindex, guint32 network, guint8 plen, guint32 metric);
const NMPObject *nmp_object_stackinit_id_ip6_route (NMPObject *obj, int ifindex, const struct in6_addr *network, guint8 plen, guint32 metric); const NMPObject *nmp_object_stackinit_id_ip6_route (NMPObject *obj, int ifindex, const struct in6_addr *network, guint8 plen, guint32 metric);

View File

@@ -143,9 +143,9 @@ test_ip6_address_general (void)
inet_pton (AF_INET6, IP6_ADDRESS, &addr); inet_pton (AF_INET6, IP6_ADDRESS, &addr);
/* Add address */ /* Add address */
g_assert (!nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); 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); 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, IP6_PLEN)); g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr));
accept_signal (address_added); accept_signal (address_added);
/* Add address again (aka update) */ /* Add address again (aka update) */
@@ -164,7 +164,7 @@ test_ip6_address_general (void)
/* Remove address */ /* Remove address */
nmtstp_ip6_address_del (NULL, EX, ifindex, addr, IP6_PLEN); nmtstp_ip6_address_del (NULL, EX, ifindex, addr, IP6_PLEN);
g_assert (!nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); g_assert (!nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr));
accept_signal (address_removed); accept_signal (address_removed);
/* Remove address again */ /* Remove address again */
@@ -229,20 +229,20 @@ test_ip6_address_general_2 (void)
/* Add/delete notification */ /* Add/delete notification */
nmtstp_ip6_address_add (NULL, EX, ifindex, addr, IP6_PLEN, in6addr_any, lifetime, preferred, 0); nmtstp_ip6_address_add (NULL, EX, ifindex, addr, IP6_PLEN, in6addr_any, lifetime, preferred, 0);
accept_signal (address_added); accept_signal (address_added);
g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr));
nmtstp_ip6_address_del (NULL, EX, ifindex, addr, IP6_PLEN); nmtstp_ip6_address_del (NULL, EX, ifindex, addr, IP6_PLEN);
accept_signal (address_removed); accept_signal (address_removed);
g_assert (!nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); g_assert (!nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr));
/* Add/delete conflict */ /* Add/delete conflict */
nmtstp_ip6_address_add (NULL, EX, ifindex, addr, IP6_PLEN, in6addr_any, lifetime, preferred, 0); nmtstp_ip6_address_add (NULL, EX, ifindex, addr, IP6_PLEN, in6addr_any, lifetime, preferred, 0);
accept_signal (address_added); accept_signal (address_added);
g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); 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); nmtstp_ip6_address_add (NULL, EX, ifindex, addr, IP6_PLEN, in6addr_any, lifetime, preferred, flags);
ensure_no_signal (address_added); ensure_no_signal (address_added);
g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); g_assert (nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, addr));
free_signal (address_added); free_signal (address_added);
free_signal (address_removed); free_signal (address_removed);

View File

@@ -717,7 +717,7 @@ _ip_address_add (NMPlatform *platform,
g_assert (label == NULL); g_assert (label == NULL);
g_assert (flags == 0); g_assert (flags == 0);
a = nm_platform_ip6_address_get (platform, ifindex, address->addr6, plen); a = nm_platform_ip6_address_get (platform, ifindex, address->addr6);
if ( a if ( a
&& !memcmp (nm_platform_ip6_address_get_peer (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)) (IN6_IS_ADDR_UNSPECIFIED (&peer_address->addr6) || IN6_ARE_ADDR_EQUAL (&address->addr6, &peer_address->addr6))
@@ -861,7 +861,7 @@ _ip_address_del (NMPlatform *platform,
if (is_v4) if (is_v4)
had_address = !!nm_platform_ip4_address_get (platform, ifindex, address->addr4, plen, peer_address->addr4); had_address = !!nm_platform_ip4_address_get (platform, ifindex, address->addr4, plen, peer_address->addr4);
else else
had_address = !!nm_platform_ip6_address_get (platform, ifindex, address->addr6, plen); had_address = !!nm_platform_ip6_address_get (platform, ifindex, address->addr6);
if (is_v4) { if (is_v4) {
success = nmtstp_run_command ("ip address delete %s%s%s/%d dev %s", success = nmtstp_run_command ("ip address delete %s%s%s/%d dev %s",
@@ -913,7 +913,7 @@ _ip_address_del (NMPlatform *platform,
} else { } else {
const NMPlatformIP6Address *a; const NMPlatformIP6Address *a;
a = nm_platform_ip6_address_get (platform, ifindex, address->addr6, plen); a = nm_platform_ip6_address_get (platform, ifindex, address->addr6);
if (!a) if (!a)
break; break;
} }

View File

@@ -268,7 +268,7 @@ test_ip6_route (void)
nmtstp_wait_for_signal (NM_PLATFORM_GET, 50); nmtstp_wait_for_signal (NM_PLATFORM_GET, 50);
nm_platform_process_events (NM_PLATFORM_GET); nm_platform_process_events (NM_PLATFORM_GET);
plt_addr = nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, pref_src, 128); plt_addr = nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, pref_src);
if (plt_addr && !NM_FLAGS_HAS (plt_addr->n_ifa_flags, IFA_F_TENTATIVE)) if (plt_addr && !NM_FLAGS_HAS (plt_addr->n_ifa_flags, IFA_F_TENTATIVE))
break; break;
}); });