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

Function rte_lpm_delete

dpdk/lib/lpm/rte_lpm.c:1142–1195  ·  view source on GitHub ↗

* Deletes a rule */

Source from the content-addressed store, hash-verified

1140 * Deletes a rule
1141 */
1142int
1143rte_lpm_delete(struct rte_lpm *lpm, uint32_t ip, uint8_t depth)
1144{
1145 int32_t rule_to_delete_index, sub_rule_index;
1146 struct __rte_lpm *i_lpm;
1147 uint32_t ip_masked;
1148 uint8_t sub_rule_depth;
1149 /*
1150 * Check input arguments. Note: IP must be a positive integer of 32
1151 * bits in length therefore it need not be checked.
1152 */
1153 if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM_MAX_DEPTH)) {
1154 return -EINVAL;
1155 }
1156
1157 i_lpm = container_of(lpm, struct __rte_lpm, lpm);
1158 ip_masked = ip & depth_to_mask(depth);
1159
1160 /*
1161 * Find the index of the input rule, that needs to be deleted, in the
1162 * rule table.
1163 */
1164 rule_to_delete_index = rule_find(i_lpm, ip_masked, depth);
1165
1166 /*
1167 * Check if rule_to_delete_index was found. If no rule was found the
1168 * function rule_find returns -EINVAL.
1169 */
1170 if (rule_to_delete_index < 0)
1171 return -EINVAL;
1172
1173 /* Delete the rule from the rule table. */
1174 rule_delete(i_lpm, rule_to_delete_index, depth);
1175
1176 /*
1177 * Find rule to replace the rule_to_delete. If there is no rule to
1178 * replace the rule_to_delete we return -1 and invalidate the table
1179 * entries associated with this rule.
1180 */
1181 sub_rule_depth = 0;
1182 sub_rule_index = find_previous_rule(i_lpm, ip, depth, &sub_rule_depth);
1183
1184 /*
1185 * If the input depth value is less than 25 use function
1186 * delete_depth_small otherwise use delete_depth_big.
1187 */
1188 if (depth <= MAX_DEPTH_TBL24) {
1189 return delete_depth_small(i_lpm, ip_masked, depth,
1190 sub_rule_index, sub_rule_depth);
1191 } else { /* If depth > MAX_DEPTH_TBL24 */
1192 return delete_depth_big(i_lpm, ip_masked, depth, sub_rule_index,
1193 sub_rule_depth);
1194 }
1195}
1196
1197/*
1198 * Delete all rules from the LPM table.

Callers 15

run_v4Function · 0.50
test4Function · 0.50
test6Function · 0.50
test7Function · 0.50
test8Function · 0.50
test9Function · 0.50
test10Function · 0.50
test11Function · 0.50
test12Function · 0.50
test13Function · 0.50
test18Function · 0.50

Calls 6

depth_to_maskFunction · 0.70
rule_findFunction · 0.70
rule_deleteFunction · 0.70
find_previous_ruleFunction · 0.70
delete_depth_smallFunction · 0.70
delete_depth_bigFunction · 0.70

Tested by 14

test4Function · 0.40
test6Function · 0.40
test7Function · 0.40
test8Function · 0.40
test9Function · 0.40
test10Function · 0.40
test11Function · 0.40
test12Function · 0.40
test13Function · 0.40
test18Function · 0.40
test20Function · 0.40
test21Function · 0.40