aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2017-04-21 06:16:00 +0800
committerglebius <glebius@FreeBSD.org>2017-04-21 06:16:00 +0800
commit6ffac0147ba5794d37625dbf08dead12032b30a4 (patch)
tree59a4a72fc918cc0fadf66c93407d0ca496c40eef
parente7b7ae1a5d2abec5cb66f4aafca5c708b70821ef (diff)
downloadfreebsd-ports-gnome-6ffac0147ba5794d37625dbf08dead12032b30a4.tar.gz
freebsd-ports-gnome-6ffac0147ba5794d37625dbf08dead12032b30a4.tar.zst
freebsd-ports-gnome-6ffac0147ba5794d37625dbf08dead12032b30a4.zip
Fixing net-snmpd after src revision r317061 (struct vmmeter changes),
I discovered that net-snmpd tries to read { CTL_VM, VM_TOTAL } mib into 'struct vmmeter' variable, instead of 'struct vmtotal'. Of course, sysctl(3) fails, but net-snmpd doesn't check for errors. Basicly this is broken for all supported FreeBSD versions, and I believe for all unsupported as well. OIDs that report interruprs, context switches, paging and swap in/out were returning garbage from the application stack. To patch that problem, provide dummy struct __vmmeter, which works both on pre-r317061 and after, and add block of code that reads all necessary stats one by one. To keep with the style of the file, do not check for errors from sysctl(3).
-rw-r--r--net-mgmt/net-snmp/Makefile2
-rw-r--r--net-mgmt/net-snmp/files/patch-agent_mibgroup_hardware_cpu_cpu_sysctl.c49
2 files changed, 50 insertions, 1 deletions
diff --git a/net-mgmt/net-snmp/Makefile b/net-mgmt/net-snmp/Makefile
index 1ae96ad7317b..e9e9c13e5bf8 100644
--- a/net-mgmt/net-snmp/Makefile
+++ b/net-mgmt/net-snmp/Makefile
@@ -3,7 +3,7 @@
PORTNAME= snmp
PORTVERSION= 5.7.3
-PORTREVISION= 15
+PORTREVISION= 16
CATEGORIES= net-mgmt ipv6
MASTER_SITES= SF/net-${PORTNAME}/net-${PORTNAME}/${PORTVERSION}
PKGNAMEPREFIX= net-
diff --git a/net-mgmt/net-snmp/files/patch-agent_mibgroup_hardware_cpu_cpu_sysctl.c b/net-mgmt/net-snmp/files/patch-agent_mibgroup_hardware_cpu_cpu_sysctl.c
new file mode 100644
index 000000000000..393c135c11b0
--- /dev/null
+++ b/net-mgmt/net-snmp/files/patch-agent_mibgroup_hardware_cpu_cpu_sysctl.c
@@ -0,0 +1,49 @@
+--- agent/mibgroup/hardware/cpu/cpu_sysctl.c.orig 2014-12-08 12:23:22.000000000 -0800
++++ agent/mibgroup/hardware/cpu/cpu_sysctl.c 2017-04-20 15:05:11.607496000 -0700
+@@ -130,8 +130,21 @@
+ #endif /* VM_UVMEXP2 || VM_UVMEXP */
+
+ #elif defined(__FreeBSD__) /* FreeBSD */
++#if __FreeBSD_version >= 1200028
++#define VMMETER_TYPE uint64_t
++#else
++#define VMMETER_TYPE u_int
++#endif
++struct __vmmeter {
++ VMMETER_TYPE v_intr;
++ VMMETER_TYPE v_swtch;
++ VMMETER_TYPE v_swappgsin;
++ VMMETER_TYPE v_swappgsout;
++ VMMETER_TYPE v_swapin;
++ VMMETER_TYPE v_swapout;
++};
+ #define NETSNMP_VM_STATS VM_METER
+-#define NETSNMP_VM_STATS_TYPE struct vmmeter
++#define NETSNMP_VM_STATS_TYPE struct __vmmeter
+ #define NS_VM_INTR v_intr
+ #define NS_VM_SWTCH v_swtch
+ #define NS_VM_PAGEIN v_swappgsin
+@@ -206,7 +219,23 @@
+ * Interrupt/Context Switch statistics
+ * XXX - Do these really belong here ?
+ */
++#ifdef __FreeBSD__
++#define GET_VM_STATS(space, name) sysctlbyname("vm.stats." #space "." #name, &mem_stats.name, &len, NULL, 0)
++ {
++ size_t len;
++
++ len = sizeof(VMMETER_TYPE);
++ GET_VM_STATS(sys, v_intr);
++ GET_VM_STATS(sys, v_swtch);
++ GET_VM_STATS(vm, v_swappgsin);
++ GET_VM_STATS(vm, v_swappgsout);
++ GET_VM_STATS(vm, v_swapin);
++ GET_VM_STATS(vm, v_swapout);
++ }
++#undef GET_VM_STATS
++#else
+ sysctl(mem_mib, 2, &mem_stats, &mem_size, NULL, 0);
++#endif
+ cpu->nInterrupts = mem_stats.NS_VM_INTR;
+ cpu->nCtxSwitches = mem_stats.NS_VM_SWTCH;
+ cpu->swapIn = mem_stats.NS_VM_SWAPIN;