tools/testing/selftests/net/tcp_ao/lib/aolib.h

Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/tcp_ao/lib/aolib.h

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/tcp_ao/lib/aolib.h
Extension
.h
Size
24661 bytes
Lines
833
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct tcp_ao_key_counters {
	uint8_t sndid;
	uint8_t rcvid;
	uint64_t pkt_good;
	uint64_t pkt_bad;
};

struct tcp_ao_counters {
	/* per-netns */
	uint64_t netns_ao_good;
	uint64_t netns_ao_bad;
	uint64_t netns_ao_key_not_found;
	uint64_t netns_ao_required;
	uint64_t netns_ao_dropped_icmp;
	/* per-socket */
	uint64_t ao_info_pkt_good;
	uint64_t ao_info_pkt_bad;
	uint64_t ao_info_pkt_key_not_found;
	uint64_t ao_info_pkt_ao_required;
	uint64_t ao_info_pkt_dropped_icmp;
	/* per-key */
	size_t nr_keys;
	struct tcp_ao_key_counters *key_cnts;
};

struct tcp_counters {
	struct tcp_ao_counters ao;
	uint64_t netns_md5_notfound;
	uint64_t netns_md5_unexpected;
	uint64_t netns_md5_failure;
};

extern int test_get_tcp_counters(int sk, struct tcp_counters *out);

#define TEST_CNT_KEY_GOOD		BIT(0)
#define TEST_CNT_KEY_BAD		BIT(1)
#define TEST_CNT_SOCK_GOOD		BIT(2)
#define TEST_CNT_SOCK_BAD		BIT(3)
#define TEST_CNT_SOCK_KEY_NOT_FOUND	BIT(4)
#define TEST_CNT_SOCK_AO_REQUIRED	BIT(5)
#define TEST_CNT_SOCK_DROPPED_ICMP	BIT(6)
#define TEST_CNT_NS_GOOD		BIT(7)
#define TEST_CNT_NS_BAD			BIT(8)
#define TEST_CNT_NS_KEY_NOT_FOUND	BIT(9)
#define TEST_CNT_NS_AO_REQUIRED		BIT(10)
#define TEST_CNT_NS_DROPPED_ICMP	BIT(11)
#define TEST_CNT_NS_MD5_NOT_FOUND	BIT(12)
#define TEST_CNT_NS_MD5_UNEXPECTED	BIT(13)
#define TEST_CNT_NS_MD5_FAILURE		BIT(14)
typedef uint16_t test_cnt;

#define _for_each_counter(f)						\
do {									\
	/* per-netns */							\
	f(ao.netns_ao_good,		TEST_CNT_NS_GOOD);		\
	f(ao.netns_ao_bad,		TEST_CNT_NS_BAD);		\
	f(ao.netns_ao_key_not_found,	TEST_CNT_NS_KEY_NOT_FOUND);	\
	f(ao.netns_ao_required,		TEST_CNT_NS_AO_REQUIRED);	\
	f(ao.netns_ao_dropped_icmp,	TEST_CNT_NS_DROPPED_ICMP);	\
	/* per-socket */						\
	f(ao.ao_info_pkt_good,		TEST_CNT_SOCK_GOOD);		\
	f(ao.ao_info_pkt_bad,		TEST_CNT_SOCK_BAD);		\
	f(ao.ao_info_pkt_key_not_found,	TEST_CNT_SOCK_KEY_NOT_FOUND);	\
	f(ao.ao_info_pkt_ao_required,	TEST_CNT_SOCK_AO_REQUIRED);	\
	f(ao.ao_info_pkt_dropped_icmp,	TEST_CNT_SOCK_DROPPED_ICMP);	\
	/* non-AO */							\
	f(netns_md5_notfound,		TEST_CNT_NS_MD5_NOT_FOUND);	\
	f(netns_md5_unexpected,		TEST_CNT_NS_MD5_UNEXPECTED);	\
	f(netns_md5_failure,		TEST_CNT_NS_MD5_FAILURE);	\
} while (0)

#define TEST_CNT_AO_GOOD		(TEST_CNT_SOCK_GOOD | TEST_CNT_NS_GOOD)
#define TEST_CNT_AO_BAD			(TEST_CNT_SOCK_BAD | TEST_CNT_NS_BAD)
#define TEST_CNT_AO_KEY_NOT_FOUND	(TEST_CNT_SOCK_KEY_NOT_FOUND | \
					 TEST_CNT_NS_KEY_NOT_FOUND)
#define TEST_CNT_AO_REQUIRED		(TEST_CNT_SOCK_AO_REQUIRED | \
					 TEST_CNT_NS_AO_REQUIRED)
#define TEST_CNT_AO_DROPPED_ICMP	(TEST_CNT_SOCK_DROPPED_ICMP | \
					 TEST_CNT_NS_DROPPED_ICMP)
#define TEST_CNT_GOOD			(TEST_CNT_KEY_GOOD | TEST_CNT_AO_GOOD)
#define TEST_CNT_BAD			(TEST_CNT_KEY_BAD | TEST_CNT_AO_BAD)

extern test_cnt test_cmp_counters(struct tcp_counters *before,
				  struct tcp_counters *after);
extern int test_assert_counters_sk(const char *tst_name,
		struct tcp_counters *before, struct tcp_counters *after,
		test_cnt expected);
extern int test_assert_counters_key(const char *tst_name,
		struct tcp_ao_counters *before, struct tcp_ao_counters *after,
		test_cnt expected, int sndid, int rcvid);

Annotation

Implementation Notes