net/handshake/handshake-test.c

Source file repositories/reference/linux-study-clean/net/handshake/handshake-test.c

File Facts

System
Linux kernel
Corpus path
net/handshake/handshake-test.c
Extension
.c
Size
14557 bytes
Lines
577
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

struct handshake_req_alloc_test_param {
	const char			*desc;
	struct handshake_proto		*proto;
	gfp_t				gfp;
	bool				expect_success;
};

static struct handshake_proto handshake_req_alloc_proto_2 = {
	.hp_handler_class	= HANDSHAKE_HANDLER_CLASS_NONE,
};

static struct handshake_proto handshake_req_alloc_proto_3 = {
	.hp_handler_class	= HANDSHAKE_HANDLER_CLASS_MAX,
};

static struct handshake_proto handshake_req_alloc_proto_4 = {
	.hp_handler_class	= HANDSHAKE_HANDLER_CLASS_TLSHD,
};

static struct handshake_proto handshake_req_alloc_proto_5 = {
	.hp_handler_class	= HANDSHAKE_HANDLER_CLASS_TLSHD,
	.hp_accept		= test_accept_func,
};

static struct handshake_proto handshake_req_alloc_proto_6 = {
	.hp_handler_class	= HANDSHAKE_HANDLER_CLASS_TLSHD,
	.hp_privsize		= UINT_MAX,
	.hp_accept		= test_accept_func,
	.hp_done		= test_done_func,
};

static struct handshake_proto handshake_req_alloc_proto_good = {
	.hp_handler_class	= HANDSHAKE_HANDLER_CLASS_TLSHD,
	.hp_accept		= test_accept_func,
	.hp_done		= test_done_func,
};

static const
struct handshake_req_alloc_test_param handshake_req_alloc_params[] = {
	{
		.desc			= "handshake_req_alloc NULL proto",
		.proto			= NULL,
		.gfp			= GFP_KERNEL,
		.expect_success		= false,
	},
	{
		.desc			= "handshake_req_alloc CLASS_NONE",
		.proto			= &handshake_req_alloc_proto_2,
		.gfp			= GFP_KERNEL,
		.expect_success		= false,
	},
	{
		.desc			= "handshake_req_alloc CLASS_MAX",
		.proto			= &handshake_req_alloc_proto_3,
		.gfp			= GFP_KERNEL,
		.expect_success		= false,
	},
	{
		.desc			= "handshake_req_alloc no callbacks",
		.proto			= &handshake_req_alloc_proto_4,
		.gfp			= GFP_KERNEL,
		.expect_success		= false,
	},
	{
		.desc			= "handshake_req_alloc no done callback",
		.proto			= &handshake_req_alloc_proto_5,
		.gfp			= GFP_KERNEL,
		.expect_success		= false,
	},
	{
		.desc			= "handshake_req_alloc excessive privsize",
		.proto			= &handshake_req_alloc_proto_6,
		.gfp			= GFP_KERNEL | __GFP_NOWARN,
		.expect_success		= false,
	},
	{
		.desc			= "handshake_req_alloc all good",
		.proto			= &handshake_req_alloc_proto_good,
		.gfp			= GFP_KERNEL,
		.expect_success		= true,
	},
};

static void
handshake_req_alloc_get_desc(const struct handshake_req_alloc_test_param *param,
			     char *desc)
{
	strscpy(desc, param->desc, KUNIT_PARAM_DESC_SIZE);
}

Annotation

Implementation Notes