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

Function rte_lpm6_delete

dpdk/lib/lpm/rte_lpm6.c:1288–1382  ·  view source on GitHub ↗

* Deletes a rule */

Source from the content-addressed store, hash-verified

1286 * Deletes a rule
1287 */
1288int
1289rte_lpm6_delete(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth)
1290{
1291 uint8_t masked_ip[RTE_LPM6_IPV6_ADDR_SIZE];
1292 struct rte_lpm6_rule lsp_rule_obj;
1293 struct rte_lpm6_rule *lsp_rule;
1294 int ret;
1295 uint32_t tbl_ind;
1296 struct rte_lpm6_tbl_entry *from, *to;
1297
1298 /* Check input arguments. */
1299 if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH))
1300 return -EINVAL;
1301
1302 /* Copy the IP and mask it to avoid modifying user's input data. */
1303 ip6_copy_addr(masked_ip, ip);
1304 ip6_mask_addr(masked_ip, depth);
1305
1306 /* Delete the rule from the rule table. */
1307 ret = rule_delete(lpm, masked_ip, depth);
1308 if (ret < 0)
1309 return -ENOENT;
1310
1311 /* find rule cells */
1312 rule_find_range(lpm, masked_ip, depth, &from, &to, &tbl_ind);
1313
1314 /* find a less specific rule (a rule with smaller depth)
1315 * note: masked_ip will be modified, don't use it anymore
1316 */
1317 ret = rule_find_less_specific(lpm, masked_ip, depth,
1318 &lsp_rule_obj);
1319 lsp_rule = ret ? &lsp_rule_obj : NULL;
1320
1321 /* decrement the table rule counter,
1322 * note that tbl24 doesn't have a header
1323 */
1324 if (tbl_ind != TBL24_IND) {
1325 struct rte_lpm_tbl8_hdr *tbl_hdr = &lpm->tbl8_hdrs[tbl_ind];
1326 if (--tbl_hdr->ref_cnt == 0) {
1327 /* remove the table */
1328 remove_tbl(lpm, tbl_hdr, tbl_ind, lsp_rule);
1329 return 0;
1330 }
1331 }
1332
1333 /* iterate rule cells */
1334 for (; from <= to; from++)
1335 if (from->ext_entry == 1) {
1336 /* reference to a more specific space
1337 * of the prefix/rule. Entries in a more
1338 * specific space that are not used by
1339 * a more specific prefix must be occupied
1340 * by the prefix
1341 */
1342 if (lsp_rule != NULL)
1343 expand_rule(lpm,
1344 from->lpm6_tbl8_gindex *
1345 RTE_LPM6_TBL8_GROUP_NUM_ENTRIES,

Callers 15

run_v6Function · 0.50
test_lpm6_perfFunction · 0.50
test5Function · 0.50
test9Function · 0.50
test10Function · 0.50
test11Function · 0.50
test13Function · 0.50
test14Function · 0.50
test15Function · 0.50
test16Function · 0.50
test17Function · 0.50

Calls 7

ip6_copy_addrFunction · 0.70
ip6_mask_addrFunction · 0.70
rule_deleteFunction · 0.70
rule_find_rangeFunction · 0.70
rule_find_less_specificFunction · 0.70
remove_tblFunction · 0.70
expand_ruleFunction · 0.70

Tested by 15

test_lpm6_perfFunction · 0.40
test5Function · 0.40
test9Function · 0.40
test10Function · 0.40
test11Function · 0.40
test13Function · 0.40
test14Function · 0.40
test15Function · 0.40
test16Function · 0.40
test17Function · 0.40
test18Function · 0.40
test19Function · 0.40