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

Function rte_lpm_is_rule_present

dpdk/lib/lpm/rte_lpm.c:849–875  ·  view source on GitHub ↗

* Look for a rule in the high-level rules table */

Source from the content-addressed store, hash-verified

847 * Look for a rule in the high-level rules table
848 */
849int
850rte_lpm_is_rule_present(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,
851uint32_t *next_hop)
852{
853 struct __rte_lpm *i_lpm;
854 uint32_t ip_masked;
855 int32_t rule_index;
856
857 /* Check user arguments. */
858 if ((lpm == NULL) ||
859 (next_hop == NULL) ||
860 (depth < 1) || (depth > RTE_LPM_MAX_DEPTH))
861 return -EINVAL;
862
863 /* Look for the rule using rule_find. */
864 i_lpm = container_of(lpm, struct __rte_lpm, lpm);
865 ip_masked = ip & depth_to_mask(depth);
866 rule_index = rule_find(i_lpm, ip_masked, depth);
867
868 if (rule_index >= 0) {
869 *next_hop = i_lpm->rules_tbl[rule_index].next_hop;
870 return 1;
871 }
872
873 /* If rule is not found return 0. */
874 return 0;
875}
876
877static int32_t
878find_previous_rule(struct __rte_lpm *i_lpm, uint32_t ip, uint8_t depth,

Callers 2

rte_table_lpm_entry_addFunction · 0.50

Calls 2

depth_to_maskFunction · 0.70
rule_findFunction · 0.70

Tested by

no test coverage detected