mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 00:38:07 +02:00
platform/tests: add test for handling IPv4 zero gateways
Adding a route via iproute2 with explicit gateway 0.0.0.0 sets the route scope to GLOBAL, contrary to a on-link device-route which has scope LINK. Add a test adding two such routes.
This commit is contained in:
parent
4c79b605bc
commit
7a2a96f8ef
1 changed files with 28 additions and 0 deletions
|
|
@ -282,6 +282,31 @@ test_ip6_route (void)
|
|||
free_signal (route_removed);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_ip4_zero_gateway (void)
|
||||
{
|
||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||
|
||||
nmtstp_run_command_check ("ip route add 1.2.3.1/32 via 0.0.0.0 dev %s", DEVICE_NAME);
|
||||
nmtstp_run_command_check ("ip route add 1.2.3.2/32 dev %s", DEVICE_NAME);
|
||||
|
||||
NMTST_WAIT_ASSERT (100, {
|
||||
nmtstp_wait_for_signal (10);
|
||||
if ( nm_platform_ip4_route_get (NM_PLATFORM_GET, ifindex, nmtst_inet4_from_string ("1.2.3.1"), 32, 0)
|
||||
&& nm_platform_ip4_route_get (NM_PLATFORM_GET, ifindex, nmtst_inet4_from_string ("1.2.3.2"), 32, 0))
|
||||
break;
|
||||
});
|
||||
|
||||
nmtstp_run_command_check ("ip route flush dev %s", DEVICE_NAME);
|
||||
|
||||
nmtstp_wait_for_signal (50);
|
||||
nm_platform_process_events (NM_PLATFORM_GET);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
init_tests (int *argc, char ***argv)
|
||||
{
|
||||
|
|
@ -304,4 +329,7 @@ setup_tests (void)
|
|||
g_test_add_func ("/route/ip4", test_ip4_route);
|
||||
g_test_add_func ("/route/ip6", test_ip6_route);
|
||||
g_test_add_func ("/route/ip4_metric0", test_ip4_route_metric0);
|
||||
|
||||
if (nmtstp_is_root_test ())
|
||||
g_test_add_func ("/route/ip4_zero_gateway", test_ip4_zero_gateway);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue