l3cfg/ipv4ll: add new nm_platform_ip4_address_is_link_local() helper
Move the static _ip4_address_is_link_local() check to a new global nm_platform_ip4_address_is_link_local() helper so we can check if an IPv4 is link local in other files
This commit is contained in:

committed by
Beniamino Galvani

parent
b39e38f272
commit
beaf4f8db3
@@ -10,8 +10,6 @@
|
|||||||
#include "n-acd/src/n-acd.h"
|
#include "n-acd/src/n-acd.h"
|
||||||
#include "nm-core-utils.h"
|
#include "nm-core-utils.h"
|
||||||
|
|
||||||
#define ADDR_IPV4LL_PREFIX_LEN 16
|
|
||||||
|
|
||||||
#define TIMED_OUT_TIME_FACTOR 5u
|
#define TIMED_OUT_TIME_FACTOR 5u
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -285,15 +283,6 @@ nm_l3_ipv4ll_register_remove(NML3IPv4LLRegistration *reg)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_ip4_address_is_link_local(const NMPlatformIP4Address *a)
|
|
||||||
{
|
|
||||||
nm_assert(a);
|
|
||||||
|
|
||||||
return nm_ip4_addr_is_link_local(a->address) && a->plen == ADDR_IPV4LL_PREFIX_LEN
|
|
||||||
&& a->address == a->peer_address;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_acd_info_is_good(const NML3AcdAddrInfo *acd_info)
|
_acd_info_is_good(const NML3AcdAddrInfo *acd_info)
|
||||||
{
|
{
|
||||||
@@ -333,7 +322,7 @@ _l3cd_config_create(int ifindex, in_addr_t addr, NMDedupMultiIndex *multi_idx)
|
|||||||
NM_PLATFORM_IP4_ADDRESS_INIT(.ifindex = ifindex,
|
NM_PLATFORM_IP4_ADDRESS_INIT(.ifindex = ifindex,
|
||||||
.address = addr,
|
.address = addr,
|
||||||
.peer_address = addr,
|
.peer_address = addr,
|
||||||
.plen = ADDR_IPV4LL_PREFIX_LEN,
|
.plen = NM_IPV4LL_PREFIXLEN,
|
||||||
.addr_source = NM_IP_CONFIG_SOURCE_IP4LL));
|
.addr_source = NM_IP_CONFIG_SOURCE_IP4LL));
|
||||||
|
|
||||||
nm_l3_config_data_add_route_4(l3cd,
|
nm_l3_config_data_add_route_4(l3cd,
|
||||||
@@ -359,7 +348,7 @@ _l3cd_config_get_addr(const NML3ConfigData *l3cd)
|
|||||||
nm_l3_config_data_iter_ip4_address_for_each (&iter, l3cd, &pladdr) {
|
nm_l3_config_data_iter_ip4_address_for_each (&iter, l3cd, &pladdr) {
|
||||||
const in_addr_t addr = pladdr->address;
|
const in_addr_t addr = pladdr->address;
|
||||||
|
|
||||||
nm_assert(_ip4_address_is_link_local(pladdr));
|
nm_assert(nm_platform_ip4_address_is_link_local(pladdr));
|
||||||
#if NM_MORE_ASSERTS > 10
|
#if NM_MORE_ASSERTS > 10
|
||||||
{
|
{
|
||||||
nm_auto_unref_l3cd const NML3ConfigData *l3cd2 = NULL;
|
nm_auto_unref_l3cd const NML3ConfigData *l3cd2 = NULL;
|
||||||
@@ -644,11 +633,11 @@ _ipv4ll_platform_ip4_address_lookup(NML3IPv4LL *self, in_addr_t addr)
|
|||||||
pladdr = nm_platform_ip4_address_get(nm_l3_ipv4ll_get_platform(self),
|
pladdr = nm_platform_ip4_address_get(nm_l3_ipv4ll_get_platform(self),
|
||||||
nm_l3_ipv4ll_get_ifindex(self),
|
nm_l3_ipv4ll_get_ifindex(self),
|
||||||
addr,
|
addr,
|
||||||
ADDR_IPV4LL_PREFIX_LEN,
|
NM_IPV4LL_PREFIXLEN,
|
||||||
addr);
|
addr);
|
||||||
|
|
||||||
nm_assert(!pladdr || pladdr->address == addr);
|
nm_assert(!pladdr || pladdr->address == addr);
|
||||||
nm_assert(!pladdr || _ip4_address_is_link_local(pladdr));
|
nm_assert(!pladdr || nm_platform_ip4_address_is_link_local(pladdr));
|
||||||
return pladdr;
|
return pladdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,7 +666,7 @@ _ipv4ll_platform_find_addr(NML3IPv4LL *self, const NML3AcdAddrInfo **out_acd_inf
|
|||||||
nm_l3_ipv4ll_get_ifindex(self));
|
nm_l3_ipv4ll_get_ifindex(self));
|
||||||
nm_platform_iter_obj_for_each (&iter, nm_l3_ipv4ll_get_platform(self), &lookup, &obj) {
|
nm_platform_iter_obj_for_each (&iter, nm_l3_ipv4ll_get_platform(self), &lookup, &obj) {
|
||||||
addr = NMP_OBJECT_CAST_IP4_ADDRESS(obj);
|
addr = NMP_OBJECT_CAST_IP4_ADDRESS(obj);
|
||||||
if (!_ip4_address_is_link_local(addr))
|
if (!nm_platform_ip4_address_is_link_local(addr))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
acd_info = _ipv4ll_l3cfg_get_acd_addr_info(self, addr->address);
|
acd_info = _ipv4ll_l3cfg_get_acd_addr_info(self, addr->address);
|
||||||
|
@@ -285,6 +285,7 @@ gboolean nm_ip6_addr_is_ula(const struct in6_addr *address);
|
|||||||
|
|
||||||
#define NM_IPV4LL_NETWORK ((in_addr_t) htonl(0xA9FE0000lu)) /* 169.254.0.0 */
|
#define NM_IPV4LL_NETWORK ((in_addr_t) htonl(0xA9FE0000lu)) /* 169.254.0.0 */
|
||||||
#define NM_IPV4LL_NETMASK ((in_addr_t) htonl(0xFFFF0000lu)) /* 255.255.0.0 */
|
#define NM_IPV4LL_NETMASK ((in_addr_t) htonl(0xFFFF0000lu)) /* 255.255.0.0 */
|
||||||
|
#define NM_IPV4LL_PREFIXLEN 16
|
||||||
#define NM_IPV4LO_NETWORK ((in_addr_t) htonl(0x7F000000lu)) /* 127.0.0.0 */
|
#define NM_IPV4LO_NETWORK ((in_addr_t) htonl(0x7F000000lu)) /* 127.0.0.0 */
|
||||||
#define NM_IPV4LO_NETMASK ((in_addr_t) htonl(0xFF000000lu)) /* 255.0.0.0 */
|
#define NM_IPV4LO_NETMASK ((in_addr_t) htonl(0xFF000000lu)) /* 255.0.0.0 */
|
||||||
#define NM_IPV4LO_PREFIXLEN 8
|
#define NM_IPV4LO_PREFIXLEN 8
|
||||||
|
@@ -195,6 +195,15 @@ nm_platform_ip4_address_cmp_full(const NMPlatformIP4Address *a, const NMPlatform
|
|||||||
return nm_platform_ip4_address_cmp(a, b, NM_PLATFORM_IP_ADDRESS_CMP_TYPE_FULL);
|
return nm_platform_ip4_address_cmp(a, b, NM_PLATFORM_IP_ADDRESS_CMP_TYPE_FULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline gboolean
|
||||||
|
nm_platform_ip4_address_is_link_local(const NMPlatformIP4Address *a)
|
||||||
|
{
|
||||||
|
nm_assert(a);
|
||||||
|
|
||||||
|
return nm_ip4_addr_is_link_local(a->address) && a->plen == NM_IPV4LL_PREFIXLEN
|
||||||
|
&& a->address == a->peer_address;
|
||||||
|
}
|
||||||
|
|
||||||
void nm_platform_ip6_address_hash_update(const NMPlatformIP6Address *obj, NMHashState *h);
|
void nm_platform_ip6_address_hash_update(const NMPlatformIP6Address *obj, NMHashState *h);
|
||||||
|
|
||||||
int nm_platform_ip6_address_cmp(const NMPlatformIP6Address *a,
|
int nm_platform_ip6_address_cmp(const NMPlatformIP6Address *a,
|
||||||
|
Reference in New Issue
Block a user