mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-06 05:38:15 +02:00
platform/tests: rename nmtst_inet6_from_string() to nmtst_inet6_from_string_p()
This helper returns a pointer (to a thread local variable).
This commit is contained in:
parent
06cf1f5e2d
commit
2786a30a7c
8 changed files with 37 additions and 37 deletions
|
|
@ -72,8 +72,8 @@ nmtst_platform_ip6_address(const char *address, const char *peer_address, guint
|
|||
g_assert(plen <= 128);
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.address = *nmtst_inet6_from_string(address);
|
||||
addr.peer_address = *nmtst_inet6_from_string(peer_address);
|
||||
addr.address = *nmtst_inet6_from_string_p(address);
|
||||
addr.peer_address = *nmtst_inet6_from_string_p(peer_address);
|
||||
addr.plen = plen;
|
||||
|
||||
return &addr;
|
||||
|
|
@ -148,10 +148,10 @@ nmtst_platform_ip6_route(const char *network, guint plen, const char *gateway, c
|
|||
nm_assert(plen <= 128);
|
||||
|
||||
memset(&route, 0, sizeof(route));
|
||||
route.network = *nmtst_inet6_from_string(network);
|
||||
route.network = *nmtst_inet6_from_string_p(network);
|
||||
route.plen = plen;
|
||||
route.gateway = *nmtst_inet6_from_string(gateway);
|
||||
route.pref_src = *nmtst_inet6_from_string(pref_src);
|
||||
route.gateway = *nmtst_inet6_from_string_p(gateway);
|
||||
route.pref_src = *nmtst_inet6_from_string_p(pref_src);
|
||||
|
||||
return &route;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ link_add_pre(NMPlatform *platform,
|
|||
g_assert(address_len == 0);
|
||||
|
||||
device->obj = o;
|
||||
device->ip6_lladdr = *nmtst_inet6_from_string(ip6_lladdr);
|
||||
device->ip6_lladdr = *nmtst_inet6_from_string_p(ip6_lladdr);
|
||||
|
||||
return device;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1203,7 +1203,7 @@ _test_wireguard_change(NMPlatform *platform, int ifindex, int test_mode)
|
|||
.in6 =
|
||||
{
|
||||
.sin6_family = AF_INET6,
|
||||
.sin6_addr = *nmtst_inet6_from_string(
|
||||
.sin6_addr = *nmtst_inet6_from_string_p(
|
||||
nm_sprintf_buf(s_addr, "a:b:c:e::1:%d", i)),
|
||||
.sin6_port = htons(16000 + i),
|
||||
},
|
||||
|
|
@ -1225,7 +1225,7 @@ _test_wireguard_change(NMPlatform *platform, int ifindex, int test_mode)
|
|||
nm_sprintf_buf(s_addr, "10.%u.%u.0", i, i_allowed_ips));
|
||||
aip->mask = 32 - (i_allowed_ips % 8);
|
||||
} else {
|
||||
aip->addr.addr6 = *nmtst_inet6_from_string(
|
||||
aip->addr.addr6 = *nmtst_inet6_from_string_p(
|
||||
nm_sprintf_buf(s_addr, "a:d:f:%02x:%02x::", i, i_allowed_ips));
|
||||
aip->mask = 128 - (i_allowed_ips % 10);
|
||||
}
|
||||
|
|
@ -1412,8 +1412,8 @@ test_software_detect(gconstpointer user_data)
|
|||
|
||||
switch (test_data->test_mode) {
|
||||
case 0:
|
||||
lnk_ip6tnl.local = *nmtst_inet6_from_string("fd01::15");
|
||||
lnk_ip6tnl.remote = *nmtst_inet6_from_string("fd01::16");
|
||||
lnk_ip6tnl.local = *nmtst_inet6_from_string_p("fd01::15");
|
||||
lnk_ip6tnl.remote = *nmtst_inet6_from_string_p("fd01::16");
|
||||
lnk_ip6tnl.parent_ifindex = ifindex_parent;
|
||||
lnk_ip6tnl.tclass = 20;
|
||||
lnk_ip6tnl.encap_limit = 6;
|
||||
|
|
@ -1421,8 +1421,8 @@ test_software_detect(gconstpointer user_data)
|
|||
lnk_ip6tnl.proto = IPPROTO_IPV6;
|
||||
break;
|
||||
case 1:
|
||||
lnk_ip6tnl.local = *nmtst_inet6_from_string("fd01::17");
|
||||
lnk_ip6tnl.remote = *nmtst_inet6_from_string("fd01::18");
|
||||
lnk_ip6tnl.local = *nmtst_inet6_from_string_p("fd01::17");
|
||||
lnk_ip6tnl.remote = *nmtst_inet6_from_string_p("fd01::18");
|
||||
lnk_ip6tnl.parent_ifindex = ifindex_parent;
|
||||
lnk_ip6tnl.tclass = 0;
|
||||
lnk_ip6tnl.encap_limit = 0;
|
||||
|
|
@ -1452,8 +1452,8 @@ test_software_detect(gconstpointer user_data)
|
|||
gracefully_skip = nmp_utils_modprobe(NULL, TRUE, "ip6_gre", NULL) != 0;
|
||||
}
|
||||
|
||||
lnk_ip6tnl.local = *nmtst_inet6_from_string("fd01::42");
|
||||
lnk_ip6tnl.remote = *nmtst_inet6_from_string("fd01::aaaa");
|
||||
lnk_ip6tnl.local = *nmtst_inet6_from_string_p("fd01::42");
|
||||
lnk_ip6tnl.remote = *nmtst_inet6_from_string_p("fd01::aaaa");
|
||||
lnk_ip6tnl.parent_ifindex = ifindex_parent;
|
||||
lnk_ip6tnl.tclass = 21;
|
||||
lnk_ip6tnl.flow_label = 1338;
|
||||
|
|
@ -1479,8 +1479,8 @@ test_software_detect(gconstpointer user_data)
|
|||
gracefully_skip = nmp_utils_modprobe(NULL, TRUE, "ip6_gre", NULL) != 0;
|
||||
}
|
||||
|
||||
lnk_ip6tnl.local = *nmtst_inet6_from_string("fe80::abcd");
|
||||
lnk_ip6tnl.remote = *nmtst_inet6_from_string("fc01::bbbb");
|
||||
lnk_ip6tnl.local = *nmtst_inet6_from_string_p("fe80::abcd");
|
||||
lnk_ip6tnl.remote = *nmtst_inet6_from_string_p("fc01::bbbb");
|
||||
lnk_ip6tnl.parent_ifindex = ifindex_parent;
|
||||
lnk_ip6tnl.ttl = 10;
|
||||
lnk_ip6tnl.tclass = 22;
|
||||
|
|
@ -1608,8 +1608,8 @@ test_software_detect(gconstpointer user_data)
|
|||
case 1:
|
||||
lnk_vxlan.parent_ifindex = nm_platform_link_get_ifindex(NM_PLATFORM_GET, PARENT_NAME);
|
||||
lnk_vxlan.id = 11214423;
|
||||
lnk_vxlan.local6 = *nmtst_inet6_from_string("1:2:3:4:334:23::23");
|
||||
lnk_vxlan.group6 = *nmtst_inet6_from_string("ff0e::115");
|
||||
lnk_vxlan.local6 = *nmtst_inet6_from_string_p("1:2:3:4:334:23::23");
|
||||
lnk_vxlan.group6 = *nmtst_inet6_from_string_p("ff0e::115");
|
||||
lnk_vxlan.ttl = 32;
|
||||
lnk_vxlan.dst_port = 57412;
|
||||
lnk_vxlan.src_port_min = 1000;
|
||||
|
|
|
|||
|
|
@ -746,7 +746,7 @@ test_ip6_route_get(void)
|
|||
nmtstp_wait_for_signal(NM_PLATFORM_GET, 10);
|
||||
if (nmtstp_ip6_route_get(NM_PLATFORM_GET,
|
||||
ifindex,
|
||||
nmtst_inet6_from_string("fd01:abcd::"),
|
||||
nmtst_inet6_from_string_p("fd01:abcd::"),
|
||||
64,
|
||||
NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6,
|
||||
NULL,
|
||||
|
|
@ -754,7 +754,7 @@ test_ip6_route_get(void)
|
|||
break;
|
||||
});
|
||||
|
||||
a = nmtst_inet6_from_string("fd01:abcd::42");
|
||||
a = nmtst_inet6_from_string_p("fd01:abcd::42");
|
||||
result = nm_platform_ip_route_get(NM_PLATFORM_GET,
|
||||
AF_INET6,
|
||||
a,
|
||||
|
|
@ -796,7 +796,7 @@ test_ip6_route_options(gconstpointer test_data)
|
|||
rts_add[rts_n++] = ((NMPlatformIP6Route){
|
||||
.ifindex = IFINDEX,
|
||||
.rt_source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.network = *nmtst_inet6_from_string("2001:db8:a:b:0:0:0:0"),
|
||||
.network = *nmtst_inet6_from_string_p("2001:db8:a:b:0:0:0:0"),
|
||||
.plen = 64,
|
||||
.gateway = in6addr_any,
|
||||
.metric = 1024,
|
||||
|
|
@ -811,7 +811,7 @@ test_ip6_route_options(gconstpointer test_data)
|
|||
case 2:
|
||||
addr[addr_n++] = ((NMPlatformIP6Address){
|
||||
.ifindex = IFINDEX,
|
||||
.address = *nmtst_inet6_from_string("2000::2"),
|
||||
.address = *nmtst_inet6_from_string_p("2000::2"),
|
||||
.plen = 128,
|
||||
.peer_address = in6addr_any,
|
||||
.lifetime = NM_PLATFORM_LIFETIME_PERMANENT,
|
||||
|
|
@ -821,17 +821,17 @@ test_ip6_route_options(gconstpointer test_data)
|
|||
rts_add[rts_n++] = ((NMPlatformIP6Route){
|
||||
.ifindex = IFINDEX,
|
||||
.rt_source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.network = *nmtst_inet6_from_string("1010::1"),
|
||||
.network = *nmtst_inet6_from_string_p("1010::1"),
|
||||
.plen = 128,
|
||||
.gateway = in6addr_any,
|
||||
.metric = 256,
|
||||
.pref_src = *nmtst_inet6_from_string("2000::2"),
|
||||
.pref_src = *nmtst_inet6_from_string_p("2000::2"),
|
||||
});
|
||||
break;
|
||||
case 3:
|
||||
addr[addr_n++] = ((NMPlatformIP6Address){
|
||||
.ifindex = IFINDEX,
|
||||
.address = *nmtst_inet6_from_string("2001:db8:8086::5"),
|
||||
.address = *nmtst_inet6_from_string_p("2001:db8:8086::5"),
|
||||
.plen = 128,
|
||||
.peer_address = in6addr_any,
|
||||
.lifetime = NM_PLATFORM_LIFETIME_PERMANENT,
|
||||
|
|
@ -841,7 +841,7 @@ test_ip6_route_options(gconstpointer test_data)
|
|||
rts_add[rts_n++] = ((NMPlatformIP6Route){
|
||||
.ifindex = IFINDEX,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string("2001:db8:8086::"),
|
||||
.network = *nmtst_inet6_from_string_p("2001:db8:8086::"),
|
||||
.plen = 110,
|
||||
.metric = 10021,
|
||||
.mss = 0,
|
||||
|
|
@ -849,9 +849,9 @@ test_ip6_route_options(gconstpointer test_data)
|
|||
rts_add[rts_n++] = ((NMPlatformIP6Route){
|
||||
.ifindex = IFINDEX,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string("2001:db8:abad:c0de::"),
|
||||
.network = *nmtst_inet6_from_string_p("2001:db8:abad:c0de::"),
|
||||
.plen = 64,
|
||||
.gateway = *nmtst_inet6_from_string("2001:db8:8086::1"),
|
||||
.gateway = *nmtst_inet6_from_string_p("2001:db8:8086::1"),
|
||||
.metric = 21,
|
||||
.mss = 0,
|
||||
});
|
||||
|
|
@ -1330,7 +1330,7 @@ _rule_create_random(NMPlatform *platform)
|
|||
p_addr->addr4 =
|
||||
nmtst_inet4_from_string(nm_sprintf_buf(saddr, "192.192.5.%u", (~p) % 256u));
|
||||
else
|
||||
p_addr->addr6 = *nmtst_inet6_from_string(
|
||||
p_addr->addr6 = *nmtst_inet6_from_string_p(
|
||||
nm_sprintf_buf(saddr, "1:2:3:4::f:%02x", (~p) % 256u));
|
||||
} else if ((p % 3u) == 1)
|
||||
nmtst_rand_buf(NULL, p_addr, addr_size);
|
||||
|
|
|
|||
|
|
@ -152,8 +152,8 @@ test_logging_error(void)
|
|||
static void
|
||||
_test_same_prefix(const char *a1, const char *a2, guint8 plen)
|
||||
{
|
||||
struct in6_addr a = *nmtst_inet6_from_string(a1);
|
||||
struct in6_addr b = *nmtst_inet6_from_string(a2);
|
||||
struct in6_addr a = *nmtst_inet6_from_string_p(a1);
|
||||
struct in6_addr b = *nmtst_inet6_from_string_p(a2);
|
||||
|
||||
g_assert(nm_ip6_addr_same_prefix(&a, &b, plen));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ test_l3cfg(gconstpointer test_data)
|
|||
|
||||
nm_l3_config_data_add_address_6(
|
||||
l3cd,
|
||||
NM_PLATFORM_IP6_ADDRESS_INIT(.address = *nmtst_inet6_from_string("1:2:3:4::45"),
|
||||
NM_PLATFORM_IP6_ADDRESS_INIT(.address = *nmtst_inet6_from_string_p("1:2:3:4::45"),
|
||||
.plen = 64, ));
|
||||
|
||||
if (nmtst_get_rand_one_case_in(2))
|
||||
|
|
@ -985,7 +985,7 @@ test_l3_ipv6ll(gconstpointer test_data)
|
|||
nmtstp_ip6_address_add(tdata->f->platform,
|
||||
-1,
|
||||
tdata->f->ifindex1,
|
||||
*nmtst_inet6_from_string(_LLADDR_TEST1),
|
||||
*nmtst_inet6_from_string_p(_LLADDR_TEST1),
|
||||
64,
|
||||
in6addr_any,
|
||||
NM_PLATFORM_LIFETIME_PERMANENT,
|
||||
|
|
|
|||
|
|
@ -10430,7 +10430,7 @@ static void
|
|||
test_nm_ip_addr_zero(void)
|
||||
{
|
||||
in_addr_t a4 = nmtst_inet4_from_string("0.0.0.0");
|
||||
struct in6_addr a6 = *nmtst_inet6_from_string("::");
|
||||
struct in6_addr a6 = *nmtst_inet6_from_string_p("::");
|
||||
char buf[NM_INET_ADDRSTRLEN];
|
||||
NMIPAddr a = NM_IP_ADDR_INIT;
|
||||
|
||||
|
|
|
|||
|
|
@ -1589,7 +1589,7 @@ nmtst_inet4_from_string(const char *str)
|
|||
}
|
||||
|
||||
static inline const struct in6_addr *
|
||||
nmtst_inet6_from_string(const char *str)
|
||||
nmtst_inet6_from_string_p(const char *str)
|
||||
{
|
||||
static _nm_thread_local struct in6_addr addr;
|
||||
int success;
|
||||
|
|
@ -1614,7 +1614,7 @@ nmtst_inet_from_string(int addr_family, const char *str)
|
|||
return &a;
|
||||
}
|
||||
if (addr_family == AF_INET6)
|
||||
return nmtst_inet6_from_string(str);
|
||||
return nmtst_inet6_from_string_p(str);
|
||||
|
||||
g_assert_not_reached();
|
||||
return NULL;
|
||||
|
|
@ -1673,7 +1673,7 @@ _nmtst_assert_ip6_address(const char *file,
|
|||
if (!addr)
|
||||
addr = &any;
|
||||
|
||||
if (memcmp(nmtst_inet6_from_string(str_expected), addr, sizeof(*addr)) != 0) {
|
||||
if (memcmp(nmtst_inet6_from_string_p(str_expected), addr, sizeof(*addr)) != 0) {
|
||||
char buf[100];
|
||||
|
||||
g_error("%s:%d: Unexpected IPv6 address: expected %s, got %s",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue