mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests/gnrc_ipv6_ext_frag: add test for nth frag with full rbuf first
Adds a test case for when the following conditions cause a crash: - a subsequent fragment is received before the first - the reassembly buffer is currently filled up when another fragment of a different datagram arrives and thus needs to be cached out to make room for the new reassembly
This commit is contained in:
parent
40f721a4b8
commit
07a6b5425e
@ -402,6 +402,53 @@ static void test_ipv6_ext_frag_reass_out_of_order(void)
|
||||
gnrc_pktbuf_is_empty();
|
||||
}
|
||||
|
||||
static void test_ipv6_ext_frag_reass_out_of_order_rbuf_full(void)
|
||||
{
|
||||
gnrc_pktsnip_t *ipv6_snip = gnrc_ipv6_hdr_build(NULL, &_src, &_dst);
|
||||
gnrc_pktsnip_t *pkt = gnrc_pktbuf_add(ipv6_snip, _test_frag3,
|
||||
sizeof(_test_frag3),
|
||||
GNRC_NETTYPE_UNDEF);
|
||||
ipv6_hdr_t *ipv6 = ipv6_snip->data;
|
||||
ipv6_ext_frag_t *frag = pkt->data;
|
||||
gnrc_ipv6_ext_frag_rbuf_t *rbuf;
|
||||
gnrc_ipv6_ext_frag_limits_t *ptr;
|
||||
static const uint32_t foreign_id = TEST_ID + 44U;
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(1, GNRC_IPV6_EXT_FRAG_RBUF_SIZE);
|
||||
/* prepare fragment from a from a foreign datagram */
|
||||
ipv6->nh = PROTNUM_IPV6_EXT_FRAG;
|
||||
ipv6->hl = TEST_HL;
|
||||
ipv6->len = byteorder_htons(pkt->size);
|
||||
frag->nh = PROTNUM_UDP;
|
||||
frag->resv = 0U;
|
||||
ipv6_ext_frag_set_offset(frag, TEST_FRAG3_OFFSET);
|
||||
frag->id = byteorder_htonl(foreign_id);
|
||||
|
||||
/* receive a fragment from a foreign datagram first */
|
||||
TEST_ASSERT_NULL(gnrc_ipv6_ext_frag_reass(pkt));
|
||||
TEST_ASSERT_NOT_NULL((rbuf = gnrc_ipv6_ext_frag_rbuf_get(ipv6,
|
||||
foreign_id)));
|
||||
TEST_ASSERT_NOT_NULL(rbuf->pkt);
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(_exp_payload), rbuf->pkt->size);
|
||||
TEST_ASSERT_EQUAL_INT(foreign_id, rbuf->id);
|
||||
TEST_ASSERT(rbuf->last);
|
||||
ptr = (gnrc_ipv6_ext_frag_limits_t *)rbuf->limits.next;
|
||||
TEST_ASSERT_NOT_NULL(ptr);
|
||||
ptr = ptr->next;
|
||||
TEST_ASSERT_NOT_NULL(ptr);
|
||||
TEST_ASSERT_EQUAL_INT(TEST_FRAG3_OFFSET / 8, ptr->start);
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(_exp_payload) / 8, ptr->end);
|
||||
TEST_ASSERT(((clist_node_t *)ptr) == rbuf->limits.next);
|
||||
TEST_ASSERT(memcmp(&_exp_payload[TEST_FRAG3_OFFSET],
|
||||
(uint8_t *)rbuf->pkt->data + TEST_FRAG3_OFFSET,
|
||||
rbuf->pkt->size - TEST_FRAG3_OFFSET) == 0);
|
||||
|
||||
/* redo test_ipv6_ext_frag_reass_one_frag but now rbuf is full and oldest
|
||||
* entry should be cycled out */
|
||||
test_ipv6_ext_frag_reass_out_of_order();
|
||||
}
|
||||
|
||||
static void test_ipv6_ext_frag_reass_one_frag(void)
|
||||
{
|
||||
gnrc_pktsnip_t *ipv6_snip = gnrc_ipv6_hdr_build(NULL, &_src, &_dst);
|
||||
@ -445,6 +492,7 @@ static void run_unittests(void)
|
||||
new_TestFixture(test_ipv6_ext_frag_rbuf_gc),
|
||||
new_TestFixture(test_ipv6_ext_frag_reass_in_order),
|
||||
new_TestFixture(test_ipv6_ext_frag_reass_out_of_order),
|
||||
new_TestFixture(test_ipv6_ext_frag_reass_out_of_order_rbuf_full),
|
||||
new_TestFixture(test_ipv6_ext_frag_reass_one_frag),
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user