1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/gnrc_ipv6_nib: rtr_ltime test: Test before removing from DRL

Keep testing for options before removing default router
This commit is contained in:
xnumad 2024-08-27 09:33:40 +02:00
parent 38d5acf87b
commit 40c9dc8320

View File

@ -1046,13 +1046,15 @@ static void test_handle_pkt__rtr_adv__invalid_opt_len(void)
TEST_ASSERT_EQUAL_INT(0, msg_avail());
}
static void test_handle_pkt__rtr_adv__options_success(bool sl2ao, bool mtuo, bool pio,
uint8_t pio_flags, unsigned exp_addr_count,
_netif_exp_t exp_netif, bool is_first_check);
static void test_handle_pkt__rtr_adv__success(uint8_t rtr_adv_flags,
bool set_rtr_adv_fields,
bool sl2ao, bool mtuo,
bool pio, uint8_t pio_flags)
{
gnrc_ipv6_nib_pl_t prefix;
gnrc_ipv6_nib_nc_t nce;
gnrc_ipv6_nib_ft_t route;
void *state = NULL;
size_t icmpv6_len = _set_rtr_adv(&_rem_ll, NDP_HOP_LIMIT, 0U,
@ -1101,6 +1103,8 @@ static void test_handle_pkt__rtr_adv__success(uint8_t rtr_adv_flags,
TEST_ASSERT_EQUAL_INT(exp_netif.cur_hl,
_mock_netif->cur_hl);
}
test_handle_pkt__rtr_adv__options_success(sl2ao, mtuo, pio, pio_flags, exp_addr_count, exp_netif, true);
{
/*
* > The Router Lifetime applies only to
@ -1108,10 +1112,9 @@ static void test_handle_pkt__rtr_adv__success(uint8_t rtr_adv_flags,
does not apply to information contained in other
message fields or options.
* - https://datatracker.ietf.org/doc/html/rfc4861#section-4.2
* So (after default router list was tested),
* send a RA with Router Lifetime value of zero.
* So send a RA with Router Lifetime value of zero,
* to test that _handle_rtr_timeout follows this behavior.
* If it doesn't, the following tests for RA options will fail.
* If it doesn't, the following tests for RA options again will fail.
*/
icmpv6_len = _set_rtr_adv(&_rem_ll, NDP_HOP_LIMIT, 0U,
false, 0U,
@ -1125,7 +1128,18 @@ static void test_handle_pkt__rtr_adv__success(uint8_t rtr_adv_flags,
rtr_adv->ltime = byteorder_htons(0);
gnrc_ipv6_nib_handle_pkt(_mock_netif, ipv6, icmpv6, icmpv6_len);
}
state = NULL;
test_handle_pkt__rtr_adv__options_success(sl2ao, mtuo, pio, pio_flags, exp_addr_count, exp_netif, false);
}
static void test_handle_pkt__rtr_adv__options_success(bool sl2ao, bool mtuo, bool pio,
uint8_t pio_flags,
const unsigned exp_addr_count,
_netif_exp_t exp_netif, bool is_first_check)
{
gnrc_ipv6_nib_pl_t prefix;
gnrc_ipv6_nib_nc_t nce;
void *state = NULL;
if (sl2ao) {
TEST_ASSERT_MESSAGE(gnrc_ipv6_nib_nc_iter(0, &state, &nce),
"No neighbor cache entry found");
@ -1163,6 +1177,7 @@ static void test_handle_pkt__rtr_adv__success(uint8_t rtr_adv_flags,
&_loc_gb) >= 0,
"Address was not configured by PIO");
if (is_first_check) {
/* Check if SLAAC generated a neighbor solicitation */
TEST_ASSERT_EQUAL_INT(1, msg_avail());
msg_receive(&msg);
@ -1198,6 +1213,7 @@ static void test_handle_pkt__rtr_adv__success(uint8_t rtr_adv_flags,
TEST_ASSERT_NULL(pkt->next->next->next);
gnrc_pktbuf_release(pkt);
}
}
else {
TEST_ASSERT_MESSAGE(gnrc_netif_ipv6_addr_idx(_mock_netif,
&_loc_gb) < 0,