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

Function test17

dpdk/app/test/test_lpm6.c:804–864  ·  view source on GitHub ↗

* Use rte_lpm6_add to add rules which effect only the second half of the lpm * table. Use all possible depths ranging from 1..32. Set the next hop = to the * depth. Check lookup hit for on every add and check for lookup miss on the * first half of the lpm table after each add. Finally delete all rules going * backwards (i.e. from depth = 32 ..1) and carry out a lookup after each * delete. The

Source from the content-addressed store, hash-verified

802 * previous depth value (i.e. depth -1).
803 */
804int32_t
805test17(void)
806{
807 struct rte_lpm6 *lpm = NULL;
808 struct rte_lpm6_config config;
809 uint8_t ip1[] = {127,255,255,255,255,255,255,255,255,
810 255,255,255,255,255,255,255};
811 uint8_t ip2[] = {128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
812 uint8_t depth;
813 uint32_t next_hop_add, next_hop_return;
814 int32_t status = 0;
815
816 config.max_rules = MAX_RULES;
817 config.number_tbl8s = NUMBER_TBL8S;
818 config.flags = 0;
819
820 lpm = rte_lpm6_create(__func__, SOCKET_ID_ANY, &config);
821 TEST_LPM_ASSERT(lpm != NULL);
822
823 /* Loop with rte_lpm6_add. */
824 for (depth = 1; depth <= 16; depth++) {
825 /* Let the next_hop_add value = depth. Just for change. */
826 next_hop_add = depth;
827
828 status = rte_lpm6_add(lpm, ip2, depth, next_hop_add);
829 TEST_LPM_ASSERT(status == 0);
830
831 /* Check IP in first half of tbl24 which should be empty. */
832 status = rte_lpm6_lookup(lpm, ip1, &next_hop_return);
833 TEST_LPM_ASSERT(status == -ENOENT);
834
835 status = rte_lpm6_lookup(lpm, ip2, &next_hop_return);
836 TEST_LPM_ASSERT((status == 0) &&
837 (next_hop_return == next_hop_add));
838 }
839
840 /* Loop with rte_lpm6_delete. */
841 for (depth = 16; depth >= 1; depth--) {
842 next_hop_add = (depth - 1);
843
844 status = rte_lpm6_delete(lpm, ip2, depth);
845 TEST_LPM_ASSERT(status == 0);
846
847 status = rte_lpm6_lookup(lpm, ip2, &next_hop_return);
848
849 if (depth != 1) {
850 TEST_LPM_ASSERT((status == 0) &&
851 (next_hop_return == next_hop_add));
852 }
853 else {
854 TEST_LPM_ASSERT(status == -ENOENT);
855 }
856
857 status = rte_lpm6_lookup(lpm, ip1, &next_hop_return);
858 TEST_LPM_ASSERT(status == -ENOENT);
859 }
860
861 rte_lpm6_free(lpm);

Callers

nothing calls this directly

Calls 5

rte_lpm6_createFunction · 0.50
rte_lpm6_addFunction · 0.50
rte_lpm6_lookupFunction · 0.50
rte_lpm6_deleteFunction · 0.50
rte_lpm6_freeFunction · 0.50

Tested by

no test coverage detected