bool test_tcp_v6_init_state_handle( void )
{
    struct sk_buff *skb;
    struct session_entry session;
    bool success = true;

    /* A V4 SYN packet arrives. */
    if (!init_skb_and_session(&skb, &session, PACKET_TYPE_V4_SYN, V6_INIT, 10))
        return false;

    success &= assert_true(tcp_v6_init_state_handle(skb, &session), "V4 syn-result");
    success &= assert_equals_u8(ESTABLISHED, session.state, "V4 syn-state");
    success &= assert_not_equals_int(10, session.dying_time, "V4 syn-lifetime");
    kfree_skb(skb);

    /* A V6 SYN packet arrives. */
    if (!init_skb_and_session(&skb, &session, PACKET_TYPE_V6_SYN, V6_INIT, 10))
        return false;

    success &= assert_true(tcp_v6_init_state_handle(skb, &session), "V6 syn-result");
    success &= assert_equals_u8(V6_INIT, session.state, "V6 syn-state");
    success &= assert_not_equals_int(10, session.dying_time, "V6 syn-lifetime");
    kfree_skb(skb);

    /* Something else arrives. */
    if (!init_skb_and_session(&skb, &session, PACKET_TYPE_V6_RST, V6_INIT, 10))
        return false;

    success &= assert_true(tcp_v6_init_state_handle(skb, &session), "else-result");
    success &= assert_equals_u8(V6_INIT, session.state, "else-state");
    success &= assert_equals_int(10, session.dying_time, "else-lifetime");
    kfree_skb(skb);

    return success;
}
Esempio n. 2
0
/*
 * Something else arrives.
 */
static bool test_tcp_v6_init_state_handle_else(void)
{
	struct session_entry *session;
	struct expire_timer *expirer;
	struct packet pkt;
	struct sk_buff *skb;
	bool success = true;

	/* Prepare */
	session = session_create_str_tcp("1::2", 1212, "3::4", 3434, "5.6.7.8", 5678, "8.7.6.5", 8765,
			V6_INIT);
	if (!session)
		return false;
	if (is_error(create_tcp_packet(&skb, L3PROTO_IPV6, false, true, false)))
		return false;
	if (is_error(pkt_init_ipv6(&pkt, skb)))
		return false;

	/* Evaluate */
	success &= assert_equals_int(0, tcp_v6_init_state_handle(&pkt, session, &expirer), "else-result");
	success &= assert_equals_u8(V6_INIT, session->state, "else-state");
	success &= assert_null(session->expirer, "null expirer");

	kfree_skb(skb);
	return success;
}
Esempio n. 3
0
/*
 * A V6 SYN packet arrives.
 */
static bool test_tcp_v6_init_state_handle_v6syn(void)
{
	struct session_entry *session;
	struct expire_timer *expirer;
	struct packet pkt;
	struct sk_buff *skb;
	unsigned long timeout = 0;
	bool success = true;

	/* Prepare */
	session = session_create_str_tcp("1::2", 1212, "3::4", 3434, "5.6.7.8", 5678, "8.7.6.5", 8765,
			V6_INIT);
	if (!session)
		return false;
	if (is_error(create_tcp_packet(&skb, L3PROTO_IPV6, true, false, false)))
		return false;
	if (is_error(pkt_init_ipv6(&pkt, skb)))
		return false;

	/* Evaluate */
	success &= assert_equals_int(0, tcp_v6_init_state_handle(&pkt, session, &expirer), "V6 syn-result");
	success &= assert_equals_u8(V6_INIT, session->state, "V6 syn-state");
	success &= assert_equals_int(0, sessiondb_get_timeout(session, &timeout), "V6 syn-toresult");
	success &= assert_equals_ulong(TCPTRANS_TIMEOUT, timeout, "V6 syn-lifetime");

	kfree_skb(skb);
	return success;
}