MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test25

Function test25

dpdk/app/test/test_lpm6.c:1563–1604  ·  view source on GitHub ↗

* Add a set of random routes with random depths. * Lookup different IP addresses that match the routes previously added. * Checks that the next hop is the expected one. * The routes, IP addresses and expected result for every case have been * precalculated by using a python script and stored in a .h file. */

Source from the content-addressed store, hash-verified

1561 * precalculated by using a python script and stored in a .h file.
1562 */
1563int32_t
1564test25(void)
1565{
1566 struct rte_lpm6 *lpm = NULL;
1567 struct rte_lpm6_config config;
1568 uint8_t ip[16];
1569 uint32_t i;
1570 uint8_t depth;
1571 uint32_t next_hop_add, next_hop_return, next_hop_expected;
1572 int32_t status = 0;
1573
1574 config.max_rules = MAX_RULES;
1575 config.number_tbl8s = NUMBER_TBL8S;
1576 config.flags = 0;
1577
1578 lpm = rte_lpm6_create(__func__, SOCKET_ID_ANY, &config);
1579 TEST_LPM_ASSERT(lpm != NULL);
1580
1581 for (i = 0; i < 1000; i++) {
1582 memcpy(ip, large_route_table[i].ip, 16);
1583 depth = large_route_table[i].depth;
1584 next_hop_add = large_route_table[i].next_hop;
1585 status = rte_lpm6_add(lpm, ip, depth, next_hop_add);
1586 TEST_LPM_ASSERT(status == 0);
1587 }
1588
1589 /* generate large IPS table and expected next_hops */
1590 generate_large_ips_table(1);
1591
1592 for (i = 0; i < 100000; i++) {
1593 memcpy(ip, large_ips_table[i].ip, 16);
1594 next_hop_expected = large_ips_table[i].next_hop;
1595
1596 status = rte_lpm6_lookup(lpm, ip, &next_hop_return);
1597 TEST_LPM_ASSERT((status == 0) &&
1598 (next_hop_return == next_hop_expected));
1599 }
1600
1601 rte_lpm6_free(lpm);
1602
1603 return PASS;
1604}
1605
1606/*
1607 * Test for overwriting of tbl8:

Callers

nothing calls this directly

Calls 6

generate_large_ips_tableFunction · 0.85
rte_lpm6_createFunction · 0.50
memcpyFunction · 0.50
rte_lpm6_addFunction · 0.50
rte_lpm6_lookupFunction · 0.50
rte_lpm6_freeFunction · 0.50

Tested by

no test coverage detected