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.

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

mercurial