* Test for recycle of tbl8 * - step 1: add a rule with depth=28 (> 24) * - step 2: add a rule with same 24-bit prefix and depth=23 (< 24) * - step 3: delete the first rule * - step 4: check tbl8 is freed * - step 5: add a rule same as the first one (depth=28) * - step 6: check same tbl8 is allocated * - step 7: add a rule with same 24-bit prefix and depth=24 * - step 8: delete the
| 1220 | * - setp 11: check same tbl8 is allocated again |
| 1221 | */ |
| 1222 | int32_t |
| 1223 | test18(void) |
| 1224 | { |
| 1225 | #define group_idx next_hop |
| 1226 | struct rte_lpm *lpm = NULL; |
| 1227 | struct rte_lpm_config config; |
| 1228 | uint32_t ip, next_hop; |
| 1229 | uint8_t depth; |
| 1230 | uint32_t tbl8_group_index; |
| 1231 | |
| 1232 | config.max_rules = MAX_RULES; |
| 1233 | config.number_tbl8s = NUMBER_TBL8S; |
| 1234 | config.flags = 0; |
| 1235 | |
| 1236 | lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config); |
| 1237 | TEST_LPM_ASSERT(lpm != NULL); |
| 1238 | |
| 1239 | ip = RTE_IPV4(192, 168, 100, 100); |
| 1240 | depth = 28; |
| 1241 | next_hop = 1; |
| 1242 | rte_lpm_add(lpm, ip, depth, next_hop); |
| 1243 | |
| 1244 | TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group); |
| 1245 | tbl8_group_index = lpm->tbl24[ip>>8].group_idx; |
| 1246 | |
| 1247 | depth = 23; |
| 1248 | next_hop = 2; |
| 1249 | rte_lpm_add(lpm, ip, depth, next_hop); |
| 1250 | TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group); |
| 1251 | |
| 1252 | depth = 28; |
| 1253 | rte_lpm_delete(lpm, ip, depth); |
| 1254 | |
| 1255 | TEST_LPM_ASSERT(!lpm->tbl24[ip>>8].valid_group); |
| 1256 | |
| 1257 | next_hop = 3; |
| 1258 | rte_lpm_add(lpm, ip, depth, next_hop); |
| 1259 | |
| 1260 | TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group); |
| 1261 | TEST_LPM_ASSERT(tbl8_group_index == lpm->tbl24[ip>>8].group_idx); |
| 1262 | |
| 1263 | depth = 24; |
| 1264 | next_hop = 4; |
| 1265 | rte_lpm_add(lpm, ip, depth, next_hop); |
| 1266 | TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group); |
| 1267 | |
| 1268 | depth = 28; |
| 1269 | rte_lpm_delete(lpm, ip, depth); |
| 1270 | |
| 1271 | TEST_LPM_ASSERT(!lpm->tbl24[ip>>8].valid_group); |
| 1272 | |
| 1273 | next_hop = 5; |
| 1274 | rte_lpm_add(lpm, ip, depth, next_hop); |
| 1275 | |
| 1276 | TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group); |
| 1277 | TEST_LPM_ASSERT(tbl8_group_index == lpm->tbl24[ip>>8].group_idx); |
| 1278 | |
| 1279 | rte_lpm_free(lpm); |
nothing calls this directly
no test coverage detected