snmp/snmp.patch

Wed, 08 Feb 2012 20:07:00 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 08 Feb 2012 20:07:00 +0200
changeset 588
300d43423c2e
parent 353
198005e4aad2
child 589
6db023bc5512
permissions
-rw-r--r--

Update version, adapt patch, correct PID writing, correct build on newer
FreeBSD releases, and most importantly introduce new patch to try to
avoid segfault caused by multiple network interfaces with the same (or
no) address. This is common when configuring bridges and tunnels.

     1 Index: agent/auto_nlist.c
     2 diff -Nau agent/auto_nlist.c.orig agent/auto_nlist.c
     3 --- agent/auto_nlist.c.orig	2011-07-02 00:35:46.000000000 +0200
     4 +++ agent/auto_nlist.c	2011-09-15 09:22:50.256627584 +0200
     5 @@ -53,6 +53,7 @@
     6      }
     7      if (*ptr == 0) {
     8          *ptr = (struct autonlist *) malloc(sizeof(struct autonlist));
     9 +	memset(*ptr, 0, sizeof(struct autonlist));
    10          it = *ptr;
    11          it->left = 0;
    12          it->right = 0;
    13 Index: agent/mibgroup/mibII/tcp.c
    14 diff -Nau agent/mibgroup/mibII/tcp.c.orig agent/mibgroup/mibII/tcp.c
    15 --- agent/mibgroup/mibII/tcp.c.orig	2011-07-02 00:35:46.000000000 +0200
    16 +++ agent/mibgroup/mibII/tcp.c	2011-09-15 09:22:50.258135285 +0200
    17 @@ -88,7 +88,7 @@
    18                   * But only define it under FreeBSD, since it
    19                   *   breaks other systems (notable AIX)
    20                   */
    21 -#ifdef freebsd4
    22 +#if defined (freebsd4) || defined (__NetBSD__)
    23  int  hz = 1000;
    24  #endif
    26 Index: agent/mibgroup/mibII/tcpTable.c
    27 diff -Nau agent/mibgroup/mibII/tcpTable.c.orig agent/mibgroup/mibII/tcpTable.c
    28 --- agent/mibgroup/mibII/tcpTable.c.orig	2011-07-02 00:35:46.000000000 +0200
    29 +++ agent/mibgroup/mibII/tcpTable.c	2011-09-15 09:22:50.260414149 +0200
    30 @@ -110,6 +110,11 @@
    31  #define	TCPTABLE_REMOTEPORT	pcb.inp_fport
    32  #define	TCPTABLE_IS_LINKED_LIST
    34 +#if defined(__FreeBSD__)
    35 +#undef  INP_NEXT_SYMBOL
    36 +#define INP_NEXT_SYMBOL inp_next
    37 +#endif
    38 +
    39  #endif                          /* linux */
    40  #endif                          /* WIN32 cygwin */
    41  #endif                          /* solaris2 */
    42 @@ -892,12 +897,17 @@
    43          nnew = SNMP_MALLOC_TYPEDEF(netsnmp_inpcb);
    44          if (!nnew)
    45              break;
    46 +#if defined(__FreeBSD__)
    47 +        memcpy(&(nnew->pcb), &(((struct xinpcb *) xig)->xi_inp),
    48 +                           sizeof(struct inpcb));
    49 +#else
    50          nnew->state = StateMap[((NS_ELEM *) xig)->xt_tp.t_state];
    51          if (nnew->state == 5 /* established */ ||
    52              nnew->state == 8 /*  closeWait  */ )
    53              tcp_estab++;
    54          memcpy(&(nnew->pcb), &(((NS_ELEM *) xig)->xt_inp),
    55                             sizeof(struct inpcb));
    56 +#endif
    58  	if (nnew->pcb.inp_vflag & INP_IPV6)
    59  	    free(nnew);
    60 Index: agent/mibgroup/ucd-snmp/diskio.c
    61 diff -Nau agent/mibgroup/ucd-snmp/diskio.c.orig agent/mibgroup/ucd-snmp/diskio.c
    62 --- agent/mibgroup/ucd-snmp/diskio.c.orig	2011-07-02 00:35:46.000000000 +0200
    63 +++ agent/mibgroup/ucd-snmp/diskio.c	2011-09-15 09:22:50.263188251 +0200
    64 @@ -800,6 +800,20 @@
    65      case DISKIO_DEVICE:
    66          *var_len = strlen(stat->dinfo->devices[indx].device_name);
    67          return (u_char *) stat->dinfo->devices[indx].device_name;
    68 +#if defined(freebsd5) && (__FreeBSD_version >= 500107)
    69 +    case DISKIO_NREAD:
    70 +        long_ret = (signed long) stat->dinfo->devices[indx].bytes[DEVSTAT_READ];
    71 +        return (u_char *) & long_ret;
    72 +    case DISKIO_NWRITTEN:
    73 +        long_ret = (signed long) stat->dinfo->devices[indx].bytes[DEVSTAT_WRITE];
    74 +        return (u_char *) & long_ret;
    75 +    case DISKIO_READS:
    76 +        long_ret = (signed long) stat->dinfo->devices[indx].operations[DEVSTAT_READ];
    77 +        return (u_char *) & long_ret;
    78 +    case DISKIO_WRITES:
    79 +        long_ret = (signed long) stat->dinfo->devices[indx].operations[DEVSTAT_WRITE];
    80 +        return (u_char *) & long_ret;
    81 +#else
    82      case DISKIO_NREAD:
    83  #if defined(freebsd5) && __FreeBSD_version >= 500107
    84          long_ret = (signed long) stat->dinfo->devices[indx].bytes[DEVSTAT_READ];
    85 @@ -857,6 +871,7 @@
    86      case DISKIO_LA15:
    87          long_ret = devloads[indx].la15;
    88          return (u_char *) & long_ret;
    89 +#endif
    91      default:
    92          ERROR_MSG("diskio.c: don't know how to handle this request.");
    93 Index: agent/mibgroup/ucd-snmp/memory_solaris2.c
    94 diff -Nau agent/mibgroup/ucd-snmp/memory_solaris2.c.orig agent/mibgroup/ucd-snmp/memory_solaris2.c
    95 --- agent/mibgroup/ucd-snmp/memory_solaris2.c.orig	2011-07-02 00:35:46.000000000 +0200
    96 +++ agent/mibgroup/ucd-snmp/memory_solaris2.c	2011-09-15 09:22:50.264370106 +0200
    97 @@ -1,3 +1,4 @@
    98 +#undef _FILE_OFFSET_BITS /* swapctl doesn't support 64bit off_t */
    99  #include <net-snmp/net-snmp-config.h>   /* local SNMP configuration details */
   100  #if HAVE_STRING_H
   101  #include <string.h>
   102 Index: agent/mibgroup/ucd-snmp/proc.c
   103 diff -Nau agent/mibgroup/ucd-snmp/proc.c.orig agent/mibgroup/ucd-snmp/proc.c
   104 --- agent/mibgroup/ucd-snmp/proc.c.orig	2011-07-02 00:35:46.000000000 +0200
   105 +++ agent/mibgroup/ucd-snmp/proc.c	2011-09-15 09:22:50.265801863 +0200
   106 @@ -1,3 +1,6 @@
   107 +#ifdef solaris2
   108 +#undef _FILE_OFFSET_BITS /* solaris procfs doesn't support 64bit off_t */
   109 +#endif
   110  #include <net-snmp/net-snmp-config.h>
   111  #include <net-snmp/net-snmp-features.h>
   113 Index: agent/mibgroup/util_funcs.c
   114 diff -Nau agent/mibgroup/util_funcs.c.orig agent/mibgroup/util_funcs.c
   115 --- agent/mibgroup/util_funcs.c.orig	2011-07-02 00:35:46.000000000 +0200
   116 +++ agent/mibgroup/util_funcs.c	2011-09-15 09:22:50.267863457 +0200
   117 @@ -477,6 +477,9 @@
   118      int             fd[2][2], i, cnt;
   119      char            ctmp[STRMAX], *cptr1, *cptr2, argvs[STRMAX], **argv,
   120          **aptr;
   121 +
   122 +    *pid = -1;  /* open_persist_pipe ignores return code but checks *pid */
   123 +
   124      /*
   125       * Setup our pipes 
   126       */
   127 Index: agent/snmpd.c
   128 diff -Nau agent/snmpd.c.orig agent/snmpd.c
   129 --- agent/snmpd.c.orig	2011-07-02 00:35:46.000000000 +0200
   130 +++ agent/snmpd.c	2011-09-15 09:22:41.994430685 +0200
   131 @@ -440,7 +440,7 @@
   132      int             log_set = 0;
   133      int             uid = 0, gid = 0;
   134      int             agent_mode = -1;
   135 -    char           *pid_file = NULL;
   136 +    char           *pid_file = "@l_prefix@/var/snmp/snmpd.pid";
   137      char            option_compatability[] = "-Le";
   138  #if HAVE_GETPID
   139      int fd;
   140 Index: apps/snmptrapd.c
   141 diff -Nau apps/snmptrapd.c.orig apps/snmptrapd.c
   142 --- apps/snmptrapd.c.orig	2011-07-02 00:35:46.000000000 +0200
   143 +++ apps/snmptrapd.c	2011-09-15 09:22:50.270293197 +0200
   144 @@ -653,6 +653,7 @@
   145       */
   146  #if HAVE_GETPID
   147      strcat(options, "p:");
   148 +    parse_config_pidFile(NULL, "@l_prefix@/var/snmp/snmptrapd.pid");
   149  #endif
   151  #ifndef NETSNMP_FEATURE_REMOVE_LOGGING_SYSLOG
   152 Index: include/net-snmp/library/system.h
   153 diff -Nau include/net-snmp/library/system.h.orig include/net-snmp/library/system.h
   154 --- include/net-snmp/library/system.h.orig	2011-07-02 00:35:46.000000000 +0200
   155 +++ include/net-snmp/library/system.h	2011-09-15 09:22:50.271350973 +0200
   156 @@ -155,7 +155,8 @@
   157  #endif
   158  #ifndef HAVE_SETENV
   159      NETSNMP_IMPORT
   160 -    int             setenv(const char *, const char *, int);
   161 +    int             __netsnmp_setenv(const char *, const char *, int);
   162 +#   define          setenv(a,b,c) __netsnmp_setenv(a,b,c)
   163  #endif
   165      NETSNMP_IMPORT
   166 Index: snmplib/system.c
   167 diff -Nau snmplib/system.c.orig snmplib/system.c
   168 --- snmplib/system.c.orig	2011-07-02 00:35:46.000000000 +0200
   169 +++ snmplib/system.c	2011-09-15 09:22:50.274625796 +0200
   170 @@ -1048,7 +1048,7 @@
   172  #ifndef HAVE_SETENV
   173  int
   174 -setenv(const char *name, const char *value, int overwrite)
   175 +__netsnmp_setenv(const char *name, const char *value, int overwrite)
   176  {
   177      char           *cp;
   178      int             ret;

mercurial