File: lsfd-bug-fix-scan-the-protocol-field-of-proc-net-packet-a.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 (59 lines) | stat: -rw-r--r-- 2,383 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
From: Masatake YAMATO <yamato@redhat.com>
Date: Mon, 6 Jan 2025 03:30:25 +0900
Subject: lsfd: (bug fix) scan the protocol field of /proc/net/packet as a hex
 number

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
(cherry picked from commit 0da7e8201aa7b9b2c5d0e901c0ccfd6f3bdc54d3)
---
 lsfd-cmd/sock-xinfo.c                          | 2 +-
 tests/expected/lsfd/mkfds-mapped-packet-socket | 4 ++--
 tests/ts/lsfd/mkfds-mapped-packet-socket       | 3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lsfd-cmd/sock-xinfo.c b/lsfd-cmd/sock-xinfo.c
index f681121..42d8e09 100644
--- a/lsfd-cmd/sock-xinfo.c
+++ b/lsfd-cmd/sock-xinfo.c
@@ -2373,7 +2373,7 @@ static void load_xinfo_from_proc_packet(ino_t netns_inode)
 		unsigned long inode;
 		struct packet_xinfo *pkt;
 
-		if (sscanf(line, "%*x %*d %" SCNu16 " %" SCNu16 " %u %*d %*d %*d %lu",
+		if (sscanf(line, "%*x %*d %" SCNu16 " %" SCNx16 " %u %*d %*d %*d %lu",
 			   &type, &protocol, &iface, &inode) < 4)
 			continue;
 
diff --git a/tests/expected/lsfd/mkfds-mapped-packet-socket b/tests/expected/lsfd/mkfds-mapped-packet-socket
index ec8795b..2e9db5e 100644
--- a/tests/expected/lsfd/mkfds-mapped-packet-socket
+++ b/tests/expected/lsfd/mkfds-mapped-packet-socket
@@ -1,8 +1,8 @@
 PACKET
 SOCK.PROTONAME: 0
-type=raw protocol=all iface=lo raw PACKET lo all
+type=raw protocol=ppptalk iface=lo raw PACKET lo ppptalk
 NAME,SOCK.TYPE,SOCK.PROTONAME,PACKET.IFACE,PACKET.PROTOCOL: 0
 PACKET
 SOCK.PROTONAME: 0
-type=dgram protocol=all iface=lo dgram PACKET lo all
+type=dgram protocol=ppptalk iface=lo dgram PACKET lo ppptalk
 NAME,SOCK.TYPE,SOCK.PROTONAME,PACKET.IFACE,PACKET.PROTOCOL: 0
diff --git a/tests/ts/lsfd/mkfds-mapped-packet-socket b/tests/ts/lsfd/mkfds-mapped-packet-socket
index 12c5ef6..c3a73c5 100755
--- a/tests/ts/lsfd/mkfds-mapped-packet-socket
+++ b/tests/ts/lsfd/mkfds-mapped-packet-socket
@@ -35,11 +35,12 @@ FD=3
 EXPR=
 INTERFACE=lo
 SOCKTYPE=
+PROTOCOL=$(printf "%d" 0x10)
 ERR=
 
 for SOCKTYPE in RAW DGRAM; do
     coproc MKFDS { "$TS_HELPER_MKFDS" mapped-packet-socket $FD \
-				      interface=${INTERFACE} socktype=${SOCKTYPE}; }
+				      interface=${INTERFACE} socktype=${SOCKTYPE} protocol=${PROTOCOL}; }
     if read -u ${MKFDS[0]} PID; then
 	EXPR='(ASSOC == "shm") and (STTYPE == "SOCK") and (MODE == "-w-")'
 	${TS_CMD_LSFD} -p "$PID" -n -o SOCK.PROTONAME -Q "${EXPR}"