/* * Adds 3 rules and look them up through the lookup_bulk function. * Includes in the lookup a fourth IP address that won't match * and checks that the result is as expected. */ int32_t test21(void) { struct rte_lpm6 *lpm = NULL; struct rte_lpm6_config config; uint8_t ip_batch[4][16]; uint8_t depth, next_hop_add; int16_t next_hop_return[4]; int32_t status = 0; config.max_rules = MAX_RULES; config.number_tbl8s = NUMBER_TBL8S; config.flags = 0; lpm = rte_lpm6_create(__func__, SOCKET_ID_ANY, &config); TEST_LPM_ASSERT(lpm != NULL); IPv6(ip_batch[0], 128, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 48; next_hop_add = 100; status = rte_lpm6_add(lpm, ip_batch[0], depth, next_hop_add); TEST_LPM_ASSERT(status == 0); IPv6(ip_batch[1], 128, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 48; next_hop_add = 101; status = rte_lpm6_add(lpm, ip_batch[1], depth, next_hop_add); TEST_LPM_ASSERT(status == 0); IPv6(ip_batch[2], 128, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 48; next_hop_add = 102; status = rte_lpm6_add(lpm, ip_batch[2], depth, next_hop_add); TEST_LPM_ASSERT(status == 0); IPv6(ip_batch[3], 128, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); status = rte_lpm6_lookup_bulk_func(lpm, ip_batch, next_hop_return, 4); TEST_LPM_ASSERT(status == 0 && next_hop_return[0] == 100 && next_hop_return[1] == 101 && next_hop_return[2] == 102 && next_hop_return[3] == -1); rte_lpm6_free(lpm); return PASS; }
static char Ethernet(u_char *bytes, unsigned long len) { struct ethhdr *eth; u_char *next; eth = (struct ethhdr *)bytes; /* pdu */ next = bytes + sizeof(struct ethhdr); len -= sizeof(struct ethhdr); switch (ntohs(eth->h_proto)) { case ETHERTYPE_IP: if (def) { if (ipv6f) return 0; } return IPv4(next, len); break; case ETHERTYPE_IPv6: if (def) { if (ipv6f == 0) return 0; } return IPv6(next, len); break; case ETHERTYPE_PPPOES: return PPPoE(next, len); break; } return 0; }
static char Ppp(u_char *bytes, unsigned long len) { unsigned char prot; int proto_offset; unsigned short ppp_prot; int nlen; u_char *next; /* PPP HDLC encapsulation */ if (*bytes == 0xff) { proto_offset = 2; } else { /* address and control are compressed (NULL) */ proto_offset = 0; } prot = *(bytes + proto_offset); len = 0; if (prot & PFC_BIT) { /* Compressed protocol field - just the byte we fetched. */ ppp_prot = prot; nlen = 1; } else { ppp_prot = ntohs(*((uint16_t *)(bytes + proto_offset))); nlen = 2; } /* pdu */ next = bytes + nlen + proto_offset; len -= nlen + proto_offset; switch (ppp_prot) { case ETHERTYPE_IP: if (def) { if (ipv6f) return 0; } return IPv4(next, len); break; case ETHERTYPE_IPv6: if (def) { if (ipv6f == 0) return 0; } return IPv6(next, len); break; } return 0; }
/* * Add an extended rule (i.e. depth greater than 24, lookup (hit), delete, * lookup (miss) in a for loop of 1000 times. This will check tbl8 extension * and contraction. */ int32_t test23(void) { struct rte_lpm6 *lpm = NULL; struct rte_lpm6_config config; uint32_t i; uint8_t ip[16]; uint8_t depth, next_hop_add, next_hop_return; int32_t status = 0; config.max_rules = MAX_RULES; config.number_tbl8s = NUMBER_TBL8S; config.flags = 0; lpm = rte_lpm6_create(__func__, SOCKET_ID_ANY, &config); TEST_LPM_ASSERT(lpm != NULL); IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 128; next_hop_add = 100; for (i = 0; i < 1000; i++) { status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT(status == -ENOENT); } rte_lpm6_free(lpm); return PASS; }
void OsSpecific::SetIPv6(bool enable) { bool curr, ok; try { curr = IPv6(); ok = true; } catch(...) {} bool doit = true; if (ok && (curr == enable)) doit = false; if (doit) { log::logt("Changing IPv6 state to: " + QString(enable ? "enabled" : "disabled")); #ifdef Q_OS_WIN HKEY hKey; LONG lRes = RegOpenKeyExW(HKEY_LOCAL_MACHINE, gs_regpath, 0, KEY_READ | KEY_WRITE, &hKey); if (lRes != ERROR_SUCCESS) { throw std::runtime_error("Cannot open IPv6 reg key for writing"); // another error } else { RegRaii ra(hKey); DWORD old = 0; DWORD val = 0; DWORD sz = sizeof(val); lRes = ::RegQueryValueExW(hKey, gs_regname, 0, NULL, reinterpret_cast<LPBYTE>(&val), &sz); if (ERROR_SUCCESS == lRes) old = val; if (enable) val = old & ( ~((DWORD)0x1)); else val = old | 0x1; lRes = ::RegSetValueEx(hKey, gs_regname, 0, REG_DWORD, reinterpret_cast<LPBYTE>(&val), sz); if (ERROR_SUCCESS != lRes) throw std::runtime_error(("IPv6 disabling failure code: " + QString::number(lRes)).toStdString().c_str()); } /* static const char * en = "netsh interface ipv6 set teredo client"; static const char * dis = "netsh interface ipv6 set teredo disabled"; const char * s = enable ? en : dis; int res = QProcess::execute(s); log::logt("IPv6 change state command return code: " + QString::number(res)); if (res != 0) throw std::runtime_error(("IPv6 change state failed with return code: " + QString::number(res)).toStdString().c_str()); */ #else #ifdef Q_OS_OSX static const char * gs_enable_ipv6 = "-setv6automatic"; static const char * gs_disable_ipv6 = "-setv6off"; const char * ac = enable ? gs_enable_ipv6 : gs_disable_ipv6; { QStringList a; a << ac << gs_wifi; ExecAsRoot(gs_ns, a); } { QStringList a; a << ac << gs_ether; ExecAsRoot(gs_ns, a); } #else throw std::logic_error("OsSpecific::SetIPv6() Not implemented for this OS"); #endif #endif // Q_OS_WIN } }
static char IPv4(u_char *bytes, unsigned long len) { struct iphdr *ip; size_t iphdr_len; size_t ip_len; u_char *next; ip = (struct iphdr *)bytes; /* IPv- or IPv4 */ if (ip->version != 4) { if (ip->version == 6) { return IPv6(bytes, len); } return 0; } /* IPv4 */ iphdr_len = ip->ihl << 2; ip_len = ntohs(ip->tot_len); if (ip_len > len) { return 0; } if (ip->frag_off != 0 && ip->frag_off != 0x40) { return 0; } next = bytes + iphdr_len; len = ip_len - iphdr_len; if (def == 0) { ipv6f = 0; ip_src = ip->saddr; ip_dst = ip->daddr; } else n_ip = ip; switch(ip->protocol) { case IP_PROTO_TCP: if (def) { if (udpf) return 0; } return Tcp(next, len); break; case IP_PROTO_UDP: if (def) { if (udpf == 0) return 0; } return Udp(next, len); break; case IP_PROTO_IPV6: if (def) { if (ipv6f == 0) return 0; } return IPv6(next, len); break; } return 0; }
char *WhereGr(FILE *fp,char *address, char *uqhn, char *domain, char *ipv4, char *ipv6) { // This model of "where?" is based on IP addresses and portnumbers, for cloud services // alternative models for "other worlds" can be added... static char where[CGN_BUFSIZE] = {0}; char attr[CGN_BUFSIZE]; if (domain == NULL || strlen(domain) == 0) { domain = "unknown domain"; } if (ipv6 && strlen(ipv6) > 0) { snprintf(where,CGN_BUFSIZE,"host location %s.%s IPv4 %s ipv6 %s",uqhn,domain,ipv4,ipv6); } else { snprintf(where,CGN_BUFSIZE,"host location %s.%s IPv4 %s",uqhn,domain,ipv4); } if (address && strlen(address) > 0) { snprintf(attr,CGN_BUFSIZE,"%s,%s,%s,%s,address %s",Hostname(uqhn),Domain(domain),IPv4(ipv4),IPv6(ipv6),address); } else { snprintf(attr,CGN_BUFSIZE,"%s,%s,%s,%s",Hostname(uqhn),Domain(domain),IPv4(ipv4),IPv6(ipv6)); } RoleGr(fp,where,"where",attr, "host location identification"); RoleGr(fp,Domain(domain),"dns domain name",domain,"host location identification"); char *hostname = Hostname(uqhn); RoleGr(fp,hostname,"hostname",uqhn,"host location identification"); Gr(fp,where,a_alias,hostname,"host location identification"); // Alias for quick association Gr(fp,Domain(domain),a_contains,hostname,"host location identification"); char *identity = HostID(uqhn); Gr(fp,hostname,a_alias,identity,"host location identification"); RoleGr(fp,IPv4(ipv4),"ipv4 address", ipv4,"host location identification"); Gr(fp,where,a_alias,IPv4(ipv4),"host location identification"); // Alias for quick association Gr(fp,Domain(domain),a_contains,IPv4(ipv4),"host location identification"); Gr(fp,IPv4(ipv4),a_alias,HostID(ipv4),"host location identification"); if (ipv6 && strlen(ipv6) > 0) { RoleGr(fp,IPv6(ipv6),"ipv6 address", ipv6,"host location identification"); Gr(fp,where,a_alias,IPv6(ipv6),"host location identification"); // Alias for quick association Gr(fp,Domain(domain),a_contains,IPv6(ipv6),"host location identification"); identity = HostID(ipv6); Gr(fp,IPv6(ipv6),a_alias,identity,"host location identification"); Gr(fp,hostname,a_alias,IPv6(ipv6),"host location identification"); } if (address && address > 0) { char addressx[CGN_BUFSIZE]; snprintf(addressx,CGN_BUFSIZE,"description address %s",address); RoleGr(fp,addressx,"description address",address,"host location identification"); Gr(fp,Domain(domain),a_origin,addressx,"host location identification"); Gr(fp,"description address",a_related_to,"street address","host location identification"); } Gr(fp,hostname,a_alias,IPv4(ipv4),"host location identification"); return where; }
/* * - Add & lookup to hit invalid TBL24 entry * - Add & lookup to hit valid TBL24 entry not extended * - Add & lookup to hit valid extended TBL24 entry with invalid TBL8 entry * - Add & lookup to hit valid extended TBL24 entry with valid TBL8 entry */ int32_t test18(void) { struct rte_lpm6 *lpm = NULL; struct rte_lpm6_config config; uint8_t ip[16], ip_1[16], ip_2[16]; uint8_t depth, depth_1, depth_2, next_hop_add, next_hop_add_1, next_hop_add_2, next_hop_return; int32_t status = 0; config.max_rules = MAX_RULES; config.number_tbl8s = NUMBER_TBL8S; config.flags = 0; /* Add & lookup to hit invalid TBL24 entry */ IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 24; next_hop_add = 100; lpm = rte_lpm6_create(__func__, SOCKET_ID_ANY, &config); TEST_LPM_ASSERT(lpm != NULL); status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT(status == -ENOENT); rte_lpm6_delete_all(lpm); /* Add & lookup to hit valid TBL24 entry not extended */ IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 23; next_hop_add = 100; status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); depth = 24; next_hop_add = 101; status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); depth = 24; status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status == 0); depth = 23; status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT(status == -ENOENT); rte_lpm6_delete_all(lpm); /* Add & lookup to hit valid extended TBL24 entry with invalid TBL8 * entry. */ IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 32; next_hop_add = 100; status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); IPv6(ip, 128, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 32; next_hop_add = 101; status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 32; next_hop_add = 100; status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT(status == -ENOENT); rte_lpm6_delete_all(lpm); /* Add & lookup to hit valid extended TBL24 entry with valid TBL8 * entry */ IPv6(ip_1, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth_1 = 25; next_hop_add_1 = 101; IPv6(ip_2, 128, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth_2 = 32; next_hop_add_2 = 102; next_hop_return = 0; status = rte_lpm6_add(lpm, ip_1, depth_1, next_hop_add_1); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip_1, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add_1)); status = rte_lpm6_add(lpm, ip_2, depth_2, next_hop_add_2); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip_2, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add_2)); status = rte_lpm6_delete(lpm, ip_2, depth_2); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip_2, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add_1)); status = rte_lpm6_delete(lpm, ip_1, depth_1); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip_1, &next_hop_return); TEST_LPM_ASSERT(status == -ENOENT); rte_lpm6_free(lpm); return PASS; }
/* * Adds 5 rules and look them up. * Use the delete_bulk function to delete two of them. Lookup again. * Use the delete_bulk function to delete one more. Lookup again. * Use the delete_bulk function to delete two more, one invalid. Lookup again. * Use the delete_bulk function to delete the remaining one. Lookup again. */ int32_t test22(void) { struct rte_lpm6 *lpm = NULL; struct rte_lpm6_config config; uint8_t ip_batch[5][16]; uint8_t depth[5], next_hop_add; int16_t next_hop_return[5]; int32_t status = 0; config.max_rules = MAX_RULES; config.number_tbl8s = NUMBER_TBL8S; config.flags = 0; lpm = rte_lpm6_create(__func__, SOCKET_ID_ANY, &config); TEST_LPM_ASSERT(lpm != NULL); /* Adds 5 rules and look them up */ IPv6(ip_batch[0], 128, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth[0] = 48; next_hop_add = 101; status = rte_lpm6_add(lpm, ip_batch[0], depth[0], next_hop_add); TEST_LPM_ASSERT(status == 0); IPv6(ip_batch[1], 128, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth[1] = 48; next_hop_add = 102; status = rte_lpm6_add(lpm, ip_batch[1], depth[1], next_hop_add); TEST_LPM_ASSERT(status == 0); IPv6(ip_batch[2], 128, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth[2] = 48; next_hop_add = 103; status = rte_lpm6_add(lpm, ip_batch[2], depth[2], next_hop_add); TEST_LPM_ASSERT(status == 0); IPv6(ip_batch[3], 128, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth[3] = 48; next_hop_add = 104; status = rte_lpm6_add(lpm, ip_batch[3], depth[3], next_hop_add); TEST_LPM_ASSERT(status == 0); IPv6(ip_batch[4], 128, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth[4] = 48; next_hop_add = 105; status = rte_lpm6_add(lpm, ip_batch[4], depth[4], next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup_bulk_func(lpm, ip_batch, next_hop_return, 5); TEST_LPM_ASSERT(status == 0 && next_hop_return[0] == 101 && next_hop_return[1] == 102 && next_hop_return[2] == 103 && next_hop_return[3] == 104 && next_hop_return[4] == 105); /* Use the delete_bulk function to delete two of them. Lookup again */ status = rte_lpm6_delete_bulk_func(lpm, &ip_batch[0], depth, 2); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup_bulk_func(lpm, ip_batch, next_hop_return, 5); TEST_LPM_ASSERT(status == 0 && next_hop_return[0] == -1 && next_hop_return[1] == -1 && next_hop_return[2] == 103 && next_hop_return[3] == 104 && next_hop_return[4] == 105); /* Use the delete_bulk function to delete one more. Lookup again */ status = rte_lpm6_delete_bulk_func(lpm, &ip_batch[2], depth, 1); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup_bulk_func(lpm, ip_batch, next_hop_return, 5); TEST_LPM_ASSERT(status == 0 && next_hop_return[0] == -1 && next_hop_return[1] == -1 && next_hop_return[2] == -1 && next_hop_return[3] == 104 && next_hop_return[4] == 105); /* Use the delete_bulk function to delete two, one invalid. Lookup again */ IPv6(ip_batch[4], 128, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); status = rte_lpm6_delete_bulk_func(lpm, &ip_batch[3], depth, 2); TEST_LPM_ASSERT(status == 0); IPv6(ip_batch[4], 128, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); status = rte_lpm6_lookup_bulk_func(lpm, ip_batch, next_hop_return, 5); TEST_LPM_ASSERT(status == 0 && next_hop_return[0] == -1 && next_hop_return[1] == -1 && next_hop_return[2] == -1 && next_hop_return[3] == -1 && next_hop_return[4] == 105); /* Use the delete_bulk function to delete the remaining one. Lookup again */ status = rte_lpm6_delete_bulk_func(lpm, &ip_batch[4], depth, 1); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup_bulk_func(lpm, ip_batch, next_hop_return, 5); TEST_LPM_ASSERT(status == 0 && next_hop_return[0] == -1 && next_hop_return[1] == -1 && next_hop_return[2] == -1 && next_hop_return[3] == -1 && next_hop_return[4] == -1); rte_lpm6_free(lpm); return PASS; }
/* * - Add rule that covers a TBL24 range previously invalid & lookup (& delete & * lookup) * - Add rule that extends a TBL24 invalid entry & lookup (& delete & lookup) * - Add rule that extends a TBL24 valid entry & lookup for both rules (& * delete & lookup) * - Add rule that updates the next hop in TBL24 & lookup (& delete & lookup) * - Add rule that updates the next hop in TBL8 & lookup (& delete & lookup) * - Delete a rule that is not present in the TBL24 & lookup * - Delete a rule that is not present in the TBL8 & lookup */ int32_t test19(void) { struct rte_lpm6 *lpm = NULL; struct rte_lpm6_config config; uint8_t ip[16]; uint8_t depth, next_hop_add, next_hop_return; int32_t status = 0; config.max_rules = MAX_RULES; config.number_tbl8s = NUMBER_TBL8S; config.flags = 0; /* Add rule that covers a TBL24 range previously invalid & lookup * (& delete & lookup) */ lpm = rte_lpm6_create(__func__, SOCKET_ID_ANY, &config); TEST_LPM_ASSERT(lpm != NULL); IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 16; next_hop_add = 100; status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT(status == -ENOENT); rte_lpm6_delete_all(lpm); IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 25; next_hop_add = 100; status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status == 0); rte_lpm6_delete_all(lpm); /* * Add rule that extends a TBL24 valid entry & lookup for both rules * (& delete & lookup) */ IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 24; next_hop_add = 100; status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); IPv6(ip, 128, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 32; next_hop_add = 101; status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); next_hop_add = 100; status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 24; status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT(status == -ENOENT); IPv6(ip, 128, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 32; status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT(status == -ENOENT); rte_lpm6_delete_all(lpm); /* * Add rule that updates the next hop in TBL24 & lookup * (& delete & lookup) */ IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 24; next_hop_add = 100; status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); next_hop_add = 101; status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT(status == -ENOENT); rte_lpm6_delete_all(lpm); /* * Add rule that updates the next hop in TBL8 & lookup * (& delete & lookup) */ IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 32; next_hop_add = 100; status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); next_hop_add = 101; status = rte_lpm6_add(lpm, ip, depth, next_hop_add); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add)); status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status == 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT(status == -ENOENT); rte_lpm6_delete_all(lpm); /* Delete a rule that is not present in the TBL24 & lookup */ IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 24; next_hop_add = 100; status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status < 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT(status == -ENOENT); rte_lpm6_delete_all(lpm); /* Delete a rule that is not present in the TBL8 & lookup */ IPv6(ip, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); depth = 32; next_hop_add = 100; status = rte_lpm6_delete(lpm, ip, depth); TEST_LPM_ASSERT(status < 0); status = rte_lpm6_lookup(lpm, ip, &next_hop_return); TEST_LPM_ASSERT(status == -ENOENT); rte_lpm6_free(lpm); return PASS; }