rpms/net-snmp/devel net-snmp-5.3.1-tcp-udp-mib-byteorder.patch, NONE, 1.1 net-snmp.spec, 1.86, 1.87 net-snmp-5.3.1-byteorder.patch, 1.1, NONE

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Wed Sep 6 07:46:18 UTC 2006


Author: rvokal

Update of /cvs/dist/rpms/net-snmp/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv28661

Modified Files:
	net-snmp.spec 
Added Files:
	net-snmp-5.3.1-tcp-udp-mib-byteorder.patch 
Removed Files:
	net-snmp-5.3.1-byteorder.patch 
Log Message:
 better upstream patch for byteorder, add epoch to corespond with upstream versioning

net-snmp-5.3.1-tcp-udp-mib-byteorder.patch:
 agent/mibgroup/tcp-mib/data_access/tcpConn_linux.c      |   52 +++++++++++++---
 agent/mibgroup/udp-mib/data_access/udp_endpoint_linux.c |   34 ++++++++--
 include/net-snmp/library/tools.h                        |    4 -
 snmplib/tools.c                                         |   32 +++++++++
 4 files changed, 107 insertions(+), 15 deletions(-)

--- NEW FILE net-snmp-5.3.1-tcp-udp-mib-byteorder.patch ---
Index: agent/mibgroup/tcp-mib/data_access/tcpConn_linux.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/tcp-mib/data_access/tcpConn_linux.c,v
retrieving revision 1.5.2.1
diff -u -p -u -r1.5.2.1 tcpConn_linux.c
--- agent/mibgroup/tcp-mib/data_access/tcpConn_linux.c	17 Aug 2006 08:52:15 -0000	1.5.2.1
+++ agent/mibgroup/tcp-mib/data_access/tcpConn_linux.c	1 Sep 2006 17:15:23 -0000
@@ -169,11 +169,20 @@ _load4(netsnmp_container *container, u_i
             break;
         }
 
-        entry->loc_port = htons((unsigned short) local_port);
-        entry->rmt_port = htons((unsigned short) remote_port);
+        /** oddly enough, these appear to already be in network order */
+        entry->loc_port = (unsigned short) local_port;
+        entry->rmt_port = (unsigned short) remote_port;
         entry->tcpConnState = state;
+        
+        /** the addr string may need work */
         buf_len = strlen(local_addr);
-        netsnmp_assert(8 == buf_len);
+        if ((8 != buf_len) ||
+            (-1 == netsnmp_addrstr_hton(local_addr, 8))) {
+            DEBUGMSGT(("verbose:access:tcpconn:container",
+                       " error processing local address\n"));
+            netsnmp_access_tcpconn_entry_free(entry);
+            continue;
+        }
         offset = 0;
         tmp_ptr = entry->loc_addr;
         rc = netsnmp_hex_to_binary(&tmp_ptr, &buf_len,
@@ -188,8 +197,15 @@ _load4(netsnmp_container *container, u_i
             continue;
         }
 
-        buf_len = strlen(remote_addr);
-        netsnmp_assert(8 == buf_len);
+        /** the addr string may need work */
+        buf_len = strlen((char*)remote_addr);
+        if ((8 != buf_len) ||
+            (-1 == netsnmp_addrstr_hton(remote_addr, 8))) {
+            DEBUGMSGT(("verbose:access:tcpconn:container",
+                       " error processing remote address\n"));
+            netsnmp_access_tcpconn_entry_free(entry);
+            continue;
+        }
         offset = 0;
         tmp_ptr = entry->rmt_addr;
         rc = netsnmp_hex_to_binary(&tmp_ptr, &buf_len,
@@ -244,6 +260,8 @@ _load6(netsnmp_container *container, u_i
     fgets(line, sizeof(line), in); /* skip header */
 
     /*
+     * Note: PPC (big endian)
+     *
      *   sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode
      *  0: 00000000000000000000000000000001:1466 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000   500        0 326699 1 efb81580 3000 0 0 2 -1
      */
@@ -291,11 +309,20 @@ _load6(netsnmp_container *container, u_i
             break;
         }
 
-        entry->loc_port = htons((unsigned short) local_port);
-        entry->rmt_port = htons((unsigned short) remote_port);
+        /** oddly enough, these appear to already be in network order */
+        entry->loc_port = (unsigned short) local_port;
+        entry->rmt_port = (unsigned short) remote_port;
         entry->tcpConnState = state;
 
-        buf_len = strlen(local_addr);
+        /** the addr string may need work */
+        buf_len = strlen((char*)local_addr);
+        if ((32 != buf_len) ||
+            (-1 == netsnmp_addrstr_hton(local_addr, 32))) {
+            DEBUGMSGT(("verbose:access:tcpconn:container",
+                       " error processing local address\n"));
+            netsnmp_access_tcpconn_entry_free(entry);
+            continue;
+        }
         offset = 0;
         tmp_ptr = entry->loc_addr;
         rc = netsnmp_hex_to_binary(&tmp_ptr, &buf_len,
@@ -310,7 +337,14 @@ _load6(netsnmp_container *container, u_i
             continue;
         }
 
-        buf_len = strlen(remote_addr);
+        buf_len = strlen((char*)remote_addr);
+        if ((32 != buf_len) ||
+            (-1 == netsnmp_addrstr_hton(remote_addr, 32))) {
+            DEBUGMSGT(("verbose:access:tcpconn:container",
+                       " error processing remote address\n"));
+            netsnmp_access_tcpconn_entry_free(entry);
+            continue;
+        }
         offset = 0;
         tmp_ptr = entry->rmt_addr;
         rc = netsnmp_hex_to_binary(&tmp_ptr, &buf_len,
Index: agent/mibgroup/udp-mib/data_access/udp_endpoint_linux.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/udp-mib/data_access/udp_endpoint_linux.c,v
retrieving revision 1.2.2.1
diff -u -p -u -r1.2.2.1 udp_endpoint_linux.c
--- agent/mibgroup/udp-mib/data_access/udp_endpoint_linux.c	25 Jan 2006 16:27:40 -0000	1.2.2.1
+++ agent/mibgroup/udp-mib/data_access/udp_endpoint_linux.c	1 Sep 2006 17:15:23 -0000
@@ -112,9 +112,9 @@ _process_line_udp_ep(netsnmp_line_info *
                      struct netsnmp_line_process_info_s* lpi)
 {
     netsnmp_udp_endpoint_entry *ep = (netsnmp_udp_endpoint_entry *)mem;
-    char                 *ptr;
+    char                 *ptr, *sep;
     u_char               *u_ptr;
-    size_t                u_ptr_len, offset;
+    size_t                u_ptr_len, offset, len;
 
     /*
      * skip 'sl'
@@ -135,10 +135,22 @@ _process_line_udp_ep(netsnmp_line_info *
     /*
      * get local address. ignore error on hex conversion, since that
      * function doesn't like the ':' between address and port. check the
-     * offset to see if it worked.
+     * offset to see if it worked. May need to flip string too.
      */
     u_ptr = ep->loc_addr;
     u_ptr_len = sizeof(ep->loc_addr);
+    sep = strchr(ptr, ':');
+    if (NULL == sep) {
+        DEBUGMSGTL(("text:util:tvi", "no ':' '%s'\n",
+                    line_info->start));
+        return PMLP_RC_MEMORY_UNUSED;
+    }
+    len = (sep - ptr);
+    if (-1 == netsnmp_addrstr_hton(ptr, len)) {
+        DEBUGMSGTL(("text:util:tvi", "bad length %d for loc addr '%s'\n",
+                    u_ptr_len, line_info->start));
+        return PMLP_RC_MEMORY_UNUSED;
+    }
     offset = 0;
     netsnmp_hex_to_binary(&u_ptr, &u_ptr_len, &offset, 0, ptr, NULL);
     if ((4 != offset) && (16 != offset)) {
@@ -159,14 +171,26 @@ _process_line_udp_ep(netsnmp_line_info *
     /*
      * get remote address. ignore error on hex conversion, since that
      * function doesn't like the ':' between address and port. check the
-     * offset to see if it worked.
+     * offset to see if it worked. May need to flip string too.
      */
     u_ptr = ep->rmt_addr;
     u_ptr_len = sizeof(ep->rmt_addr);
+    sep = strchr(ptr, ':');
+    if (NULL == sep) {
+        DEBUGMSGTL(("text:util:tvi", "no ':' '%s'\n",
+                    line_info->start));
+        return PMLP_RC_MEMORY_UNUSED;
+    }
+    len = (sep - ptr);
+    if (-1 == netsnmp_addrstr_hton(ptr, len)) {
+        DEBUGMSGTL(("text:util:tvi", "bad length %d for rmt addr '%s'\n",
+                    u_ptr_len, line_info->start));
+        return PMLP_RC_MEMORY_UNUSED;
+    }
     offset = 0;
     netsnmp_hex_to_binary(&u_ptr, &u_ptr_len, &offset, 0, ptr, NULL);
     if ((4 != offset) && (16 != offset)) {
-        DEBUGMSGTL(("text:util:tvi", "bad offset %d for loc addr '%s'\n",
+        DEBUGMSGTL(("text:util:tvi", "bad offset %d for rmt addr '%s'\n",
                     offset, line_info->start));
         return PMLP_RC_MEMORY_UNUSED;
     }
Index: include/net-snmp/library/tools.h
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/include/net-snmp/library/tools.h,v
retrieving revision 5.8.2.2
diff -u -p -u -r5.8.2.2 tools.h
--- include/net-snmp/library/tools.h	13 Jun 2006 12:50:36 -0000	5.8.2.2
+++ include/net-snmp/library/tools.h	1 Sep 2006 17:15:24 -0000
@@ -198,7 +198,9 @@ extern          "C" {
     int             marker_tticks(marker_t pm);
     int             timeval_tticks(struct timeval *tv);
     char            *netsnmp_getenv(const char *name);
-    
+
+    int             netsnmp_addrstr_hton(char *ptr, size_t len);
+
 #ifdef __cplusplus
 }
 #endif
Index: snmplib/tools.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/snmplib/tools.c,v
retrieving revision 5.10.2.2
diff -u -p -u -r5.10.2.2 tools.c
--- snmplib/tools.c	25 Jul 2006 08:04:35 -0000	5.10.2.2
+++ snmplib/tools.c	1 Sep 2006 17:15:26 -0000
@@ -1042,3 +1042,35 @@ char *netsnmp_getenv(const char *name)
 #endif
 }
 
+/*
+ * swap the order of an inet addr string
+ */
+int
+netsnmp_addrstr_hton(char *ptr, size_t len)
+{
+#ifndef WORDS_BIGENDIAN
+    char tmp[8];
+    
+    if (8 == len) {
+        tmp[0] = ptr[6];
+        tmp[1] = ptr[7];
+        tmp[2] = ptr[4];
+        tmp[3] = ptr[5];
+        tmp[4] = ptr[2];
+        tmp[5] = ptr[3];
+        tmp[6] = ptr[0];
+        tmp[7] = ptr[1];
+        memcpy (ptr, &tmp, 8);
+    }
+    else if (32 == len) {
+        netsnmp_addrstr_hton(ptr   , 8);
+        netsnmp_addrstr_hton(ptr+8 , 8);
+        netsnmp_addrstr_hton(ptr+16, 8);
+        netsnmp_addrstr_hton(ptr+24, 8);
+    }
+    else
+        return -1;
+#endif
+
+    return 0;
+}


Index: net-snmp.spec
===================================================================
RCS file: /cvs/dist/rpms/net-snmp/devel/net-snmp.spec,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- net-snmp.spec	30 Aug 2006 09:26:31 -0000	1.86
+++ net-snmp.spec	6 Sep 2006 07:46:15 -0000	1.87
@@ -6,8 +6,9 @@
 
 Summary: A collection of SNMP protocol tools and libraries.
 Name: net-snmp
-Version: %{major_ver}.0
-Release: 6%{?dist}
+Version: %{major_ver}
+Release: 7%{?dist}
+Epoch: 1
 
 License: BSDish
 Group: System Environment/Daemons
@@ -40,7 +41,7 @@
 Patch28: net-snmp-5.3.1-retrans_time.patch
 Patch29: net-snmp-5.3.1-config_libdir.patch
 Patch30: net-snmp-5.3.1-lm_sensors.patch
-Patch31: net-snmp-5.3.1-byteorder.patch
+Patch31: net-snmp-5.3.1-tcp-udp-mib-byteorder.patch
 
 Prereq: /sbin/chkconfig
 Obsoletes: ucd-snmp
@@ -76,7 +77,7 @@
 %package utils
 Group: Applications/System
 Summary: Network management utilities using SNMP, from the NET-SNMP project.
-Requires: %{name} = %{version}
+Requires: %{name} = %{epoch}:%{version}
 Obsoletes: ucd-snmp-utils
 
 %description utils
@@ -90,7 +91,7 @@
 %package devel
 Group: Development/Libraries
 Summary: The development environment for the NET-SNMP project.
-Requires: %{name} = %{version}
+Requires: %{name} = %{epoch}:%{version}
 Obsoletes: ucd-snmp-devel
 Requires: beecrypt-devel, elfutils-devel, rpm-devel, elfutils-libelf-devel
 
@@ -107,7 +108,7 @@
 %package perl
 Group: Development/Libraries
 Summary: The perl NET-SNMP module and the mib2c tool.
-Requires: %{name} = %{version}, perl >= 5
+Requires: %{name} = %{epoch}:%{version}, perl >= 5
 BuildRequires: perl >= 5
 
 %description perl
@@ -147,7 +148,7 @@
 %patch28 -p0 -b .retrans_ms
 %patch29 -p1 -b .libdir
 %patch30 -p1 -b .lm_sensors
-%patch31 -p1 -b .byteorder
+%patch31 -p0 -b .byteorder
 
 # Do this patch with a perl hack...
 perl -pi -e "s|'\\\$install_libdir'|'%{_libdir}'|" ltmain.sh
@@ -350,6 +351,10 @@
 %{_libdir}/lib*.so.*
 
 %changelog
+* Tue Sep  5 2006 Radek Vokal <rvokal at redhat.com> 5.3.1-7
+- better upstream patch for byteorder
+- add epoch to corespond with upstream versioning 
+
 * Wed Aug 30 2006 Radek Vokal <rvokal at redhat.com> 5.3.1.0-6
 - fix IPv4/IPv6 address presentation (#200255)
 


--- net-snmp-5.3.1-byteorder.patch DELETED ---




More information about the fedora-cvs-commits mailing list