static bool test_icmp(void) { struct xlation state; struct sk_buff *skb; bool success = true; xlation_init(&state, &jool); log_debug("== IPv4 packet attempts to be translated without state =="); if (create_skb4_icmp_info("0.0.0.4", "192.0.2.128", 1024, 16, 32, &skb)) return false; if (pkt_init_ipv4(&state, skb)) return false; if (determine_in_tuple(&state) != VERDICT_CONTINUE) return false; success &= ASSERT_VERDICT(UNTRANSLATABLE, ipv4_simple(&state), "result 1"); success &= assert_bib_count(0, L4PROTO_ICMP); success &= assert_session_count(0, L4PROTO_ICMP); kfree_skb(skb); log_debug("== IPv6 packet and gets translated correctly =="); if (create_skb6_icmp_info("1::2", "3::4", 1212, 16, 32, &skb)) return false; if (pkt_init_ipv6(&state, skb)) return false; if (determine_in_tuple(&state) != VERDICT_CONTINUE) return false; success &= ASSERT_VERDICT(CONTINUE, ipv6_simple(&state), "result 2"); success &= assert_bib_count(1, L4PROTO_ICMP); success &= assert_bib_exists("1::2", 1212, "192.0.2.128", 1024, L4PROTO_ICMP, 1); success &= assert_session_count(1, L4PROTO_ICMP); success &= assert_session_exists("1::2", 1212, "3::4", 1212, "192.0.2.128", 1024, "0.0.0.4", 1024, L4PROTO_ICMP, ESTABLISHED, SESSION_TIMER_EST, ICMP_DEFAULT); kfree_skb(skb); log_debug("== Now that there's state, the IPv4 packet manages to traverse =="); if (!invert_packet(&state, &skb)) return false; success &= ASSERT_VERDICT(CONTINUE, ipv4_simple(&state), "result 3"); success &= assert_bib_count(1, L4PROTO_ICMP); success &= assert_bib_exists("1::2", 1212, "192.0.2.128", 1024, L4PROTO_ICMP, 1); success &= assert_session_count(1, L4PROTO_ICMP); success &= assert_session_exists("1::2", 1212, "3::4", 1212, "192.0.2.128", 1024, "0.0.0.4", 1024, L4PROTO_ICMP, ESTABLISHED, SESSION_TIMER_EST, ICMP_DEFAULT); kfree_skb(skb); return success; }
static bool test_icmp(void) { struct tuple tuple6; struct sk_buff *skb; bool success = true; if (is_error(init_ipv6_tuple(&tuple6, CLIENT_ADDR, CLIENT_PORT, SERVER_HAIRPIN_ADDR, SERVER_PORT6, L4PROTO_ICMP))) return false; if (is_error(create_skb6_icmp_info(&tuple6, &skb, 100, 32))) return false; set_sent_skb(NULL); success &= assert_equals_int(NF_DROP, core_6to4(skb), "Request result"); success &= assert_null(get_sent_skb(), "Sent SKB"); return success; }