File: tests-test_mkfds-mapped-packet-socket-add-a-new-parameter.patch

package info (click to toggle)
util-linux 2.41-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 95,208 kB
  • sloc: ansic: 179,016; sh: 22,689; yacc: 1,284; makefile: 528; xml: 422; python: 316; lex: 89; ruby: 75; csh: 37; exp: 19; sed: 16; perl: 15; sql: 9
file content (67 lines) | stat: -rw-r--r-- 2,289 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
From: Masatake YAMATO <yamato@redhat.com>
Date: Mon, 6 Jan 2025 03:49:46 +0900
Subject: tests: (test_mkfds::mapped-packet-socket) add a new parameter,
 protocol

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
(cherry picked from commit a6584a456835bbef703d7aae1f51d4e07177f8cb)
---
 tests/helpers/test_mkfds.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tests/helpers/test_mkfds.c b/tests/helpers/test_mkfds.c
index bde500b..5ceaa3f 100644
--- a/tests/helpers/test_mkfds.c
+++ b/tests/helpers/test_mkfds.c
@@ -1004,12 +1004,12 @@ static void *open_ro_blkdev(const struct factory *factory, struct fdesc fdescs[]
 	return NULL;
 }
 
-static int make_packet_socket(int socktype, const char *interface)
+static int make_packet_socket(int socktype, const char *interface, int protocol)
 {
 	int sd;
 	struct sockaddr_ll addr;
 
-	sd = socket(AF_PACKET, socktype, htons(ETH_P_ALL));
+	sd = socket(AF_PACKET, socktype, htons(protocol));
 	if (sd < 0)
 		err(EXIT_FAILURE, "failed to make a socket with AF_PACKET");
 
@@ -1050,9 +1050,11 @@ static void *make_mmapped_packet_socket(const struct factory *factory, struct fd
 	int sd;
 	struct arg socktype = decode_arg("socktype", factory->params, argc, argv);
 	struct arg interface = decode_arg("interface", factory->params, argc, argv);
+	struct arg protocol = decode_arg("protocol", factory->params, argc, argv);
 
 	int isocktype;
 	const char *sinterface;
+	int iprotocol;
 	struct tpacket_req req;
 	struct munmap_data *munmap_data;
 
@@ -1067,7 +1069,9 @@ static void *make_mmapped_packet_socket(const struct factory *factory, struct fd
 	free_arg(&socktype);
 
 	sinterface = ARG_STRING(interface);
-	sd = make_packet_socket(isocktype, sinterface);
+	iprotocol = ARG_INTEGER(protocol);
+	sd = make_packet_socket(isocktype, sinterface, iprotocol);
+	free_arg(&protocol);
 	free_arg(&interface);
 
 	/* Specify the spec of ring buffers.
@@ -3599,6 +3603,13 @@ static const struct factory factories[] = {
 				.desc = "a name of network interface like eth0 or lo",
 				.defv.string = "lo",
 			},
+			{
+				.name = "protocol",
+				.type = PTYPE_INTEGER,
+				.desc = "protocol passed to socket(AF_PACKET, *, htons(protocol))",
+				.defv.integer = ETH_P_ALL,
+			},
+
 			PARAM_END
 		},
 	},