summaryrefslogtreecommitdiffstats
path: root/meta-networking
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2025-03-29 08:24:15 -0700
committerKhem Raj <raj.khem@gmail.com>2025-03-29 09:31:02 -0700
commit8147a884c68d8fdd89939a8443a902b65297520c (patch)
tree5469477e57c3b03c647750a28e23b91129c296e2 /meta-networking
parente129534f679493df469e6edf85fe380547474a3d (diff)
downloadmeta-openembedded-8147a884c68d8fdd89939a8443a902b65297520c.tar.gz
net-snmp: Fix a crash and support for 6.7+ kernel
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-networking')
-rw-r--r--meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-5.9.4-kernel-6.7.patch123
-rw-r--r--meta-networking/recipes-protocols/net-snmp/net-snmp/netsnmp-swinst-crash.patch17
-rw-r--r--meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.4.bb2
3 files changed, 142 insertions, 0 deletions
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-5.9.4-kernel-6.7.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-5.9.4-kernel-6.7.patch
new file mode 100644
index 0000000000..3f978d5f80
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/net-snmp-5.9.4-kernel-6.7.patch
@@ -0,0 +1,123 @@
1From f5ae6baf0018abda9dedc368fe6d52c0d7a8ab8f Mon Sep 17 00:00:00 2001
2From: Philippe Troin <phil+github-commits@fifi.org>
3Date: Sat, 3 Feb 2024 10:30:30 -0800
4Subject: [PATCH] Add Linux 6.7 compatibility parsing /proc/net/snmp
5
6Linux 6.7 adds a new OutTransmits field to Ip in /proc/net/snmp.
7This breaks the hard-coded assumptions about the Ip line length.
8Add compatibility to parse Linux 6.7 Ip header while keep support
9for previous versions.
10
11Upstream-Status: Pending
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 .../ip-mib/data_access/systemstats_linux.c | 46 +++++++++++++++----
15 1 file changed, 37 insertions(+), 9 deletions(-)
16
17diff --git a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
18index 49e0a34d5c..f04e828a94 100644
19--- a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
20+++ b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
21@@ -36,7 +36,7 @@ netsnmp_access_systemstats_arch_init(void)
22 }
23
24 /*
25- /proc/net/snmp
26+ /proc/net/snmp - Linux 6.6 and lower
27
28 Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates
29 Ip: 2 64 7083534 0 0 0 0 0 6860233 6548963 0 0 1 286623 63322 1 259920 0 0
30@@ -49,6 +49,26 @@ netsnmp_access_systemstats_arch_init(void)
31
32 Udp: InDatagrams NoPorts InErrors OutDatagrams
33 Udp: 1491094 122 0 1466178
34+*
35+ /proc/net/snmp - Linux 6.7 and higher
36+
37+ Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates OutTransmits
38+ Ip: 1 64 50859058 496 0 37470604 0 0 20472980 7515791 1756 0 0 7264 3632 0 3548 0 7096 44961424
39+
40+ Icmp: InMsgs InErrors InCsumErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutRateLimitGlobal OutRateLimitHost OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps
41+ Icmp: 114447 2655 0 17589 0 0 0 0 66905 29953 0 0 0 0 143956 0 0 572 16610 484 0 0 0 59957 66905 0 0 0 0
42+
43+ IcmpMsg: InType0 InType3 InType8 OutType0 OutType3 OutType8 OutType11
44+ IcmpMsg: 29953 17589 66905 66905 16610 59957 484
45+
46+ Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors
47+ Tcp: 1 200 120000 -1 17744 13525 307 3783 6 18093137 9277788 3499 8 7442 0
48+
49+ Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
50+ Udp: 2257832 1422 0 2252835 0 0 0 84 0
51+
52+ UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
53+ UdpLite: 0 0 0 0 0 0 0 0 0
54 */
55
56
57@@ -101,10 +121,10 @@ _systemstats_v4(netsnmp_container* container, u_int load_flags)
58 FILE *devin;
59 char line[1024];
60 netsnmp_systemstats_entry *entry = NULL;
61- int scan_count;
62+ int scan_count, expected_scan_count;
63 char *stats, *start = line;
64 int len;
65- unsigned long long scan_vals[19];
66+ unsigned long long scan_vals[20];
67
68 DEBUGMSGTL(("access:systemstats:container:arch", "load v4 (flags %x)\n",
69 load_flags));
70@@ -126,10 +146,17 @@ _systemstats_v4(netsnmp_container* container, u_int load_flags)
71 */
72 NETSNMP_IGNORE_RESULT(fgets(line, sizeof(line), devin));
73 len = strlen(line);
74- if (224 != len) {
75+ switch (len) {
76+ case 224:
77+ expected_scan_count = 19;
78+ break;
79+ case 237:
80+ expected_scan_count = 20;
81+ break;
82+ default:
83 fclose(devin);
84 snmp_log(LOG_ERR, "systemstats_linux: unexpected header length in /proc/net/snmp."
85- " %d != 224\n", len);
86+ " %d not in { 224, 237 } \n", len);
87 return -4;
88 }
89
90@@ -178,20 +205,20 @@ _systemstats_v4(netsnmp_container* container, u_int load_flags)
91 memset(scan_vals, 0x0, sizeof(scan_vals));
92 scan_count = sscanf(stats,
93 "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu"
94- "%llu %llu %llu %llu %llu %llu %llu %llu %llu",
95+ "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu",
96 &scan_vals[0],&scan_vals[1],&scan_vals[2],
97 &scan_vals[3],&scan_vals[4],&scan_vals[5],
98 &scan_vals[6],&scan_vals[7],&scan_vals[8],
99 &scan_vals[9],&scan_vals[10],&scan_vals[11],
100 &scan_vals[12],&scan_vals[13],&scan_vals[14],
101 &scan_vals[15],&scan_vals[16],&scan_vals[17],
102- &scan_vals[18]);
103+ &scan_vals[18],&scan_vals[19]);
104 DEBUGMSGTL(("access:systemstats", " read %d values\n", scan_count));
105
106- if(scan_count != 19) {
107+ if(scan_count != expected_scan_count) {
108 snmp_log(LOG_ERR,
109 "error scanning systemstats data (expected %d, got %d)\n",
110- 19, scan_count);
111+ expected_scan_count, scan_count);
112 netsnmp_access_systemstats_entry_free(entry);
113 return -4;
114 }
115@@ -223,6 +250,7 @@ _systemstats_v4(netsnmp_container* container, u_int load_flags)
116 entry->stats.HCOutFragFails.high = scan_vals[17] >> 32;
117 entry->stats.HCOutFragCreates.low = scan_vals[18] & 0xffffffff;
118 entry->stats.HCOutFragCreates.high = scan_vals[18] >> 32;
119+ /* entry->stats. = scan_vals[19]; / * OutTransmits */
120
121 entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINRECEIVES] = 1;
122 entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INHDRERRORS] = 1;
123
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/netsnmp-swinst-crash.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/netsnmp-swinst-crash.patch
new file mode 100644
index 0000000000..109a0600a6
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/netsnmp-swinst-crash.patch
@@ -0,0 +1,17 @@
1Fix crash in swinst
2
3Upstream-Status: Pending
4Signed-off-by: Khem Raj <raj.khem@gmail.com>
5--- a/agent/mibgroup/host/data_access/swinst_pkginfo.c
6+++ b/agent/mibgroup/host/data_access/swinst_pkginfo.c
7@@ -210,7 +210,9 @@ netsnmp_swinst_arch_load( netsnmp_contai
8 memcpy( entry->swDate, cp, date_len );
9 entry->swDate_len = date_len;
10 }
11- closedir( d );
12+ if (d != NULL)
13+ closedir( d );
14+
15 #ifdef HAVE_LIBPKG
16 }
17 #endif
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.4.bb b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.4.bb
index 0840e4955b..6a62304a1c 100644
--- a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.4.bb
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.4.bb
@@ -28,6 +28,8 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.tar.gz \
28 file://0011-ac_add_search_path.m4-keep-consistent-between-32bit-.patch \ 28 file://0011-ac_add_search_path.m4-keep-consistent-between-32bit-.patch \
29 file://0012-Fix-configuration-of-NETSNMP_FD_MASK_TYPE.patch \ 29 file://0012-Fix-configuration-of-NETSNMP_FD_MASK_TYPE.patch \
30 file://0001-Android-Fix-the-build.patch \ 30 file://0001-Android-Fix-the-build.patch \
31 file://netsnmp-swinst-crash.patch \
32 file://net-snmp-5.9.4-kernel-6.7.patch \
31 " 33 "
32SRC_URI[sha256sum] = "8b4de01391e74e3c7014beb43961a2d6d6fa03acc34280b9585f4930745b0544" 34SRC_URI[sha256sum] = "8b4de01391e74e3c7014beb43961a2d6d6fa03acc34280b9585f4930745b0544"
33 35