pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/34671: [Patch] 64-bitness fix and some enhancements to the net-snmp port



>Number:         34671
>Category:       pkg
>Synopsis:       [Patch] 64-bitness fix and some enhancements to the net-snmp 
>port
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 30 13:10:00 +0000 2006
>Originator:     Jan Andres
>Release:        NetBSD 4.0_BETA
>Organization:
        
>Environment:
        
        
System: NetBSD delta.home.jan 4.0_BETA NetBSD 4.0_BETA (DELTA_PF) #2: Wed Aug 9 
06:39:28 MEST 2006 
jan%pitr.home.jan@localhost:/xfs/0/jan/nb/obj-alpha/sys/arch/alpha/compile/DELTA_PF
 alpha
Architecture: alpha
Machine: alpha
>Description:
I've made some small fixes and enhancements to the net-snmp port:

- Support for 64-bit counters in the Disk I/O MIB
- Support raw counters for IRQs, context switches, swap I/O (in ucd-snmp
  MIB)
- Fix 64-bitness issue in measurement of CPU usage. int is used as target
  of the oldlenp pointer passed to sysctl(3) where it should be size_t.

I've emailed those patches to the port maintainer a while ago, but he
never replied.

Please find the patch in the "Fix" section.

Regards,
Jan

>How-To-Repeat:
        
>Fix:
diff -ur net-snmp-5.3.1/agent/mibgroup/ucd-snmp/diskio.c 
net-snmp-5.3.1-patched/agent/mibgroup/ucd-snmp/diskio.c
--- net-snmp-5.3.1/agent/mibgroup/ucd-snmp/diskio.c     2006-09-30 
14:36:55.000000000 +0200
+++ net-snmp-5.3.1-patched/agent/mibgroup/ucd-snmp/diskio.c     2006-09-30 
14:35:38.000000000 +0200
@@ -498,8 +498,9 @@
            size_t * length,
            int exact, size_t * var_len, WriteMethod ** write_method)
 {
-    static long     long_ret;
-    unsigned int    indx;
+    static long               long_ret;
+    static struct counter64   c64_ret;
+    unsigned int              indx;
 
     if (getstats() == 0)
         return 0;
@@ -561,6 +562,32 @@
 #endif
         return (u_char *) & long_ret;
 
+    case DISKIO_NREADX:
+#ifdef HW_DISKSTATS
+       c64_ret.low = dk[indx].dk_rbytes & 0xffffffff;
+       c64_ret.high = dk[indx].dk_rbytes >> 32;
+#endif
+#ifdef HW_IOSTATS
+       if (dk[indx].type == IOSTAT_DISK) {
+           c64_ret.low = dk[indx].rbytes & 0xffffffff;
+           c64_ret.high = dk[indx].rbytes >> 32;
+       }
+#endif
+        return (u_char *) & c64_ret;
+
+    case DISKIO_NWRITTENX:
+#ifdef HW_DISKSTATS
+       c64_ret.low = dk[indx].dk_wbytes & 0xffffffff;
+       c64_ret.high = dk[indx].dk_wbytes >> 32;
+#endif
+#ifdef HW_IOSTATS
+       if (dk[indx].type == IOSTAT_DISK) {
+           c64_ret.low = dk[indx].wbytes & 0xffffffff;
+           c64_ret.high = dk[indx].wbytes >> 32;
+       }
+#endif
+        return (u_char *) & c64_ret;
+
     default:
         ERROR_MSG("diskio.c: don't know how to handle this request.");
     }
diff -ur net-snmp-5.3.1/agent/mibgroup/ucd-snmp/vmstat_netbsd1.c 
net-snmp-5.3.1-patched/agent/mibgroup/ucd-snmp/vmstat_netbsd1.c
--- net-snmp-5.3.1/agent/mibgroup/ucd-snmp/vmstat_netbsd1.c     2004-07-07 
22:31:54.000000000 +0200
+++ net-snmp-5.3.1-patched/agent/mibgroup/ucd-snmp/vmstat_netbsd1.c     
2006-09-30 14:35:42.000000000 +0200
@@ -95,6 +95,14 @@
          {CPURAWKERNEL}},
         {CPURAWINTR, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
          {CPURAWINTR}},
+        {SYSRAWINTERRUPTS, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
+         {SYSRAWINTERRUPTS}},
+        {SYSRAWCONTEXT, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
+         {SYSRAWCONTEXT}},
+        {RAWSWAPIN, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
+         {RAWSWAPIN}},
+        {RAWSWAPOUT, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
+         {RAWSWAPOUT}},
 
         /*
          * Future use: 
@@ -170,7 +178,7 @@
 
     static struct uvmexp mem_old, mem_new;
     int             mem_mib[] = { CTL_VM, VM_UVMEXP };
-    int             mem_size = sizeof(struct uvmexp);
+    size_t          mem_size = sizeof(struct uvmexp);
 
     static long     long_ret;
     static char     errmsg[300];
@@ -186,13 +194,13 @@
     if (time_new != time_old) {
 #ifdef KERN_CP_TIME
         int             mib[2] = { CTL_KERN, KERN_CP_TIME };
-        int             ssize = sizeof(cpu_new);
+        size_t          ssize = sizeof(cpu_new);
 
         if (sysctl(mib, 2, cpu_new, &ssize, NULL, 0) < 0)
             memset(cpu_new, 0, sizeof(cpu_new));
 #elif defined(KERN_CPTIME)
         int             mib[2] = { CTL_KERN, KERN_CPTIME };
-        int             ssize = sizeof(cpu_new);
+        size_t          ssize = sizeof(cpu_new);
 
         if (sysctl(mib, 2, cpu_new, &ssize, NULL, 0) < 0)
             memset(cpu_new, 0, sizeof(cpu_new));
@@ -301,6 +309,20 @@
     case CPURAWINTR:
         long_ret = cpu_new[CP_INTR];
         return ((u_char *) (&long_ret));
+    case SYSRAWINTERRUPTS:
+        long_ret = mem_new.intrs;
+        return ((u_char *) (&long_ret));
+    case SYSRAWCONTEXT:
+        long_ret = mem_new.swtch;
+        return ((u_char *) (&long_ret));
+    case RAWSWAPIN:
+        long_ret = mem_new.pgswapin * (mem_new.pagesize >> 9);
+        return ((u_char *) (&long_ret));
+    case RAWSWAPOUT:
+        long_ret = mem_new.pgswapout * (mem_new.pagesize >> 9);
+        return ((u_char *) (&long_ret));
+
+
         /*
          * reserved for future use 
          */

>Unformatted:
        
        



Home | Main Index | Thread Index | Old Index