* @internal helper function * Delete a rule of type SPI_DIP or SPI_DIP_SIP. * Deletes an entry from an appropriate hash table and decrements * an entry counter for given SPI. * If entry to remove is the last one with given SPI within the table, * then it will also update related entry in SPI_ONLY table. * Removes an entry from SPI_ONLY hash table if there no rule left * for this SPI in any
| 165 | * for this SPI in any table. |
| 166 | */ |
| 167 | static inline int |
| 168 | del_specific(struct rte_ipsec_sad *sad, const void *key, int key_type) |
| 169 | { |
| 170 | void *tmp_val; |
| 171 | int ret; |
| 172 | uint32_t *cnt; |
| 173 | |
| 174 | /* Remove an SA from the corresponding table.*/ |
| 175 | ret = rte_hash_del_key_with_hash(sad->hash[key_type], key, |
| 176 | rte_hash_crc(key, sad->keysize[key_type], sad->init_val)); |
| 177 | if (ret < 0) |
| 178 | return ret; |
| 179 | |
| 180 | /* Get an index of cnt_arr entry for a given SPI */ |
| 181 | ret = rte_hash_lookup_with_hash_data(sad->hash[RTE_IPSEC_SAD_SPI_ONLY], |
| 182 | key, rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY], |
| 183 | sad->init_val), &tmp_val); |
| 184 | if (ret < 0) |
| 185 | return ret; |
| 186 | cnt = (key_type == RTE_IPSEC_SAD_SPI_DIP) ? |
| 187 | &sad->cnt_arr[ret].cnt_dip : |
| 188 | &sad->cnt_arr[ret].cnt_dip_sip; |
| 189 | if (--(*cnt) != 0) |
| 190 | return 0; |
| 191 | |
| 192 | /* corresponding counter is 0, clear the bit indicating |
| 193 | * the presence of more specific rule for a given SPI. |
| 194 | */ |
| 195 | tmp_val = CLEAR_BIT(tmp_val, key_type); |
| 196 | |
| 197 | /* if there are no rules left with same SPI, |
| 198 | * remove an entry from SPI_only table |
| 199 | */ |
| 200 | if (tmp_val == NULL) |
| 201 | ret = rte_hash_del_key_with_hash( |
| 202 | sad->hash[RTE_IPSEC_SAD_SPI_ONLY], key, |
| 203 | rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY], |
| 204 | sad->init_val)); |
| 205 | else |
| 206 | ret = rte_hash_add_key_with_hash_data( |
| 207 | sad->hash[RTE_IPSEC_SAD_SPI_ONLY], key, |
| 208 | rte_hash_crc(key, sad->keysize[RTE_IPSEC_SAD_SPI_ONLY], |
| 209 | sad->init_val), tmp_val); |
| 210 | if (ret < 0) |
| 211 | return ret; |
| 212 | return 0; |
| 213 | } |
| 214 | |
| 215 | int |
| 216 | rte_ipsec_sad_del(struct rte_ipsec_sad *sad, |
no test coverage detected