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

Function test11

dpdk/app/test/test_lpm.c:810–871  ·  view source on GitHub ↗

* Add two rules, lookup to hit the more specific one, lookup to hit the less * specific one delete the less specific rule and lookup previous values again; * add a more specific rule than the existing rule, lookup again * * */

Source from the content-addressed store, hash-verified

808 *
809 * */
810int32_t
811test11(void)
812{
813
814 struct rte_lpm *lpm = NULL;
815 struct rte_lpm_config config;
816
817 config.max_rules = MAX_RULES;
818 config.number_tbl8s = NUMBER_TBL8S;
819 config.flags = 0;
820 uint32_t ip, next_hop_add, next_hop_return;
821 uint8_t depth;
822 int32_t status = 0;
823
824 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
825 TEST_LPM_ASSERT(lpm != NULL);
826
827 ip = RTE_IPV4(128, 0, 0, 0);
828 depth = 24;
829 next_hop_add = 100;
830
831 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
832 TEST_LPM_ASSERT(status == 0);
833
834 ip = RTE_IPV4(128, 0, 0, 10);
835 depth = 32;
836 next_hop_add = 101;
837
838 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
839 TEST_LPM_ASSERT(status == 0);
840
841 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
842 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
843
844 ip = RTE_IPV4(128, 0, 0, 0);
845 next_hop_add = 100;
846
847 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
848 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
849
850 ip = RTE_IPV4(128, 0, 0, 0);
851 depth = 24;
852
853 status = rte_lpm_delete(lpm, ip, depth);
854 TEST_LPM_ASSERT(status == 0);
855
856 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
857 TEST_LPM_ASSERT(status == -ENOENT);
858
859 ip = RTE_IPV4(128, 0, 0, 10);
860 depth = 32;
861
862 status = rte_lpm_delete(lpm, ip, depth);
863 TEST_LPM_ASSERT(status == 0);
864
865 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
866 TEST_LPM_ASSERT(status == -ENOENT);
867

Callers

nothing calls this directly

Calls 5

rte_lpm_createFunction · 0.50
rte_lpm_addFunction · 0.50
rte_lpm_lookupFunction · 0.50
rte_lpm_deleteFunction · 0.50
rte_lpm_freeFunction · 0.50

Tested by

no test coverage detected