* Call insert, lookup/lookup_exact and delete for a single rule */
| 237 | * Call insert, lookup/lookup_exact and delete for a single rule |
| 238 | */ |
| 239 | int32_t |
| 240 | test_basic(void) |
| 241 | { |
| 242 | struct rte_rib6 *rib = NULL; |
| 243 | struct rte_rib6_node *node; |
| 244 | struct rte_rib6_conf config; |
| 245 | |
| 246 | uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE] = {192, 0, 2, 0, 0, 0, 0, 0, |
| 247 | 0, 0, 0, 0, 0, 0, 0, 0}; |
| 248 | uint64_t next_hop_add = 10; |
| 249 | uint64_t next_hop_return; |
| 250 | uint8_t depth = 24; |
| 251 | uint32_t status = 0; |
| 252 | |
| 253 | config.max_nodes = MAX_RULES; |
| 254 | config.ext_sz = 0; |
| 255 | |
| 256 | rib = rte_rib6_create(__func__, SOCKET_ID_ANY, &config); |
| 257 | RTE_TEST_ASSERT(rib != NULL, "Failed to create RIB\n"); |
| 258 | |
| 259 | node = rte_rib6_insert(rib, ip, depth); |
| 260 | RTE_TEST_ASSERT(node != NULL, "Failed to insert rule\n"); |
| 261 | |
| 262 | status = rte_rib6_set_nh(node, next_hop_add); |
| 263 | RTE_TEST_ASSERT(status == 0, |
| 264 | "Failed to set rte_rib_node field\n"); |
| 265 | |
| 266 | node = rte_rib6_lookup(rib, ip); |
| 267 | RTE_TEST_ASSERT(node != NULL, "Failed to lookup\n"); |
| 268 | |
| 269 | status = rte_rib6_get_nh(node, &next_hop_return); |
| 270 | RTE_TEST_ASSERT((status == 0) && (next_hop_add == next_hop_return), |
| 271 | "Failed to get proper nexthop\n"); |
| 272 | |
| 273 | node = rte_rib6_lookup_exact(rib, ip, depth); |
| 274 | RTE_TEST_ASSERT(node != NULL, |
| 275 | "Failed to lookup\n"); |
| 276 | |
| 277 | status = rte_rib6_get_nh(node, &next_hop_return); |
| 278 | RTE_TEST_ASSERT((status == 0) && (next_hop_add == next_hop_return), |
| 279 | "Failed to get proper nexthop\n"); |
| 280 | |
| 281 | rte_rib6_remove(rib, ip, depth); |
| 282 | |
| 283 | node = rte_rib6_lookup(rib, ip); |
| 284 | RTE_TEST_ASSERT(node == NULL, |
| 285 | "Lookup returns non existent rule\n"); |
| 286 | node = rte_rib6_lookup_exact(rib, ip, depth); |
| 287 | RTE_TEST_ASSERT(node == NULL, |
| 288 | "Lookup returns non existent rule\n"); |
| 289 | |
| 290 | rte_rib6_free(rib); |
| 291 | |
| 292 | return TEST_SUCCESS; |
| 293 | } |
| 294 | |
| 295 | int32_t |
| 296 | test_tree_traversal(void) |
nothing calls this directly
no test coverage detected