platform: don't require cloned flag for RTM_GETROUTE IPv6 result
IPv4 routes that are a response to RTM_GETROUTE must have the cloned flag while IPv6 routes don't have to. Don't check the flag for IPv6 routes and add a test case to verify that RTM_GETROUTE works for IPv6. https://bugzilla.gnome.org/show_bug.cgi?id=793962
This commit is contained in:
@@ -4327,10 +4327,13 @@ event_valid_msg (NMPlatform *platform, struct nl_msg *msg, gboolean handle_event
|
||||
nm_auto_nmpobj const NMPObject *obj_replace = NULL;
|
||||
gboolean resync_required = FALSE;
|
||||
gboolean only_dirty = FALSE;
|
||||
gboolean is_ipv6;
|
||||
|
||||
if (NM_FLAGS_HAS (obj->ip_route.r_rtm_flags, RTM_F_CLONED)) {
|
||||
/* a cloned route might be a response for RTM_GETROUTE. Check, whether it is. */
|
||||
nm_assert (!nmp_object_is_alive (obj));
|
||||
/* IPv4 routes that are a response to RTM_GETROUTE must have
|
||||
* the cloned flag while IPv6 routes don't have to. */
|
||||
is_ipv6 = NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_IP6_ROUTE;
|
||||
if (is_ipv6 || NM_FLAGS_HAS (obj->ip_route.r_rtm_flags, RTM_F_CLONED)) {
|
||||
nm_assert (is_ipv6 || !nmp_object_is_alive (obj));
|
||||
priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||
if (NM_FLAGS_HAS (priv->delayed_action.flags, DELAYED_ACTION_TYPE_WAIT_FOR_NL_RESPONSE)) {
|
||||
guint i;
|
||||
|
@@ -423,7 +423,7 @@ test_ip6_route (void)
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_ip_route_get (void)
|
||||
test_ip4_route_get (void)
|
||||
{
|
||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
in_addr_t a;
|
||||
@@ -584,6 +584,45 @@ test_ip4_route_options (gconstpointer test_data)
|
||||
#undef RTS_MAX
|
||||
}
|
||||
|
||||
static void
|
||||
test_ip6_route_get (void)
|
||||
{
|
||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
const struct in6_addr *a;
|
||||
NMPlatformError result;
|
||||
nm_auto_nmpobj NMPObject *route = NULL;
|
||||
const NMPlatformIP6Route *r;
|
||||
|
||||
nmtstp_run_command_check ("ip -6 route add fd01:abcd::/64 via fe80::99 dev %s", DEVICE_NAME);
|
||||
|
||||
NMTST_WAIT_ASSERT (100, {
|
||||
nmtstp_wait_for_signal (NM_PLATFORM_GET, 10);
|
||||
if (nmtstp_ip6_route_get (NM_PLATFORM_GET, ifindex, nmtst_inet6_from_string ("fd01:abcd::"), 64, 0, NULL, 0))
|
||||
break;
|
||||
});
|
||||
|
||||
a = nmtst_inet6_from_string ("fd01:abcd::42");
|
||||
result = nm_platform_ip_route_get (NM_PLATFORM_GET,
|
||||
AF_INET6,
|
||||
a,
|
||||
nmtst_get_rand_int () % 2 ? 0 : ifindex,
|
||||
&route);
|
||||
|
||||
g_assert (result == NM_PLATFORM_ERROR_SUCCESS);
|
||||
g_assert (NMP_OBJECT_GET_TYPE (route) == NMP_OBJECT_TYPE_IP6_ROUTE);
|
||||
g_assert (!NMP_OBJECT_IS_STACKINIT (route));
|
||||
g_assert (route->parent._ref_count == 1);
|
||||
r = NMP_OBJECT_CAST_IP6_ROUTE (route);
|
||||
g_assert (r->ifindex == ifindex);
|
||||
nmtst_assert_ip6_address (&r->network, "fd01:abcd::42");
|
||||
g_assert_cmpint (r->plen, ==, 128);
|
||||
nmtst_assert_ip6_address (&r->gateway, "fe80::99");
|
||||
|
||||
nmtstp_run_command_check ("ip -6 route flush dev %s", DEVICE_NAME);
|
||||
|
||||
nmtstp_wait_for_signal (NM_PLATFORM_GET, 50);
|
||||
}
|
||||
|
||||
static void
|
||||
test_ip6_route_options (gconstpointer test_data)
|
||||
{
|
||||
@@ -859,7 +898,8 @@ _nmtstp_setup_tests (void)
|
||||
|
||||
if (nmtstp_is_root_test ()) {
|
||||
add_test_func_data ("/route/ip/1", test_ip, GINT_TO_POINTER (1));
|
||||
add_test_func ("/route/ip_route_get", test_ip_route_get);
|
||||
add_test_func ("/route/ip4_route_get", test_ip4_route_get);
|
||||
add_test_func ("/route/ip6_route_get", test_ip6_route_get);
|
||||
add_test_func ("/route/ip4_zero_gateway", test_ip4_zero_gateway);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user