src/dpdk/lib/librte_lpm/rte_lpm6.c
static void
remove_tbl(struct rte_lpm6 *lpm, struct rte_lpm_tbl8_hdr *tbl_hdr,
		  uint32_t tbl_ind, struct rte_lpm6_rule *lsp_rule)
{
	struct rte_lpm6_tbl_entry *owner_entry;

	if (tbl_hdr->owner_tbl_ind == TBL24_IND)
		owner_entry = &lpm->tbl24[tbl_hdr->owner_entry_ind];
	else {
		uint32_t owner_tbl_ind = tbl_hdr->owner_tbl_ind;
		owner_entry = &lpm->tbl8[
			owner_tbl_ind * RTE_LPM6_TBL8_GROUP_NUM_ENTRIES +
			tbl_hdr->owner_entry_ind];

		struct rte_lpm_tbl8_hdr *owner_tbl_hdr =
			&lpm->tbl8_hdrs[owner_tbl_ind];
		if (--owner_tbl_hdr->ref_cnt == 0)
			remove_tbl(lpm, owner_tbl_hdr, owner_tbl_ind, lsp_rule);
	}

	assert(owner_entry->ext_entry == 1);

	/* unlink the table */
	if (lsp_rule != NULL) {
		struct rte_lpm6_tbl_entry new_tbl_entry = {
			.next_hop = lsp_rule->next_hop,
			.depth = lsp_rule->depth,
			.valid = VALID,
			.valid_group = VALID,
			.ext_entry = 0
		};

		*owner_entry = new_tbl_entry;
	} else {
		struct rte_lpm6_tbl_entry new_tbl_entry = {
			.next_hop = 0,
			.depth = 0,
			.valid = INVALID,
			.valid_group = INVALID,
			.ext_entry = 0
		};

		*owner_entry = new_tbl_entry;
	}

	/* return the table to the pool */
	tbl8_put(lpm, tbl_ind);
}
/*
 * Remove a table from the LPM tree
 */
Remove a table from the LPM tree
Remove a table from the LPM tree
static void
remove_tbl(struct rte_lpm6 *lpm, struct rte_lpm_tbl8_hdr *tbl_hdr,
		  uint32_t tbl_ind, struct rte_lpm6_rule *lsp_rule)
{
	struct rte_lpm6_tbl_entry *owner_entry;
	if (tbl_hdr->owner_tbl_ind == TBL24_IND)
		owner_entry = &lpm->tbl24[tbl_hdr->owner_entry_ind];
	else {
		uint32_t owner_tbl_ind = tbl_hdr->owner_tbl_ind;
		owner_entry = &lpm->tbl8[
			owner_tbl_ind * RTE_LPM6_TBL8_GROUP_NUM_ENTRIES +
			tbl_hdr->owner_entry_ind];
		struct rte_lpm_tbl8_hdr *owner_tbl_hdr =
			&lpm->tbl8_hdrs[owner_tbl_ind];
		if (--owner_tbl_hdr->ref_cnt == 0)
			remove_tbl(lpm, owner_tbl_hdr, owner_tbl_ind, lsp_rule);
	}
	assert(owner_entry->ext_entry == 1);
	if (lsp_rule != NULL) {
		struct rte_lpm6_tbl_entry new_tbl_entry = {
			.next_hop = lsp_rule->next_hop,
			.depth = lsp_rule->depth,
			.valid = VALID,
			.valid_group = VALID,
			.ext_entry = 0
		};
		*owner_entry = new_tbl_entry;
	} else {
		struct rte_lpm6_tbl_entry new_tbl_entry = {
			.next_hop = 0,
			.depth = 0,
			.valid = INVALID,
			.valid_group = INVALID,
			.ext_entry = 0
		};
		*owner_entry = new_tbl_entry;
	}
	tbl8_put(lpm, tbl_ind);
}
static void remove_tbl ( struct rte_lpm6 * lpm , struct rte_lpm_tbl8_hdr * tbl_hdr , uint32_t tbl_ind , struct rte_lpm6_rule * lsp_rule ) { struct rte_lpm6_tbl_entry * owner_entry ; if ( tbl_hdr -> owner_tbl_ind == TBL24_IND ) owner_entry = & lpm -> tbl24 [ tbl_hdr -> owner_entry_ind ] ; else { uint32_t owner_tbl_ind = tbl_hdr -> owner_tbl_ind ; owner_entry = & lpm -> tbl8 [ owner_tbl_ind * RTE_LPM6_TBL8_GROUP_NUM_ENTRIES + tbl_hdr -> owner_entry_ind ] ; struct rte_lpm_tbl8_hdr * owner_tbl_hdr = & lpm -> tbl8_hdrs [ owner_tbl_ind ] ; if ( -- owner_tbl_hdr -> ref_cnt == 0 ) remove_tbl ( lpm , owner_tbl_hdr , owner_tbl_ind , lsp_rule ) ; } assert ( owner_entry -> ext_entry == 1 ) ; if ( lsp_rule != NULL ) { struct rte_lpm6_tbl_entry new_tbl_entry = { . next_hop = lsp_rule -> next_hop , . depth = lsp_rule -> depth , . valid = VALID , . valid_group = VALID , . ext_entry = 0 } ; * owner_entry = new_tbl_entry ; } else { struct rte_lpm6_tbl_entry new_tbl_entry = { . next_hop = 0 , . depth = 0 , . valid = INVALID , . valid_group = INVALID , . ext_entry = 0 } ; * owner_entry = new_tbl_entry ; } tbl8_put ( lpm , tbl_ind ) ; }
Remove a table from the LPM tree
Remove a table from the LPM tree
/* unlink the table */ /* return the table to the pool */