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

Function test12

dpdk/app/test/test_lpm.c:880–927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

878 * */
879
880int32_t
881test12(void)
882{
883 xmm_t ipx4;
884 uint32_t hop[4];
885 struct rte_lpm *lpm = NULL;
886 struct rte_lpm_config config;
887
888 config.max_rules = MAX_RULES;
889 config.number_tbl8s = NUMBER_TBL8S;
890 config.flags = 0;
891 uint32_t ip, i, next_hop_add, next_hop_return;
892 uint8_t depth;
893 int32_t status = 0;
894
895 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
896 TEST_LPM_ASSERT(lpm != NULL);
897
898 ip = RTE_IPV4(128, 0, 0, 0);
899 depth = 32;
900 next_hop_add = 100;
901
902 for (i = 0; i < 1000; i++) {
903 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
904 TEST_LPM_ASSERT(status == 0);
905
906 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
907 TEST_LPM_ASSERT((status == 0) &&
908 (next_hop_return == next_hop_add));
909
910 ipx4 = vect_set_epi32(ip, ip + 1, ip, ip - 1);
911 rte_lpm_lookupx4(lpm, ipx4, hop, UINT32_MAX);
912 TEST_LPM_ASSERT(hop[0] == UINT32_MAX);
913 TEST_LPM_ASSERT(hop[1] == next_hop_add);
914 TEST_LPM_ASSERT(hop[2] == UINT32_MAX);
915 TEST_LPM_ASSERT(hop[3] == next_hop_add);
916
917 status = rte_lpm_delete(lpm, ip, depth);
918 TEST_LPM_ASSERT(status == 0);
919
920 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
921 TEST_LPM_ASSERT(status == -ENOENT);
922 }
923
924 rte_lpm_free(lpm);
925
926 return PASS;
927}
928
929/*
930 * Add a rule to tbl24, lookup (hit), then add a rule that will extend this

Callers

nothing calls this directly

Calls 7

vect_set_epi32Function · 0.85
rte_lpm_createFunction · 0.50
rte_lpm_addFunction · 0.50
rte_lpm_lookupFunction · 0.50
rte_lpm_lookupx4Function · 0.50
rte_lpm_deleteFunction · 0.50
rte_lpm_freeFunction · 0.50

Tested by

no test coverage detected