Skip to contentSkip to conversation

net-snmp: Fix systemstats_linux unexpected header length

PATCH In review Vijay Anusuri 2 participants 4 messages Dec 5, 2025 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net-snmp: Fix systemstats_linux unexpected header length

currently system journal contains:

snmpd[10442]: systemstats_linux: unexpected header length in /proc/net/snmp. 237 != 224

Backport a patch to fix this issue.

Upstream-Status: Backport [https://github.com/net-snmp/net-snmp/commit/49d60ba57f4b462df7dc5fd5b38b4425dab0982c]

Reference: https://github.com/net-snmp/net-snmp/issues/786

---
 ...-compatibility-parsing-proc-net-snmp.patch | 122 ++++++++++++++++++
 .../net-snmp/net-snmp_5.9.4.bb                |   1 +
 2 files changed, 123 insertions(+)
 create mode 100644 meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch
meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +122 -0
new file mode 100644
index 0000000000..2d9c310e39
@@ -0,0 +1,122 @@
+From 49d60ba57f4b462df7dc5fd5b38b4425dab0982c Mon Sep 17 00:00:00 2001
+From: Philippe Troin <[email protected]>
+Date: Sat, 3 Feb 2024 10:30:30 -0800
+Subject: [PATCH] Add Linux 6.7 compatibility parsing /proc/net/snmp
+
+Linux 6.7 adds a new OutTransmits field to Ip in /proc/net/snmp.
+This breaks the hard-coded assumptions about the Ip line length.
+Add compatibility to parse Linux 6.7 Ip header while keep support
+for previous versions.
+
+Upstream-Status: Backport [https://github.com/net-snmp/net-snmp/commit/49d60ba57f4b462df7dc5fd5b38b4425dab0982c]
+Signed-off-by: Vijay Anusuri <[email protected]>
+---
+ .../ip-mib/data_access/systemstats_linux.c    | 46 +++++++++++++++----
+ 1 file changed, 37 insertions(+), 9 deletions(-)
+
+diff --git a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
+index 49e0a34d5c..f04e828a94 100644
+--- a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
++++ b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
+@@ -36,7 +36,7 @@ netsnmp_access_systemstats_arch_init(void)
+ }
+ 
+ /*
+-  /proc/net/snmp
++  /proc/net/snmp - Linux 6.6 and lower
+ 
+   Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates
+   Ip: 2 64 7083534 0 0 0 0 0 6860233 6548963 0 0 1 286623 63322 1 259920 0 0
+@@ -49,6 +49,26 @@ netsnmp_access_systemstats_arch_init(void)
+   
+   Udp: InDatagrams NoPorts InErrors OutDatagrams
+   Udp: 1491094 122 0 1466178
++*
++  /proc/net/snmp - Linux 6.7 and higher
++
++  Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates OutTransmits
++  Ip: 1 64 50859058 496 0 37470604 0 0 20472980 7515791 1756 0 0 7264 3632 0 3548 0 7096 44961424
++
++  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
++  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
++
++  IcmpMsg: InType0 InType3 InType8 OutType0 OutType3 OutType8 OutType11
++  IcmpMsg: 29953 17589 66905 66905 16610 59957 484
++
++  Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors
++  Tcp: 1 200 120000 -1 17744 13525 307 3783 6 18093137 9277788 3499 8 7442 0
++
++  Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
++  Udp: 2257832 1422 0 2252835 0 0 0 84 0
++
++  UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
++  UdpLite: 0 0 0 0 0 0 0 0 0
+ */
+ 
+ 
+@@ -101,10 +121,10 @@ _systemstats_v4(netsnmp_container* container, u_int load_flags)
+     FILE           *devin;
+     char            line[1024];
+     netsnmp_systemstats_entry *entry = NULL;
+-    int             scan_count;
++    int             scan_count, expected_scan_count;
+     char           *stats, *start = line;
+     int             len;
+-    unsigned long long scan_vals[19];
++    unsigned long long scan_vals[20];
+ 
+     DEBUGMSGTL(("access:systemstats:container:arch", "load v4 (flags %x)\n",
+                 load_flags));
+@@ -126,10 +146,17 @@ _systemstats_v4(netsnmp_container* container, u_int load_flags)
+      */
+     NETSNMP_IGNORE_RESULT(fgets(line, sizeof(line), devin));
+     len = strlen(line);
+-    if (224 != len) {
++    switch (len) {
++    case 224:
++	expected_scan_count = 19;
++	break;
++    case 237:
++	expected_scan_count = 20;
++	break;
++    default:
+         fclose(devin);
+         snmp_log(LOG_ERR, "systemstats_linux: unexpected header length in /proc/net/snmp."
+-                 " %d != 224\n", len);
++                 " %d not in { 224, 237 } \n", len);
+         return -4;
+     }
+ 
+@@ -178,20 +205,20 @@ _systemstats_v4(netsnmp_container* container, u_int load_flags)
+         memset(scan_vals, 0x0, sizeof(scan_vals));
+         scan_count = sscanf(stats,
+                             "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu"
+-                            "%llu %llu %llu %llu %llu %llu %llu %llu %llu",
++                            "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu",
+                             &scan_vals[0],&scan_vals[1],&scan_vals[2],
+                             &scan_vals[3],&scan_vals[4],&scan_vals[5],
+                             &scan_vals[6],&scan_vals[7],&scan_vals[8],
+                             &scan_vals[9],&scan_vals[10],&scan_vals[11],
+                             &scan_vals[12],&scan_vals[13],&scan_vals[14],
+                             &scan_vals[15],&scan_vals[16],&scan_vals[17],
+-                            &scan_vals[18]);
++                            &scan_vals[18],&scan_vals[19]);
+         DEBUGMSGTL(("access:systemstats", "  read %d values\n", scan_count));
+ 
+-        if(scan_count != 19) {
++        if(scan_count != expected_scan_count) {
+             snmp_log(LOG_ERR,
+                      "error scanning systemstats data (expected %d, got %d)\n",
+-                     19, scan_count);
++                     expected_scan_count, scan_count);
+             netsnmp_access_systemstats_entry_free(entry);
+             return -4;
+         }
+@@ -223,6 +250,7 @@ _systemstats_v4(netsnmp_container* container, u_int load_flags)
+         entry->stats.HCOutFragFails.high = scan_vals[17] >> 32;
+         entry->stats.HCOutFragCreates.low = scan_vals[18] & 0xffffffff;
+         entry->stats.HCOutFragCreates.high = scan_vals[18] >> 32;
++        /* entry->stats. = scan_vals[19]; / * OutTransmits */
+ 
+         entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINRECEIVES] = 1;
+         entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INHDRERRORS] = 1;
meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.4.bb +1 -0
index f9572a1869..4b24520019 100644
@@ -28,6 +28,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.tar.gz \
            file://0011-ac_add_search_path.m4-keep-consistent-between-32bit-.patch \
            file://0012-Fix-configuration-of-NETSNMP_FD_MASK_TYPE.patch \
            file://0001-Android-Fix-the-build.patch \
+           file://0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch \
           "
 SRC_URI[sha256sum] = "8b4de01391e74e3c7014beb43961a2d6d6fa03acc34280b9585f4930745b0544"
 
Signature · 1 line
2.43.0
#1 lore raw

if this is meant for master then please rebase it on top of latest master or master-next and resend please.

Quoted 217 lines · Vijay Anusuri via lists.openembedded.org

currently system journal contains:

snmpd[10442]: systemstats_linux: unexpected header length in /proc/net/snmp. 237 != 224

Backport a patch to fix this issue.

Upstream-Status: Backport [
https://github.com/net-snmp/net-snmp/commit/49d60ba57f4b462df7dc5fd5b38b4425dab0982c
]

Reference: https://github.com/net-snmp/net-snmp/issues/786

---
 ...-compatibility-parsing-proc-net-snmp.patch | 122 ++++++++++++++++++
 .../net-snmp/net-snmp_5.9.4.bb                |   1 +
 2 files changed, 123 insertions(+)
 create mode 100644

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch

diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file mode 100644
index 0000000000..2d9c310e39
--- /dev/null
+++
b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +11 -0
@@ -0,0 +1,122 @@
+From 49d60ba57f4b462df7dc5fd5b38b4425dab0982c Mon Sep 17 00:00:00 2001
+From: Philippe Troin <[email protected]>
+Date: Sat, 3 Feb 2024 10:30:30 -0800
+Subject: [PATCH] Add Linux 6.7 compatibility parsing /proc/net/snmp
+
+Linux 6.7 adds a new OutTransmits field to Ip in /proc/net/snmp.
+This breaks the hard-coded assumptions about the Ip line length.
+Add compatibility to parse Linux 6.7 Ip header while keep support
+for previous versions.
+
+Upstream-Status: Backport [

https://github.com/net-snmp/net-snmp/commit/49d60ba57f4b462df7dc5fd5b38b4425dab0982c
]

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +6 -0
+Signed-off-by: Vijay Anusuri <[email protected]>
+---
+ .../ip-mib/data_access/systemstats_linux.c    | 46 +++++++++++++++----
+ 1 file changed, 37 insertions(+), 9 deletions(-)
+
+diff --git a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c

b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +11 -0
+index 49e0a34d5c..f04e828a94 100644
+--- a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
++++ b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
+@@ -36,7 +36,7 @@ netsnmp_access_systemstats_arch_init(void)
+ }
+
+ /*
+-  /proc/net/snmp
++  /proc/net/snmp - Linux 6.6 and lower
+
+   Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors

ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates
+ Ip: 2 64 7083534 0 0 0 0 0 6860233 6548963 0 0 1 286623 63322 1 259920
0 0
+@@ -49,6 +49,26 @@ netsnmp_access_systemstats_arch_init(void)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +7 -0
+
+   Udp: InDatagrams NoPorts InErrors OutDatagrams
+   Udp: 1491094 122 0 1466178
++*
++  /proc/net/snmp - Linux 6.7 and higher
++
++  Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors

ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates OutTransmits
++ Ip: 1 64 50859058 496 0 37470604 0 0 20472980 7515791 1756 0 0 7264 3632 0 3548 0 7096 44961424
++
++ 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
++ 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
++
++ IcmpMsg: InType0 InType3 InType8 OutType0 OutType3 OutType8 OutType11 ++ IcmpMsg: 29953 17589 66905 66905 16610 59957 484
++
++ Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors
++ Tcp: 1 200 120000 -1 17744 13525 307 3783 6 18093137 9277788 3499 8 7442 0
++
++ Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
++ Udp: 2257832 1422 0 2252835 0 0 0 84 0
++
++ UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
++ UdpLite: 0 0 0 0 0 0 0 0 0
+ */

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +3 -0
+
+
+@@ -101,10 +121,10 @@ _systemstats_v4(netsnmp_container* container, u_int

load_flags)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +11 -0
+     FILE           *devin;
+     char            line[1024];
+     netsnmp_systemstats_entry *entry = NULL;
+-    int             scan_count;
++    int             scan_count, expected_scan_count;
+     char           *stats, *start = line;
+     int             len;
+-    unsigned long long scan_vals[19];
++    unsigned long long scan_vals[20];
+
+     DEBUGMSGTL(("access:systemstats:container:arch", "load v4 (flags

%x)\n",
+ load_flags));
+@@ -126,10 +146,17 @@ _systemstats_v4(netsnmp_container* container, u_int load_flags)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +14 -0
+      */
+     NETSNMP_IGNORE_RESULT(fgets(line, sizeof(line), devin));
+     len = strlen(line);
+-    if (224 != len) {
++    switch (len) {
++    case 224:
++      expected_scan_count = 19;
++      break;
++    case 237:
++      expected_scan_count = 20;
++      break;
++    default:
+         fclose(devin);
+         snmp_log(LOG_ERR, "systemstats_linux: unexpected header length

in /proc/net/snmp."

+-                 " %d != 224\n", len);
++                 " %d not in { 224, 237 } \n", len);
meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +4 -0
+         return -4;
+     }
+
+@@ -178,20 +205,20 @@ _systemstats_v4(netsnmp_container* container, u_int

load_flags)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +3 -0
+         memset(scan_vals, 0x0, sizeof(scan_vals));
+         scan_count = sscanf(stats,
+                             "%llu %llu %llu %llu %llu %llu %llu %llu

%llu %llu"
+- "%llu %llu %llu %llu %llu %llu %llu %llu
%llu",
++ "%llu %llu %llu %llu %llu %llu %llu %llu
%llu %llu",

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +9 -0
+                             &scan_vals[0],&scan_vals[1],&scan_vals[2],
+                             &scan_vals[3],&scan_vals[4],&scan_vals[5],
+                             &scan_vals[6],&scan_vals[7],&scan_vals[8],
+                             &scan_vals[9],&scan_vals[10],&scan_vals[11],
+                             &scan_vals[12],&scan_vals[13],&scan_vals[14],
+                             &scan_vals[15],&scan_vals[16],&scan_vals[17],
+-                            &scan_vals[18]);
++                            &scan_vals[18],&scan_vals[19]);
+         DEBUGMSGTL(("access:systemstats", "  read %d values\n",

scan_count));

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +5 -0
+
+-        if(scan_count != 19) {
++        if(scan_count != expected_scan_count) {
+             snmp_log(LOG_ERR,
+                      "error scanning systemstats data (expected %d, got

%d)\n",

+-                     19, scan_count);
++                     expected_scan_count, scan_count);
meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +4 -0
+             netsnmp_access_systemstats_entry_free(entry);
+             return -4;
+         }
+@@ -223,6 +250,7 @@ _systemstats_v4(netsnmp_container* container, u_int

load_flags)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +7 -0
+         entry->stats.HCOutFragFails.high = scan_vals[17] >> 32;
+         entry->stats.HCOutFragCreates.low = scan_vals[18] & 0xffffffff;
+         entry->stats.HCOutFragCreates.high = scan_vals[18] >> 32;
++        /* entry->stats. = scan_vals[19]; / * OutTransmits */
+
+         entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINRECEIVES] = 1;
+         entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INHDRERRORS] = 1;
meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.4.bb +1 -0
index f9572a1869..4b24520019 100644
@@ -28,6 +28,7 @@ SRC_URI =
 "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.tar.gz \
 
 file://0011-ac_add_search_path.m4-keep-consistent-between-32bit-.patch \
            file://0012-Fix-configuration-of-NETSNMP_FD_MASK_TYPE.patch \
            file://0001-Android-Fix-the-build.patch \
+
 file://0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch \
           "

SRC_URI[sha256sum] =
"8b4de01391e74e3c7014beb43961a2d6d6fa03acc34280b9585f4930745b0544"

--
2.43.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#122335):
https://lists.openembedded.org/g/openembedded-devel/message/122335
Mute This Topic: https://lists.openembedded.org/mt/116626611/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

Hi Khem,

This patch is intended for the *scarthgap* branch. The issue has already been addressed in *master* by the following commit:

https://git.openembedded.org/meta-openembedded/commit/?id=8147a884c68d8fdd89939a8443a902b65297520c

Thanks & Regards,
Vijay

Quoted 225 lines · Khem Raj

if this is meant for master then please rebase it on top of latest master or master-next and resend please.

Quoted 219 lines · Vijay Anusuri via lists.openembedded.org

currently system journal contains:

snmpd[10442]: systemstats_linux: unexpected header length in /proc/net/snmp. 237 != 224

Backport a patch to fix this issue.

Upstream-Status: Backport [
https://github.com/net-snmp/net-snmp/commit/49d60ba57f4b462df7dc5fd5b38b4425dab0982c
]

Reference: https://github.com/net-snmp/net-snmp/issues/786

---
 ...-compatibility-parsing-proc-net-snmp.patch | 122 ++++++++++++++++++
 .../net-snmp/net-snmp_5.9.4.bb                |   1 +
 2 files changed, 123 insertions(+)
 create mode 100644

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch

diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file mode 100644
index 0000000000..2d9c310e39
--- /dev/null
+++
b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +11 -0
@@ -0,0 +1,122 @@
+From 49d60ba57f4b462df7dc5fd5b38b4425dab0982c Mon Sep 17 00:00:00 2001
+From: Philippe Troin <[email protected]>
+Date: Sat, 3 Feb 2024 10:30:30 -0800
+Subject: [PATCH] Add Linux 6.7 compatibility parsing /proc/net/snmp
+
+Linux 6.7 adds a new OutTransmits field to Ip in /proc/net/snmp.
+This breaks the hard-coded assumptions about the Ip line length.
+Add compatibility to parse Linux 6.7 Ip header while keep support
+for previous versions.
+
+Upstream-Status: Backport [

https://github.com/net-snmp/net-snmp/commit/49d60ba57f4b462df7dc5fd5b38b4425dab0982c
]

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +6 -0
+Signed-off-by: Vijay Anusuri <[email protected]>
+---
+ .../ip-mib/data_access/systemstats_linux.c    | 46 +++++++++++++++----
+ 1 file changed, 37 insertions(+), 9 deletions(-)
+
+diff --git a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c

b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +11 -0
+index 49e0a34d5c..f04e828a94 100644
+--- a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
++++ b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
+@@ -36,7 +36,7 @@ netsnmp_access_systemstats_arch_init(void)
+ }
+
+ /*
+-  /proc/net/snmp
++  /proc/net/snmp - Linux 6.6 and lower
+
+   Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors

ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates
+ Ip: 2 64 7083534 0 0 0 0 0 6860233 6548963 0 0 1 286623 63322 1
259920 0 0
+@@ -49,6 +49,26 @@ netsnmp_access_systemstats_arch_init(void)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +7 -0
+
+   Udp: InDatagrams NoPorts InErrors OutDatagrams
+   Udp: 1491094 122 0 1466178
++*
++  /proc/net/snmp - Linux 6.7 and higher
++
++  Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors

ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates OutTransmits
++ Ip: 1 64 50859058 496 0 37470604 0 0 20472980 7515791 1756 0 0 7264 3632 0 3548 0 7096 44961424
++
++ 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
++ 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
++
++ IcmpMsg: InType0 InType3 InType8 OutType0 OutType3 OutType8 OutType11 ++ IcmpMsg: 29953 17589 66905 66905 16610 59957 484
++
++ Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors
++ Tcp: 1 200 120000 -1 17744 13525 307 3783 6 18093137 9277788 3499 8 7442 0
++
++ Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
++ Udp: 2257832 1422 0 2252835 0 0 0 84 0
++
++ UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
++ UdpLite: 0 0 0 0 0 0 0 0 0
+ */

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +3 -0
+
+
+@@ -101,10 +121,10 @@ _systemstats_v4(netsnmp_container* container,

u_int load_flags)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +11 -0
+     FILE           *devin;
+     char            line[1024];
+     netsnmp_systemstats_entry *entry = NULL;
+-    int             scan_count;
++    int             scan_count, expected_scan_count;
+     char           *stats, *start = line;
+     int             len;
+-    unsigned long long scan_vals[19];
++    unsigned long long scan_vals[20];
+
+     DEBUGMSGTL(("access:systemstats:container:arch", "load v4 (flags

%x)\n",
+ load_flags));
+@@ -126,10 +146,17 @@ _systemstats_v4(netsnmp_container* container, u_int load_flags)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +14 -0
+      */
+     NETSNMP_IGNORE_RESULT(fgets(line, sizeof(line), devin));
+     len = strlen(line);
+-    if (224 != len) {
++    switch (len) {
++    case 224:
++      expected_scan_count = 19;
++      break;
++    case 237:
++      expected_scan_count = 20;
++      break;
++    default:
+         fclose(devin);
+         snmp_log(LOG_ERR, "systemstats_linux: unexpected header length

in /proc/net/snmp."

+-                 " %d != 224\n", len);
++                 " %d not in { 224, 237 } \n", len);
meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +4 -0
+         return -4;
+     }
+
+@@ -178,20 +205,20 @@ _systemstats_v4(netsnmp_container* container,

u_int load_flags)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +3 -0
+         memset(scan_vals, 0x0, sizeof(scan_vals));
+         scan_count = sscanf(stats,
+                             "%llu %llu %llu %llu %llu %llu %llu %llu

%llu %llu"
+- "%llu %llu %llu %llu %llu %llu %llu %llu
%llu",
++ "%llu %llu %llu %llu %llu %llu %llu %llu
%llu %llu",

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +9 -0
+                             &scan_vals[0],&scan_vals[1],&scan_vals[2],
+                             &scan_vals[3],&scan_vals[4],&scan_vals[5],
+                             &scan_vals[6],&scan_vals[7],&scan_vals[8],
+                             &scan_vals[9],&scan_vals[10],&scan_vals[11],
+
 &scan_vals[12],&scan_vals[13],&scan_vals[14],
+
 &scan_vals[15],&scan_vals[16],&scan_vals[17],
+-                            &scan_vals[18]);
++                            &scan_vals[18],&scan_vals[19]);
+         DEBUGMSGTL(("access:systemstats", "  read %d values\n",

scan_count));

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +5 -0
+
+-        if(scan_count != 19) {
++        if(scan_count != expected_scan_count) {
+             snmp_log(LOG_ERR,
+                      "error scanning systemstats data (expected %d, got

%d)\n",

+-                     19, scan_count);
++                     expected_scan_count, scan_count);
meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +4 -0
+             netsnmp_access_systemstats_entry_free(entry);
+             return -4;
+         }
+@@ -223,6 +250,7 @@ _systemstats_v4(netsnmp_container* container, u_int

load_flags)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +7 -0
+         entry->stats.HCOutFragFails.high = scan_vals[17] >> 32;
+         entry->stats.HCOutFragCreates.low = scan_vals[18] & 0xffffffff;
+         entry->stats.HCOutFragCreates.high = scan_vals[18] >> 32;
++        /* entry->stats. = scan_vals[19]; / * OutTransmits */
+
+         entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINRECEIVES] = 1;
+         entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INHDRERRORS] = 1;
meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.4.bb +1 -0
index f9572a1869..4b24520019 100644
@@ -28,6 +28,7 @@ SRC_URI =
 "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.tar.gz \
 
 file://0011-ac_add_search_path.m4-keep-consistent-between-32bit-.patch \
            file://0012-Fix-configuration-of-NETSNMP_FD_MASK_TYPE.patch \
            file://0001-Android-Fix-the-build.patch \
+
 file://0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch \
           "

SRC_URI[sha256sum] =
"8b4de01391e74e3c7014beb43961a2d6d6fa03acc34280b9585f4930745b0544"

--
2.43.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#122335):
https://lists.openembedded.org/g/openembedded-devel/message/122335
Mute This Topic: https://lists.openembedded.org/mt/116626611/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

I forgot to add scarthgap in the subject line. I will resend the patch again.

Thanks & Regards,
Vijay

Quoted 243 lines · Vijay Anusuri via lists.openembedded.org

Hi Khem,

This patch is intended for the *scarthgap* branch. The issue has already been addressed in *master* by the following commit:

https://git.openembedded.org/meta-openembedded/commit/?id=8147a884c68d8fdd89939a8443a902b65297520c

Thanks & Regards,
Vijay

Quoted 212 lines · Khem Raj

if this is meant for master then please rebase it on top of latest master or master-next and resend please.

Quoted 206 lines · Vijay Anusuri via lists.openembedded.org

currently system journal contains:

snmpd[10442]: systemstats_linux: unexpected header length in /proc/net/snmp. 237 != 224

Backport a patch to fix this issue.

Upstream-Status: Backport [
https://github.com/net-snmp/net-snmp/commit/49d60ba57f4b462df7dc5fd5b38b4425dab0982c
]

Reference: https://github.com/net-snmp/net-snmp/issues/786

---
 ...-compatibility-parsing-proc-net-snmp.patch | 122 ++++++++++++++++++
 .../net-snmp/net-snmp_5.9.4.bb                |   1 +
 2 files changed, 123 insertions(+)
 create mode 100644

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch

diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file mode 100644
index 0000000000..2d9c310e39
--- /dev/null
+++
b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +11 -0
@@ -0,0 +1,122 @@
+From 49d60ba57f4b462df7dc5fd5b38b4425dab0982c Mon Sep 17 00:00:00 2001
+From: Philippe Troin <[email protected]>
+Date: Sat, 3 Feb 2024 10:30:30 -0800
+Subject: [PATCH] Add Linux 6.7 compatibility parsing /proc/net/snmp
+
+Linux 6.7 adds a new OutTransmits field to Ip in /proc/net/snmp.
+This breaks the hard-coded assumptions about the Ip line length.
+Add compatibility to parse Linux 6.7 Ip header while keep support
+for previous versions.
+
+Upstream-Status: Backport [

https://github.com/net-snmp/net-snmp/commit/49d60ba57f4b462df7dc5fd5b38b4425dab0982c
]

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +6 -0
+Signed-off-by: Vijay Anusuri <[email protected]>
+---
+ .../ip-mib/data_access/systemstats_linux.c    | 46 +++++++++++++++----
+ 1 file changed, 37 insertions(+), 9 deletions(-)
+
+diff --git a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c

b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +11 -0
+index 49e0a34d5c..f04e828a94 100644
+--- a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
++++ b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
+@@ -36,7 +36,7 @@ netsnmp_access_systemstats_arch_init(void)
+ }
+
+ /*
+-  /proc/net/snmp
++  /proc/net/snmp - Linux 6.6 and lower
+
+   Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors

ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates
+ Ip: 2 64 7083534 0 0 0 0 0 6860233 6548963 0 0 1 286623 63322 1
259920 0 0
+@@ -49,6 +49,26 @@ netsnmp_access_systemstats_arch_init(void)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +7 -0
+
+   Udp: InDatagrams NoPorts InErrors OutDatagrams
+   Udp: 1491094 122 0 1466178
++*
++  /proc/net/snmp - Linux 6.7 and higher
++
++  Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors

ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates OutTransmits
++ Ip: 1 64 50859058 496 0 37470604 0 0 20472980 7515791 1756 0 0 7264 3632 0 3548 0 7096 44961424
++
++ 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
++ 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
++
++ IcmpMsg: InType0 InType3 InType8 OutType0 OutType3 OutType8 OutType11 ++ IcmpMsg: 29953 17589 66905 66905 16610 59957 484
++
++ Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors
++ Tcp: 1 200 120000 -1 17744 13525 307 3783 6 18093137 9277788 3499 8 7442 0
++
++ Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
++ Udp: 2257832 1422 0 2252835 0 0 0 84 0
++
++ UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
++ UdpLite: 0 0 0 0 0 0 0 0 0
+ */

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +3 -0
+
+
+@@ -101,10 +121,10 @@ _systemstats_v4(netsnmp_container* container,

u_int load_flags)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +11 -0
+     FILE           *devin;
+     char            line[1024];
+     netsnmp_systemstats_entry *entry = NULL;
+-    int             scan_count;
++    int             scan_count, expected_scan_count;
+     char           *stats, *start = line;
+     int             len;
+-    unsigned long long scan_vals[19];
++    unsigned long long scan_vals[20];
+
+     DEBUGMSGTL(("access:systemstats:container:arch", "load v4 (flags

%x)\n",
+ load_flags));
+@@ -126,10 +146,17 @@ _systemstats_v4(netsnmp_container* container, u_int load_flags)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +14 -0
+      */
+     NETSNMP_IGNORE_RESULT(fgets(line, sizeof(line), devin));
+     len = strlen(line);
+-    if (224 != len) {
++    switch (len) {
++    case 224:
++      expected_scan_count = 19;
++      break;
++    case 237:
++      expected_scan_count = 20;
++      break;
++    default:
+         fclose(devin);
+         snmp_log(LOG_ERR, "systemstats_linux: unexpected header length

in /proc/net/snmp."

+-                 " %d != 224\n", len);
++                 " %d not in { 224, 237 } \n", len);
meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +4 -0
+         return -4;
+     }
+
+@@ -178,20 +205,20 @@ _systemstats_v4(netsnmp_container* container,

u_int load_flags)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +3 -0
+         memset(scan_vals, 0x0, sizeof(scan_vals));
+         scan_count = sscanf(stats,
+                             "%llu %llu %llu %llu %llu %llu %llu %llu

%llu %llu"
+- "%llu %llu %llu %llu %llu %llu %llu %llu
%llu",
++ "%llu %llu %llu %llu %llu %llu %llu %llu
%llu %llu",

(quoted diff) +9 -0
+                             &scan_vals[0],&scan_vals[1],&scan_vals[2],
+                             &scan_vals[3],&scan_vals[4],&scan_vals[5],
+                             &scan_vals[6],&scan_vals[7],&scan_vals[8],
+
 &scan_vals[9],&scan_vals[10],&scan_vals[11],
+
 &scan_vals[12],&scan_vals[13],&scan_vals[14],
+
 &scan_vals[15],&scan_vals[16],&scan_vals[17],
+-                            &scan_vals[18]);
++                            &scan_vals[18],&scan_vals[19]);
+         DEBUGMSGTL(("access:systemstats", "  read %d values\n",

scan_count));

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +5 -0
+
+-        if(scan_count != 19) {
++        if(scan_count != expected_scan_count) {
+             snmp_log(LOG_ERR,
+                      "error scanning systemstats data (expected %d,

got %d)\n",

+-                     19, scan_count);
++                     expected_scan_count, scan_count);
meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +4 -0
+             netsnmp_access_systemstats_entry_free(entry);
+             return -4;
+         }
+@@ -223,6 +250,7 @@ _systemstats_v4(netsnmp_container* container, u_int

load_flags)

meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch new file +7 -0
+         entry->stats.HCOutFragFails.high = scan_vals[17] >> 32;
+         entry->stats.HCOutFragCreates.low = scan_vals[18] & 0xffffffff;
+         entry->stats.HCOutFragCreates.high = scan_vals[18] >> 32;
++        /* entry->stats. = scan_vals[19]; / * OutTransmits */
+
+         entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINRECEIVES] = 1;
+         entry->stats.columnAvail[IPSYSTEMSTATSTABLE_INHDRERRORS] = 1;
(quoted diff) +0 -0

net-snmp_5.9.4.bb b/meta-networking/recipes-protocols/net-snmp/ net-snmp_5.9.4.bb
index f9572a1869..4b24520019 100644

meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.4.bb +1 -0
@@ -28,6 +28,7 @@ SRC_URI =
 "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.tar.gz \
 
 file://0011-ac_add_search_path.m4-keep-consistent-between-32bit-.patch \
            file://0012-Fix-configuration-of-NETSNMP_FD_MASK_TYPE.patch \
            file://0001-Android-Fix-the-build.patch \
+
 file://0001-Add-Linux-6.7-compatibility-parsing-proc-net-snmp.patch \
           "

SRC_URI[sha256sum] =
"8b4de01391e74e3c7014beb43961a2d6d6fa03acc34280b9585f4930745b0544"

Quoted 7 lines
Quoted 7 lines

--
2.43.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#122337):
https://lists.openembedded.org/g/openembedded-devel/message/122337
Mute This Topic: https://lists.openembedded.org/mt/116626611/7301997
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-