static bool daniel_test(void) { bool success = true; success &= test_6to4("::", NULL); success &= test_6to4("ffff::ffff", NULL); success &= test_4to6("0.0.0.0", NULL); success &= test_4to6("255.255.255.255", NULL); success &= add_entry("10.0.0.0", 30, "2001:db8::0", 126); success &= add_entry("10.0.0.12", 30, "2001:db8::4", 126); success &= add_entry("10.0.0.16", 28, "2001:db8::20", 124); success &= add_entry("10.0.0.254", 32, "2001:db8::111", 128); success &= add_entry("10.0.1.0", 24, "2001:db8::200", 120); if (!success) return false; success &= test("10.0.0.2", "2001:db8::2"); success &= test("10.0.0.14", "2001:db8::6"); success &= test("10.0.0.27", "2001:db8::2b"); success &= test("10.0.0.254", "2001:db8::111"); success &= test("10.0.1.15", "2001:db8::20f"); success &= test_6to4("2001:db8::8", NULL); success &= test_6to4("8000::", NULL); /* "test first bit doesn't match root". */ success &= test_6to4("8000::", NULL); success &= test_4to6("128.0.0.0", NULL); return success; }
int init_module(void) { START_TESTS("Outgoing"); if (!init()) return -EINVAL; CALL_TEST(test_6to4(L4PROTO_UDP), "Tuple-5, 6 to 4, UDP"); CALL_TEST(test_4to6(L4PROTO_UDP), "Tuple-5, 4 to 6, UDP"); CALL_TEST(test_6to4(L4PROTO_TCP), "Tuple-5, 6 to 4, TCP"); CALL_TEST(test_4to6(L4PROTO_TCP), "Tuple-5, 4 to 6, TCP"); CALL_TEST(test_6to4(L4PROTO_ICMP), "Tuple-3, 6 to 4, ICMP"); CALL_TEST(test_4to6(L4PROTO_ICMP), "Tuple-3, 4 to 6, ICMP"); cleanup(); END_TESTS; }
static bool remove_test(void) { bool success = true; /* trie is empty */ success &= remove_entry("10.0.0.0", 24, "1::", 120, -ESRCH); /* trie is one node high */ success &= add_entry("20.0.0.0", 25, "2::", 121); success &= remove_entry("30.0.0.1", 25, NULL, 0, -ESRCH); success &= remove_entry("20.0.0.130", 25, NULL, 0, -ESRCH); success &= remove_entry("20.0.0.120", 25, NULL, 0, 0); success &= add_entry("30.0.0.0", 24, "3::", 120); success &= test("30.0.0.0", "3::"); success &= remove_entry(NULL, 0, "3::1:0", 120, -ESRCH); success &= test("30.0.0.0", "3::"); success &= remove_entry(NULL, 0, "3::0", 120, 0); success &= test_6to4("3::", NULL); success &= test_4to6("30.0.0.0", NULL); success &= ASSERT_U64(0ULL, eamt.count, "Table count"); if (!success) return false; /* trie is two nodes high */ success &= create_two_story_trie(); success &= remove_entry(NULL, 0, "1::10", 124, 0); success &= test("1.0.0.0", "1::00"); success &= test_6to4("1::10", "1.0.0.0"); success &= test_4to6("2.0.0.0", NULL); success &= test("3.0.0.0", "1::20"); eamt_flush(); success &= create_two_story_trie(); success &= remove_entry(NULL, 0, "1::20", 124, 0); success &= test("1.0.0.0", "1::00"); success &= test("2.0.0.0", "1::10"); success &= test_6to4("1::20", "1.0.0.0"); success &= test_4to6("3.0.0.0", NULL); eamt_flush(); success &= create_two_story_trie(); success &= remove_entry(NULL, 0, "1::00", 120, 0); success &= test_6to4("1::00", NULL); success &= test_4to6("1.0.0.0", NULL); success &= test("2.0.0.0", "1::10"); success &= test("3.0.0.0", "1::20"); eamt_flush(); /* trie is three or more nodes high */ success &= create_four_story_trie(); success &= remove_entry(NULL, 0, "1::", 16, 0); success &= test_6to4("1::", NULL); success &= test_4to6("1.0.0.0", NULL); success &= test("2.0.0.0", "1:1::"); success &= test("3.0.0.0", "1:2::"); success &= test("4.0.0.0", "1:1:1::"); success &= test("5.0.0.0", "1:1:2::"); success &= test("6.0.0.0", "1:2:1::"); success &= test("7.0.0.0", "1:2:1:1::"); eamt_flush(); success &= create_four_story_trie(); success &= remove_entry(NULL, 0, "1:1::", 32, 0); success &= test("1.0.0.0", "1::"); success &= test_6to4("1:1::", "1.0.0.0"); success &= test("3.0.0.0", "1:2::"); success &= test("4.0.0.0", "1:1:1::"); success &= test("5.0.0.0", "1:1:2::"); success &= test("6.0.0.0", "1:2:1::"); success &= test("7.0.0.0", "1:2:1:1::"); eamt_flush(); success &= create_four_story_trie(); success &= remove_entry(NULL, 0, "1:2::", 32, 0); success &= test("1.0.0.0", "1::"); success &= test("2.0.0.0", "1:1::"); success &= test_6to4("1:2::", "1.0.0.0"); success &= test("4.0.0.0", "1:1:1::"); success &= test("5.0.0.0", "1:1:2::"); success &= test("6.0.0.0", "1:2:1::"); success &= test("7.0.0.0", "1:2:1:1::"); eamt_flush(); success &= create_four_story_trie(); success &= remove_entry(NULL, 0, "1:1:1::", 48, 0); success &= test("1.0.0.0", "1::"); success &= test("2.0.0.0", "1:1::"); success &= test("3.0.0.0", "1:2::"); success &= test_6to4("1:1:1::", "2.0.0.0"); success &= test("5.0.0.0", "1:1:2::"); success &= test("6.0.0.0", "1:2:1::"); success &= test("7.0.0.0", "1:2:1:1::"); eamt_flush(); success &= create_four_story_trie(); success &= remove_entry(NULL, 0, "1:1:2::", 48, 0); success &= test("1.0.0.0", "1::"); success &= test("2.0.0.0", "1:1::"); success &= test("3.0.0.0", "1:2::"); success &= test("4.0.0.0", "1:1:1::"); success &= test_6to4("1:1:2::", "2.0.0.0"); success &= test("6.0.0.0", "1:2:1::"); success &= test("7.0.0.0", "1:2:1:1::"); eamt_flush(); success &= create_four_story_trie(); success &= remove_entry(NULL, 0, "1:2:1::", 48, 0); success &= test("1.0.0.0", "1::"); success &= test("2.0.0.0", "1:1::"); success &= test("3.0.0.0", "1:2::"); success &= test("4.0.0.0", "1:1:1::"); success &= test("5.0.0.0", "1:1:2::"); success &= test_6to4("1:2:1::", "3.0.0.0"); success &= test("7.0.0.0", "1:2:1:1::"); eamt_flush(); success &= create_four_story_trie(); success &= remove_entry(NULL, 0, "1:2:1:1::", 64, 0); success &= test("1.0.0.0", "1::"); success &= test("2.0.0.0", "1:1::"); success &= test("3.0.0.0", "1:2::"); success &= test("4.0.0.0", "1:1:1::"); success &= test("5.0.0.0", "1:1:2::"); success &= test("6.0.0.0", "1:2:1::"); success &= test_6to4("1:2:1:1::", "6.0.0.0"); eamt_flush(); return success; }
static bool test(char *addr4, char *addr6) { return test_6to4(addr6, addr4) && test_4to6(addr4, addr6); }
static bool test_6to4frag_udp(void) { return test_6to4(L4PROTO_UDP, create_skb6frags_udp, create_skb4frags_udp, 100); }
static bool test_6to4frag_icmp(void) { return test_6to4(L4PROTO_ICMP, create_skb6frags_icmp, create_skb4frags_icmp, 100); }
static bool test_6to4frag_tcp(void) { return test_6to4(L4PROTO_TCP, create_skb6frags_tcp, create_skb4frags_tcp, 100); }
static bool test_6to4_icmp_error(void) { return test_6to4(L4PROTO_TCP, create_skb6_icmp_error, create_skb4_icmp_error, 80); }
static bool test_6to4_icmp_info(void) { return test_6to4(L4PROTO_ICMP, create_skb6_icmp_info, create_skb4_icmp_info, 100); }
static bool test_6to4_tcp(void) { return test_6to4(L4PROTO_TCP, create_skb6_tcp, create_skb4_tcp, 100); }
static bool test_6to4_udp(void) { return test_6to4(L4PROTO_UDP, create_skb6_udp, create_skb4_udp, 100); }