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

Function simulate_add

dpdk/lib/lpm/rte_lpm6.c:814–846  ·  view source on GitHub ↗

* Simulate adding a route to LPM * * Returns: * 0 on success * -ENOSPC not enough tbl8 left */

Source from the content-addressed store, hash-verified

812 * -ENOSPC not enough tbl8 left
813 */
814static int
815simulate_add(struct rte_lpm6 *lpm, const uint8_t *masked_ip, uint8_t depth)
816{
817 struct rte_lpm6_tbl_entry *tbl;
818 struct rte_lpm6_tbl_entry *tbl_next = NULL;
819 int ret, i;
820
821 /* number of new tables needed for a step */
822 uint32_t need_tbl_nb;
823 /* total number of new tables needed */
824 uint32_t total_need_tbl_nb;
825
826 /* Inspect the first three bytes through tbl24 on the first step. */
827 ret = simulate_add_step(lpm, lpm->tbl24, &tbl_next, masked_ip,
828 ADD_FIRST_BYTE, 1, depth, &need_tbl_nb);
829 total_need_tbl_nb = need_tbl_nb;
830 /*
831 * Inspect one by one the rest of the bytes until
832 * the process is completed.
833 */
834 for (i = ADD_FIRST_BYTE; i < RTE_LPM6_IPV6_ADDR_SIZE && ret == 1; i++) {
835 tbl = tbl_next;
836 ret = simulate_add_step(lpm, tbl, &tbl_next, masked_ip, 1,
837 (uint8_t)(i + 1), depth, &need_tbl_nb);
838 total_need_tbl_nb += need_tbl_nb;
839 }
840
841 if (tbl8_available(lpm) < total_need_tbl_nb)
842 /* not enough tbl8 to add a rule */
843 return -ENOSPC;
844
845 return 0;
846}
847
848/*
849 * Add a route

Callers 1

rte_lpm6_addFunction · 0.70

Calls 2

simulate_add_stepFunction · 0.70
tbl8_availableFunction · 0.70

Tested by

no test coverage detected