net-snmp package update
Signed-off-by: basebuilder_pel7x64builder0 <basebuilder@powerel.org>master
parent
b6531026a8
commit
c0a8ac2e4e
|
@ -0,0 +1,74 @@
|
||||||
|
diff -urNp orig/agent/mibgroup/sctp-mib/sctpScalars_linux.c new/agent/mibgroup/sctp-mib/sctpScalars_linux.c
|
||||||
|
--- orig/agent/mibgroup/sctp-mib/sctpScalars_linux.c 2016-08-25 09:18:55.239801239 +0200
|
||||||
|
+++ new/agent/mibgroup/sctp-mib/sctpScalars_linux.c 2016-08-25 10:37:02.416999975 +0200
|
||||||
|
@@ -84,17 +84,17 @@ netsnmp_access_sctp_stats_arch_load(nets
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (line[6] == 'r')
|
||||||
|
+ if (line[4] == 'C' && line[8] == 'E')
|
||||||
|
sctp_stats->curr_estab = value;
|
||||||
|
- else if (line[5] == 'c')
|
||||||
|
+ else if (line[4] == 'A' && line[10] == 'E')
|
||||||
|
sctp_stats->active_estabs = value;
|
||||||
|
- else if (line[4] == 'P')
|
||||||
|
+ else if (line[4] == 'P' && line[11] == 'E')
|
||||||
|
sctp_stats->passive_estabs = value;
|
||||||
|
- else if (line[5] == 'b')
|
||||||
|
+ else if (line[4] == 'a' && line[5] == 'b')
|
||||||
|
sctp_stats->aborteds = value;
|
||||||
|
- else if (line[4] == 'S')
|
||||||
|
+ else if (line[4] == 'S' && line[5] == 'h')
|
||||||
|
sctp_stats->shutdowns = value;
|
||||||
|
- else if (line[8] == 'f')
|
||||||
|
+ else if (line[4] == 'O' && line[9] == 'B')
|
||||||
|
sctp_stats->out_of_blues = value;
|
||||||
|
else if (line[6] == 'e')
|
||||||
|
sctp_stats->checksum_errors = value;
|
||||||
|
@@ -113,7 +113,7 @@ netsnmp_access_sctp_stats_arch_load(nets
|
||||||
|
sctp_stats->out_sctp_packs.high = value >> 32;
|
||||||
|
} else
|
||||||
|
ret = -1;
|
||||||
|
- } else {
|
||||||
|
+ } else if (line[4] == 'I'){
|
||||||
|
if (line[6] == 'C') {
|
||||||
|
sctp_stats->in_ctrl_chunks.low = value & 0xffffffff;
|
||||||
|
sctp_stats->in_ctrl_chunks.high = value >> 32;
|
||||||
|
@@ -123,24 +123,27 @@ netsnmp_access_sctp_stats_arch_load(nets
|
||||||
|
} else if (line[6] == 'U') {
|
||||||
|
sctp_stats->in_unorder_chunks.low = value & 0xffffffff;
|
||||||
|
sctp_stats->in_unorder_chunks.high = value >> 32;
|
||||||
|
- } else if (line[4] == 'F') {
|
||||||
|
- sctp_stats->frag_usr_msgs.low = value & 0xffffffff;
|
||||||
|
- sctp_stats->frag_usr_msgs.high = value >> 32;
|
||||||
|
- } else if (line[4] == 'R') {
|
||||||
|
- sctp_stats->reasm_usr_msgs.low = value & 0xffffffff;
|
||||||
|
- sctp_stats->reasm_usr_msgs.high = value >> 32;
|
||||||
|
} else if (line[6] == 'S') {
|
||||||
|
sctp_stats->in_sctp_packs.low = value & 0xffffffff;
|
||||||
|
sctp_stats->in_sctp_packs.high = value >> 32;
|
||||||
|
- } else
|
||||||
|
+ } else {
|
||||||
|
ret = -1;
|
||||||
|
+ }
|
||||||
|
+ } else if (line[4] == 'F' && line[8] == 'U') {
|
||||||
|
+ sctp_stats->frag_usr_msgs.low = value & 0xffffffff;
|
||||||
|
+ sctp_stats->frag_usr_msgs.high = value >> 32;
|
||||||
|
+ } else if (line[4] == 'R') {
|
||||||
|
+ sctp_stats->reasm_usr_msgs.low = value & 0xffffffff;
|
||||||
|
+ sctp_stats->reasm_usr_msgs.high = value >> 32;
|
||||||
|
+ } else if (line[4] == 'T') {
|
||||||
|
+ } else {
|
||||||
|
+ ret = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret < 0) {
|
||||||
|
DEBUGMSGTL(("sctp:scalars:stats:arch_load",
|
||||||
|
- "Unknown entry!'\n"));
|
||||||
|
- fclose(f);
|
||||||
|
- return ret;
|
||||||
|
+ "Unknown entry: %s\n", line));
|
||||||
|
+ ret = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,155 @@
|
||||||
|
953926 - snmptrapd crash "buffer overflow detected" at fortify_fail.c
|
||||||
|
|
||||||
|
commit 40938a62619590b4ea071ae85baa2f42a0b7fcb2
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Apr 22 15:00:00 2013 +0200
|
||||||
|
|
||||||
|
Check if 'asn_parse_* ' actually succeeded.
|
||||||
|
|
||||||
|
If not, discard the packet instead of using wrong data.
|
||||||
|
|
||||||
|
diff --git a/snmplib/snmp_api.c b/snmplib/snmp_api.c
|
||||||
|
index e5c45d9..0842842 100644
|
||||||
|
--- a/snmplib/snmp_api.c
|
||||||
|
+++ b/snmplib/snmp_api.c
|
||||||
|
@@ -4709,9 +4709,11 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
|
||||||
|
case ASN_INTEGER:
|
||||||
|
vp->val.integer = (long *) vp->buf;
|
||||||
|
vp->val_len = sizeof(long);
|
||||||
|
- asn_parse_int(var_val, &len, &vp->type,
|
||||||
|
+ data = asn_parse_int(var_val, &len, &vp->type,
|
||||||
|
(long *) vp->val.integer,
|
||||||
|
sizeof(*vp->val.integer));
|
||||||
|
+ if (!data)
|
||||||
|
+ return -1;
|
||||||
|
break;
|
||||||
|
case ASN_COUNTER:
|
||||||
|
case ASN_GAUGE:
|
||||||
|
@@ -4719,9 +4721,11 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
|
||||||
|
case ASN_UINTEGER:
|
||||||
|
vp->val.integer = (long *) vp->buf;
|
||||||
|
vp->val_len = sizeof(u_long);
|
||||||
|
- asn_parse_unsigned_int(var_val, &len, &vp->type,
|
||||||
|
+ data = asn_parse_unsigned_int(var_val, &len, &vp->type,
|
||||||
|
(u_long *) vp->val.integer,
|
||||||
|
vp->val_len);
|
||||||
|
+ if (!data)
|
||||||
|
+ return -1;
|
||||||
|
break;
|
||||||
|
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||||
|
case ASN_OPAQUE_COUNTER64:
|
||||||
|
@@ -4730,34 +4734,45 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
|
||||||
|
case ASN_COUNTER64:
|
||||||
|
vp->val.counter64 = (struct counter64 *) vp->buf;
|
||||||
|
vp->val_len = sizeof(struct counter64);
|
||||||
|
- asn_parse_unsigned_int64(var_val, &len, &vp->type,
|
||||||
|
+ data = asn_parse_unsigned_int64(var_val, &len, &vp->type,
|
||||||
|
(struct counter64 *) vp->val.
|
||||||
|
counter64, vp->val_len);
|
||||||
|
+ if (!data)
|
||||||
|
+ return -1;
|
||||||
|
break;
|
||||||
|
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||||
|
case ASN_OPAQUE_FLOAT:
|
||||||
|
vp->val.floatVal = (float *) vp->buf;
|
||||||
|
vp->val_len = sizeof(float);
|
||||||
|
- asn_parse_float(var_val, &len, &vp->type,
|
||||||
|
+ data = asn_parse_float(var_val, &len, &vp->type,
|
||||||
|
vp->val.floatVal, vp->val_len);
|
||||||
|
+ if (!data)
|
||||||
|
+ return -1;
|
||||||
|
break;
|
||||||
|
case ASN_OPAQUE_DOUBLE:
|
||||||
|
vp->val.doubleVal = (double *) vp->buf;
|
||||||
|
vp->val_len = sizeof(double);
|
||||||
|
- asn_parse_double(var_val, &len, &vp->type,
|
||||||
|
+ data = asn_parse_double(var_val, &len, &vp->type,
|
||||||
|
vp->val.doubleVal, vp->val_len);
|
||||||
|
+ if (!data)
|
||||||
|
+ return -1;
|
||||||
|
break;
|
||||||
|
case ASN_OPAQUE_I64:
|
||||||
|
vp->val.counter64 = (struct counter64 *) vp->buf;
|
||||||
|
vp->val_len = sizeof(struct counter64);
|
||||||
|
- asn_parse_signed_int64(var_val, &len, &vp->type,
|
||||||
|
+ data = asn_parse_signed_int64(var_val, &len, &vp->type,
|
||||||
|
(struct counter64 *) vp->val.counter64,
|
||||||
|
sizeof(*vp->val.counter64));
|
||||||
|
|
||||||
|
+ if (!data)
|
||||||
|
+ return -1;
|
||||||
|
break;
|
||||||
|
#endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
|
||||||
|
- case ASN_OCTET_STR:
|
||||||
|
case ASN_IPADDRESS:
|
||||||
|
+ if (vp->val_len != 4)
|
||||||
|
+ return -1;
|
||||||
|
+ /* fallthrough */
|
||||||
|
+ case ASN_OCTET_STR:
|
||||||
|
case ASN_OPAQUE:
|
||||||
|
case ASN_NSAP:
|
||||||
|
if (vp->val_len < sizeof(vp->buf)) {
|
||||||
|
@@ -4768,12 +4783,16 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
|
||||||
|
if (vp->val.string == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
- asn_parse_string(var_val, &len, &vp->type, vp->val.string,
|
||||||
|
+ data = asn_parse_string(var_val, &len, &vp->type, vp->val.string,
|
||||||
|
&vp->val_len);
|
||||||
|
+ if (!data)
|
||||||
|
+ return -1;
|
||||||
|
break;
|
||||||
|
case ASN_OBJECT_ID:
|
||||||
|
vp->val_len = MAX_OID_LEN;
|
||||||
|
- asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
|
||||||
|
+ data = asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
|
||||||
|
+ if (!data)
|
||||||
|
+ return -1;
|
||||||
|
vp->val_len *= sizeof(oid);
|
||||||
|
vp->val.objid = (oid *) malloc(vp->val_len);
|
||||||
|
if (vp->val.objid == NULL) {
|
||||||
|
@@ -4791,8 +4810,10 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
|
||||||
|
if (vp->val.bitstring == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
- asn_parse_bitstring(var_val, &len, &vp->type,
|
||||||
|
+ data = asn_parse_bitstring(var_val, &len, &vp->type,
|
||||||
|
vp->val.bitstring, &vp->val_len);
|
||||||
|
+ if (!data)
|
||||||
|
+ return -1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
snmp_log(LOG_ERR, "bad type returned (%x)\n", vp->type);
|
||||||
|
|
||||||
|
commit aa4fb949012d7c022a436992ac203c065fd7420a
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Apr 22 14:58:41 2013 +0200
|
||||||
|
|
||||||
|
Integer values encoded in BER must have at least one character.
|
||||||
|
|
||||||
|
If asn_length == 0, we would read the first byte of the next varbind on next line:
|
||||||
|
if (*bufp & 0x80)
|
||||||
|
-> reading past the buffer if there is no such variable -> sigsegv.
|
||||||
|
|
||||||
|
diff --git a/snmplib/asn1.c b/snmplib/asn1.c
|
||||||
|
index 1af7787..5de6b75 100644
|
||||||
|
--- a/snmplib/asn1.c
|
||||||
|
+++ b/snmplib/asn1.c
|
||||||
|
@@ -510,7 +510,7 @@ asn_parse_int(u_char * data,
|
||||||
|
(errpre, bufp, data, asn_length, *datalength))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
- if ((size_t) asn_length > intsize) {
|
||||||
|
+ if ((size_t) asn_length > intsize || (int) asn_length == 0) {
|
||||||
|
_asn_length_err(errpre, (size_t) asn_length, intsize);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@@ -582,7 +582,7 @@ asn_parse_unsigned_int(u_char * data,
|
||||||
|
(errpre, bufp, data, asn_length, *datalength))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
- if ((asn_length > (intsize + 1)) ||
|
||||||
|
+ if (((int) asn_length > (intsize + 1)) || ((int) asn_length == 0) ||
|
||||||
|
((asn_length == intsize + 1) && *bufp != 0x00)) {
|
||||||
|
_asn_length_err(errpre, (size_t) asn_length, intsize);
|
||||||
|
return NULL;
|
|
@ -0,0 +1,127 @@
|
||||||
|
983116: net-snmp query fails after update to 1:5.5-44.el6_4.2
|
||||||
|
|
||||||
|
|
||||||
|
commit e41c2f574c25d8dd273f2406eeeac19bc2ae16db
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Aug 12 14:30:51 2013 +0200
|
||||||
|
|
||||||
|
CHANGES: snmplib: Fixed parsing of sequences.
|
||||||
|
|
||||||
|
Don't overwrite 'data' variable, it's used when parsing bulk responses.
|
||||||
|
|
||||||
|
diff --git a/snmplib/snmp_api.c b/snmplib/snmp_api.c
|
||||||
|
index 403ea2b..e67945f 100644
|
||||||
|
--- a/snmplib/snmp_api.c
|
||||||
|
+++ b/snmplib/snmp_api.c
|
||||||
|
@@ -4537,6 +4537,7 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
|
||||||
|
size_t four;
|
||||||
|
netsnmp_variable_list *vp = NULL;
|
||||||
|
oid objid[MAX_OID_LEN];
|
||||||
|
+ u_char *p;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the PDU type
|
||||||
|
@@ -4709,10 +4710,10 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
|
||||||
|
case ASN_INTEGER:
|
||||||
|
vp->val.integer = (long *) vp->buf;
|
||||||
|
vp->val_len = sizeof(long);
|
||||||
|
- data = asn_parse_int(var_val, &len, &vp->type,
|
||||||
|
+ p = asn_parse_int(var_val, &len, &vp->type,
|
||||||
|
(long *) vp->val.integer,
|
||||||
|
sizeof(*vp->val.integer));
|
||||||
|
- if (!data)
|
||||||
|
+ if (!p)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
case ASN_COUNTER:
|
||||||
|
@@ -4721,10 +4722,10 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
|
||||||
|
case ASN_UINTEGER:
|
||||||
|
vp->val.integer = (long *) vp->buf;
|
||||||
|
vp->val_len = sizeof(u_long);
|
||||||
|
- data = asn_parse_unsigned_int(var_val, &len, &vp->type,
|
||||||
|
+ p = asn_parse_unsigned_int(var_val, &len, &vp->type,
|
||||||
|
(u_long *) vp->val.integer,
|
||||||
|
vp->val_len);
|
||||||
|
- if (!data)
|
||||||
|
+ if (!p)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||||
|
@@ -4734,37 +4735,37 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
|
||||||
|
case ASN_COUNTER64:
|
||||||
|
vp->val.counter64 = (struct counter64 *) vp->buf;
|
||||||
|
vp->val_len = sizeof(struct counter64);
|
||||||
|
- data = asn_parse_unsigned_int64(var_val, &len, &vp->type,
|
||||||
|
+ p = asn_parse_unsigned_int64(var_val, &len, &vp->type,
|
||||||
|
(struct counter64 *) vp->val.
|
||||||
|
counter64, vp->val_len);
|
||||||
|
- if (!data)
|
||||||
|
+ if (!p)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||||
|
case ASN_OPAQUE_FLOAT:
|
||||||
|
vp->val.floatVal = (float *) vp->buf;
|
||||||
|
vp->val_len = sizeof(float);
|
||||||
|
- data = asn_parse_float(var_val, &len, &vp->type,
|
||||||
|
+ p = asn_parse_float(var_val, &len, &vp->type,
|
||||||
|
vp->val.floatVal, vp->val_len);
|
||||||
|
- if (!data)
|
||||||
|
+ if (!p)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
case ASN_OPAQUE_DOUBLE:
|
||||||
|
vp->val.doubleVal = (double *) vp->buf;
|
||||||
|
vp->val_len = sizeof(double);
|
||||||
|
- data = asn_parse_double(var_val, &len, &vp->type,
|
||||||
|
+ p = asn_parse_double(var_val, &len, &vp->type,
|
||||||
|
vp->val.doubleVal, vp->val_len);
|
||||||
|
- if (!data)
|
||||||
|
+ if (!p)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
case ASN_OPAQUE_I64:
|
||||||
|
vp->val.counter64 = (struct counter64 *) vp->buf;
|
||||||
|
vp->val_len = sizeof(struct counter64);
|
||||||
|
- data = asn_parse_signed_int64(var_val, &len, &vp->type,
|
||||||
|
+ p = asn_parse_signed_int64(var_val, &len, &vp->type,
|
||||||
|
(struct counter64 *) vp->val.counter64,
|
||||||
|
sizeof(*vp->val.counter64));
|
||||||
|
|
||||||
|
- if (!data)
|
||||||
|
+ if (!p)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
#endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
|
||||||
|
@@ -4783,15 +4784,15 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
|
||||||
|
if (vp->val.string == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
- data = asn_parse_string(var_val, &len, &vp->type, vp->val.string,
|
||||||
|
+ p = asn_parse_string(var_val, &len, &vp->type, vp->val.string,
|
||||||
|
&vp->val_len);
|
||||||
|
- if (!data)
|
||||||
|
+ if (!p)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
case ASN_OBJECT_ID:
|
||||||
|
vp->val_len = MAX_OID_LEN;
|
||||||
|
- data = asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
|
||||||
|
- if (!data)
|
||||||
|
+ p = asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
|
||||||
|
+ if (!p)
|
||||||
|
return -1;
|
||||||
|
vp->val_len *= sizeof(oid);
|
||||||
|
vp->val.objid = (oid *) malloc(vp->val_len);
|
||||||
|
@@ -4810,9 +4811,9 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length)
|
||||||
|
if (vp->val.bitstring == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
- data = asn_parse_bitstring(var_val, &len, &vp->type,
|
||||||
|
+ p = asn_parse_bitstring(var_val, &len, &vp->type,
|
||||||
|
vp->val.bitstring, &vp->val_len);
|
||||||
|
- if (!data)
|
||||||
|
+ if (!p)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
default:
|
|
@ -0,0 +1,14 @@
|
||||||
|
Let net-snmp-create-v3-user save settings into /etc/ instead of /usr/
|
||||||
|
|
||||||
|
diff -up net-snmp-5.5/net-snmp-create-v3-user.in.orig net-snmp-5.5/net-snmp-create-v3-user.in
|
||||||
|
--- net-snmp-5.5/net-snmp-create-v3-user.in.orig 2008-07-22 16:33:25.000000000 +0200
|
||||||
|
+++ net-snmp-5.5/net-snmp-create-v3-user.in 2009-09-29 16:30:36.000000000 +0200
|
||||||
|
@@ -158,7 +158,7 @@ if test ! -d $outfile ; then
|
||||||
|
touch $outfile
|
||||||
|
fi
|
||||||
|
echo $line >> $outfile
|
||||||
|
-outfile="@datadir@/snmp/snmpd.conf"
|
||||||
|
+outfile="/etc/snmp/snmpd.conf"
|
||||||
|
line="$token $user"
|
||||||
|
echo "adding the following line to $outfile:"
|
||||||
|
echo " " $line
|
|
@ -0,0 +1,14 @@
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/agent/extend.c.orig net-snmp-5.7.2/agent/mibgroup/agent/extend.c
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/agent/extend.c.orig 2013-07-09 17:12:14.169821974 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/agent/extend.c 2013-07-09 17:12:39.885729685 +0200
|
||||||
|
@@ -1463,8 +1463,8 @@ char * _get_cmdline(netsnmp_extend *exte
|
||||||
|
if (args == NULL)
|
||||||
|
/* Use empty string for processes without arguments. */
|
||||||
|
args = "";
|
||||||
|
-
|
||||||
|
- size = strlen(extend->command) + strlen(extend->args) + 2;
|
||||||
|
+
|
||||||
|
+ size = strlen(extend->command) + strlen(args) + 2;
|
||||||
|
if (size > cmdlinesize) {
|
||||||
|
newbuf = realloc(cmdlinebuf, size);
|
||||||
|
if (!newbuf) {
|
|
@ -0,0 +1,43 @@
|
||||||
|
978384 - possible memory leak while realocking extend.c:1364
|
||||||
|
|
||||||
|
commit 55605ee3452aef5aabe4ed15a83374a97728e64a
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Wed Jan 9 09:26:56 2013 +0100
|
||||||
|
|
||||||
|
Fixed memory leak on failed realloc.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/agent/extend.c.orig net-snmp-5.7.2/agent/mibgroup/agent/extend.c
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/agent/extend.c.orig 2013-06-26 15:50:15.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/agent/extend.c 2013-06-26 15:55:09.839899740 +0200
|
||||||
|
@@ -1457,17 +1457,26 @@ handle_nsExtendOutput2Table(netsnmp_mib_
|
||||||
|
char * _get_cmdline(netsnmp_extend *extend)
|
||||||
|
{
|
||||||
|
size_t size;
|
||||||
|
+ char *args = extend->args;
|
||||||
|
+ char *newbuf;
|
||||||
|
+
|
||||||
|
+ if (args == NULL)
|
||||||
|
+ /* Use empty string for processes without arguments. */
|
||||||
|
+ args = "";
|
||||||
|
|
||||||
|
size = strlen(extend->command) + strlen(extend->args) + 2;
|
||||||
|
if (size > cmdlinesize) {
|
||||||
|
- cmdlinebuf = realloc(cmdlinebuf, size);
|
||||||
|
- if (!cmdlinebuf) {
|
||||||
|
+ newbuf = realloc(cmdlinebuf, size);
|
||||||
|
+ if (!newbuf) {
|
||||||
|
+ free(cmdlinebuf);
|
||||||
|
+ cmdlinebuf = NULL;
|
||||||
|
cmdlinesize = 0;
|
||||||
|
return NULL;
|
||||||
|
- }
|
||||||
|
- cmdlinesize = size;
|
||||||
|
+ }
|
||||||
|
+ cmdlinesize = size;
|
||||||
|
+ cmdlinebuf = newbuf;
|
||||||
|
}
|
||||||
|
- sprintf(cmdlinebuf, "%s %s", extend->command, extend->args);
|
||||||
|
+ sprintf(cmdlinebuf, "%s %s", extend->command, args);
|
||||||
|
return cmdlinebuf;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
851637 - snmpd loops inifinitely after receiving SIGTERM
|
||||||
|
|
||||||
|
commit 9b15aa36d0fc40b46fe9461d56cf584bbf040691
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Thu Sep 13 15:25:52 2012 +0200
|
||||||
|
|
||||||
|
CHANGES: snmpd: fixed infinite loop when SIGTEM arrives in middle of internal query processing.
|
||||||
|
|
||||||
|
When snmpd starts internal query, e.g. for 'monitor' config options, it calls
|
||||||
|
netsnmp_query_walk(). This function loops until either error occurs or the
|
||||||
|
internal request is processed. And if SIGTERM comes to this loop, the request
|
||||||
|
is not marked as failed.
|
||||||
|
|
||||||
|
Patch originally from Masahiro Matsuya, mmatsuya [at] redhat.com
|
||||||
|
|
||||||
|
diff --git a/agent/snmp_agent.c b/agent/snmp_agent.c
|
||||||
|
index 1c00a4c..b7761b0 100644
|
||||||
|
--- a/agent/snmp_agent.c
|
||||||
|
+++ b/agent/snmp_agent.c
|
||||||
|
@@ -3057,6 +3057,9 @@ handle_getnext_loop(netsnmp_agent_session *asp)
|
||||||
|
return status; /* should never really happen */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ if (!netsnmp_running) {
|
||||||
|
+ return SNMP_ERR_GENERR;
|
||||||
|
+ }
|
||||||
|
return SNMP_ERR_NOERROR;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
1104293 - net-snmp OID 32 bit integer returning number larger than 32 bit signed value
|
||||||
|
1192221 - net-snmp OID 32 bit integer returning number larger than 32 bit signed value
|
||||||
|
|
||||||
|
commit 6a421248afab56035066355727380781d515c545
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Jan 26 10:40:10 2015 +0100
|
||||||
|
|
||||||
|
Fix 32 bit integeres in hrStorageTable.
|
||||||
|
|
||||||
|
RFC says the integers are de-facto 31 bits: 1..2147483647.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/host/hrh_storage.c b/agent/mibgroup/host/hrh_storage.c
|
||||||
|
index ca2f854..96b7198 100644
|
||||||
|
--- a/agent/mibgroup/host/hrh_storage.c
|
||||||
|
+++ b/agent/mibgroup/host/hrh_storage.c
|
||||||
|
@@ -421,7 +421,7 @@ really_try_next:
|
||||||
|
if (store_idx > NETSNMP_MEM_TYPE_MAX) {
|
||||||
|
if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
|
NETSNMP_DS_AGENT_REALSTORAGEUNITS))
|
||||||
|
- long_return = HRFS_entry->units & 0xffffffff;
|
||||||
|
+ long_return = HRFS_entry->units & 0x7fffffff;
|
||||||
|
else
|
||||||
|
long_return = HRFS_entry->units_32;
|
||||||
|
} else {
|
||||||
|
@@ -434,7 +434,7 @@ really_try_next:
|
||||||
|
if (store_idx > NETSNMP_MEM_TYPE_MAX) {
|
||||||
|
if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
|
NETSNMP_DS_AGENT_REALSTORAGEUNITS))
|
||||||
|
- long_return = HRFS_entry->size & 0xffffffff;
|
||||||
|
+ long_return = HRFS_entry->size & 0x7fffffff;
|
||||||
|
else
|
||||||
|
long_return = HRFS_entry->size_32;
|
||||||
|
} else {
|
||||||
|
@@ -447,7 +447,7 @@ really_try_next:
|
||||||
|
if (store_idx > NETSNMP_MEM_TYPE_MAX) {
|
||||||
|
if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
|
NETSNMP_DS_AGENT_REALSTORAGEUNITS))
|
||||||
|
- long_return = HRFS_entry->used & 0xffffffff;
|
||||||
|
+ long_return = HRFS_entry->used & 0x7fffffff;
|
||||||
|
else
|
||||||
|
long_return = HRFS_entry->used_32;
|
||||||
|
} else {
|
|
@ -0,0 +1,27 @@
|
||||||
|
978398 - net-snmp does not honor configuration file look-ups as specified in man
|
||||||
|
|
||||||
|
commit 9bd0413bfbdcd845413c135bbff8771fa7130809
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Feb 11 11:57:01 2013 +0100
|
||||||
|
|
||||||
|
Explicitly enumerate configuration files.
|
||||||
|
|
||||||
|
The generic conf and local.conf extensions were interpreted as my.snmp.conf and my.other.snmp.local.conf by some customers.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/man/snmp_config.5.defptch net-snmp-5.7.2/man/snmp_config.5.def
|
||||||
|
--- net-snmp-5.7.2/man/snmp_config.5.defptch 2013-06-26 16:14:33.039284390 +0200
|
||||||
|
+++ net-snmp-5.7.2/man/snmp_config.5.def 2013-06-26 16:14:49.616233272 +0200
|
||||||
|
@@ -11,9 +11,10 @@ found and read from. By default, the ap
|
||||||
|
configuration files in the following 4 directories, in order:
|
||||||
|
SYSCONFDIR/snmp,
|
||||||
|
DATADIR/snmp, /usr/lib(64)/snmp, and $HOME/.snmp. In each of these
|
||||||
|
-directories, it looks for files with the extension of both
|
||||||
|
-.IR conf " and " local.conf
|
||||||
|
-(reading the second ones last). In this manner, there are
|
||||||
|
+directories, it looks for files snmp.conf, snmpd.conf and/or
|
||||||
|
+snmptrapd.conf, as well as snmp.local.conf, snmpd.local.conf
|
||||||
|
+and/or snmptrapd.local.conf. *.local.conf are always
|
||||||
|
+read last. In this manner, there are
|
||||||
|
8 default places a configuration file can exist for any given
|
||||||
|
configuration file type.
|
||||||
|
.PP
|
|
@ -0,0 +1,25 @@
|
||||||
|
Bug 1073237 - "skipNFSInHostResources" option in net-snmp does not skip mvfs type filesystem (IBM clearcase)
|
||||||
|
Bug 1086606
|
||||||
|
|
||||||
|
Non-ABI and non-behavior breaking patch.
|
||||||
|
|
||||||
|
Upstream (upcoming 5.8.0 release) will report mvfs as 'NFS' filesystem, which
|
||||||
|
is then skipped when skipNFSInHostResources is set. We can't do so in RHEL
|
||||||
|
minor updates -> this patch.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.5/agent/mibgroup/hardware/fsys/fsys_mntent.c.mvfs net-snmp-5.5/agent/mibgroup/hardware/fsys/fsys_mntent.c
|
||||||
|
--- net-snmp-5.5/agent/mibgroup/hardware/fsys/fsys_mntent.c.mvfs 2014-04-08 12:56:42.419201488 +0200
|
||||||
|
+++ net-snmp-5.5/agent/mibgroup/hardware/fsys/fsys_mntent.c 2014-04-11 09:41:13.374316570 +0200
|
||||||
|
@@ -208,6 +208,12 @@ netsnmp_fsys_arch_load( void )
|
||||||
|
|
||||||
|
if ( _fsys_remote( entry->device, entry->type ))
|
||||||
|
entry->flags |= NETSNMP_FS_FLAG_REMOTE;
|
||||||
|
+ /* Mark also mvfs (reported as NETSNMP_FS_TYPE_OTHER) as remote.
|
||||||
|
+ * In upstream, it's solved as reporting mvfs as NFS
|
||||||
|
+ * (-> behavior change, forbidden in RHEL minor updates).
|
||||||
|
+ */
|
||||||
|
+ if (!strcmp(m->NSFS_TYPE, MNTTYPE_MVFS))
|
||||||
|
+ entry->flags |= NETSNMP_FS_FLAG_REMOTE;
|
||||||
|
#if HAVE_HASMNTOPT
|
||||||
|
if (hasmntopt( m, "ro" ))
|
||||||
|
entry->flags |= NETSNMP_FS_FLAG_RONLY;
|
|
@ -0,0 +1,104 @@
|
||||||
|
1064338 - various net-snmp-python return code errors
|
||||||
|
|
||||||
|
commit 71a31dabc05e4e86ba14deff427a6911c167e713
|
||||||
|
Author: Wes Hardaker <hardaker@users.sourceforge.net>
|
||||||
|
Date: Fri Jul 30 13:00:49 2010 +0000
|
||||||
|
|
||||||
|
CHANGES: python: patch 3035578: from sws: keep error codes up to date
|
||||||
|
|
||||||
|
git-svn-id: file:///home/hardaker/lib/sf-bkups/net-snmp-convert-svnrepo/trunk@19268 06827809-a52a-0410-b366-d66718629ded
|
||||||
|
|
||||||
|
|
||||||
|
commit 7e1cae42bd79a0cdfb70521558a0dedc5aa0c42d
|
||||||
|
Author: Dave Shield <dts12@users.sourceforge.net>
|
||||||
|
Date: Thu Apr 14 21:31:09 2011 +0000
|
||||||
|
|
||||||
|
CHANGES: python: PATCHES: 3185085: Fix segfault on 64-bit systems
|
||||||
|
git-svn-id: file:///home/hardaker/lib/sf-bkups/net-snmp-convert-svnrepo/trunk@20180 06827809-a52a-0410-b366-d66718629ded
|
||||||
|
|
||||||
|
commit 9a2bfc8f95d6e926dcbf16ff44b53b27e38c8437
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Jul 1 13:54:38 2013 +0200
|
||||||
|
|
||||||
|
CHANGES: python: Fixed returning of empty strings.
|
||||||
|
Varbind type (SNMP_NOSUCHOBJECT etc.) should be used to detect errors instead of length of the variable - it can be empty string.
|
||||||
|
|
||||||
|
commit 408cc9732c346111fc1fda23e136d60883cdb7e4
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Jul 1 14:25:41 2013 +0200
|
||||||
|
|
||||||
|
CHANGES: python: correctly report error when parsing malformed OID.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/python/netsnmp/client_intf.c.test net-snmp-5.7.2/python/netsnmp/client_intf.c
|
||||||
|
--- net-snmp-5.7.2/python/netsnmp/client_intf.c.test 2014-02-13 09:34:37.456480927 +0100
|
||||||
|
+++ net-snmp-5.7.2/python/netsnmp/client_intf.c 2014-02-13 09:51:22.475642391 +0100
|
||||||
|
@@ -658,7 +658,10 @@ int best_guess;
|
||||||
|
newname_len = MAX_OID_LEN;
|
||||||
|
if (read_objid(tag, newname, &newname_len)) { /* long name */
|
||||||
|
rtp = tp = get_tree(newname, newname_len, get_tree_head());
|
||||||
|
- }
|
||||||
|
+ } else {
|
||||||
|
+ /* failed to parse the OID */
|
||||||
|
+ newname_len = 0;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rtp = tp = get_tree(newname, newname_len, get_tree_head());
|
||||||
|
@@ -885,6 +887,15 @@ int *err_ind;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ tmp_err_str = calloc(1, STR_BUF_SIZE);
|
||||||
|
+ if (tmp_err_str == NULL) {
|
||||||
|
+ *err_num = errno;
|
||||||
|
+ *err_ind = SNMPERR_MALLOC;
|
||||||
|
+ status = SNMPERR_MALLOC;
|
||||||
|
+ strncpy(err_str, snmp_api_errstring(*err_ind), STR_BUF_SIZE - 1);
|
||||||
|
+ goto done;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
retry:
|
||||||
|
|
||||||
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
@@ -1589,10 +1600,16 @@ netsnmp_get(PyObject *self, PyObject *ar
|
||||||
|
py_netsnmp_attr_set_string(varbind, "val", (char *) str_buf, len);
|
||||||
|
|
||||||
|
/* save in return tuple as well */
|
||||||
|
- PyTuple_SetItem(val_tuple, varlist_ind,
|
||||||
|
- (len ? Py_BuildValue("s#", str_buf, len) :
|
||||||
|
- Py_BuildValue("")));
|
||||||
|
-
|
||||||
|
+ if ((type == SNMP_ENDOFMIBVIEW) ||
|
||||||
|
+ (type == SNMP_NOSUCHOBJECT) ||
|
||||||
|
+ (type == SNMP_NOSUCHINSTANCE)) {
|
||||||
|
+ /* Translate error to None */
|
||||||
|
+ PyTuple_SetItem(val_tuple, varlist_ind,
|
||||||
|
+ Py_BuildValue(""));
|
||||||
|
+ } else {
|
||||||
|
+ PyTuple_SetItem(val_tuple, varlist_ind,
|
||||||
|
+ Py_BuildValue("s#", str_buf, len));
|
||||||
|
+ }
|
||||||
|
Py_DECREF(varbind);
|
||||||
|
} else {
|
||||||
|
printf("netsnmp_get: bad varbind (%d)\n", varlist_ind);
|
||||||
|
@@ -1801,10 +1818,16 @@ netsnmp_getnext(PyObject *self, PyObject
|
||||||
|
py_netsnmp_attr_set_string(varbind, "val", (char *) str_buf, len);
|
||||||
|
|
||||||
|
/* save in return tuple as well */
|
||||||
|
- PyTuple_SetItem(val_tuple, varlist_ind,
|
||||||
|
- (len ? Py_BuildValue("s#", str_buf, len) :
|
||||||
|
- Py_BuildValue("")));
|
||||||
|
-
|
||||||
|
+ if ((type == SNMP_ENDOFMIBVIEW) ||
|
||||||
|
+ (type == SNMP_NOSUCHOBJECT) ||
|
||||||
|
+ (type == SNMP_NOSUCHINSTANCE)) {
|
||||||
|
+ /* Translate error to None */
|
||||||
|
+ PyTuple_SetItem(val_tuple, varlist_ind,
|
||||||
|
+ Py_BuildValue(""));
|
||||||
|
+ } else {
|
||||||
|
+ PyTuple_SetItem(val_tuple, varlist_ind,
|
||||||
|
+ Py_BuildValue("s#", str_buf, len));
|
||||||
|
+ }
|
||||||
|
Py_DECREF(varbind);
|
||||||
|
} else {
|
||||||
|
printf("netsnmp_getnext: bad varbind (%d)\n", varlist_ind);
|
|
@ -0,0 +1,56 @@
|
||||||
|
Bug 967871 - net-snmp does not display correct lm_sensors sensor data / missing CPU cores
|
||||||
|
|
||||||
|
commit e886f5eb9701851ad6948583156bfd59fcb6110f
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Wed Feb 25 09:30:24 2015 +0100
|
||||||
|
|
||||||
|
CHANGES: snmpd: fixed lm_sensors not reporting sensors with duplicate names.
|
||||||
|
|
||||||
|
Some systems report two or more sensors with the same name.
|
||||||
|
This patch adds support for reporting of all these duplicate
|
||||||
|
sensor names.
|
||||||
|
|
||||||
|
Before the patch, these sensors were reported:
|
||||||
|
> lmTempSensorsDevice.2 = STRING: Core 0
|
||||||
|
|
||||||
|
After the patch, new sensors appear with a prefix:
|
||||||
|
> lmTempSensorsDevice.2 = STRING: Core 0
|
||||||
|
> lmTempSensorsDevice.6 = STRING: coretemp-isa-0004:Core 0
|
||||||
|
|
||||||
|
This approach keeps backward compatibility (applications used to 'Core 0'
|
||||||
|
will keep workig, while it adds new sensorscto the table (with a prefix).
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/hardware/sensors/lmsensors_v3.c b/agent/mibgroup/hardware/sensors/lmsensors_v3.c
|
||||||
|
index 60af9e6..1de7c68 100644
|
||||||
|
--- a/agent/mibgroup/hardware/sensors/lmsensors_v3.c
|
||||||
|
+++ b/agent/mibgroup/hardware/sensors/lmsensors_v3.c
|
||||||
|
@@ -86,7 +86,28 @@ netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
|
||||||
|
* (inserting it in the appropriate sub-containers)
|
||||||
|
*/
|
||||||
|
sp = sensor_by_name( label, type );
|
||||||
|
- if ( sp ) {
|
||||||
|
+ if ( sp && sp->flags & NETSNMP_SENSOR_FLAG_ACTIVE) {
|
||||||
|
+ /*
|
||||||
|
+ * Some HW does not have unique sensors labels.
|
||||||
|
+ * We already have a sensor with this label, thus
|
||||||
|
+ * try to create unique label by adding chip-name prefix
|
||||||
|
+ * and try again.
|
||||||
|
+ */
|
||||||
|
+ char chip_name[64];
|
||||||
|
+ char new_label[128];
|
||||||
|
+ int ret;
|
||||||
|
+ DEBUGMSGTL(("sensors:arch:detail", "Already know label %s, adding prefix\n", label));
|
||||||
|
+ ret = sensors_snprintf_chip_name(chip_name, sizeof(chip_name), chip);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ DEBUGMSGTL(("sensors:arch:detail", "Can't get chip name for label %s\n", label));
|
||||||
|
+ free(label);
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ snprintf(new_label, sizeof(new_label), "%s:%s", chip_name, label);
|
||||||
|
+ DEBUGMSGTL(("sensors:arch:detail", "New label: %s\n", new_label));
|
||||||
|
+ sp = sensor_by_name( new_label, type );
|
||||||
|
+ }
|
||||||
|
+ if (sp) {
|
||||||
|
sp->value = val;
|
||||||
|
sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
1125793 - [RHEL6] net-snmp "storageUseNFS 2" option does not report NFS mount as "Fixed Disks"
|
||||||
|
1193006 - net-snmp "storageUseNFS 2" option does not report NFS mount as "Fixed Disks"
|
||||||
|
|
||||||
|
commit e69e09f8c316cc1bf2456cdc837c487ba3b03837
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Jan 26 13:29:49 2015 +0100
|
||||||
|
|
||||||
|
Fixed storageUseNFS functionality in hrStorageTable.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/host/hrh_storage.c b/agent/mibgroup/host/hrh_storage.c
|
||||||
|
index 96b7198..61ead75 100644
|
||||||
|
--- a/agent/mibgroup/host/hrh_storage.c
|
||||||
|
+++ b/agent/mibgroup/host/hrh_storage.c
|
||||||
|
@@ -384,7 +384,7 @@ really_try_next:
|
||||||
|
return (u_char *) & long_return;
|
||||||
|
case HRSTORE_TYPE:
|
||||||
|
if (store_idx > NETSNMP_MEM_TYPE_MAX)
|
||||||
|
- if (HRFS_entry->flags & NETSNMP_FS_FLAG_REMOTE )
|
||||||
|
+ if (HRFS_entry->flags & NETSNMP_FS_FLAG_REMOTE && storageUseNFS == 1)
|
||||||
|
storage_type_id[storage_type_len - 1] = 10; /* Network Disk */
|
||||||
|
else if (HRFS_entry->flags & NETSNMP_FS_FLAG_REMOVE )
|
||||||
|
storage_type_id[storage_type_len - 1] = 5; /* Removable Disk */
|
|
@ -0,0 +1,32 @@
|
||||||
|
Bug 1146948 - snmptrapd "Forward failed" when SNMPv3 requestid=0
|
||||||
|
Bug 1192511 - snmptrapd "Forward failed" when SNMPv3 requestid=0
|
||||||
|
|
||||||
|
commit 148f2de48e1cd6ba8ebdab8591424df64ab967a3
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Thu Feb 5 14:01:44 2015 +0100
|
||||||
|
|
||||||
|
CHANGES: snmptrapd: Correctly forward traps with Request-ID '0'.
|
||||||
|
|
||||||
|
Request-ID of forwarded traps is taken from the incoming trap and it can be zero.
|
||||||
|
We should not report error in this case.
|
||||||
|
|
||||||
|
diff --git a/apps/snmptrapd_handlers.c b/apps/snmptrapd_handlers.c
|
||||||
|
index 37ca5ab..74cc62e 100644
|
||||||
|
--- a/apps/snmptrapd_handlers.c
|
||||||
|
+++ b/apps/snmptrapd_handlers.c
|
||||||
|
@@ -1013,9 +1013,12 @@ int forward_handler( netsnmp_pdu *pdu,
|
||||||
|
pdu2->transport_data = NULL;
|
||||||
|
pdu2->transport_data_length = 0;
|
||||||
|
}
|
||||||
|
- if (!snmp_send( ss, pdu2 )) {
|
||||||
|
- snmp_sess_perror("Forward failed", ss);
|
||||||
|
- snmp_free_pdu(pdu2);
|
||||||
|
+
|
||||||
|
+ ss->s_snmp_errno = SNMPERR_SUCCESS;
|
||||||
|
+ if (!snmp_send( ss, pdu2 ) &&
|
||||||
|
+ ss->s_snmp_errno != SNMPERR_SUCCESS) {
|
||||||
|
+ snmp_sess_perror("Forward failed", ss);
|
||||||
|
+ snmp_free_pdu(pdu2);
|
||||||
|
}
|
||||||
|
snmp_close( ss );
|
||||||
|
return NETSNMPTRAPD_HANDLER_OK;
|
|
@ -0,0 +1,47 @@
|
||||||
|
Make the man pages multilib safe.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.6/man/netsnmp_config_api.3.def.multilib net-snmp-5.6/man/netsnmp_config_api.3.def
|
||||||
|
--- net-snmp-5.6/man/netsnmp_config_api.3.def.multilib 2010-09-08 17:41:37.000000000 +0200
|
||||||
|
+++ net-snmp-5.6/man/netsnmp_config_api.3.def 2010-10-25 17:40:43.433726423 +0200
|
||||||
|
@@ -295,7 +295,7 @@ for one particular machine.
|
||||||
|
.PP
|
||||||
|
The default list of directories to search is \fC SYSCONFDIR/snmp\fP,
|
||||||
|
followed by \fC DATADIR/snmp\fP,
|
||||||
|
-followed by \fC LIBDIR/snmp\fP,
|
||||||
|
+followed by \fC /usr/lib(64)/snmp\fP,
|
||||||
|
followed by \fC $HOME/.snmp\fP.
|
||||||
|
This list can be changed by setting the environmental variable
|
||||||
|
.I SNMPCONFPATH
|
||||||
|
@@ -365,7 +365,7 @@ function that it should abort the operat
|
||||||
|
SNMPCONFPATH
|
||||||
|
A colon separated list of directories to search for configuration
|
||||||
|
files in.
|
||||||
|
-Default: SYSCONFDIR/snmp:DATADIR/snmp:LIBDIR/snmp:$HOME/.snmp
|
||||||
|
+Default: SYSCONFDIR/snmp:DATADIR/snmp:/usr/lib(64)/snmp:$HOME/.snmp
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
.BR mib_api "(3), " snmp_api (3)
|
||||||
|
.\" Local Variables:
|
||||||
|
diff -up net-snmp-5.6/man/snmp_config.5.def.multilib net-snmp-5.6/man/snmp_config.5.def
|
||||||
|
--- net-snmp-5.6/man/snmp_config.5.def.multilib 2010-09-17 11:51:52.000000000 +0200
|
||||||
|
+++ net-snmp-5.6/man/snmp_config.5.def 2010-10-25 17:40:12.681976439 +0200
|
||||||
|
@@ -10,7 +10,7 @@ First off, there are numerous places tha
|
||||||
|
found and read from. By default, the applications look for
|
||||||
|
configuration files in the following 4 directories, in order:
|
||||||
|
SYSCONFDIR/snmp,
|
||||||
|
-DATADIR/snmp, LIBDIR/snmp, and $HOME/.snmp. In each of these
|
||||||
|
+DATADIR/snmp, /usr/lib(64)/snmp, and $HOME/.snmp. In each of these
|
||||||
|
directories, it looks for files with the extension of both
|
||||||
|
.IR conf " and " local.conf
|
||||||
|
(reading the second ones last). In this manner, there are
|
||||||
|
diff -up net-snmp-5.6/man/snmpd.conf.5.def.multilib net-snmp-5.6/man/snmpd.conf.5.def
|
||||||
|
--- net-snmp-5.6/man/snmpd.conf.5.def.multilib 2010-09-17 11:51:52.000000000 +0200
|
||||||
|
+++ net-snmp-5.6/man/snmpd.conf.5.def 2010-10-25 17:40:12.682976925 +0200
|
||||||
|
@@ -1387,7 +1387,7 @@ filename), and call the initialisation r
|
||||||
|
.RS
|
||||||
|
.IP "Note:"
|
||||||
|
If the specified PATH is not a fully qualified filename, it will
|
||||||
|
-be interpreted relative to LIBDIR/snmp/dlmod, and \fC.so\fR
|
||||||
|
+be interpreted relative to /usr/lib(64)/snmp/dlmod, and \fC.so\fR
|
||||||
|
will be appended to the filename.
|
||||||
|
.RE
|
||||||
|
.PP
|
|
@ -0,0 +1,29 @@
|
||||||
|
Don't check tests which depend on DNS - it's disabled in Koji
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/testing/fulltests/default/T070com2sec_simple.debug net-snmp-5.7.2/testing/fulltests/default/T070com2sec_simple
|
||||||
|
--- net-snmp-5.7.2/testing/fulltests/default/T070com2sec_simple.debug 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/testing/fulltests/default/T070com2sec_simple 2012-10-18 10:16:39.276416510 +0200
|
||||||
|
@@ -134,6 +134,10 @@ SAVECHECKAGENT '<"c406a", 255.255.255.25
|
||||||
|
SAVECHECKAGENT 'line 30: Error:' # msg from h_strerror so it varies
|
||||||
|
SAVECHECKAGENT 'line 31: Error:' # msg from h_strerror so it varies
|
||||||
|
|
||||||
|
+FINISHED
|
||||||
|
+
|
||||||
|
+# don't test the later, it depends on DNS, which is not available in Koji
|
||||||
|
+
|
||||||
|
CHECKAGENT '<"c408a"'
|
||||||
|
if [ "$snmp_last_test_result" -eq 0 ] ; then
|
||||||
|
CHECKAGENT 'line 32: Error:'
|
||||||
|
diff -up net-snmp-5.7.2/testing/fulltests/default/T071com2sec6_simple.debug net-snmp-5.7.2/testing/fulltests/default/T071com2sec6_simple
|
||||||
|
--- net-snmp-5.7.2/testing/fulltests/default/T071com2sec6_simple.debug 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/testing/fulltests/default/T071com2sec6_simple 2012-10-18 10:16:39.276416510 +0200
|
||||||
|
@@ -132,6 +132,9 @@ SAVECHECKAGENT '<"c606a", ffff:ffff:ffff
|
||||||
|
SAVECHECKAGENT 'line 27: Error:'
|
||||||
|
SAVECHECKAGENT 'line 28: Error:'
|
||||||
|
|
||||||
|
+FINISHED
|
||||||
|
+
|
||||||
|
+# don't test the later, it depends on DNS, which is not available in Koji
|
||||||
|
# 608
|
||||||
|
CHECKAGENT '<"c608a"'
|
||||||
|
if [ "$snmp_last_test_result" -eq 0 ] ; then
|
|
@ -0,0 +1,56 @@
|
||||||
|
729738 - net-snmp dumps core in netsnmp_oid_find_prefix
|
||||||
|
|
||||||
|
commit f9304c83f76202db0e684269ca1af32e43cd9db4
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Tue Feb 7 14:53:44 2012 +0100
|
||||||
|
|
||||||
|
CHANGES: PATCH 1633670: fixed snmpd crashing when an AgentX subagent disconnect in the middle of processing of a request.
|
||||||
|
|
||||||
|
I fixed also the memory leak reported in the tracker comments.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/agentx/master.c b/agent/mibgroup/agentx/master.c
|
||||||
|
index c42a42a..baeebaf 100644
|
||||||
|
--- a/agent/mibgroup/agentx/master.c
|
||||||
|
+++ b/agent/mibgroup/agentx/master.c
|
||||||
|
@@ -219,6 +219,9 @@ agentx_got_response(int operation,
|
||||||
|
if (!cache) {
|
||||||
|
DEBUGMSGTL(("agentx/master", "response too late on session %8p\n",
|
||||||
|
session));
|
||||||
|
+ /* response is too late, free the cache */
|
||||||
|
+ if (magic)
|
||||||
|
+ netsnmp_free_delegated_cache((netsnmp_delegated_cache*) magic);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
requests = cache->requests;
|
||||||
|
@@ -606,6 +609,8 @@ agentx_master_handler(netsnmp_mib_handler *handler,
|
||||||
|
result = snmp_async_send(ax_session, pdu, agentx_got_response, cb_data);
|
||||||
|
if (result == 0) {
|
||||||
|
snmp_free_pdu(pdu);
|
||||||
|
+ if (cb_data)
|
||||||
|
+ netsnmp_free_delegated_cache((netsnmp_delegated_cache*) cb_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SNMP_ERR_NOERROR;
|
||||||
|
diff --git a/agent/mibgroup/agentx/master_admin.c b/agent/mibgroup/agentx/master_admin.c
|
||||||
|
index f16f392..b84b85e 100644
|
||||||
|
--- a/agent/mibgroup/agentx/master_admin.c
|
||||||
|
+++ b/agent/mibgroup/agentx/master_admin.c
|
||||||
|
@@ -133,11 +133,16 @@ close_agentx_session(netsnmp_session * session, int sessid)
|
||||||
|
* requests, so that the delegated request will be completed and
|
||||||
|
* further requests can be processed
|
||||||
|
*/
|
||||||
|
- netsnmp_remove_delegated_requests_for_session(session);
|
||||||
|
+ while (netsnmp_remove_delegated_requests_for_session(session)) {
|
||||||
|
+ DEBUGMSGTL(("agentx/master", "Continue removing delegated reqests\n"));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (session->subsession != NULL) {
|
||||||
|
netsnmp_session *subsession = session->subsession;
|
||||||
|
for(; subsession; subsession = subsession->next) {
|
||||||
|
- netsnmp_remove_delegated_requests_for_session(subsession);
|
||||||
|
+ while (netsnmp_remove_delegated_requests_for_session(subsession)) {
|
||||||
|
+ DEBUGMSGTL(("agentx/master", "Continue removing delegated subsession reqests\n"));
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
877326 - dskEntry should be cached
|
||||||
|
|
||||||
|
commit ca7b17a41d4d16bd27aacf92116bea3562eeea36
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Dec 17 12:40:32 2012 +0100
|
||||||
|
|
||||||
|
CHANGES: snmpd: use cache for dskTable to speed it up.
|
||||||
|
|
||||||
|
UCD-SNMP::dskTable was slow on NFS mounts. Now it uses fsys cache
|
||||||
|
to reload mounts every 5 seconds.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/ucd-snmp/disk_hw.c b/agent/mibgroup/ucd-snmp/disk_hw.c
|
||||||
|
index 93ecde3..ea37610 100644
|
||||||
|
--- a/agent/mibgroup/ucd-snmp/disk_hw.c
|
||||||
|
+++ b/agent/mibgroup/ucd-snmp/disk_hw.c
|
||||||
|
@@ -305,8 +305,11 @@ var_extensible_disk(struct variable *vp,
|
||||||
|
unsigned long long val;
|
||||||
|
static long long_ret;
|
||||||
|
static char errmsg[300];
|
||||||
|
+ netsnmp_cache *cache;
|
||||||
|
|
||||||
|
- netsnmp_fsys_load( NULL, NULL ); /* Update the fsys H/W module */
|
||||||
|
+ /* Update the fsys H/W module */
|
||||||
|
+ cache = netsnmp_fsys_get_cache();
|
||||||
|
+ netsnmp_cache_check_and_reload(cache);
|
||||||
|
|
||||||
|
tryAgain:
|
||||||
|
if (header_simple_table
|
|
@ -0,0 +1,62 @@
|
||||||
|
725657: net-snmp should be compiled with relro
|
||||||
|
|
||||||
|
This patch probably won't get ever upstream. It ensures that relro options [1]
|
||||||
|
are propagated where appropriate.
|
||||||
|
|
||||||
|
[1]: configure --with-ldflags="-Wl,-z,relro -Wl,-z,now"
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2.pre2/apps/Makefile.in.rhel net-snmp-5.7.2.pre2/apps/Makefile.in
|
||||||
|
--- net-snmp-5.7.2.pre2/apps/Makefile.in.rhel 2012-07-31 14:00:04.051915227 +0200
|
||||||
|
+++ net-snmp-5.7.2.pre2/apps/Makefile.in 2012-07-31 14:00:05.506909768 +0200
|
||||||
|
@@ -204,7 +204,7 @@ snmpdf$(EXEEXT): snmpdf.$(OSUFFIX) $(
|
||||||
|
$(LINK) ${CFLAGS} -o $@ snmpdf.$(OSUFFIX) ${LDFLAGS} ${LIBS}
|
||||||
|
|
||||||
|
libnetsnmptrapd.$(LIB_EXTENSION)$(LIB_VERSION): $(LLIBTRAPD_OBJS)
|
||||||
|
- $(LIB_LD_CMD) $@ ${LLIBTRAPD_OBJS} $(MIBLIB) $(USELIBS) $(PERLLDOPTS_FOR_LIBS) $(LIB_LD_LIBS)
|
||||||
|
+ $(LIB_LD_CMD) $@ ${LLIBTRAPD_OBJS} $(MIBLIB) $(USELIBS) $(PERLLDOPTS_FOR_LIBS) $(LIB_LD_LIBS) ${LDFLAGS}
|
||||||
|
$(RANLIB) $@
|
||||||
|
|
||||||
|
snmpinforminstall:
|
||||||
|
diff -up net-snmp-5.7.2.pre2/perl/agent/default_store/Makefile.PL.rhel net-snmp-5.7.2.pre2/perl/agent/default_store/Makefile.PL
|
||||||
|
--- net-snmp-5.7.2.pre2/perl/agent/default_store/Makefile.PL.rhel 2012-07-12 04:23:25.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2.pre2/perl/agent/default_store/Makefile.PL 2012-07-31 14:00:08.835898341 +0200
|
||||||
|
@@ -69,6 +69,8 @@ sub InitMakeParams {
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$opts = NetSNMPGetOpts("../../");
|
||||||
|
+ $Params{'LDDLFLAGS'} = "$Config{lddlflags} " . `$opts->{'nsconfig'} --ldflags`;
|
||||||
|
+ chomp($Params{'LDDLFLAGS'});
|
||||||
|
$Params{'LIBS'} = `$opts->{'nsconfig'} --libs`;
|
||||||
|
chomp($Params{'LIBS'});
|
||||||
|
$Params{'CCFLAGS'} = `$opts->{'nsconfig'} --cflags`;
|
||||||
|
diff -up net-snmp-5.7.2.pre2/python/setup.py.rhel net-snmp-5.7.2.pre2/python/setup.py
|
||||||
|
--- net-snmp-5.7.2.pre2/python/setup.py.rhel 2012-07-12 04:23:25.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2.pre2/python/setup.py 2012-07-31 14:00:07.618902228 +0200
|
||||||
|
@@ -18,14 +18,18 @@ if intree:
|
||||||
|
netsnmp_libs = os.popen(basedir+'/net-snmp-config --libs').read()
|
||||||
|
libdir = os.popen(basedir+'/net-snmp-config --build-lib-dirs '+basedir).read()
|
||||||
|
incdir = os.popen(basedir+'/net-snmp-config --build-includes '+basedir).read()
|
||||||
|
+ ldflags = os.popen(basedir+'/net-snmp-config --ldflags').read()
|
||||||
|
libs = re.findall(r"-l(\S+)", netsnmp_libs)
|
||||||
|
libdirs = re.findall(r"-L(\S+)", libdir)
|
||||||
|
incdirs = re.findall(r"-I(\S+)", incdir)
|
||||||
|
+ linkargs = ldflags.split()
|
||||||
|
else:
|
||||||
|
netsnmp_libs = os.popen('net-snmp-config --libs').read()
|
||||||
|
+ ldflags = os.popen('net-snmp-config --ldflags').read()
|
||||||
|
libdirs = re.findall(r"-L(\S+)", netsnmp_libs)
|
||||||
|
incdirs = []
|
||||||
|
libs = re.findall(r"-l(\S+)", netsnmp_libs)
|
||||||
|
+ linkargs = ldflags.split()
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="netsnmp-python", version="1.0a1",
|
||||||
|
@@ -41,6 +45,7 @@ setup(
|
||||||
|
Extension("netsnmp.client_intf", ["netsnmp/client_intf.c"],
|
||||||
|
library_dirs=libdirs,
|
||||||
|
include_dirs=incdirs,
|
||||||
|
- libraries=libs )
|
||||||
|
+ libraries=libs,
|
||||||
|
+ extra_link_args=linkargs )
|
||||||
|
]
|
||||||
|
)
|
|
@ -0,0 +1,38 @@
|
||||||
|
657835: IPv6 tests fail instead of being skipped
|
||||||
|
|
||||||
|
Detect ipv6 before testing ipv6 transports.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2.pre2/testing/fulltests/transports/T320udpv6_simple.rhel net-snmp-5.7.2.pre2/testing/fulltests/transports/T320udpv6_simple
|
||||||
|
--- net-snmp-5.7.2.pre2/testing/fulltests/transports/T320udpv6_simple.rhel 2012-07-12 04:23:25.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2.pre2/testing/fulltests/transports/T320udpv6_simple 2012-07-31 11:10:22.668307328 +0200
|
||||||
|
@@ -6,6 +6,13 @@ HEADER UDP6 Transport
|
||||||
|
|
||||||
|
SKIPIFNOT NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
|
||||||
|
|
||||||
|
+# primitive detection of ipv6
|
||||||
|
+if test `uname -s` == "Linux" ; then
|
||||||
|
+ if test ! -e /proc/net/if_inet6; then
|
||||||
|
+ SKIP
|
||||||
|
+ fi
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
#
|
||||||
|
# Begin test
|
||||||
|
#
|
||||||
|
diff -up net-snmp-5.7.2.pre2/testing/fulltests/transports/T330tcpv6_simple.rhel net-snmp-5.7.2.pre2/testing/fulltests/transports/T330tcpv6_simple
|
||||||
|
--- net-snmp-5.7.2.pre2/testing/fulltests/transports/T330tcpv6_simple.rhel 2012-07-12 04:23:25.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2.pre2/testing/fulltests/transports/T330tcpv6_simple 2012-07-31 11:10:07.756378344 +0200
|
||||||
|
@@ -6,6 +6,13 @@ HEADER TCP6 Transport
|
||||||
|
|
||||||
|
SKIPIFNOT NETSNMP_TRANSPORT_TCPIPV6_DOMAIN
|
||||||
|
|
||||||
|
+# primitive detection of ipv6
|
||||||
|
+if test `uname -s` == "Linux" ; then
|
||||||
|
+ if test ! -e /proc/net/if_inet6; then
|
||||||
|
+ SKIP
|
||||||
|
+ fi
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
#
|
||||||
|
# Begin test
|
||||||
|
#
|
|
@ -0,0 +1,339 @@
|
||||||
|
708370 - net-snmp increments request-id when generating multiple SMUX-PDUs for a SMUX peer
|
||||||
|
|
||||||
|
Source: upstream, copied from master after commit 3fa0088c63fe0dd73417af94d888333192194093
|
||||||
|
(too many individial commits to list)
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2.pre2/agent/mibgroup/smux/smux.c.rhel net-snmp-5.7.2.pre2/agent/mibgroup/smux/smux.c
|
||||||
|
--- net-snmp-5.7.2.pre2/agent/mibgroup/smux/smux.c.rhel 2012-07-31 14:13:18.069018537 +0200
|
||||||
|
+++ net-snmp-5.7.2.pre2/agent/mibgroup/smux/smux.c 2012-07-31 13:49:55.000000000 +0200
|
||||||
|
@@ -66,7 +66,6 @@
|
||||||
|
#include <net-snmp/library/tools.h>
|
||||||
|
|
||||||
|
#include "smux.h"
|
||||||
|
-#include "mibdefs.h"
|
||||||
|
#include "snmpd.h"
|
||||||
|
|
||||||
|
netsnmp_feature_require(snprint_objid)
|
||||||
|
@@ -103,10 +102,9 @@ static int smux_pdu_process(int, u_
|
||||||
|
static int smux_send_rrsp(int, int);
|
||||||
|
static smux_reg *smux_find_match(smux_reg *, int, oid *, size_t, long);
|
||||||
|
static smux_reg *smux_find_replacement(oid *, size_t);
|
||||||
|
-u_char *var_smux(struct variable *, oid *, size_t *, int, size_t *,
|
||||||
|
- WriteMethod ** write_method);
|
||||||
|
-int var_smux_write(int, u_char *, u_char, size_t, u_char *,
|
||||||
|
- oid *, size_t);
|
||||||
|
+u_char *var_smux_get(oid *, size_t, oid *, size_t *, int, size_t *,
|
||||||
|
+ u_char *);
|
||||||
|
+int var_smux_write(int, u_char *, u_char, size_t, oid *, size_t);
|
||||||
|
|
||||||
|
static smux_reg *ActiveRegs; /* Active registrations */
|
||||||
|
static smux_reg *PassiveRegs; /* Currently unused registrations */
|
||||||
|
@@ -114,14 +112,6 @@ static smux_reg *PassiveRegs; /* Curre
|
||||||
|
static smux_peer_auth *Auths[SMUX_MAX_PEERS]; /* Configured peers */
|
||||||
|
static int nauths, npeers = 0;
|
||||||
|
|
||||||
|
-struct variable2 smux_variables[] = {
|
||||||
|
- /*
|
||||||
|
- * bogus entry, as in pass.c
|
||||||
|
- */
|
||||||
|
- {MIBINDEX, ASN_INTEGER, NETSNMP_OLDAPI_RWRITE,
|
||||||
|
- var_smux, 0, {MIBINDEX}},
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -244,7 +234,7 @@ real_init_smux(void)
|
||||||
|
#endif
|
||||||
|
netsnmp_sockaddr_in( &lo_socket, smux_socket, SMUXPORT );
|
||||||
|
|
||||||
|
- if ((smux_listen_sd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||||
|
+ if ((smux_listen_sd = (int) socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||||
|
snmp_log_perror("[init_smux] socket failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@@ -291,21 +281,88 @@ real_init_smux(void)
|
||||||
|
smux_listen_sd, ntohs(lo_socket.sin_port)));
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int
|
||||||
|
+smux_handler(netsnmp_mib_handler *handler,
|
||||||
|
+ netsnmp_handler_registration *reginfo,
|
||||||
|
+ netsnmp_agent_request_info *reqinfo,
|
||||||
|
+ netsnmp_request_info *requests)
|
||||||
|
+{
|
||||||
|
+ u_char *access = NULL;
|
||||||
|
+ size_t var_len;
|
||||||
|
+ int exact = 1;
|
||||||
|
+ int status = 0;
|
||||||
|
+ u_char var_type;
|
||||||
|
+ static long old_reqid = -1;
|
||||||
|
+ static long old_sessid = -1;
|
||||||
|
+ long new_reqid, new_sessid;
|
||||||
|
+
|
||||||
|
+ /* Increment the reqid of outgoing SMUX messages only when processing
|
||||||
|
+ * new incoming SNMP message, i.e. when reqid or session id chamges */
|
||||||
|
+ new_reqid = reqinfo->asp->pdu->reqid;
|
||||||
|
+ new_sessid = reqinfo->asp->session->sessid;
|
||||||
|
+ DEBUGMSGTL(("smux", "smux_handler: incoming reqid=%ld, sessid=%ld\n",
|
||||||
|
+ new_reqid, new_sessid));
|
||||||
|
+ if (old_reqid != new_reqid || old_sessid != new_sessid) {
|
||||||
|
+ smux_reqid++;
|
||||||
|
+ old_reqid = new_reqid;
|
||||||
|
+ old_sessid = new_sessid;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ switch (reqinfo->mode) {
|
||||||
|
+ case MODE_GETNEXT:
|
||||||
|
+ case MODE_GETBULK:
|
||||||
|
+ exact = 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (; requests; requests = requests->next) {
|
||||||
|
+ switch(reqinfo->mode) {
|
||||||
|
+ case MODE_GET:
|
||||||
|
+ case MODE_GETNEXT:
|
||||||
|
+ case MODE_SET_RESERVE1:
|
||||||
|
+ access = var_smux_get(reginfo->rootoid,
|
||||||
|
+ reginfo->rootoid_len,
|
||||||
|
+ requests->requestvb->name,
|
||||||
|
+ &requests->requestvb->name_length,
|
||||||
|
+ exact,
|
||||||
|
+ &var_len,
|
||||||
|
+ &var_type);
|
||||||
|
+ if (access)
|
||||||
|
+ if (reqinfo->mode != MODE_SET_RESERVE1)
|
||||||
|
+ snmp_set_var_typed_value(requests->requestvb,
|
||||||
|
+ var_type, access, var_len);
|
||||||
|
+ if (reqinfo->mode != MODE_SET_RESERVE1)
|
||||||
|
+ break;
|
||||||
|
+ /* fall through if MODE_SET_RESERVE1 */
|
||||||
|
+
|
||||||
|
+ default:
|
||||||
|
+ /* SET processing */
|
||||||
|
+ status = var_smux_write(reqinfo->mode,
|
||||||
|
+ requests->requestvb->val.string,
|
||||||
|
+ requests->requestvb->type,
|
||||||
|
+ requests->requestvb->val_len,
|
||||||
|
+ requests->requestvb->name,
|
||||||
|
+ requests->requestvb->name_length);
|
||||||
|
+ if (status != SNMP_ERR_NOERROR) {
|
||||||
|
+ netsnmp_set_request_error(reqinfo, requests, status);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return SNMP_ERR_NOERROR;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
u_char *
|
||||||
|
-var_smux(struct variable * vp,
|
||||||
|
- oid * name,
|
||||||
|
- size_t * length,
|
||||||
|
- int exact, size_t * var_len, WriteMethod ** write_method)
|
||||||
|
+var_smux_get(oid *root, size_t root_len,
|
||||||
|
+ oid * name, size_t * length,
|
||||||
|
+ int exact, size_t * var_len, u_char *var_type)
|
||||||
|
{
|
||||||
|
- u_char *valptr, val_type;
|
||||||
|
+ u_char *valptr;
|
||||||
|
smux_reg *rptr;
|
||||||
|
|
||||||
|
- *write_method = var_smux_write;
|
||||||
|
/*
|
||||||
|
* search the active registration list
|
||||||
|
*/
|
||||||
|
for (rptr = ActiveRegs; rptr; rptr = rptr->sr_next) {
|
||||||
|
- if (0 >= snmp_oidtree_compare(vp->name, vp->namelen, rptr->sr_name,
|
||||||
|
+ if (0 >= snmp_oidtree_compare(root, root_len, rptr->sr_name,
|
||||||
|
rptr->sr_name_len))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
@@ -315,7 +372,7 @@ var_smux(struct variable * vp,
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
valptr = smux_snmp_process(exact, name, length,
|
||||||
|
- var_len, &val_type, rptr->sr_fd);
|
||||||
|
+ var_len, var_type, rptr->sr_fd);
|
||||||
|
|
||||||
|
if (valptr == NULL)
|
||||||
|
return NULL;
|
||||||
|
@@ -328,10 +385,6 @@ var_smux(struct variable * vp,
|
||||||
|
*/
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
- /*
|
||||||
|
- * set the type and return the value
|
||||||
|
- */
|
||||||
|
- vp->type = val_type;
|
||||||
|
return valptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -341,7 +394,7 @@ var_smux_write(int action,
|
||||||
|
u_char * var_val,
|
||||||
|
u_char var_val_type,
|
||||||
|
size_t var_val_len,
|
||||||
|
- u_char * statP, oid * name, size_t name_len)
|
||||||
|
+ oid * name, size_t name_len)
|
||||||
|
{
|
||||||
|
smux_reg *rptr;
|
||||||
|
u_char buf[SMUXMAXPKTSIZE], *ptr, sout[3], type;
|
||||||
|
@@ -589,7 +642,7 @@ smux_accept(int sd)
|
||||||
|
*/
|
||||||
|
DEBUGMSGTL(("smux", "[smux_accept] Calling accept()\n"));
|
||||||
|
errno = 0;
|
||||||
|
- if ((fd = accept(sd, (struct sockaddr *) &in_socket, &alen)) < 0) {
|
||||||
|
+ if ((fd = (int) accept(sd, (struct sockaddr *) &in_socket, &alen)) < 0) {
|
||||||
|
snmp_log_perror("[smux_accept] accept failed");
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
@@ -1000,6 +1053,7 @@ smux_rreq_process(int sd, u_char * ptr,
|
||||||
|
int i, result;
|
||||||
|
u_char type;
|
||||||
|
smux_reg *rptr, *nrptr;
|
||||||
|
+ netsnmp_handler_registration *reg;
|
||||||
|
|
||||||
|
oid_name_len = MAX_OID_LEN;
|
||||||
|
ptr = asn_parse_objid(ptr, len, &type, oid_name, &oid_name_len);
|
||||||
|
@@ -1157,17 +1211,27 @@ smux_rreq_process(int sd, u_char * ptr,
|
||||||
|
*/
|
||||||
|
if (nrptr->sr_priority == -1)
|
||||||
|
nrptr->sr_priority = 0;
|
||||||
|
+
|
||||||
|
+ reg = netsnmp_create_handler_registration("smux",
|
||||||
|
+ smux_handler,
|
||||||
|
+ nrptr->sr_name,
|
||||||
|
+ nrptr->sr_name_len,
|
||||||
|
+ HANDLER_CAN_RWRITE);
|
||||||
|
+ if (reg == NULL) {
|
||||||
|
+ snmp_log(LOG_ERR, "SMUX: cannot create new smux peer "
|
||||||
|
+ "registration\n");
|
||||||
|
+ smux_send_rrsp(sd, -1);
|
||||||
|
+ free(nrptr);
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+ if (netsnmp_register_handler(reg) != MIB_REGISTERED_OK) {
|
||||||
|
+ snmp_log(LOG_ERR, "SMUX: cannot register new smux peer\n");
|
||||||
|
+ smux_send_rrsp(sd, -1);
|
||||||
|
+ free(nrptr);
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+ nrptr->reginfo = reg;
|
||||||
|
smux_list_add(&ActiveRegs, nrptr);
|
||||||
|
- if (register_mib("smux", (struct variable *)
|
||||||
|
- smux_variables, sizeof(struct variable2),
|
||||||
|
- 1, nrptr->sr_name, nrptr->sr_name_len)
|
||||||
|
- != SNMPERR_SUCCESS) {
|
||||||
|
- DEBUGMSGTL(("smux", "[smux_rreq_process] Failed to register subtree\n"));
|
||||||
|
- smux_list_detach(&ActiveRegs, nrptr);
|
||||||
|
- free(nrptr);
|
||||||
|
- smux_send_rrsp(sd, -1);
|
||||||
|
- return NULL;
|
||||||
|
- }
|
||||||
|
|
||||||
|
done:
|
||||||
|
smux_send_rrsp(sd, nrptr->sr_priority);
|
||||||
|
@@ -1214,16 +1278,35 @@ smux_find_match(smux_reg * regs, int sd,
|
||||||
|
static void
|
||||||
|
smux_replace_active(smux_reg * actptr, smux_reg * pasptr)
|
||||||
|
{
|
||||||
|
+ netsnmp_handler_registration *reg;
|
||||||
|
+
|
||||||
|
smux_list_detach(&ActiveRegs, actptr);
|
||||||
|
- unregister_mib(actptr->sr_name, actptr->sr_name_len);
|
||||||
|
+ if (actptr->reginfo) {
|
||||||
|
+ netsnmp_unregister_handler(actptr->reginfo);
|
||||||
|
+ actptr->reginfo = NULL;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
smux_list_detach(&PassiveRegs, pasptr);
|
||||||
|
- (void) smux_list_add(&ActiveRegs, pasptr);
|
||||||
|
|
||||||
|
- register_mib("smux", (struct variable *) smux_variables,
|
||||||
|
- sizeof(struct variable2), 1, pasptr->sr_name,
|
||||||
|
- pasptr->sr_name_len);
|
||||||
|
+ (void) smux_list_add(&ActiveRegs, pasptr);
|
||||||
|
free(actptr);
|
||||||
|
+
|
||||||
|
+ reg = netsnmp_create_handler_registration("smux",
|
||||||
|
+ smux_handler,
|
||||||
|
+ pasptr->sr_name,
|
||||||
|
+ pasptr->sr_name_len,
|
||||||
|
+ HANDLER_CAN_RWRITE);
|
||||||
|
+ if (reg == NULL) {
|
||||||
|
+ snmp_log(LOG_ERR, "SMUX: cannot create new smux peer registration\n");
|
||||||
|
+ pasptr->reginfo = NULL;
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ if (netsnmp_register_handler(reg) != MIB_REGISTERED_OK) {
|
||||||
|
+ snmp_log(LOG_ERR, "SMUX: cannot register new smux peer\n");
|
||||||
|
+ pasptr->reginfo = NULL;
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ pasptr->reginfo = reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
@@ -1373,8 +1456,6 @@ smux_snmp_process(int exact,
|
||||||
|
/*
|
||||||
|
* Send the query to the peer
|
||||||
|
*/
|
||||||
|
- smux_reqid++;
|
||||||
|
-
|
||||||
|
if (exact)
|
||||||
|
type = SMUX_GET;
|
||||||
|
else
|
||||||
|
@@ -1757,6 +1838,7 @@ smux_peer_cleanup(int sd)
|
||||||
|
{
|
||||||
|
smux_reg *nrptr, *rptr, *rptr2;
|
||||||
|
int i;
|
||||||
|
+ netsnmp_handler_registration *reg;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* close the descriptor
|
||||||
|
@@ -1781,15 +1863,30 @@ smux_peer_cleanup(int sd)
|
||||||
|
rptr2 = rptr->sr_next;
|
||||||
|
if (rptr->sr_fd == sd) {
|
||||||
|
smux_list_detach(&ActiveRegs, rptr);
|
||||||
|
- unregister_mib(rptr->sr_name, rptr->sr_name_len);
|
||||||
|
+ if (rptr->reginfo) {
|
||||||
|
+ netsnmp_unregister_handler(rptr->reginfo);
|
||||||
|
+ rptr->reginfo = NULL;
|
||||||
|
+ }
|
||||||
|
if ((nrptr = smux_find_replacement(rptr->sr_name,
|
||||||
|
rptr->sr_name_len)) !=
|
||||||
|
- NULL) {
|
||||||
|
+ NULL) {
|
||||||
|
smux_list_detach(&PassiveRegs, nrptr);
|
||||||
|
+ reg = netsnmp_create_handler_registration("smux",
|
||||||
|
+ smux_handler,
|
||||||
|
+ nrptr->sr_name,
|
||||||
|
+ nrptr->sr_name_len,
|
||||||
|
+ HANDLER_CAN_RWRITE);
|
||||||
|
+ if (reg == NULL) {
|
||||||
|
+ snmp_log(LOG_ERR, "SMUX: cannot create new smux peer "
|
||||||
|
+ "registration\n");
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ if (netsnmp_register_handler(reg) != MIB_REGISTERED_OK) {
|
||||||
|
+ snmp_log(LOG_ERR, "SMUX: cannot register new smux peer\n");
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ nrptr->reginfo = reg;
|
||||||
|
smux_list_add(&ActiveRegs, nrptr);
|
||||||
|
- register_mib("smux", (struct variable *)
|
||||||
|
- smux_variables, sizeof(struct variable2),
|
||||||
|
- 1, nrptr->sr_name, nrptr->sr_name_len);
|
||||||
|
}
|
||||||
|
free(rptr);
|
||||||
|
}
|
||||||
|
diff -up net-snmp-5.7.2.pre2/agent/mibgroup/smux/smux.h.rhel net-snmp-5.7.2.pre2/agent/mibgroup/smux/smux.h
|
||||||
|
--- net-snmp-5.7.2.pre2/agent/mibgroup/smux/smux.h.rhel 2012-07-31 14:13:21.893006290 +0200
|
||||||
|
+++ net-snmp-5.7.2.pre2/agent/mibgroup/smux/smux.h 2012-07-31 13:49:55.000000000 +0200
|
||||||
|
@@ -60,6 +60,7 @@ typedef struct _smux_reg {
|
||||||
|
int sr_priority; /* priority of registration */
|
||||||
|
int sr_fd; /* descriptor of owner */
|
||||||
|
struct _smux_reg *sr_next; /* next one */
|
||||||
|
+ netsnmp_handler_registration *reginfo;
|
||||||
|
} smux_reg;
|
||||||
|
|
||||||
|
extern void init_smux(void);
|
|
@ -0,0 +1,24 @@
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/hardware/fsys/fsys_mntent.c.orig net-snmp-5.7.2/agent/mibgroup/hardware/fsys/fsys_mntent.c
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/hardware/fsys/fsys_mntent.c.orig 2018-04-05 18:29:29.042682282 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/hardware/fsys/fsys_mntent.c 2018-04-05 19:03:16.270523986 +0200
|
||||||
|
@@ -142,6 +142,7 @@ _fsys_type( char *typename )
|
||||||
|
!strcmp(typename, MNTTYPE_SIMFS) ||
|
||||||
|
!strcmp(typename, MNTTYPE_VZFS) ||
|
||||||
|
!strcmp(typename, MNTTYPE_BTRFS) ||
|
||||||
|
+ !strcmp(typename, MNTTYPE_ACFS) ||
|
||||||
|
!strcmp(typename, MNTTYPE_LOFS))
|
||||||
|
return NETSNMP_FS_TYPE_OTHER;
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/hardware/fsys/mnttypes.h.orig net-snmp-5.7.2/agent/mibgroup/hardware/fsys/mnttypes.h
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/hardware/fsys/mnttypes.h.orig 2018-04-05 18:28:36.694091896 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/hardware/fsys/mnttypes.h 2018-04-05 20:14:55.695813461 +0200
|
||||||
|
@@ -151,6 +151,9 @@
|
||||||
|
#ifndef MNTTYPE_BTRFS
|
||||||
|
#define MNTTYPE_BTRFS "btrfs"
|
||||||
|
#endif
|
||||||
|
+#ifndef MNTTYPE_ACFS
|
||||||
|
+#define MNTTYPE_ACFS "acfs"
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File systems to skip
|
|
@ -0,0 +1,12 @@
|
||||||
|
diff -urNp old/agent/mibgroup/agentx/master.c new/agent/mibgroup/agentx/master.c
|
||||||
|
--- old/agent/mibgroup/agentx/master.c 2017-03-29 11:33:29.643295606 +0200
|
||||||
|
+++ new/agent/mibgroup/agentx/master.c 2017-03-29 11:36:56.532670645 +0200
|
||||||
|
@@ -222,7 +222,7 @@ agentx_got_response(int operation,
|
||||||
|
/* response is too late, free the cache */
|
||||||
|
if (magic)
|
||||||
|
netsnmp_free_delegated_cache((netsnmp_delegated_cache*) magic);
|
||||||
|
- return 0;
|
||||||
|
+ return 1;
|
||||||
|
}
|
||||||
|
requests = cache->requests;
|
||||||
|
|
|
@ -0,0 +1,207 @@
|
||||||
|
969061 - net-snmpd crash on time out
|
||||||
|
|
||||||
|
ABI breaking upstream patch.
|
||||||
|
|
||||||
|
commit 793d596838ff7cb48a73b675d62897c56c9e62df
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Tue Jul 2 14:32:56 2013 +0200
|
||||||
|
|
||||||
|
From: Jiri Cervenka: snmpd: Fixed agentx crashing and/or freezing on timeout.
|
||||||
|
|
||||||
|
Queued requests are dropped gracefuly.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/agentx/master_admin.c b/agent/mibgroup/agentx/master_admin.c
|
||||||
|
index 999128a..4b42104 100644
|
||||||
|
--- a/agent/mibgroup/agentx/master_admin.c
|
||||||
|
+++ b/agent/mibgroup/agentx/master_admin.c
|
||||||
|
@@ -158,6 +158,7 @@ close_agentx_session(netsnmp_session * session, int sessid)
|
||||||
|
for (sp = session->subsession; sp != NULL; sp = sp->next) {
|
||||||
|
|
||||||
|
if (sp->sessid == sessid) {
|
||||||
|
+ netsnmp_remove_delegated_requests_for_session(sp);
|
||||||
|
unregister_mibs_by_session(sp);
|
||||||
|
unregister_index_by_session(sp);
|
||||||
|
unregister_sysORTable_by_session(sp);
|
||||||
|
diff --git a/agent/snmp_agent.c b/agent/snmp_agent.c
|
||||||
|
index 1261c53..51eb287 100644
|
||||||
|
--- a/agent/snmp_agent.c
|
||||||
|
+++ b/agent/snmp_agent.c
|
||||||
|
@@ -1415,6 +1415,7 @@ init_agent_snmp_session(netsnmp_session * session, netsnmp_pdu *pdu)
|
||||||
|
asp->treecache_num = -1;
|
||||||
|
asp->treecache_len = 0;
|
||||||
|
asp->reqinfo = SNMP_MALLOC_TYPEDEF(netsnmp_agent_request_info);
|
||||||
|
+ asp->flags = SNMP_AGENT_FLAGS_NONE;
|
||||||
|
DEBUGMSGTL(("verbose:asp", "asp %p reqinfo %p created\n",
|
||||||
|
asp, asp->reqinfo));
|
||||||
|
|
||||||
|
@@ -1463,6 +1464,9 @@ netsnmp_check_for_delegated(netsnmp_agent_session *asp)
|
||||||
|
|
||||||
|
if (NULL == asp->treecache)
|
||||||
|
return 0;
|
||||||
|
+
|
||||||
|
+ if (asp->flags & SNMP_AGENT_FLAGS_CANCEL_IN_PROGRESS)
|
||||||
|
+ return 0;
|
||||||
|
|
||||||
|
for (i = 0; i <= asp->treecache_num; i++) {
|
||||||
|
for (request = asp->treecache[i].requests_begin; request;
|
||||||
|
@@ -1541,39 +1545,48 @@ int
|
||||||
|
netsnmp_remove_delegated_requests_for_session(netsnmp_session *sess)
|
||||||
|
{
|
||||||
|
netsnmp_agent_session *asp;
|
||||||
|
- int count = 0;
|
||||||
|
+ int total_count = 0;
|
||||||
|
|
||||||
|
for (asp = agent_delegated_list; asp; asp = asp->next) {
|
||||||
|
/*
|
||||||
|
* check each request
|
||||||
|
*/
|
||||||
|
+ int i;
|
||||||
|
+ int count = 0;
|
||||||
|
netsnmp_request_info *request;
|
||||||
|
- for(request = asp->requests; request; request = request->next) {
|
||||||
|
- /*
|
||||||
|
- * check session
|
||||||
|
- */
|
||||||
|
- netsnmp_assert(NULL!=request->subtree);
|
||||||
|
- if(request->subtree->session != sess)
|
||||||
|
- continue;
|
||||||
|
+ for (i = 0; i <= asp->treecache_num; i++) {
|
||||||
|
+ for (request = asp->treecache[i].requests_begin; request;
|
||||||
|
+ request = request->next) {
|
||||||
|
+ /*
|
||||||
|
+ * check session
|
||||||
|
+ */
|
||||||
|
+ netsnmp_assert(NULL!=request->subtree);
|
||||||
|
+ if(request->subtree->session != sess)
|
||||||
|
+ continue;
|
||||||
|
|
||||||
|
- /*
|
||||||
|
- * matched! mark request as done
|
||||||
|
- */
|
||||||
|
- netsnmp_request_set_error(request, SNMP_ERR_GENERR);
|
||||||
|
- ++count;
|
||||||
|
+ /*
|
||||||
|
+ * matched! mark request as done
|
||||||
|
+ */
|
||||||
|
+ netsnmp_request_set_error(request, SNMP_ERR_GENERR);
|
||||||
|
+ ++count;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ if (count) {
|
||||||
|
+ asp->flags |= SNMP_AGENT_FLAGS_CANCEL_IN_PROGRESS;
|
||||||
|
+ total_count += count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if we found any, that request may be finished now
|
||||||
|
*/
|
||||||
|
- if(count) {
|
||||||
|
+ if(total_count) {
|
||||||
|
DEBUGMSGTL(("snmp_agent", "removed %d delegated request(s) for session "
|
||||||
|
- "%8p\n", count, sess));
|
||||||
|
- netsnmp_check_outstanding_agent_requests();
|
||||||
|
+ "%8p\n", total_count, sess));
|
||||||
|
+ netsnmp_check_delegated_requests();
|
||||||
|
}
|
||||||
|
|
||||||
|
- return count;
|
||||||
|
+ return total_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
@@ -2745,19 +2758,11 @@ handle_var_requests(netsnmp_agent_session *asp)
|
||||||
|
return final_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
-/*
|
||||||
|
- * loop through our sessions known delegated sessions and check to see
|
||||||
|
- * if they've completed yet. If there are no more delegated sessions,
|
||||||
|
- * check for and process any queued requests
|
||||||
|
- */
|
||||||
|
void
|
||||||
|
-netsnmp_check_outstanding_agent_requests(void)
|
||||||
|
+netsnmp_check_delegated_requests(void)
|
||||||
|
{
|
||||||
|
netsnmp_agent_session *asp, *prev_asp = NULL, *next_asp = NULL;
|
||||||
|
|
||||||
|
- /*
|
||||||
|
- * deal with delegated requests
|
||||||
|
- */
|
||||||
|
for (asp = agent_delegated_list; asp; asp = next_asp) {
|
||||||
|
next_asp = asp->next; /* save in case we clean up asp */
|
||||||
|
if (!netsnmp_check_for_delegated(asp)) {
|
||||||
|
@@ -2796,6 +2801,22 @@ netsnmp_check_outstanding_agent_requests(void)
|
||||||
|
prev_asp = asp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * loop through our sessions known delegated sessions and check to see
|
||||||
|
+ * if they've completed yet. If there are no more delegated sessions,
|
||||||
|
+ * check for and process any queued requests
|
||||||
|
+ */
|
||||||
|
+void
|
||||||
|
+netsnmp_check_outstanding_agent_requests(void)
|
||||||
|
+{
|
||||||
|
+ netsnmp_agent_session *asp;
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * deal with delegated requests
|
||||||
|
+ */
|
||||||
|
+ netsnmp_check_delegated_requests();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if we are processing a set and there are more delegated
|
||||||
|
@@ -2825,7 +2846,8 @@ netsnmp_check_outstanding_agent_requests(void)
|
||||||
|
|
||||||
|
netsnmp_processing_set = netsnmp_agent_queued_list;
|
||||||
|
DEBUGMSGTL(("snmp_agent", "SET request remains queued while "
|
||||||
|
- "delegated requests finish, asp = %8p\n", asp));
|
||||||
|
+ "delegated requests finish, asp = %8p\n",
|
||||||
|
+ agent_delegated_list));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||||
|
@@ -2886,6 +2908,10 @@ check_delayed_request(netsnmp_agent_session *asp)
|
||||||
|
case SNMP_MSG_GETBULK:
|
||||||
|
case SNMP_MSG_GETNEXT:
|
||||||
|
netsnmp_check_all_requests_status(asp, 0);
|
||||||
|
+ if (asp->flags & SNMP_AGENT_FLAGS_CANCEL_IN_PROGRESS) {
|
||||||
|
+ DEBUGMSGTL(("snmp_agent","canceling next walk for asp %p\n", asp));
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
handle_getnext_loop(asp);
|
||||||
|
if (netsnmp_check_for_delegated(asp) &&
|
||||||
|
netsnmp_check_transaction_id(asp->pdu->transid) !=
|
||||||
|
diff --git a/include/net-snmp/agent/snmp_agent.h b/include/net-snmp/agent/snmp_agent.h
|
||||||
|
index aad8837..43f4fff 100644
|
||||||
|
--- a/include/net-snmp/agent/snmp_agent.h
|
||||||
|
+++ b/include/net-snmp/agent/snmp_agent.h
|
||||||
|
@@ -32,6 +32,9 @@ extern "C" {
|
||||||
|
#define SNMP_MAX_PDU_SIZE 64000 /* local constraint on PDU size sent by agent
|
||||||
|
* (see also SNMP_MAX_MSG_SIZE in snmp_api.h) */
|
||||||
|
|
||||||
|
+#define SNMP_AGENT_FLAGS_NONE 0x0
|
||||||
|
+#define SNMP_AGENT_FLAGS_CANCEL_IN_PROGRESS 0x1
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* If non-zero, causes the addresses of peers to be logged when receptions
|
||||||
|
* occur.
|
||||||
|
@@ -205,6 +208,7 @@ extern "C" {
|
||||||
|
int treecache_num; /* number of current cache entries */
|
||||||
|
netsnmp_cachemap *cache_store;
|
||||||
|
int vbcount;
|
||||||
|
+ int flags;
|
||||||
|
} netsnmp_agent_session;
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ -240,6 +244,7 @@ extern "C" {
|
||||||
|
int init_master_agent(void);
|
||||||
|
void shutdown_master_agent(void);
|
||||||
|
int agent_check_and_process(int block);
|
||||||
|
+ void netsnmp_check_delegated_requests(void);
|
||||||
|
void netsnmp_check_outstanding_agent_requests(void);
|
||||||
|
|
||||||
|
int netsnmp_request_set_error(netsnmp_request_info *request,
|
|
@ -0,0 +1,199 @@
|
||||||
|
diff -urNp oold/agent/mibgroup/hardware/fsys/fsys_mntctl.c nnew/agent/mibgroup/hardware/fsys/fsys_mntctl.c
|
||||||
|
--- oold/agent/mibgroup/hardware/fsys/fsys_mntctl.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ nnew/agent/mibgroup/hardware/fsys/fsys_mntctl.c 2017-10-31 10:21:53.433280099 +0100
|
||||||
|
@@ -43,8 +43,9 @@ _fsys_type( int type)
|
||||||
|
|
||||||
|
case MNT_NFS:
|
||||||
|
case MNT_NFS3:
|
||||||
|
- case MNT_AUTOFS:
|
||||||
|
return NETSNMP_FS_TYPE_NFS;
|
||||||
|
+ case MNT_AUTOFS:
|
||||||
|
+ return NETSNMP_FS_TYPE_AUTOFS;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following code covers selected filesystems
|
||||||
|
@@ -153,10 +154,12 @@ netsnmp_fsys_arch_load( void )
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Optionally skip retrieving statistics for remote mounts
|
||||||
|
+ * AUTOFS is skipped by default
|
||||||
|
*/
|
||||||
|
- if ( (entry->flags & NETSNMP_FS_FLAG_REMOTE) &&
|
||||||
|
+ if ( ((entry->flags & NETSNMP_FS_FLAG_REMOTE) &&
|
||||||
|
netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
|
- NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES))
|
||||||
|
+ NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES)) ||
|
||||||
|
+ entry->type == (NETSNMP_FS_TYPE_AUTOFS))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( statfs( entry->path, &stat_buf ) < 0 ) {
|
||||||
|
diff -urNp oold/agent/mibgroup/hardware/fsys/fsys_mntent.c nnew/agent/mibgroup/hardware/fsys/fsys_mntent.c
|
||||||
|
--- oold/agent/mibgroup/hardware/fsys/fsys_mntent.c 2017-10-30 14:50:41.784743150 +0100
|
||||||
|
+++ nnew/agent/mibgroup/hardware/fsys/fsys_mntent.c 2017-10-31 08:59:08.953114110 +0100
|
||||||
|
@@ -145,6 +145,13 @@ _fsys_type( char *typename )
|
||||||
|
!strcmp(typename, MNTTYPE_LOFS))
|
||||||
|
return NETSNMP_FS_TYPE_OTHER;
|
||||||
|
|
||||||
|
+ /* Detection of AUTOFS.
|
||||||
|
+ * This file system will be ignored by default
|
||||||
|
+ */
|
||||||
|
+ else if ( !strcmp(typename, MNTTYPE_AUTOFS))
|
||||||
|
+ return NETSNMP_FS_TYPE_AUTOFS;
|
||||||
|
+
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* All other types are silently skipped
|
||||||
|
*/
|
||||||
|
@@ -239,6 +246,10 @@ netsnmp_fsys_arch_load( void )
|
||||||
|
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
+ /* Skip AUTOFS enteries */
|
||||||
|
+ if ( entry->type == (NETSNMP_FS_TYPE_AUTOFS))
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
#ifdef irix6
|
||||||
|
if ( NSFS_STATFS( entry->path, &stat_buf, sizeof(struct statfs), 0) < 0 )
|
||||||
|
#else
|
||||||
|
diff -urNp oold/agent/mibgroup/hardware/fsys/mnttypes.h nnew/agent/mibgroup/hardware/fsys/mnttypes.h
|
||||||
|
--- oold/agent/mibgroup/hardware/fsys/mnttypes.h 2017-10-30 14:50:41.741743139 +0100
|
||||||
|
+++ nnew/agent/mibgroup/hardware/fsys/mnttypes.h 2017-10-31 09:01:40.462427047 +0100
|
||||||
|
@@ -159,6 +159,9 @@
|
||||||
|
#ifndef MNTTYPE_APP
|
||||||
|
#define MNTTYPE_APP "app"
|
||||||
|
#endif
|
||||||
|
+#ifndef MNTTYPE_AUTOFS
|
||||||
|
+#define MNTTYPE_AUTOFS "autofs"
|
||||||
|
+#endif
|
||||||
|
#ifndef MNTTYPE_DEVPTS
|
||||||
|
#define MNTTYPE_DEVPTS "devpts"
|
||||||
|
#endif
|
||||||
|
diff -urNp oold/agent/mibgroup/host/hr_filesys.c nnew/agent/mibgroup/host/hr_filesys.c
|
||||||
|
--- oold/agent/mibgroup/host/hr_filesys.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ nnew/agent/mibgroup/host/hr_filesys.c 2017-10-31 09:28:46.926093897 +0100
|
||||||
|
@@ -839,6 +839,27 @@ Check_HR_FileSys_NFS (void)
|
||||||
|
return 0; /* no NFS file system */
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* This function checks whether current file system is an AutoFs
|
||||||
|
+ * HRFS_entry must be valid prior to calling this function
|
||||||
|
+ * return 1 if AutoFs, 0 otherwise
|
||||||
|
+ */
|
||||||
|
+int
|
||||||
|
+Check_HR_FileSys_AutoFs (void)
|
||||||
|
+{
|
||||||
|
+#if HAVE_GETFSSTAT
|
||||||
|
+ if ( HRFS_entry->HRFS_type != NULL &&
|
||||||
|
+#if defined(MNTTYPE_AUTOFS)
|
||||||
|
+ !strcmp( HRFS_entry->HRFS_type, MNTTYPE_AUTOFS)
|
||||||
|
+#else
|
||||||
|
+ !strcmp( HRFS_entry->HRFS_type, "autofs")
|
||||||
|
+#endif
|
||||||
|
+ )
|
||||||
|
+#endif /* HAVE_GETFSSTAT */
|
||||||
|
+ return 1; /* AUTOFS */
|
||||||
|
+
|
||||||
|
+ return 0; /* no AUTOFS */
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
End_HR_FileSys(void)
|
||||||
|
{
|
||||||
|
diff -urNp oold/agent/mibgroup/host/hr_filesys.h nnew/agent/mibgroup/host/hr_filesys.h
|
||||||
|
--- oold/agent/mibgroup/host/hr_filesys.h 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ nnew/agent/mibgroup/host/hr_filesys.h 2017-10-31 09:29:44.541837515 +0100
|
||||||
|
@@ -10,6 +10,7 @@ extern void Init_HR_FileSys(void);
|
||||||
|
extern FindVarMethod var_hrfilesys;
|
||||||
|
extern int Get_Next_HR_FileSys(void);
|
||||||
|
extern int Check_HR_FileSys_NFS(void);
|
||||||
|
+extern int Check_HR_FileSys_AutoFs(void);
|
||||||
|
|
||||||
|
extern int Get_FSIndex(char *);
|
||||||
|
extern long Get_FSSize(char *); /* Temporary */
|
||||||
|
diff -urNp oold/agent/mibgroup/host/hrh_filesys.c nnew/agent/mibgroup/host/hrh_filesys.c
|
||||||
|
--- oold/agent/mibgroup/host/hrh_filesys.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ nnew/agent/mibgroup/host/hrh_filesys.c 2017-10-31 09:37:36.787634605 +0100
|
||||||
|
@@ -427,3 +427,9 @@ Check_HR_FileSys_NFS (void)
|
||||||
|
{
|
||||||
|
return (HRFS_entry->flags & NETSNMP_FS_FLAG_REMOTE) ? 1 : 0;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+int
|
||||||
|
+Check_HR_FileSys_AutoFs (void)
|
||||||
|
+{
|
||||||
|
+ return (HRFS_entry->type == (NETSNMP_FS_TYPE_AUTOFS)) ? 1 : 0;
|
||||||
|
+}
|
||||||
|
diff -urNp oold/agent/mibgroup/host/hrh_filesys.h nnew/agent/mibgroup/host/hrh_filesys.h
|
||||||
|
--- oold/agent/mibgroup/host/hrh_filesys.h 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ nnew/agent/mibgroup/host/hrh_filesys.h 2017-10-31 09:38:00.644616572 +0100
|
||||||
|
@@ -10,6 +10,7 @@ extern void Init_HR_FileSys(void);
|
||||||
|
extern FindVarMethod var_hrhfilesys;
|
||||||
|
extern int Get_Next_HR_FileSys(void);
|
||||||
|
extern int Check_HR_FileSys_NFS(void);
|
||||||
|
+extern int Check_HR_FileSys_AutoFs(void);
|
||||||
|
|
||||||
|
extern int Get_FSIndex(char *);
|
||||||
|
extern long Get_FSSize(char *); /* Temporary */
|
||||||
|
diff -urNp oold/agent/mibgroup/host/hrh_storage.c nnew/agent/mibgroup/host/hrh_storage.c
|
||||||
|
--- oold/agent/mibgroup/host/hrh_storage.c 2017-10-30 14:50:41.766743146 +0100
|
||||||
|
+++ nnew/agent/mibgroup/host/hrh_storage.c 2017-10-31 10:08:25.482217951 +0100
|
||||||
|
@@ -368,9 +368,10 @@ really_try_next:
|
||||||
|
store_idx = name[ HRSTORE_ENTRY_NAME_LENGTH ];
|
||||||
|
if (HRFS_entry &&
|
||||||
|
store_idx > NETSNMP_MEM_TYPE_MAX &&
|
||||||
|
- netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
|
+ ((netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
|
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||||
|
- Check_HR_FileSys_NFS())
|
||||||
|
+ Check_HR_FileSys_NFS()) ||
|
||||||
|
+ Check_HR_FileSys_AutoFs()))
|
||||||
|
return NULL;
|
||||||
|
if (store_idx <= NETSNMP_MEM_TYPE_MAX ) {
|
||||||
|
mem = (netsnmp_memory_info*)ptr;
|
||||||
|
@@ -509,7 +510,8 @@ Get_Next_HR_Store(void)
|
||||||
|
if (HRS_index >= 0) {
|
||||||
|
if (!(netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
|
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||||
|
- Check_HR_FileSys_NFS())) {
|
||||||
|
+ Check_HR_FileSys_NFS()) &&
|
||||||
|
+ !Check_HR_FileSys_AutoFs()) {
|
||||||
|
return HRS_index + NETSNMP_MEM_TYPE_MAX;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
diff -urNp oold/agent/mibgroup/host/hr_storage.c nnew/agent/mibgroup/host/hr_storage.c
|
||||||
|
--- oold/agent/mibgroup/host/hr_storage.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ nnew/agent/mibgroup/host/hr_storage.c 2017-10-31 10:11:41.161064352 +0100
|
||||||
|
@@ -545,9 +545,10 @@ really_try_next:
|
||||||
|
|
||||||
|
store_idx = name[ HRSTORE_ENTRY_NAME_LENGTH ];
|
||||||
|
if (store_idx > NETSNMP_MEM_TYPE_MAX ) {
|
||||||
|
- if ( netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
|
+ if ( (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
|
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||||
|
- Check_HR_FileSys_NFS())
|
||||||
|
+ Check_HR_FileSys_NFS()) ||
|
||||||
|
+ Check_HR_FileSys_AutoFs())
|
||||||
|
return NULL; /* or goto try_next; */
|
||||||
|
if (HRFS_statfs(HRFS_entry->HRFS_mount, &stat_buf) < 0) {
|
||||||
|
snmp_log_perror(HRFS_entry->HRFS_mount);
|
||||||
|
@@ -688,7 +689,8 @@ Get_Next_HR_Store(void)
|
||||||
|
if (HRS_index >= 0) {
|
||||||
|
if (!(netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
|
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||||
|
- Check_HR_FileSys_NFS())) {
|
||||||
|
+ Check_HR_FileSys_NFS()) &&
|
||||||
|
+ !Check_HR_FileSys_AutoFs()) {
|
||||||
|
return HRS_index + NETSNMP_MEM_TYPE_MAX;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
diff -urNp oold/include/net-snmp/agent/hardware/fsys.h nnew/include/net-snmp/agent/hardware/fsys.h
|
||||||
|
--- oold/include/net-snmp/agent/hardware/fsys.h 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ nnew/include/net-snmp/agent/hardware/fsys.h 2017-10-31 10:14:59.560581680 +0100
|
||||||
|
@@ -41,6 +41,7 @@ typedef struct netsnmp_fsys_info_s netsn
|
||||||
|
#define NETSNMP_FS_TYPE_SYSFS 4 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT
|
||||||
|
#define NETSNMP_FS_TYPE_TMPFS 5 | _NETSNMP_FS_TYPE_LOCAL
|
||||||
|
#define NETSNMP_FS_TYPE_USBFS 6 | _NETSNMP_FS_TYPE_LOCAL
|
||||||
|
+#define NETSNMP_FS_TYPE_AUTOFS 7 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT
|
||||||
|
|
||||||
|
#define NETSNMP_FS_FLAG_ACTIVE 0x01
|
||||||
|
#define NETSNMP_FS_FLAG_REMOTE 0x02
|
|
@ -0,0 +1,33 @@
|
||||||
|
Bug 965348 - HOST-RESOURCES-MIB::hrFS* not includes btrfs
|
||||||
|
1006758 - HOST-RESOURCES-MIB::hrFS* not includes btrfs
|
||||||
|
|
||||||
|
commit da1fef382591ff45dc92eb3b95a6bfeff9ecfa4f
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Tue May 21 09:13:41 2013 +0200
|
||||||
|
|
||||||
|
CHANGES: snmpd: Added btrfs support to hrFSTable
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/hardware/fsys/fsys_mntent.c.btrfs net-snmp-5.7.2/agent/mibgroup/hardware/fsys/fsys_mntent.c
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/hardware/fsys/fsys_mntent.c.btrfs 2013-09-11 12:12:54.586891414 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/hardware/fsys/fsys_mntent.c 2013-09-11 12:12:41.565947166 +0200
|
||||||
|
@@ -141,6 +141,7 @@ _fsys_type( char *typename )
|
||||||
|
!strcmp(typename, MNTTYPE_CVFS) ||
|
||||||
|
!strcmp(typename, MNTTYPE_SIMFS) ||
|
||||||
|
!strcmp(typename, MNTTYPE_VZFS) ||
|
||||||
|
+ !strcmp(typename, MNTTYPE_BTRFS) ||
|
||||||
|
!strcmp(typename, MNTTYPE_LOFS))
|
||||||
|
return NETSNMP_FS_TYPE_OTHER;
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/hardware/fsys/mnttypes.h.btrfs net-snmp-5.7.2/agent/mibgroup/hardware/fsys/mnttypes.h
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/hardware/fsys/mnttypes.h.btrfs 2013-09-11 12:00:15.283166852 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/hardware/fsys/mnttypes.h 2013-09-11 12:00:15.284166847 +0200
|
||||||
|
@@ -148,6 +148,9 @@
|
||||||
|
#ifndef MNTTYPE_VZFS
|
||||||
|
#define MNTTYPE_VZFS "vzfs"
|
||||||
|
#endif
|
||||||
|
+#ifndef MNTTYPE_BTRFS
|
||||||
|
+#define MNTTYPE_BTRFS "btrfs"
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File systems to skip
|
|
@ -0,0 +1,112 @@
|
||||||
|
diff -urpN old/snmplib/snmp_api.c new/snmplib/snmp_api.c
|
||||||
|
--- old/snmplib/snmp_api.c 2017-04-03 09:07:41.795091238 +0200
|
||||||
|
+++ new/snmplib/snmp_api.c 2017-04-03 10:54:47.809422106 +0200
|
||||||
|
@@ -1553,12 +1553,12 @@ _sess_open(netsnmp_session * in_session)
|
||||||
|
if (in_session->flags & SNMP_FLAGS_STREAM_SOCKET) {
|
||||||
|
transport =
|
||||||
|
netsnmp_tdomain_transport_full("snmp", in_session->peername,
|
||||||
|
- in_session->local_port, "tcp",
|
||||||
|
+ in_session->local_port, "tcp,tcp6",
|
||||||
|
NULL);
|
||||||
|
} else {
|
||||||
|
transport =
|
||||||
|
netsnmp_tdomain_transport_full("snmp", in_session->peername,
|
||||||
|
- in_session->local_port, "udp",
|
||||||
|
+ in_session->local_port, "udp,udp6",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff -urpN old/snmplib/snmp_transport.c new/snmplib/snmp_transport.c
|
||||||
|
--- old/snmplib/snmp_transport.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ new/snmplib/snmp_transport.c 2017-04-03 11:50:49.158878706 +0200
|
||||||
|
@@ -498,6 +498,9 @@ netsnmp_tdomain_transport_full(const cha
|
||||||
|
const char * const *spec = NULL;
|
||||||
|
int any_found = 0;
|
||||||
|
char buf[SNMP_MAXPATH];
|
||||||
|
+ char **lspec = 0;
|
||||||
|
+ char *tokenized_domain = 0;
|
||||||
|
+
|
||||||
|
|
||||||
|
DEBUGMSGTL(("tdomain",
|
||||||
|
"tdomain_transport_full(\"%s\", \"%s\", %d, \"%s\", \"%s\")\n",
|
||||||
|
@@ -587,7 +590,23 @@ netsnmp_tdomain_transport_full(const cha
|
||||||
|
DEBUGMSGTL(("tdomain",
|
||||||
|
"Use user specified default domain \"%s\"\n",
|
||||||
|
default_domain));
|
||||||
|
- match = find_tdomain(default_domain);
|
||||||
|
+ if (!strchr(default_domain, ','))
|
||||||
|
+ match = find_tdomain(default_domain);
|
||||||
|
+ else {
|
||||||
|
+ int commas = 0;
|
||||||
|
+ const char *cp = default_domain;
|
||||||
|
+ char *ptr = NULL;
|
||||||
|
+ tokenized_domain = strdup(default_domain);
|
||||||
|
+
|
||||||
|
+ while (*++cp) if (*cp == ',') commas++;
|
||||||
|
+ lspec = calloc(commas+2, sizeof(char *));
|
||||||
|
+ commas = 1;
|
||||||
|
+ lspec[0] = strtok_r(tokenized_domain, ",", &ptr);
|
||||||
|
+ while ((lspec[commas++] = strtok_r(NULL, ",", &ptr)))
|
||||||
|
+ ;
|
||||||
|
+ spec = (const char * const *)lspec;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
} else {
|
||||||
|
spec = netsnmp_lookup_default_domains(application);
|
||||||
|
if (spec == NULL) {
|
||||||
|
@@ -636,6 +655,10 @@ netsnmp_tdomain_transport_full(const cha
|
||||||
|
else
|
||||||
|
t = match->f_create_from_tstring_new(addr, local, addr2);
|
||||||
|
if (t) {
|
||||||
|
+ if (lspec) {
|
||||||
|
+ free(tokenized_domain);
|
||||||
|
+ free(lspec);
|
||||||
|
+ }
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -647,6 +670,10 @@ netsnmp_tdomain_transport_full(const cha
|
||||||
|
}
|
||||||
|
if (!any_found)
|
||||||
|
snmp_log(LOG_ERR, "No support for any checked transport domain\n");
|
||||||
|
+ if (lspec) {
|
||||||
|
+ free(tokenized_domain);
|
||||||
|
+ free(lspec);
|
||||||
|
+ }
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff -urpN old/snmplib/system.c new/snmplib/system.c
|
||||||
|
--- old/snmplib/system.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ new/snmplib/system.c 2017-04-03 12:02:35.693153449 +0200
|
||||||
|
@@ -750,13 +750,6 @@ netsnmp_gethostbyname_v4(const char* nam
|
||||||
|
|
||||||
|
err = netsnmp_getaddrinfo(name, NULL, &hint, &addrs);
|
||||||
|
if (err != 0) {
|
||||||
|
-#if HAVE_GAI_STRERROR
|
||||||
|
- snmp_log(LOG_ERR, "getaddrinfo: %s %s\n", name,
|
||||||
|
- gai_strerror(err));
|
||||||
|
-#else
|
||||||
|
- snmp_log(LOG_ERR, "getaddrinfo: %s (error %d)\n", name,
|
||||||
|
- err);
|
||||||
|
-#endif
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff -urpN old/snmplib/transports/snmpIPv6BaseDomain.c new/snmplib/transports/snmpIPv6BaseDomain.c
|
||||||
|
--- old/snmplib/transports/snmpIPv6BaseDomain.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ new/snmplib/transports/snmpIPv6BaseDomain.c 2017-04-03 12:00:38.669641503 +0200
|
||||||
|
@@ -342,13 +342,6 @@ netsnmp_sockaddr_in6_2(struct sockaddr_i
|
||||||
|
err = netsnmp_getaddrinfo(peername, NULL, &hint, &addrs);
|
||||||
|
}
|
||||||
|
if (err != 0) {
|
||||||
|
-#if HAVE_GAI_STRERROR
|
||||||
|
- snmp_log(LOG_ERR, "getaddrinfo(\"%s\", NULL, ...): %s\n", peername,
|
||||||
|
- gai_strerror(err));
|
||||||
|
-#else
|
||||||
|
- snmp_log(LOG_ERR, "getaddrinfo(\"%s\", NULL, ...): (error %d)\n",
|
||||||
|
- peername, err);
|
||||||
|
-#endif
|
||||||
|
free(peername);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
1151310 - snmptrap can't create (or write to) /var/lib/net-snmp/snmpapp.conf if isn't run under root
|
||||||
|
Backported from:
|
||||||
|
|
||||||
|
commit 53ee5f1d240ac90adae935538bdc2ca13a8caa32
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Wed Feb 18 16:29:16 2015 +0100
|
||||||
|
|
||||||
|
CHANGES: snmplib: Fixed reporting 'error writing to /var/xxx/snmpapp.conf'.
|
||||||
|
|
||||||
|
When a client utility, such as snmptrap, tries to write to its persistent
|
||||||
|
configuration file (/var/net-snmp/snmpapp.conf in Fedora), do not report
|
||||||
|
any error when open() fails. The tool is typically run by non-root, who
|
||||||
|
cannot write to /var and the error just confuses users.
|
||||||
|
|
||||||
|
And when doing it, make sure that "snmpapp" string is defined only on one
|
||||||
|
place, just in case.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/disman/expression/expValueTable.c.test net-snmp-5.7.2/agent/mibgroup/disman/expression/expValueTable.c
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/disman/expression/expValueTable.c.test 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/disman/expression/expValueTable.c 2015-06-18 14:06:47.871027563 +0200
|
||||||
|
@@ -127,7 +127,7 @@ init_expValueTable(void)
|
||||||
|
REGISTER_MIB("expValueTable",
|
||||||
|
expValueTable_variables, variable2,
|
||||||
|
expValueTable_variables_oid);
|
||||||
|
- init_snmp("snmpapp");
|
||||||
|
+ init_snmp(NETSNMP_APPLICATION_CONFIG_TYPE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize a "session" that defines who we're going to talk to
|
||||||
|
diff -up net-snmp-5.7.2/apps/snmptranslate.c.test net-snmp-5.7.2/apps/snmptranslate.c
|
||||||
|
--- net-snmp-5.7.2/apps/snmptranslate.c.test 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/apps/snmptranslate.c 2015-06-18 14:06:47.872027568 +0200
|
||||||
|
@@ -236,7 +236,7 @@ main(int argc, char *argv[])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- init_snmp("snmpapp");
|
||||||
|
+ init_snmp(NETSNMP_APPLICATION_CONFIG_TYPE);
|
||||||
|
if (optind < argc)
|
||||||
|
current_name = argv[optind];
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/apps/snmptrap.c.test net-snmp-5.7.2/apps/snmptrap.c
|
||||||
|
--- net-snmp-5.7.2/apps/snmptrap.c.test 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/apps/snmptrap.c 2015-06-18 14:06:47.872027568 +0200
|
||||||
|
@@ -386,7 +386,7 @@ main(int argc, char *argv[])
|
||||||
|
snmp_free_pdu(response);
|
||||||
|
|
||||||
|
snmp_close(ss);
|
||||||
|
- snmp_shutdown("snmpapp");
|
||||||
|
+ snmp_shutdown(NETSNMP_APPLICATION_CONFIG_TYPE);
|
||||||
|
SOCK_CLEANUP;
|
||||||
|
return exitval;
|
||||||
|
}
|
||||||
|
diff -up net-snmp-5.7.2/include/net-snmp/library/read_config.h.test net-snmp-5.7.2/include/net-snmp/library/read_config.h
|
||||||
|
--- net-snmp-5.7.2/include/net-snmp/library/read_config.h.test 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/include/net-snmp/library/read_config.h 2015-06-18 14:06:47.873027572 +0200
|
||||||
|
@@ -15,6 +15,12 @@ extern "C" {
|
||||||
|
#define PREMIB_CONFIG 1
|
||||||
|
#define EITHER_CONFIG 2
|
||||||
|
|
||||||
|
+/*
|
||||||
|
+ * Value of 'type' parameter of various snmp_config calls,
|
||||||
|
+ * used by Net-SNMP client utilities.
|
||||||
|
+ */
|
||||||
|
+#define NETSNMP_APPLICATION_CONFIG_TYPE "snmpapp"
|
||||||
|
+
|
||||||
|
#include <net-snmp/config_api.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
diff -up net-snmp-5.7.2/snmplib/read_config.c.test net-snmp-5.7.2/snmplib/read_config.c
|
||||||
|
--- net-snmp-5.7.2/snmplib/read_config.c.test 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/snmplib/read_config.c 2015-06-18 14:06:47.874027577 +0200
|
||||||
|
@@ -1540,7 +1540,14 @@ read_config_store(const char *type, cons
|
||||||
|
DEBUGMSGTL(("read_config:store", "storing: %s\n", line));
|
||||||
|
fclose(fout);
|
||||||
|
} else {
|
||||||
|
- snmp_log(LOG_ERR, "read_config_store open failure on %s\n", filep);
|
||||||
|
+ if (strcmp(NETSNMP_APPLICATION_CONFIG_TYPE, type) != 0) {
|
||||||
|
+ /*
|
||||||
|
+ * Ignore this error in client utilities, they can run with random
|
||||||
|
+ * UID/GID and typically cannot write to /var. Error message just
|
||||||
|
+ * confuses people.
|
||||||
|
+ */
|
||||||
|
+ snmp_log(LOG_ERR, "read_config_store open failure on %s");
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
#ifdef NETSNMP_PERSISTENT_MASK
|
||||||
|
umask(oldmask);
|
||||||
|
diff -up net-snmp-5.7.2/snmplib/snmp_parse_args.c.test net-snmp-5.7.2/snmplib/snmp_parse_args.c
|
||||||
|
--- net-snmp-5.7.2/snmplib/snmp_parse_args.c.test 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/snmplib/snmp_parse_args.c 2015-06-18 14:06:47.874027577 +0200
|
||||||
|
@@ -250,7 +250,7 @@ netsnmp_parse_args(int argc,
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'H':
|
||||||
|
- init_snmp("snmpapp");
|
||||||
|
+ init_snmp(NETSNMP_APPLICATION_CONFIG_TYPE);
|
||||||
|
fprintf(stderr, "Configuration directives understood:\n");
|
||||||
|
read_config_print_usage(" ");
|
||||||
|
return (NETSNMP_PARSE_ARGS_SUCCESS_EXIT);
|
||||||
|
@@ -640,7 +640,7 @@ netsnmp_parse_args(int argc,
|
||||||
|
/*
|
||||||
|
* read in MIB database and initialize the snmp library
|
||||||
|
*/
|
||||||
|
- init_snmp("snmpapp");
|
||||||
|
+ init_snmp(NETSNMP_APPLICATION_CONFIG_TYPE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* session default version
|
||||||
|
commit 653da2f955f88d7419363e6d31f2b5f0ffdc4f73
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Thu Feb 19 13:40:37 2015 +0100
|
||||||
|
|
||||||
|
Fixed missing printf argument from previous commit.
|
||||||
|
|
||||||
|
diff --git a/snmplib/read_config.c b/snmplib/read_config.c
|
||||||
|
index 6157fc6..2972232 100644
|
||||||
|
--- a/snmplib/read_config.c
|
||||||
|
+++ b/snmplib/read_config.c
|
||||||
|
@@ -1317,7 +1317,7 @@ read_config_store(const char *type, const char *line)
|
||||||
|
* UID/GID and typically cannot write to /var. Error message just
|
||||||
|
* confuses people.
|
||||||
|
*/
|
||||||
|
- snmp_log(LOG_ERR, "read_config_store open failure on %s");
|
||||||
|
+ snmp_log(LOG_ERR, "read_config_store open failure on %s\n", filep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef NETSNMP_PERSISTENT_MASK
|
|
@ -0,0 +1,21 @@
|
||||||
|
1086925 - snmpd does not report error when clientaddr <ip>:<port> cannot bind to the specified port
|
||||||
|
|
||||||
|
commit 68d2c8fd4bf2390612f288ff488b7c08102bcd0a
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Wed Jan 14 11:52:05 2015 +0100
|
||||||
|
|
||||||
|
Added error message when bind for clientaddr fails.
|
||||||
|
|
||||||
|
diff --git a/snmplib/transports/snmpUDPIPv4BaseDomain.c b/snmplib/transports/snmpUDPIPv4BaseDomain.c
|
||||||
|
index fa39e4b..b8b6683 100644
|
||||||
|
--- a/snmplib/transports/snmpUDPIPv4BaseDomain.c
|
||||||
|
+++ b/snmplib/transports/snmpUDPIPv4BaseDomain.c
|
||||||
|
@@ -221,6 +221,8 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local)
|
||||||
|
if ( rc != 0 ) {
|
||||||
|
DEBUGMSGTL(("netsnmp_udpbase", "failed to bind for clientaddr: %d %s\n",
|
||||||
|
errno, strerror(errno)));
|
||||||
|
+ snmp_log(LOG_ERR, "Cannot bind for clientaddr: %s\n",
|
||||||
|
+ strerror(errno));
|
||||||
|
netsnmp_socketbase_close(t);
|
||||||
|
netsnmp_transport_free(t);
|
||||||
|
return NULL;
|
|
@ -0,0 +1,158 @@
|
||||||
|
833013 - The port number specified with clientaddr is not used for trap udp socket
|
||||||
|
|
||||||
|
commit 521b4e28b4c794a9d6d929858478d13875246ce3
|
||||||
|
Author: Ivosh <ivosh@users.sourceforge.net>
|
||||||
|
Date: Mon Jul 30 10:53:22 2012 -0700
|
||||||
|
|
||||||
|
CHANGES: libnetsnmp: PATCH 3404876: from hardaker: ability to specify local-bound port in addition to address
|
||||||
|
|
||||||
|
Signed-off-by: Wes Hardaker <hardaker@users.sourceforge.net>
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/include/net-snmp/library/default_store.h.port net-snmp-5.7.2/include/net-snmp/library/default_store.h
|
||||||
|
--- net-snmp-5.7.2/include/net-snmp/library/default_store.h.port 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/include/net-snmp/library/default_store.h 2012-11-13 10:51:34.528804796 +0100
|
||||||
|
@@ -94,6 +94,7 @@ extern "C" {
|
||||||
|
#define NETSNMP_DS_LIB_TSM_USE_PREFIX 39 /* TSM's simple security name mapping */
|
||||||
|
#define NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES 40 /* don't read host.conf files */
|
||||||
|
#define NETSNMP_DS_LIB_DNSSEC_WARN_ONLY 41 /* tread DNSSEC errors as warnings */
|
||||||
|
+#define NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT 42 /* NETSNMP_DS_LIB_CLIENT_ADDR includes address and also port */
|
||||||
|
#define NETSNMP_DS_LIB_MAX_BOOL_ID 48 /* match NETSNMP_DS_MAX_SUBIDS */
|
||||||
|
|
||||||
|
/*
|
||||||
|
diff -up net-snmp-5.7.2/perl/default_store/default_store.pm.port net-snmp-5.7.2/perl/default_store/default_store.pm
|
||||||
|
--- net-snmp-5.7.2/perl/default_store/default_store.pm.port 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/perl/default_store/default_store.pm 2012-11-13 10:51:34.679804190 +0100
|
||||||
|
@@ -63,6 +63,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK
|
||||||
|
NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD
|
||||||
|
NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE
|
||||||
|
NETSNMP_DS_LIB_APPEND_LOGFILES
|
||||||
|
+ NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT
|
||||||
|
NETSNMP_DS_LIB_MIB_WARNINGS
|
||||||
|
NETSNMP_DS_LIB_SECLEVEL
|
||||||
|
NETSNMP_DS_LIB_SNMPVERSION
|
||||||
|
@@ -161,6 +162,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK
|
||||||
|
NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD
|
||||||
|
NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE
|
||||||
|
NETSNMP_DS_LIB_APPEND_LOGFILES
|
||||||
|
+ NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT
|
||||||
|
NETSNMP_DS_LIB_MIB_WARNINGS
|
||||||
|
NETSNMP_DS_LIB_SECLEVEL
|
||||||
|
NETSNMP_DS_LIB_SNMPVERSION
|
||||||
|
@@ -299,6 +301,7 @@ None by default.
|
||||||
|
NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD
|
||||||
|
NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE
|
||||||
|
NETSNMP_DS_LIB_APPEND_LOGFILES
|
||||||
|
+ NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT
|
||||||
|
NETSNMP_DS_LIB_MIB_WARNINGS
|
||||||
|
NETSNMP_DS_LIB_SECLEVEL
|
||||||
|
NETSNMP_DS_LIB_SNMPVERSION
|
||||||
|
diff -up net-snmp-5.7.2/perl/default_store/default_store.xs.port net-snmp-5.7.2/perl/default_store/default_store.xs
|
||||||
|
--- net-snmp-5.7.2/perl/default_store/default_store.xs.port 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/perl/default_store/default_store.xs 2012-11-13 10:51:35.154802043 +0100
|
||||||
|
@@ -1238,6 +1238,17 @@ __END__
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
+ case 36:
|
||||||
|
+ if (memEQ(name, "NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT", 36)) {
|
||||||
|
+#ifdef NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT
|
||||||
|
+ *iv_return = NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT;
|
||||||
|
+ return PERL_constant_ISIV;
|
||||||
|
+#else
|
||||||
|
+ return PERL_constant_NOTDEF;
|
||||||
|
+#endif
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
case 38:
|
||||||
|
return constant_38 (aTHX_ name, iv_return);
|
||||||
|
break;
|
||||||
|
@@ -1245,8 +1256,6 @@ __END__
|
||||||
|
return PERL_constant_NOTFOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
-
|
||||||
|
-
|
||||||
|
/* autogenerated by "gen" from const-xs.inc */
|
||||||
|
|
||||||
|
MODULE = NetSNMP::default_store PACKAGE = NetSNMP::default_store
|
||||||
|
diff -up net-snmp-5.7.2/perl/default_store/test.pl.port net-snmp-5.7.2/perl/default_store/test.pl
|
||||||
|
--- net-snmp-5.7.2/perl/default_store/test.pl.port 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/perl/default_store/test.pl 2012-11-13 10:51:35.185801918 +0100
|
||||||
|
@@ -52,6 +52,7 @@ BEGIN { $| = 1;
|
||||||
|
"NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD" => 35,
|
||||||
|
"NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE" => 36,
|
||||||
|
"NETSNMP_DS_LIB_APPEND_LOGFILES" => 37,
|
||||||
|
+ "NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT" => 42,
|
||||||
|
"NETSNMP_DS_LIB_MIB_WARNINGS" => 0,
|
||||||
|
"NETSNMP_DS_LIB_SECLEVEL" => 1,
|
||||||
|
"NETSNMP_DS_LIB_SNMPVERSION" => 2,
|
||||||
|
diff -up net-snmp-5.7.2/snmplib/snmp_api.c.port net-snmp-5.7.2/snmplib/snmp_api.c
|
||||||
|
--- net-snmp-5.7.2/snmplib/snmp_api.c.port 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/snmplib/snmp_api.c 2012-11-13 10:51:35.188801906 +0100
|
||||||
|
@@ -769,6 +769,8 @@ register_default_handlers(void)
|
||||||
|
NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS);
|
||||||
|
netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "clientaddr",
|
||||||
|
NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR);
|
||||||
|
+ netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "clientaddrUsesPort",
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
|
||||||
|
netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverSendBuf",
|
||||||
|
NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERSENDBUF);
|
||||||
|
netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverRecvBuf",
|
||||||
|
diff -up net-snmp-5.7.2/snmplib/transports/snmpUDPIPv4BaseDomain.c.port net-snmp-5.7.2/snmplib/transports/snmpUDPIPv4BaseDomain.c
|
||||||
|
--- net-snmp-5.7.2/snmplib/transports/snmpUDPIPv4BaseDomain.c.port 2012-11-13 10:51:32.781812675 +0100
|
||||||
|
+++ net-snmp-5.7.2/snmplib/transports/snmpUDPIPv4BaseDomain.c 2012-11-13 10:51:35.190801898 +0100
|
||||||
|
@@ -183,8 +183,29 @@ netsnmp_udpipv4base_transport(struct soc
|
||||||
|
NETSNMP_DS_LIB_CLIENT_ADDR);
|
||||||
|
if (client_socket) {
|
||||||
|
struct sockaddr_in client_addr;
|
||||||
|
- netsnmp_sockaddr_in2(&client_addr, client_socket, NULL);
|
||||||
|
- client_addr.sin_port = 0;
|
||||||
|
+
|
||||||
|
+ char *client_address = client_socket;
|
||||||
|
+ int uses_port = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
|
||||||
|
+ NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
|
||||||
|
+ if ((uses_port == 1) && (strchr(client_socket, ':') == NULL)) {
|
||||||
|
+ client_address = malloc(strlen(client_socket) + 3);
|
||||||
|
+ if (client_address == NULL) {
|
||||||
|
+ netsnmp_socketbase_close(t);
|
||||||
|
+ netsnmp_transport_free(t);
|
||||||
|
+ return NULL;
|
||||||
|
+ } /* if NETSNMP_DS_LIB_CLIENT_ADDR */
|
||||||
|
+ strcpy(client_address, client_socket); /* expects a port but there is none */
|
||||||
|
+ strcat(client_address, ":0"); /* specified then provide ephemeral one */
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ netsnmp_sockaddr_in2(&client_addr, client_address, NULL);
|
||||||
|
+ if (uses_port == 0) {
|
||||||
|
+ client_addr.sin_port = 0;
|
||||||
|
+ }
|
||||||
|
+ if (client_address != client_socket) {
|
||||||
|
+ free(client_address);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
DEBUGMSGTL(("netsnmp_udpbase", "binding socket: %d\n", t->sock));
|
||||||
|
rc = bind(t->sock, (struct sockaddr *)&client_addr,
|
||||||
|
sizeof(struct sockaddr));
|
||||||
|
commit 9e00fff692081e36c9d883fab7b6bd8881c670fc
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Tue Aug 7 12:27:18 2012 +0200
|
||||||
|
|
||||||
|
Document new clientaddrUsesPort option.
|
||||||
|
|
||||||
|
diff --git a/man/snmp.conf.5.def b/man/snmp.conf.5.def
|
||||||
|
index 9c7c55b..904635b 100644
|
||||||
|
--- a/man/snmp.conf.5.def
|
||||||
|
+++ b/man/snmp.conf.5.def
|
||||||
|
@@ -127,6 +127,10 @@ This value is also used by \fBsnmpd\fR when generating notifications.
|
||||||
|
.\" But not responses to an incoming request?
|
||||||
|
.\" What about snmptrapd?
|
||||||
|
.\"
|
||||||
|
+.IP "clientaddrUsesPort no"
|
||||||
|
+specifies, if clientaddr option contains a port number. Set this option
|
||||||
|
+to "yes", if clientaddr contains a port number and this port should
|
||||||
|
+be used for sending outgoing SNMP requests.
|
||||||
|
.IP "clientRecvBuf INTEGER"
|
||||||
|
specifies the desired size of the buffer to be used when receiving
|
||||||
|
responses to SNMP requests.
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
Make net-snmp-create-v3-user multilib-clean
|
||||||
|
|
||||||
|
The file had different NSC_AGENTLIBS on different architectures.
|
||||||
|
|
||||||
|
Source: upstream
|
||||||
|
|
||||||
|
commit 68300a9fb43568c5d833c48a2fef3ff16c2923c3
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Thu Feb 7 10:14:33 2013 +0100
|
||||||
|
|
||||||
|
Remove unused variables.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/net-snmp-create-v3-user.in.multilib net-snmp-5.7.2/net-snmp-create-v3-user.in
|
||||||
|
--- net-snmp-5.7.2/net-snmp-create-v3-user.in.multilib 2013-03-22 10:19:41.151901243 +0100
|
||||||
|
+++ net-snmp-5.7.2/net-snmp-create-v3-user.in 2013-03-22 10:20:02.476801266 +0100
|
||||||
|
@@ -8,25 +8,7 @@
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
includedir=@includedir@
|
||||||
|
-libdir=@libdir@
|
||||||
|
datarootdir=@datarootdir@
|
||||||
|
-NSC_LDFLAGS="@LDFLAGS@"
|
||||||
|
-NSC_INCLUDEDIR=${includedir}
|
||||||
|
-NSC_LIBDIR=-L${libdir}
|
||||||
|
-NSC_LIBS="@LIBS@"
|
||||||
|
-NSC_AGENTLIBS="@AGENTLIBS@ @PERLLDOPTS_FOR_APPS@"
|
||||||
|
-NSC_PREFIX=$prefix
|
||||||
|
-NSC_EXEC_PREFIX=$exec_prefix
|
||||||
|
-NSC_SRCDIR=@srcdir@
|
||||||
|
-NSC_INCDIR=${NSC_PREFIX}/include
|
||||||
|
-NSC_BASE_SUBAGENT_LIBS="-lnetsnmpagent -lnetsnmp"
|
||||||
|
-NSC_BASE_AGENT_LIBS="-lnetsnmpagent -lnetsnmpmibs -lnetsnmp"
|
||||||
|
-NSC_SRC_LIBDIRS="agent/.libs snmplib/.libs"
|
||||||
|
-NSC_SRC_LIBDEPS="agent/.libs/libnetsnmpmibs.a agent/.libs/libnetsnmpagent.a snmplib/.libs/libnetsnmp.a"
|
||||||
|
-
|
||||||
|
-if test "x$NSC_SRCDIR" = "x." ; then
|
||||||
|
- NSC_SRCDIR="NET-SNMP-SOURCE-DIR"
|
||||||
|
-fi
|
||||||
|
|
||||||
|
if @PSCMD@ | egrep ' snmpd *$' > /dev/null 2>&1 ; then
|
||||||
|
echo "Apparently at least one snmpd demon is already running."
|
|
@ -0,0 +1,427 @@
|
||||||
|
1092308 - backport diskio device filtering
|
||||||
|
|
||||||
|
Backported from:
|
||||||
|
|
||||||
|
commit 5be210c90870ff6bab193d497d401b92c1d50db9
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Thu Mar 6 13:26:30 2014 +0100
|
||||||
|
|
||||||
|
CHANGES: snmpd: add new snmpd.conf option 'diskio' to monitor only selected disks.
|
||||||
|
|
||||||
|
On machines with thousands of block devices, parsing /proc/diskstats is really
|
||||||
|
slow. The new option enables monitoring of selected devices, saving lot of CPU
|
||||||
|
time.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/ucd-snmp/diskio.c.test net-snmp-5.7.2/agent/mibgroup/ucd-snmp/diskio.c
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/ucd-snmp/diskio.c.test 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/ucd-snmp/diskio.c 2015-06-18 15:14:57.164891695 +0200
|
||||||
|
@@ -27,11 +27,18 @@
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
+#if defined (linux)
|
||||||
|
+/* for stat() */
|
||||||
|
+#include <ctype.h>
|
||||||
|
+#include <sys/stat.h>
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
#include <net-snmp/net-snmp-includes.h>
|
||||||
|
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||||
|
|
||||||
|
#include "util_funcs/header_simple_table.h"
|
||||||
|
|
||||||
|
+#include "struct.h"
|
||||||
|
/*
|
||||||
|
* include our .h file
|
||||||
|
*/
|
||||||
|
@@ -95,6 +102,66 @@ static int ps_numdisks; /* number of d
|
||||||
|
#if defined (linux)
|
||||||
|
#define DISKIO_SAMPLE_INTERVAL 5
|
||||||
|
void devla_getstats(unsigned int regno, void * dummy);
|
||||||
|
+static void diskio_parse_config_disks(const char *token, char *cptr);
|
||||||
|
+static void diskio_free_config(void);
|
||||||
|
+static int get_sysfs_stats(void);
|
||||||
|
+
|
||||||
|
+struct diskiopart {
|
||||||
|
+ char syspath[STRMAX]; /* full stat path */
|
||||||
|
+ char name[STRMAX]; /* name as provided */
|
||||||
|
+ char shortname[STRMAX]; /* short name for output */
|
||||||
|
+ int major;
|
||||||
|
+ int minor;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static int numdisks;
|
||||||
|
+static int maxdisks = 0;
|
||||||
|
+static struct diskiopart *disks;
|
||||||
|
+
|
||||||
|
+#define DISK_INCR 2
|
||||||
|
+
|
||||||
|
+typedef struct linux_diskio
|
||||||
|
+{
|
||||||
|
+ int major;
|
||||||
|
+ int minor;
|
||||||
|
+ unsigned long blocks;
|
||||||
|
+ char name[256];
|
||||||
|
+ unsigned long rio;
|
||||||
|
+ unsigned long rmerge;
|
||||||
|
+ unsigned long rsect;
|
||||||
|
+ unsigned long ruse;
|
||||||
|
+ unsigned long wio;
|
||||||
|
+ unsigned long wmerge;
|
||||||
|
+ unsigned long wsect;
|
||||||
|
+ unsigned long wuse;
|
||||||
|
+ unsigned long running;
|
||||||
|
+ unsigned long use;
|
||||||
|
+ unsigned long aveq;
|
||||||
|
+} linux_diskio;
|
||||||
|
+
|
||||||
|
+/* disk load averages */
|
||||||
|
+typedef struct linux_diskio_la
|
||||||
|
+{
|
||||||
|
+ unsigned long use_prev;
|
||||||
|
+ double la1, la5, la15;
|
||||||
|
+} linux_diskio_la;
|
||||||
|
+
|
||||||
|
+typedef struct linux_diskio_header
|
||||||
|
+{
|
||||||
|
+ linux_diskio* indices;
|
||||||
|
+ int length;
|
||||||
|
+ int alloc;
|
||||||
|
+} linux_diskio_header;
|
||||||
|
+
|
||||||
|
+typedef struct linux_diskio_la_header
|
||||||
|
+{
|
||||||
|
+ linux_diskio_la * indices;
|
||||||
|
+ int length;
|
||||||
|
+} linux_diskio_la_header;
|
||||||
|
+
|
||||||
|
+static linux_diskio_header head;
|
||||||
|
+static linux_diskio_la_header la_head;
|
||||||
|
+
|
||||||
|
#endif /* linux */
|
||||||
|
|
||||||
|
#if defined (darwin)
|
||||||
|
@@ -228,6 +295,8 @@ init_diskio(void)
|
||||||
|
devla_getstats(0, NULL);
|
||||||
|
/* collect LA data regularly */
|
||||||
|
snmp_alarm_register(DISKIO_SAMPLE_INTERVAL, SA_REPEAT, devla_getstats, NULL);
|
||||||
|
+ snmpd_register_config_handler("diskio", diskio_parse_config_disks,
|
||||||
|
+ diskio_free_config, "path | device");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@@ -870,49 +939,134 @@ var_diskio(struct variable * vp,
|
||||||
|
|
||||||
|
#ifdef linux
|
||||||
|
|
||||||
|
-#define DISK_INCR 2
|
||||||
|
-
|
||||||
|
-typedef struct linux_diskio
|
||||||
|
+static void
|
||||||
|
+diskio_free_config()
|
||||||
|
+ {
|
||||||
|
+ if (la_head.length) {
|
||||||
|
+ /* reset any usage stats, we may get different list of devices from config */
|
||||||
|
+ free(la_head.indices);
|
||||||
|
+ la_head.length = 0;
|
||||||
|
+ la_head.indices = NULL;
|
||||||
|
+ }
|
||||||
|
+ if (numdisks > 0) {
|
||||||
|
+ int i;
|
||||||
|
+ head.length = 0;
|
||||||
|
+ numdisks = 0;
|
||||||
|
+ for (i = 0; i < maxdisks; i++) { /* init/erase disk db */
|
||||||
|
+ disks[i].syspath[0] = 0;
|
||||||
|
+ disks[i].name[0] = 0;
|
||||||
|
+ disks[i].shortname[0] = 0;
|
||||||
|
+ disks[i].major = -1;
|
||||||
|
+ disks[i].minor = -1;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+static int
|
||||||
|
+disk_exists(char *path)
|
||||||
|
{
|
||||||
|
- int major;
|
||||||
|
- int minor;
|
||||||
|
- unsigned long blocks;
|
||||||
|
- char name[256];
|
||||||
|
- unsigned long rio;
|
||||||
|
- unsigned long rmerge;
|
||||||
|
- unsigned long rsect;
|
||||||
|
- unsigned long ruse;
|
||||||
|
- unsigned long wio;
|
||||||
|
- unsigned long wmerge;
|
||||||
|
- unsigned long wsect;
|
||||||
|
- unsigned long wuse;
|
||||||
|
- unsigned long running;
|
||||||
|
- unsigned long use;
|
||||||
|
- unsigned long aveq;
|
||||||
|
-} linux_diskio;
|
||||||
|
+ int index;
|
||||||
|
+ for(index = 0; index < numdisks; index++) {
|
||||||
|
+ DEBUGMSGTL(("ucd-snmp/disk", "Checking for %s. Found %s at %d\n", path, disks[index].syspath, index));
|
||||||
|
+ if(strcmp(path, disks[index].syspath) == 0) {
|
||||||
|
+ return index;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return -1;
|
||||||
|
+}
|
||||||
|
|
||||||
|
-/* disk load averages */
|
||||||
|
-typedef struct linux_diskio_la
|
||||||
|
-{
|
||||||
|
- unsigned long use_prev;
|
||||||
|
- double la1, la5, la15;
|
||||||
|
-} linux_diskio_la;
|
||||||
|
+static void
|
||||||
|
+add_device(char *path, int addNewDisks )
|
||||||
|
+ {
|
||||||
|
+ int index;
|
||||||
|
+ char device[STRMAX];
|
||||||
|
+ char syspath[STRMAX];
|
||||||
|
+ char *basename;
|
||||||
|
+ struct stat stbuf;
|
||||||
|
|
||||||
|
-typedef struct linux_diskio_header
|
||||||
|
-{
|
||||||
|
- linux_diskio* indices;
|
||||||
|
- int length;
|
||||||
|
- int alloc;
|
||||||
|
-} linux_diskio_header;
|
||||||
|
+ if (!path || !strcmp(path, "none")) {
|
||||||
|
+ DEBUGMSGTL(("ucd-snmp/diskio", "Skipping null path device (%s)\n", path));
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ if (numdisks == maxdisks) {
|
||||||
|
+ if (maxdisks == 0) {
|
||||||
|
+ maxdisks = 50;
|
||||||
|
+ disks = malloc(maxdisks * sizeof(struct diskiopart));
|
||||||
|
+ if (!disks) {
|
||||||
|
+ config_perror("malloc failed for new disko allocation.");
|
||||||
|
+ netsnmp_config_error("\tignoring: %s", path);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ memset(disks, 0, maxdisks * sizeof(struct diskiopart));
|
||||||
|
+ } else {
|
||||||
|
+ maxdisks *= 2;
|
||||||
|
+ disks = realloc(disks, maxdisks * sizeof(struct diskiopart));
|
||||||
|
+ if (!disks) {
|
||||||
|
+ config_perror("malloc failed for new disko allocation.");
|
||||||
|
+ netsnmp_config_error("\tignoring: %s", path);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ memset(disks + maxdisks/2, 0, maxdisks/2 * sizeof(struct diskiopart));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
|
||||||
|
-typedef struct linux_diskio_la_header
|
||||||
|
-{
|
||||||
|
- linux_diskio_la * indices;
|
||||||
|
- int length;
|
||||||
|
-} linux_diskio_la_header;
|
||||||
|
+ /* first find the path for this device */
|
||||||
|
+ device[0]='\0';
|
||||||
|
+ if ( *path != '/' ) {
|
||||||
|
+ strlcpy(device, "/dev/", STRMAX - 1 );
|
||||||
|
+ }
|
||||||
|
+ strncat(device, path, STRMAX - 1 );
|
||||||
|
+
|
||||||
|
+ /* check for /dev existence */
|
||||||
|
+ if ( stat(device,&stbuf)!=0 ) { /* ENOENT */
|
||||||
|
+ config_perror("diskio path does not exist.");
|
||||||
|
+ netsnmp_config_error("\tignoring: %s", path);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ else if ( ! S_ISBLK(stbuf.st_mode) ) { /* ENODEV */
|
||||||
|
+ config_perror("diskio path is not a device.");
|
||||||
|
+ netsnmp_config_error("\tignoring: %s", path);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
-static linux_diskio_header head;
|
||||||
|
-static linux_diskio_la_header la_head;
|
||||||
|
+ /* either came with a slash or we just put one there, so the following always works */
|
||||||
|
+ basename = strrchr(device, '/' )+1;
|
||||||
|
+ /* construct a sys path using the device numbers to avoid having to disambiguate the various text forms */
|
||||||
|
+ snprintf( syspath, STRMAX - 1, "/sys/dev/block/%d:%d/stat", major(stbuf.st_rdev), minor(stbuf.st_rdev) );
|
||||||
|
+ DEBUGMSGTL(("ucd-snmp/diskio", " monitoring sys path (%s)\n", syspath));
|
||||||
|
+
|
||||||
|
+ index = disk_exists(syspath);
|
||||||
|
+
|
||||||
|
+ if(index == -1 && addNewDisks){
|
||||||
|
+ /* The following buffers are cleared above, no need to add '\0' */
|
||||||
|
+ strlcpy(disks[numdisks].syspath, syspath, sizeof(disks[numdisks].syspath) - 1);
|
||||||
|
+ strlcpy(disks[numdisks].name, path, sizeof(disks[numdisks].name) - 1);
|
||||||
|
+ strlcpy(disks[numdisks].shortname, basename, sizeof(disks[numdisks].shortname) - 1);
|
||||||
|
+ disks[numdisks].major = major(stbuf.st_rdev);
|
||||||
|
+ disks[numdisks].minor = minor(stbuf.st_rdev);
|
||||||
|
+ numdisks++;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+diskio_parse_config_disks(const char *token, char *cptr)
|
||||||
|
+ {
|
||||||
|
+#if HAVE_FSTAB_H || HAVE_GETMNTENT || HAVE_STATFS
|
||||||
|
+ char path[STRMAX];
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * read disk path (eg, /1 or /usr)
|
||||||
|
+ */
|
||||||
|
+ copy_nword(cptr, path, sizeof(path));
|
||||||
|
+
|
||||||
|
+ /* TODO: we may include regular expressions in future */
|
||||||
|
+ /*
|
||||||
|
+ * check if the disk already exists, if so then modify its
|
||||||
|
+ * parameters. if it does not exist then add it
|
||||||
|
+ */
|
||||||
|
+ add_device(path, 1);
|
||||||
|
+#endif /* HAVE_FSTAB_H || HAVE_GETMNTENT || HAVE_STATFS */
|
||||||
|
+}
|
||||||
|
|
||||||
|
void devla_getstats(unsigned int regno, void * dummy) {
|
||||||
|
|
||||||
|
@@ -976,6 +1130,47 @@ int is_excluded(const char *name)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int get_sysfs_stats()
|
||||||
|
+{
|
||||||
|
+ int i;
|
||||||
|
+ char buffer[1024];
|
||||||
|
+
|
||||||
|
+ head.length = 0;
|
||||||
|
+
|
||||||
|
+ for(i = 0; i < numdisks; i++) {
|
||||||
|
+ FILE *f = fopen(disks[i].syspath, "r");
|
||||||
|
+ if ( f == NULL ) {
|
||||||
|
+ DEBUGMSGTL(("ucd-snmp/diskio", "Can't open %s, skipping", disks[i].syspath));
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ if (fgets(buffer, sizeof(buffer), f) == NULL) {
|
||||||
|
+ DEBUGMSGTL(("ucd-snmp/diskio", "Can't read %s, skipping", disks[i].syspath));
|
||||||
|
+ fclose(f);
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ linux_diskio* pTemp;
|
||||||
|
+ if (head.length == head.alloc) {
|
||||||
|
+ head.alloc += DISK_INCR;
|
||||||
|
+ head.indices = (linux_diskio *) realloc(head.indices, head.alloc*sizeof(linux_diskio));
|
||||||
|
+ }
|
||||||
|
+ pTemp = &head.indices[head.length];
|
||||||
|
+ pTemp->major = disks[i].major;
|
||||||
|
+ pTemp->minor = disks[i].minor;
|
||||||
|
+ strlcpy( pTemp->name, disks[i].shortname, sizeof(pTemp->name) - 1 );
|
||||||
|
+ if (sscanf (buffer, "%*[ \n\t]%lu%*[ \n\t]%lu%*[ \n\t]%lu%*[ \n\t]%lu%*[ \n\t]%lu%*[ \n\t]%lu%*[ \n\t]%lu%*[ \n\t]%lu%*[ \n\t]%lu%*[ \n\t]%lu%*[ \n\t]%lu\n",
|
||||||
|
+ &pTemp->rio, &pTemp->rmerge, &pTemp->rsect, &pTemp->ruse,
|
||||||
|
+ &pTemp->wio, &pTemp->wmerge, &pTemp->wsect, &pTemp->wuse,
|
||||||
|
+ &pTemp->running, &pTemp->use, &pTemp->aveq) != 11)
|
||||||
|
+ sscanf (buffer, "%*[ \n\t]%lu%*[ \n\t]%lu%*[ \n\t]%lu%*[ \n\t]%lu\n",
|
||||||
|
+ &pTemp->rio, &pTemp->rsect,
|
||||||
|
+ &pTemp->wio, &pTemp->wsect);
|
||||||
|
+ head.length++;
|
||||||
|
+ fclose(f);
|
||||||
|
+ }
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int
|
||||||
|
getstats(void)
|
||||||
|
{
|
||||||
|
@@ -995,6 +1189,14 @@ getstats(void)
|
||||||
|
|
||||||
|
memset(head.indices, 0, head.alloc*sizeof(linux_diskio));
|
||||||
|
|
||||||
|
+ if (numdisks>0) {
|
||||||
|
+ /* 'diskio' configuration is used - go through the whitelist only and
|
||||||
|
+ * read /sys/dev/block/xxx */
|
||||||
|
+ cache_time = now;
|
||||||
|
+ return get_sysfs_stats();
|
||||||
|
+ }
|
||||||
|
+ /* 'diskio' configuration is not used - report all devices */
|
||||||
|
+
|
||||||
|
/* Is this a 2.6 kernel? */
|
||||||
|
parts = fopen("/proc/diskstats", "r");
|
||||||
|
if (parts) {
|
||||||
|
@@ -1111,13 +1313,22 @@ var_diskio(struct variable * vp,
|
||||||
|
long_ret = head.indices[indx].wio & 0xffffffff;
|
||||||
|
return (u_char *) & long_ret;
|
||||||
|
case DISKIO_LA1:
|
||||||
|
- long_ret = la_head.indices[indx].la1;
|
||||||
|
+ if (la_head.length > indx)
|
||||||
|
+ long_ret = la_head.indices[indx].la1;
|
||||||
|
+ else
|
||||||
|
+ long_ret = 0;
|
||||||
|
return (u_char *) & long_ret;
|
||||||
|
case DISKIO_LA5:
|
||||||
|
- long_ret = la_head.indices[indx].la5;
|
||||||
|
+ if (la_head.length > indx)
|
||||||
|
+ long_ret = la_head.indices[indx].la5;
|
||||||
|
+ else
|
||||||
|
+ long_ret = 0;
|
||||||
|
return (u_char *) & long_ret;
|
||||||
|
case DISKIO_LA15:
|
||||||
|
- long_ret = la_head.indices[indx].la15;
|
||||||
|
+ if (la_head.length > indx)
|
||||||
|
+ long_ret = la_head.indices[indx].la15;
|
||||||
|
+ else
|
||||||
|
+ long_ret = 0;
|
||||||
|
return (u_char *) & long_ret;
|
||||||
|
case DISKIO_NREADX:
|
||||||
|
*var_len = sizeof(struct counter64);
|
||||||
|
diff -up net-snmp-5.7.2/man/snmpd.conf.5.def.test net-snmp-5.7.2/man/snmpd.conf.5.def
|
||||||
|
--- net-snmp-5.7.2/man/snmpd.conf.5.def.test 2015-06-18 15:13:31.249470179 +0200
|
||||||
|
+++ net-snmp-5.7.2/man/snmpd.conf.5.def 2015-06-18 15:16:45.481423115 +0200
|
||||||
|
@@ -715,6 +715,15 @@ e.g. "loop0"
|
||||||
|
.IP "diskio_exclude_ram yes"
|
||||||
|
Excludes all LInux ramdisk block devices, whose names start with "ram", e.g.
|
||||||
|
"ram0"
|
||||||
|
+.PP
|
||||||
|
+On Linux systems, it is possible to report only explicitly whitelisted
|
||||||
|
+devices. It may take significant amount of time to process diskIOTable data
|
||||||
|
+on systems with tens of thousands of block devices and whitelisting only the
|
||||||
|
+important ones avoids large CPU consumption.
|
||||||
|
+.IP "diskio <device>"
|
||||||
|
+Enables whitelisting of devices and adds the device to the whitelist. Only
|
||||||
|
+explicitly whitelisted devices will be reported. This option may be used
|
||||||
|
+multiple times.
|
||||||
|
.SS System Load Monitoring
|
||||||
|
This requires that the agent was built with support for either the
|
||||||
|
\fIucd\-snmp/loadave\fR module or the \fIucd\-snmp/memory\fR module
|
||||||
|
|
||||||
|
|
||||||
|
commit 59f9f3387dab4238114804a0be9e4c15667d868c
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Fri Jun 19 09:29:06 2015 +0200
|
||||||
|
|
||||||
|
Fixed memory leak on realloc failure.
|
||||||
|
|
||||||
|
Found by Coverity.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/ucd-snmp/diskio.c b/agent/mibgroup/ucd-snmp/diskio.c
|
||||||
|
index f04d5c5..58163d8 100644
|
||||||
|
--- a/agent/mibgroup/ucd-snmp/diskio.c
|
||||||
|
+++ b/agent/mibgroup/ucd-snmp/diskio.c
|
||||||
|
@@ -405,13 +405,17 @@ add_device(char *path, int addNewDisks )
|
||||||
|
}
|
||||||
|
memset(disks, 0, maxdisks * sizeof(struct diskiopart));
|
||||||
|
} else {
|
||||||
|
+ struct diskiopart *newdisks;
|
||||||
|
maxdisks *= 2;
|
||||||
|
- disks = realloc(disks, maxdisks * sizeof(struct diskiopart));
|
||||||
|
- if (!disks) {
|
||||||
|
+ newdisks = realloc(disks, maxdisks * sizeof(struct diskiopart));
|
||||||
|
+ if (!newdisks) {
|
||||||
|
+ free(disks);
|
||||||
|
+ disks = NULL;
|
||||||
|
config_perror("malloc failed for new disko allocation.");
|
||||||
|
netsnmp_config_error("\tignoring: %s", path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
+ disks = newdisks;
|
||||||
|
memset(disks + maxdisks/2, 0, maxdisks/2 * sizeof(struct diskiopart));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
diff -urNp a/man/snmp_config.5.def b/man/snmp_config.5.def
|
||||||
|
--- a/man/snmp_config.5.def 2017-06-26 11:30:42.728527539 +0200
|
||||||
|
+++ b/man/snmp_config.5.def 2017-06-26 11:33:19.766436329 +0200
|
||||||
|
@@ -179,14 +179,28 @@ during normal configuration file process
|
||||||
|
.RS
|
||||||
|
.nf
|
||||||
|
# include site specific config
|
||||||
|
-include site.conf
|
||||||
|
+includeFile site.conf
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
|
-This will search every directory in the configuration path for files
|
||||||
|
-named site.conf, and will process those files before returning to the
|
||||||
|
-processing of the original file. Note that if '.conf' is omitted,
|
||||||
|
-it will be appended. That is, all configuration files must end
|
||||||
|
-in '.conf'.
|
||||||
|
+This will load the specified configuration file. The
|
||||||
|
+path to file must be either absolute, starting with '/',
|
||||||
|
+or relative. The relative path is then relative to the directory
|
||||||
|
+where the parent file with 'includeFile' directive resides.
|
||||||
|
+.PP
|
||||||
|
+The included file name does not need to have '.conf' suffix.
|
||||||
|
+.PP
|
||||||
|
+.RS
|
||||||
|
+.nf
|
||||||
|
+# include a all *.conf files in a directory
|
||||||
|
+includeDir /etc/snmp/config.d
|
||||||
|
+.RE
|
||||||
|
+.PP
|
||||||
|
+This will search specified directory for all files with '.conf'
|
||||||
|
+suffix and process them as if they were included using includeFile
|
||||||
|
+directive. The configuration files are not processed in any particular
|
||||||
|
+order.
|
||||||
|
+.PP
|
||||||
|
+The specified directory must be absolute directory path.
|
||||||
|
.SH "API INTERFACE"
|
||||||
|
.PP
|
||||||
|
Information about writing C code that makes use of this system in
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
1305933 - snmpd leaks memory in ether like-mib implementation
|
||||||
|
|
||||||
|
commit ed4e48b5fab165d1ba4c431e31e543f808a2c25f
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Wed Feb 10 14:00:12 2016 +0100
|
||||||
|
|
||||||
|
CHANGES: snmpd: fixed memory leak in ETHERLIKE-MIB.
|
||||||
|
|
||||||
|
ke->name in stdup-ed at line 297:
|
||||||
|
n->name = strdup(RTA_DATA(tb[IFLA_IFNAME]));
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/etherlike-mib/data_access/dot3stats_linux.c b/agent/mibgroup/etherlike-mib/data_access/dot3stats_linux.c
|
||||||
|
index b110950..a884bb3 100644
|
||||||
|
--- a/agent/mibgroup/etherlike-mib/data_access/dot3stats_linux.c
|
||||||
|
+++ b/agent/mibgroup/etherlike-mib/data_access/dot3stats_linux.c
|
||||||
|
@@ -463,6 +463,7 @@ _dot3Stats_netlink_get_errorcntrs(dot3StatsTable_rowreq_ctx *rowreq_ctx, const c
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
kern_db = ke->next;
|
||||||
|
+ free(ke->name);
|
||||||
|
free(ke);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
915302 - snmpd logging strange messages when reading MIB
|
||||||
|
|
||||||
|
commit ecf8682d864d2f08525078543858d361b3adca5c
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Wed Jul 10 10:47:33 2013 +0200
|
||||||
|
|
||||||
|
Lower importance of debugging messages, they spam syslog.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/etherlike-mib/data_access/dot3stats_linux.c b/agent/mibgroup/etherlike-mib/data_access/dot3stats_linux.c
|
||||||
|
index 49c3fdb..b110950 100644
|
||||||
|
--- a/agent/mibgroup/etherlike-mib/data_access/dot3stats_linux.c
|
||||||
|
+++ b/agent/mibgroup/etherlike-mib/data_access/dot3stats_linux.c
|
||||||
|
@@ -440,7 +440,7 @@ _dot3Stats_netlink_get_errorcntrs(dot3StatsTable_rowreq_ctx *rowreq_ctx, const c
|
||||||
|
{
|
||||||
|
dot3StatsTable_data *data = &rowreq_ctx->data;
|
||||||
|
|
||||||
|
- snmp_log(LOG_ERR, "IFLA_STATS for %s\n", name);
|
||||||
|
+ DEBUGMSGTL(("access:dot3StatsTable", "IFLA_STATS for %s\n", name));
|
||||||
|
|
||||||
|
data->dot3StatsFCSErrors = ke->stats.rx_crc_errors;
|
||||||
|
rowreq_ctx->column_exists_flags |= COLUMN_DOT3STATSFCSERRORS_FLAG;
|
||||||
|
@@ -527,7 +527,7 @@ interface_dot3stats_get_errorcounters (dot3StatsTable_rowreq_ctx *rowreq_ctx, co
|
||||||
|
|
||||||
|
if (_dot3Stats_netlink_get_errorcntrs(rowreq_ctx, name) == 0)
|
||||||
|
{
|
||||||
|
- snmp_log(LOG_NOTICE, "interface_dot3stats_get_errorcounters: got data from IFLA_STATS\n");
|
||||||
|
+ DEBUGMSGTL(("access:dot3StatsTable", "interface_dot3stats_get_errorcounters: got data from IFLA_STATS\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,175 @@
|
||||||
|
commit e3fc76e0ae502fb8ef0aac87eee237db9d9690f5
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Tue Jul 9 14:26:59 2013 +0200
|
||||||
|
|
||||||
|
CHANGES: snmpd: Make UCD-SNMP::dskTable dynamic if includeAllDisks is set.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/ucd-snmp/disk_hw.c b/agent/mibgroup/ucd-snmp/disk_hw.c
|
||||||
|
index ea37610..f7911d9 100644
|
||||||
|
--- a/agent/mibgroup/ucd-snmp/disk_hw.c
|
||||||
|
+++ b/agent/mibgroup/ucd-snmp/disk_hw.c
|
||||||
|
@@ -55,6 +55,7 @@ static netsnmp_fsys_info ** _expand_disk_array( char *cptr );
|
||||||
|
|
||||||
|
int numdisks;
|
||||||
|
int allDisksIncluded = 0;
|
||||||
|
+int allDisksMinPercent = 0;
|
||||||
|
int maxdisks = 0;
|
||||||
|
netsnmp_fsys_info **disks = NULL;
|
||||||
|
|
||||||
|
@@ -119,6 +120,7 @@ init_disk_hw(void)
|
||||||
|
disk_free_config,
|
||||||
|
"minpercent%");
|
||||||
|
allDisksIncluded = 0;
|
||||||
|
+ allDisksMinPercent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
@@ -140,6 +142,7 @@ disk_free_config(void)
|
||||||
|
maxdisks = numdisks = 0;
|
||||||
|
}
|
||||||
|
allDisksIncluded = 0;
|
||||||
|
+ allDisksMinPercent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
@@ -199,8 +202,7 @@ static void
|
||||||
|
disk_parse_config_all(const char *token, char *cptr)
|
||||||
|
{
|
||||||
|
int minpercent = DISKMINPERCENT;
|
||||||
|
- netsnmp_fsys_info *entry;
|
||||||
|
-
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* read the minimum disk usage percent
|
||||||
|
*/
|
||||||
|
@@ -220,30 +222,36 @@ disk_parse_config_all(const char *token, char *cptr)
|
||||||
|
netsnmp_config_error("\tignoring: includeAllDisks %s", cptr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
-
|
||||||
|
- netsnmp_fsys_load( NULL, NULL ); /* Prime the fsys H/W module */
|
||||||
|
- for ( entry = netsnmp_fsys_get_first();
|
||||||
|
- entry != NULL;
|
||||||
|
- entry = netsnmp_fsys_get_next( entry )) {
|
||||||
|
-
|
||||||
|
- if ( !(entry->flags & NETSNMP_FS_FLAG_ACTIVE ))
|
||||||
|
- continue;
|
||||||
|
- entry->minspace = -1;
|
||||||
|
- entry->minpercent = minpercent;
|
||||||
|
- entry->flags |= NETSNMP_FS_FLAG_UCD;
|
||||||
|
- /*
|
||||||
|
- * Ensure there is space for the new entry
|
||||||
|
- */
|
||||||
|
- if (numdisks == maxdisks) {
|
||||||
|
- if (!_expand_disk_array( entry->device ))
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
- disks[numdisks++] = entry;
|
||||||
|
- }
|
||||||
|
allDisksIncluded = 1;
|
||||||
|
+ allDisksMinPercent = minpercent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* add new entries to dskTable dynamically */
|
||||||
|
+static void _refresh_disks(int minpercent)
|
||||||
|
+{
|
||||||
|
+ netsnmp_fsys_info *entry;
|
||||||
|
+
|
||||||
|
+ for ( entry = netsnmp_fsys_get_first();
|
||||||
|
+ entry != NULL;
|
||||||
|
+ entry = netsnmp_fsys_get_next( entry )) {
|
||||||
|
+
|
||||||
|
+ if (!(entry->flags & NETSNMP_FS_FLAG_UCD)) {
|
||||||
|
+ /* this is new disk, add it to the table */
|
||||||
|
+ entry->minspace = -1;
|
||||||
|
+ entry->minpercent = minpercent;
|
||||||
|
+ entry->flags |= NETSNMP_FS_FLAG_UCD;
|
||||||
|
+ /*
|
||||||
|
+ * Ensure there is space for the new entry
|
||||||
|
+ */
|
||||||
|
+ if (numdisks == maxdisks) {
|
||||||
|
+ if (!_expand_disk_array( entry->device ))
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ disks[numdisks++] = entry;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
|
||||||
|
static int _percent( unsigned long long value, unsigned long long total ) {
|
||||||
|
float v=value, t=total, pct;
|
||||||
|
@@ -301,7 +309,7 @@ var_extensible_disk(struct variable *vp,
|
||||||
|
size_t * var_len, WriteMethod ** write_method)
|
||||||
|
{
|
||||||
|
int disknum = 0;
|
||||||
|
- netsnmp_fsys_info *entry;
|
||||||
|
+ netsnmp_fsys_info *entry;
|
||||||
|
unsigned long long val;
|
||||||
|
static long long_ret;
|
||||||
|
static char errmsg[300];
|
||||||
|
@@ -310,6 +318,8 @@ var_extensible_disk(struct variable *vp,
|
||||||
|
/* Update the fsys H/W module */
|
||||||
|
cache = netsnmp_fsys_get_cache();
|
||||||
|
netsnmp_cache_check_and_reload(cache);
|
||||||
|
+ if (allDisksIncluded)
|
||||||
|
+ _refresh_disks(allDisksMinPercent);
|
||||||
|
|
||||||
|
tryAgain:
|
||||||
|
if (header_simple_table
|
||||||
|
@@ -318,9 +328,14 @@ tryAgain:
|
||||||
|
disknum = name[*length - 1] - 1;
|
||||||
|
entry = disks[disknum];
|
||||||
|
if ( !entry ) {
|
||||||
|
- if (!exact || !(entry->flags & NETSNMP_FS_FLAG_UCD))
|
||||||
|
- goto tryAgain;
|
||||||
|
- return NULL;
|
||||||
|
+ if (exact)
|
||||||
|
+ return NULL;
|
||||||
|
+ goto tryAgain;
|
||||||
|
+ }
|
||||||
|
+ if (!(entry->flags & NETSNMP_FS_FLAG_ACTIVE) || !(entry->flags & NETSNMP_FS_FLAG_UCD)) {
|
||||||
|
+ if (exact)
|
||||||
|
+ return NULL;
|
||||||
|
+ goto tryAgain;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (vp->magic) {
|
||||||
|
diff --git a/man/snmpd.conf.5.def b/man/snmpd.conf.5.def
|
||||||
|
index 5f85f72..d2caf9c 100644
|
||||||
|
--- a/man/snmpd.conf.5.def
|
||||||
|
+++ b/man/snmpd.conf.5.def
|
||||||
|
@@ -652,6 +652,8 @@ This requires that the agent was built with support for the
|
||||||
|
default build configuration).
|
||||||
|
.IP "disk PATH [ MINSPACE | MINPERCENT% ]"
|
||||||
|
monitors the disk mounted at PATH for available disk space.
|
||||||
|
+Disks mounted after the agent has started will not be monitored,
|
||||||
|
+unless \fIincludeAllDisks\fR option is specified.
|
||||||
|
.IP
|
||||||
|
The minimum threshold can either be specified in kB (MINSPACE) or
|
||||||
|
as a percentage of the total disk (MINPERCENT% with a '%' character),
|
||||||
|
@@ -668,6 +670,9 @@ the problem - see the DisMan Event MIB section later.
|
||||||
|
.IP "includeAllDisks MINPERCENT%"
|
||||||
|
configures monitoring of all disks found on the system,
|
||||||
|
using the specified (percentage) threshold.
|
||||||
|
+The \fCdskTable\fR is dynamically updated, unmounted disks
|
||||||
|
+disappear from the table and newly mounted disks are
|
||||||
|
+added to the table.
|
||||||
|
The threshold for individual disks can be adjusted using suitable
|
||||||
|
\fIdisk\fR directives (which can come either before or after the
|
||||||
|
\fIincludeAllDisks\fR directive).
|
||||||
|
@@ -680,12 +685,8 @@ may affect the indexing of the \fCdskTable\fR.
|
||||||
|
Only one \fIincludeAllDisks\fR directive should be specified - any
|
||||||
|
subsequent copies will be ignored.
|
||||||
|
.IP
|
||||||
|
-The list of mounted disks will be determined when the agent starts using the
|
||||||
|
-setmntent(3) and getmntent(3), or fopen(3) and getmntent(3), or
|
||||||
|
-setfsent(3) and getfsent(3) system calls. If none of the above
|
||||||
|
-system calls are available then the root partition "/"
|
||||||
|
-(which is assumed to exist on any UNIX based system) will be monitored.
|
||||||
|
-Disks mounted after the agent has started will not be monitored.
|
||||||
|
+The list of mounted disks will be determined from
|
||||||
|
+HOST-RESOURCES-MIB::hrFSTable.
|
||||||
|
.\"
|
||||||
|
.\" XXX - unless the config is re-read ??
|
||||||
|
.\"
|
|
@ -0,0 +1,11 @@
|
||||||
|
diff -urNp old/agent/mibgroup/ip-mib/data_access/ipaddress_common.c new/agent/mibgroup/ip-mib/data_access/ipaddress_common.c
|
||||||
|
--- old/agent/mibgroup/ip-mib/data_access/ipaddress_common.c 2017-04-26 08:46:40.272404217 +0200
|
||||||
|
+++ new/agent/mibgroup/ip-mib/data_access/ipaddress_common.c 2017-04-26 08:50:30.681323779 +0200
|
||||||
|
@@ -144,6 +144,7 @@ _remove_duplicates(netsnmp_container *co
|
||||||
|
for (entry = ITERATOR_FIRST(it); entry; entry = ITERATOR_NEXT(it)) {
|
||||||
|
if (prev_entry && _access_ipaddress_entry_compare_addr(prev_entry, entry) == 0) {
|
||||||
|
/* 'entry' is duplicate of the previous one -> delete it */
|
||||||
|
+ NETSNMP_LOGONCE((LOG_ERR, "Duplicate IPv4 address detected, some interfaces may not be visible in IP-MIB\n"));
|
||||||
|
netsnmp_access_ipaddress_entry_free(entry);
|
||||||
|
} else {
|
||||||
|
CONTAINER_INSERT(ret, entry);
|
|
@ -0,0 +1,83 @@
|
||||||
|
842279 - Incomplete command line in UCD-SNMP-MIB::extCommand
|
||||||
|
|
||||||
|
commit e8e44b3faecdba5daedfb45d815fae65117d1b22
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Sep 10 13:25:38 2012 +0200
|
||||||
|
|
||||||
|
CHANGES: snmpd: fixed value of UCD-SNMP-MIB::extCommand to contain full command line.
|
||||||
|
|
||||||
|
MIB description of UCD-SNMP-MIB::extCommand suggests it should contail full command line.
|
||||||
|
Also in Net-SNMP 5.3.2.2, whole command line was shown.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/agent/extend.c b/agent/mibgroup/agent/extend.c
|
||||||
|
index 085d762..0b2c660 100644
|
||||||
|
--- a/agent/mibgroup/agent/extend.c
|
||||||
|
+++ b/agent/mibgroup/agent/extend.c
|
||||||
|
@@ -44,6 +44,9 @@ unsigned int num_compatability_entries = 0;
|
||||||
|
unsigned int max_compatability_entries = 50;
|
||||||
|
netsnmp_old_extend *compatability_entries;
|
||||||
|
|
||||||
|
+char *cmdlinebuf;
|
||||||
|
+size_t cmdlinesize;
|
||||||
|
+
|
||||||
|
WriteMethod fixExec2Error;
|
||||||
|
FindVarMethod var_extensible_old;
|
||||||
|
oid old_extensible_variables_oid[] = { NETSNMP_UCDAVIS_MIB, NETSNMP_SHELLMIBNUM, 1 };
|
||||||
|
@@ -1354,6 +1357,23 @@ handle_nsExtendOutput2Table(netsnmp_mib_handler *handler,
|
||||||
|
*
|
||||||
|
*************************/
|
||||||
|
|
||||||
|
+char * _get_cmdline(netsnmp_extend *extend)
|
||||||
|
+{
|
||||||
|
+ size_t size;
|
||||||
|
+
|
||||||
|
+ size = strlen(extend->command) + strlen(extend->args) + 2;
|
||||||
|
+ if (size > cmdlinesize) {
|
||||||
|
+ cmdlinebuf = realloc(cmdlinebuf, size);
|
||||||
|
+ if (!cmdlinebuf) {
|
||||||
|
+ cmdlinesize = 0;
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+ cmdlinesize = size;
|
||||||
|
+ }
|
||||||
|
+ sprintf(cmdlinebuf, "%s %s", extend->command, extend->args);
|
||||||
|
+ return cmdlinebuf;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
u_char *
|
||||||
|
var_extensible_old(struct variable * vp,
|
||||||
|
oid * name,
|
||||||
|
@@ -1364,6 +1384,7 @@ var_extensible_old(struct variable * vp,
|
||||||
|
netsnmp_old_extend *exten = NULL;
|
||||||
|
static long long_ret;
|
||||||
|
unsigned int idx;
|
||||||
|
+ char *cmdline;
|
||||||
|
|
||||||
|
if (header_simple_table
|
||||||
|
(vp, name, length, exact, var_len, write_method, num_compatability_entries))
|
||||||
|
@@ -1382,8 +1403,10 @@ var_extensible_old(struct variable * vp,
|
||||||
|
*var_len = strlen(exten->exec_entry->token);
|
||||||
|
return ((u_char *) (exten->exec_entry->token));
|
||||||
|
case SHELLCOMMAND:
|
||||||
|
- *var_len = strlen(exten->exec_entry->command);
|
||||||
|
- return ((u_char *) (exten->exec_entry->command));
|
||||||
|
+ cmdline = _get_cmdline(exten->exec_entry);
|
||||||
|
+ if (cmdline)
|
||||||
|
+ *var_len = strlen(cmdline);
|
||||||
|
+ return ((u_char *) cmdline);
|
||||||
|
case ERRORFLAG: /* return code from the process */
|
||||||
|
netsnmp_cache_check_and_reload( exten->exec_entry->cache );
|
||||||
|
long_ret = exten->exec_entry->result;
|
||||||
|
@@ -1406,8 +1429,10 @@ var_extensible_old(struct variable * vp,
|
||||||
|
|
||||||
|
case ERRORFIXCMD:
|
||||||
|
if (exten->efix_entry) {
|
||||||
|
- *var_len = strlen(exten->efix_entry->command);
|
||||||
|
- return ((u_char *) exten->efix_entry->command);
|
||||||
|
+ cmdline = _get_cmdline(exten->efix_entry);
|
||||||
|
+ if (cmdline)
|
||||||
|
+ *var_len = strlen(cmdline);
|
||||||
|
+ return ((u_char *) cmdline);
|
||||||
|
} else {
|
||||||
|
*var_len = 0;
|
||||||
|
return ((u_char *) &long_return); /* Just needs to be non-null! */
|
|
@ -0,0 +1,181 @@
|
||||||
|
Bug 1252048 - net-snmp snmpd fork() overhead [fix available]
|
||||||
|
|
||||||
|
Backported from:
|
||||||
|
|
||||||
|
commit f0e87f4918ffc41e03f707e9670ea422cd154a9b
|
||||||
|
Author: Bart Van Assche <bvanassche@acm.org>
|
||||||
|
Date: Sat Jan 31 12:05:24 2015 +0100
|
||||||
|
|
||||||
|
CHANGES: snmpd: BUG: 2596: Reduce fork() overhead
|
||||||
|
|
||||||
|
Avoid that the close() loop that is executed after a fork() delays
|
||||||
|
the pass/extend API on systems with a large maximum number of files
|
||||||
|
by reducing the number of iterations of this loop on Linux systems.
|
||||||
|
|
||||||
|
See also http://sourceforge.net/p/net-snmp/bugs/2596.
|
||||||
|
|
||||||
|
Reported-by: andymf <andymf@users.sf.net>
|
||||||
|
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/util_funcs.c.test net-snmp-5.7.2/agent/mibgroup/util_funcs.c
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/util_funcs.c.test 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/util_funcs.c 2015-08-18 10:15:18.888767023 +0200
|
||||||
|
@@ -480,8 +480,7 @@ get_exec_pipes(char *cmd, int *fdIn, int
|
||||||
|
/*
|
||||||
|
* close all non-standard open file descriptors
|
||||||
|
*/
|
||||||
|
- for (cnt = getdtablesize() - 1; cnt >= 2; --cnt)
|
||||||
|
- (void) close(cnt);
|
||||||
|
+ netsnmp_close_fds(1);
|
||||||
|
(void) dup(1); /* stderr */
|
||||||
|
|
||||||
|
for (cnt = 1, cptr1 = cmd, cptr2 = argvs; *cptr1 != 0;
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/utilities/execute.c.test net-snmp-5.7.2/agent/mibgroup/utilities/execute.c
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/utilities/execute.c.test 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/utilities/execute.c 2015-08-18 10:15:18.889767028 +0200
|
||||||
|
@@ -22,6 +22,9 @@
|
||||||
|
#if HAVE_FCNTL_H
|
||||||
|
#include <fcntl.h>
|
||||||
|
#endif
|
||||||
|
+#if HAVE_DIRENT_H
|
||||||
|
+#include <dirent.h>
|
||||||
|
+#endif
|
||||||
|
#if HAVE_SYS_WAIT_H
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#endif
|
||||||
|
@@ -207,8 +210,8 @@ run_exec_command( char *command, char *i
|
||||||
|
close(opipe[0]);
|
||||||
|
close(2);
|
||||||
|
dup(1);
|
||||||
|
- for (i = getdtablesize()-1; i>2; i--)
|
||||||
|
- close(i);
|
||||||
|
+
|
||||||
|
+ netsnmp_close_fds(2);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up the argv array and execute it
|
||||||
|
@@ -406,3 +409,30 @@ run_exec_command( char *command, char *i
|
||||||
|
return run_shell_command( command, input, output, out_len );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Close all file descriptors larger than @fd.
|
||||||
|
+ */
|
||||||
|
+void netsnmp_close_fds(int fd)
|
||||||
|
+{
|
||||||
|
+#if defined(HAVE_FORK)
|
||||||
|
+ DIR *dir;
|
||||||
|
+ struct dirent *ent;
|
||||||
|
+ int i, largest_fd = -1;
|
||||||
|
+
|
||||||
|
+ if ((dir = opendir("/proc/self/fd"))) {
|
||||||
|
+ while ((ent = readdir(dir))) {
|
||||||
|
+ if (sscanf(ent->d_name, "%d", &i) == 1) {
|
||||||
|
+ if (i > largest_fd)
|
||||||
|
+ largest_fd = i;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ closedir(dir);
|
||||||
|
+ } else {
|
||||||
|
+ largest_fd = getdtablesize() - 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (i = largest_fd; i > fd && i > 0; i--)
|
||||||
|
+ close(i);
|
||||||
|
+#endif
|
||||||
|
+}
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/utilities/execute.h.test net-snmp-5.7.2/agent/mibgroup/utilities/execute.h
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/utilities/execute.h.test 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/utilities/execute.h 2015-08-18 10:15:18.889767028 +0200
|
||||||
|
@@ -3,6 +3,7 @@
|
||||||
|
|
||||||
|
config_belongs_in(agent_module)
|
||||||
|
|
||||||
|
+void netsnmp_close_fds(int fd);
|
||||||
|
int run_shell_command(char *command, char *input,
|
||||||
|
char *output, int *out_len);
|
||||||
|
int run_exec_command( char *command, char *input,
|
||||||
|
diff -up net-snmp-5.7.2/agent/snmpd.c.test net-snmp-5.7.2/agent/snmpd.c
|
||||||
|
--- net-snmp-5.7.2/agent/snmpd.c.test 2015-08-18 10:15:08.450714809 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/snmpd.c 2015-08-18 10:17:31.579430763 +0200
|
||||||
|
@@ -143,6 +143,7 @@ typedef long fd_mask;
|
||||||
|
#include <net-snmp/agent/agent_module_config.h>
|
||||||
|
#include <net-snmp/agent/mib_module_config.h>
|
||||||
|
|
||||||
|
+#include "utilities/execute.h" /* netsnmp_close_fds() */
|
||||||
|
#include "snmpd.h"
|
||||||
|
|
||||||
|
#include <net-snmp/agent/mib_modules.h>
|
||||||
|
@@ -451,7 +452,6 @@ main(int argc, char *argv[])
|
||||||
|
FILE *PID;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#ifndef WIN32
|
||||||
|
#ifndef NETSNMP_NO_SYSYSTEMD
|
||||||
|
/* check if systemd has sockets for us and don't close them */
|
||||||
|
prepared_sockets = netsnmp_sd_listen_fds(0);
|
||||||
|
@@ -462,11 +462,8 @@ main(int argc, char *argv[])
|
||||||
|
* inherited from the shell.
|
||||||
|
*/
|
||||||
|
if (!prepared_sockets) {
|
||||||
|
- for (i = getdtablesize() - 1; i > 2; --i) {
|
||||||
|
- (void) close(i);
|
||||||
|
- }
|
||||||
|
+ netsnmp_close_fds(2);
|
||||||
|
}
|
||||||
|
-#endif /* #WIN32 */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* register signals ASAP to prevent default action (usually core)
|
||||||
|
diff -up net-snmp-5.7.2/apps/snmptrapd.c.test net-snmp-5.7.2/apps/snmptrapd.c
|
||||||
|
--- net-snmp-5.7.2/apps/snmptrapd.c.test 2015-08-18 10:15:08.450714809 +0200
|
||||||
|
+++ net-snmp-5.7.2/apps/snmptrapd.c 2015-08-18 10:18:15.454650235 +0200
|
||||||
|
@@ -97,6 +97,7 @@ SOFTWARE.
|
||||||
|
#include <net-snmp/net-snmp-includes.h>
|
||||||
|
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||||
|
#include <net-snmp/library/fd_event_manager.h>
|
||||||
|
+#include "utilities/execute.h" /* netsnmp_close_fds() */
|
||||||
|
#include "snmptrapd_handlers.h"
|
||||||
|
#include "snmptrapd_log.h"
|
||||||
|
#include "snmptrapd_auth.h"
|
||||||
|
@@ -662,7 +663,6 @@ main(int argc, char *argv[])
|
||||||
|
int prepared_sockets = 0;
|
||||||
|
|
||||||
|
|
||||||
|
-#ifndef WIN32
|
||||||
|
#ifndef NETSNMP_NO_SYSTEMD
|
||||||
|
/* check if systemd has sockets for us and don't close them */
|
||||||
|
prepared_sockets = netsnmp_sd_listen_fds(0);
|
||||||
|
@@ -672,11 +672,8 @@ main(int argc, char *argv[])
|
||||||
|
* inherited from the shell.
|
||||||
|
*/
|
||||||
|
if (!prepared_sockets) {
|
||||||
|
- for (i = getdtablesize() - 1; i > 2; --i) {
|
||||||
|
- (void) close(i);
|
||||||
|
- }
|
||||||
|
+ netsnmp_close_fds(2);
|
||||||
|
}
|
||||||
|
-#endif /* #WIN32 */
|
||||||
|
|
||||||
|
#ifdef SIGTERM
|
||||||
|
signal(SIGTERM, term_handler);
|
||||||
|
@@ -1382,18 +1379,6 @@ trapd_update_config(void)
|
||||||
|
read_configs();
|
||||||
|
}
|
||||||
|
|
||||||
|
-
|
||||||
|
-#if !defined(HAVE_GETDTABLESIZE) && !defined(WIN32)
|
||||||
|
-#include <sys/resource.h>
|
||||||
|
-int
|
||||||
|
-getdtablesize(void)
|
||||||
|
-{
|
||||||
|
- struct rlimit rl;
|
||||||
|
- getrlimit(RLIMIT_NOFILE, &rl);
|
||||||
|
- return (rl.rlim_cur);
|
||||||
|
-}
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
/*
|
||||||
|
* Windows Service Related functions
|
||||||
|
*/
|
|
@ -0,0 +1,54 @@
|
||||||
|
1228893 - snmpd segfaults on reload with multiple 'exec' entry
|
||||||
|
|
||||||
|
commit 54290bede338164ca65a3eed224fa5040d7dd857
|
||||||
|
Author: Niels Baggesen <nba@users.sourceforge.net>
|
||||||
|
Date: Fri Oct 26 07:50:11 2012 +0200
|
||||||
|
|
||||||
|
Better cleanup of "exec" config to avoid crash during reload of config
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/agent/extend.c b/agent/mibgroup/agent/extend.c
|
||||||
|
index 68a11e2..9cb641c 100644
|
||||||
|
--- a/agent/mibgroup/agent/extend.c
|
||||||
|
+++ b/agent/mibgroup/agent/extend.c
|
||||||
|
@@ -34,7 +34,7 @@ typedef struct extend_registration_block_s {
|
||||||
|
size_t oid_len;
|
||||||
|
long num_entries;
|
||||||
|
netsnmp_extend *ehead;
|
||||||
|
- netsnmp_handler_registration *reg[3];
|
||||||
|
+ netsnmp_handler_registration *reg[4];
|
||||||
|
struct extend_registration_block_s *next;
|
||||||
|
} extend_registration_block;
|
||||||
|
extend_registration_block *ereg_head = NULL;
|
||||||
|
@@ -222,10 +222,13 @@ _register_extend( oid *base, size_t len )
|
||||||
|
rc = netsnmp_register_watched_scalar2( reg, winfo );
|
||||||
|
if (rc != SNMPERR_SUCCESS)
|
||||||
|
goto bail;
|
||||||
|
+ eptr->reg[3] = reg;
|
||||||
|
|
||||||
|
return eptr;
|
||||||
|
|
||||||
|
bail:
|
||||||
|
+ if (eptr->reg[3])
|
||||||
|
+ netsnmp_unregister_handler(eptr->reg[3]);
|
||||||
|
if (eptr->reg[2])
|
||||||
|
netsnmp_unregister_handler(eptr->reg[2]);
|
||||||
|
if (eptr->reg[1])
|
||||||
|
@@ -267,6 +270,7 @@ extend_clear_callback(int majorID, int minorID,
|
||||||
|
netsnmp_unregister_handler( eptr->reg[0] );
|
||||||
|
netsnmp_unregister_handler( eptr->reg[1] );
|
||||||
|
netsnmp_unregister_handler( eptr->reg[2] );
|
||||||
|
+ netsnmp_unregister_handler( eptr->reg[3] );
|
||||||
|
SNMP_FREE(eptr);
|
||||||
|
}
|
||||||
|
ereg_head = NULL;
|
||||||
|
@@ -550,6 +554,10 @@ extend_parse_config(const char *token, char *cptr)
|
||||||
|
}
|
||||||
|
|
||||||
|
eptr = _register_extend( oid_buf, oid_len );
|
||||||
|
+ if (!eptr) {
|
||||||
|
+ snmp_log(LOG_ERR, "Failed to register extend entry '%s' - possibly duplicate name.\n", exec_name );
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
extension = _new_extension( exec_name, flags, eptr );
|
||||||
|
if (extension) {
|
||||||
|
extension->command = strdup( exec_command );
|
|
@ -0,0 +1,116 @@
|
||||||
|
874440 - net-snmp does not work in FIPS mode
|
||||||
|
|
||||||
|
Three upstream commits are here:
|
||||||
|
|
||||||
|
commit dde3a35baaeb683cf1441a16a15441f8b456c520
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Nov 12 15:45:27 2012 +0100
|
||||||
|
|
||||||
|
CHANGES: snmplib: Fixed crash when MD5 hash is not supported by OpenSSL.
|
||||||
|
|
||||||
|
commit dd53ffbafeb31cde616a89949e70e3d5fe0cc1b3
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Nov 12 15:46:43 2012 +0100
|
||||||
|
|
||||||
|
Fall back to SHA-1 if MD5 is not available.
|
||||||
|
On paranoid systems where MD5 is disabled use SHA-1 instead of MD5 and don't crash.
|
||||||
|
|
||||||
|
commit 743cb66718904979f55895472501584c30c66f10
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Mon Nov 12 15:49:15 2012 +0100
|
||||||
|
|
||||||
|
Fixed crash when MD5 and/or SHA-1 hash is not supported by OpenSSL.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/snmplib/keytools.c.fips net-snmp-5.7.2/snmplib/keytools.c
|
||||||
|
--- net-snmp-5.7.2/snmplib/keytools.c.fips 2012-11-12 13:36:17.868635391 +0100
|
||||||
|
+++ net-snmp-5.7.2/snmplib/keytools.c 2012-11-12 14:24:23.031293984 +0100
|
||||||
|
@@ -156,27 +156,36 @@ generate_Ku(const oid * hashtype, u_int
|
||||||
|
EVP_MD_CTX_init(ctx);
|
||||||
|
#endif
|
||||||
|
#ifndef NETSNMP_DISABLE_MD5
|
||||||
|
- if (ISTRANSFORM(hashtype, HMACMD5Auth))
|
||||||
|
- EVP_DigestInit(ctx, EVP_md5());
|
||||||
|
- else
|
||||||
|
+ if (ISTRANSFORM(hashtype, HMACMD5Auth)) {
|
||||||
|
+ if (!EVP_DigestInit(ctx, EVP_md5()))
|
||||||
|
+ /* MD5 not supported */
|
||||||
|
+ return SNMPERR_GENERR;
|
||||||
|
+ } else
|
||||||
|
#endif
|
||||||
|
- if (ISTRANSFORM(hashtype, HMACSHA1Auth))
|
||||||
|
- EVP_DigestInit(ctx, EVP_sha1());
|
||||||
|
- else
|
||||||
|
- QUITFUN(SNMPERR_GENERR, generate_Ku_quit);
|
||||||
|
+ if (ISTRANSFORM(hashtype, HMACSHA1Auth)) {
|
||||||
|
+ if (!EVP_DigestInit(ctx, EVP_sha1()))
|
||||||
|
+ /* SHA1 not supported */
|
||||||
|
+ return SNMPERR_GENERR;
|
||||||
|
+ } else {
|
||||||
|
+ QUITFUN(SNMPERR_GENERR, generate_Ku_quit);
|
||||||
|
+ }
|
||||||
|
#elif NETSNMP_USE_INTERNAL_CRYPTO
|
||||||
|
#ifndef NETSNMP_DISABLE_MD5
|
||||||
|
if (ISTRANSFORM(hashtype, HMACMD5Auth)) {
|
||||||
|
- MD5_Init(&cmd5);
|
||||||
|
+ if (!MD5_Init(&cmd5))
|
||||||
|
+ /* MD5 not supported */
|
||||||
|
+ return SNMPERR_GENERR;
|
||||||
|
cryptotype = TYPE_MD5;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
- if (ISTRANSFORM(hashtype, HMACSHA1Auth)) {
|
||||||
|
- SHA1_Init(&csha1);
|
||||||
|
- cryptotype = TYPE_SHA1;
|
||||||
|
- } else {
|
||||||
|
- return (SNMPERR_GENERR);
|
||||||
|
- }
|
||||||
|
+ if (ISTRANSFORM(hashtype, HMACSHA1Auth)) {
|
||||||
|
+ if (!SHA1_Init(&csha1))
|
||||||
|
+ /* SHA1 not supported */
|
||||||
|
+ return SNMPERR_GENERR;
|
||||||
|
+ cryptotype = TYPE_SHA1;
|
||||||
|
+ } else {
|
||||||
|
+ return (SNMPERR_GENERR);
|
||||||
|
+ }
|
||||||
|
#else
|
||||||
|
MDbegin(&MD);
|
||||||
|
#endif /* NETSNMP_USE_OPENSSL */
|
||||||
|
diff -up net-snmp-5.7.2/snmplib/lcd_time.c.fips net-snmp-5.7.2/snmplib/lcd_time.c
|
||||||
|
--- net-snmp-5.7.2/snmplib/lcd_time.c.fips 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/snmplib/lcd_time.c 2012-11-12 13:36:11.326657629 +0100
|
||||||
|
@@ -505,6 +505,12 @@ hash_engineID(const u_char * engineID, u
|
||||||
|
rval = sc_hash(usmHMACMD5AuthProtocol,
|
||||||
|
sizeof(usmHMACMD5AuthProtocol) / sizeof(oid),
|
||||||
|
engineID, engineID_len, buf, &buf_len);
|
||||||
|
+ if (rval == SNMPERR_SC_NOT_CONFIGURED) {
|
||||||
|
+ /* fall back to sha1 */
|
||||||
|
+ rval = sc_hash(usmHMACSHA1AuthProtocol,
|
||||||
|
+ sizeof(usmHMACSHA1AuthProtocol) / sizeof(oid),
|
||||||
|
+ engineID, engineID_len, buf, &buf_len);
|
||||||
|
+ }
|
||||||
|
#else
|
||||||
|
rval = sc_hash(usmHMACSHA1AuthProtocol,
|
||||||
|
sizeof(usmHMACSHA1AuthProtocol) / sizeof(oid),
|
||||||
|
diff -up net-snmp-5.7.2/snmplib/scapi.c.fips net-snmp-5.7.2/snmplib/scapi.c
|
||||||
|
--- net-snmp-5.7.2/snmplib/scapi.c.fips 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/snmplib/scapi.c 2012-11-12 13:36:11.327657627 +0100
|
||||||
|
@@ -438,6 +438,7 @@ sc_generate_keyed_hash(const oid * autht
|
||||||
|
* Returns:
|
||||||
|
* SNMPERR_SUCCESS Success.
|
||||||
|
* SNMP_SC_GENERAL_FAILURE Any error.
|
||||||
|
+ * SNMPERR_SC_NOT_CONFIGURED Hash type not supported.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
sc_hash(const oid * hashtype, size_t hashtypelen, const u_char * buf,
|
||||||
|
@@ -495,7 +496,10 @@ sc_hash(const oid * hashtype, size_t has
|
||||||
|
EVP_MD_CTX_init(cptr);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
- EVP_DigestInit(cptr, hashfn);
|
||||||
|
+ if (!EVP_DigestInit(cptr, hashfn)) {
|
||||||
|
+ /* requested hash function is not available */
|
||||||
|
+ return SNMPERR_SC_NOT_CONFIGURED;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
/** pass the data */
|
||||||
|
EVP_DigestUpdate(cptr, buf, buf_len);
|
|
@ -0,0 +1,19 @@
|
||||||
|
commit aff1fb31dac236bb5f8e641c92e5651f00fa4f7d
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Thu Jul 30 11:25:48 2015 +0200
|
||||||
|
|
||||||
|
CHANGES: snmpd: restore read-write flag in hrFSTable when a device becomes writable
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/hardware/fsys/fsys_mntent.c b/agent/mibgroup/hardware/fsys/fsys_mntent.c
|
||||||
|
index 6fe4ed4..8a12181 100644
|
||||||
|
--- a/agent/mibgroup/hardware/fsys/fsys_mntent.c
|
||||||
|
+++ b/agent/mibgroup/hardware/fsys/fsys_mntent.c
|
||||||
|
@@ -206,6 +206,8 @@ netsnmp_fsys_arch_load( void )
|
||||||
|
#if HAVE_HASMNTOPT
|
||||||
|
if (hasmntopt( m, "ro" ))
|
||||||
|
entry->flags |= NETSNMP_FS_FLAG_RONLY;
|
||||||
|
+ else
|
||||||
|
+ entry->flags &= ~NETSNMP_FS_FLAG_RONLY;
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* The root device is presumably bootable.
|
|
@ -0,0 +1,22 @@
|
||||||
|
1070076 - SNMP HRPROCESSORLOAD RETURNS INCORRECT VALUES FOR PROCESSOR #'S > 100
|
||||||
|
|
||||||
|
commit eef2f64b46357b353c79504bc593535ebe7421e7
|
||||||
|
Author: Niels Baggesen <nba@users.sourceforge.net>
|
||||||
|
Date: Thu Jan 23 16:27:07 2014 +0100
|
||||||
|
|
||||||
|
cpu_linux: support systems with more than 100 cpus.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/hardware/cpu/cpu_linux.c.hrProcessorLoad-many-cpus net-snmp-5.7.2/agent/mibgroup/hardware/cpu/cpu_linux.c
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/hardware/cpu/cpu_linux.c.hrProcessorLoad-many-cpus 2015-01-16 10:01:49.728398670 +0100
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/hardware/cpu/cpu_linux.c 2015-01-16 10:02:58.796486160 +0100
|
||||||
|
@@ -154,7 +154,9 @@ int netsnmp_cpu_arch_load( netsnmp_cache
|
||||||
|
snmp_log_perror("Missing CPU info entry");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
- b1 = b2+5; /* Skip "cpuN " */
|
||||||
|
+ b1 = b2; /* Skip "cpuN " */
|
||||||
|
+ while(*b1 != ' ') b1++;
|
||||||
|
+ b1++;
|
||||||
|
}
|
||||||
|
|
||||||
|
num_cpuline_elem = sscanf(b1, "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu",
|
|
@ -0,0 +1,31 @@
|
||||||
|
989498 - vzfs missing in hrStorage in an Virtuozzo Container
|
||||||
|
861152 - simfs missing in hrStorage in an OpenVZ container
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/hardware/fsys/fsys_mntent.c.orig net-snmp-5.7.2/agent/mibgroup/hardware/fsys/fsys_mntent.c
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/hardware/fsys/fsys_mntent.c.orig 2013-08-12 15:38:17.602977746 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/hardware/fsys/fsys_mntent.c 2013-08-12 15:38:42.018888560 +0200
|
||||||
|
@@ -139,6 +139,8 @@ _fsys_type( char *typename )
|
||||||
|
!strcmp(typename, MNTTYPE_REISERFS) ||
|
||||||
|
!strcmp(typename, MNTTYPE_OCFS2) ||
|
||||||
|
!strcmp(typename, MNTTYPE_CVFS) ||
|
||||||
|
+ !strcmp(typename, MNTTYPE_SIMFS) ||
|
||||||
|
+ !strcmp(typename, MNTTYPE_VZFS) ||
|
||||||
|
!strcmp(typename, MNTTYPE_LOFS))
|
||||||
|
return NETSNMP_FS_TYPE_OTHER;
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/hardware/fsys/mnttypes.h.orig net-snmp-5.7.2/agent/mibgroup/hardware/fsys/mnttypes.h
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/hardware/fsys/mnttypes.h.orig 2013-08-12 15:38:52.112851691 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/hardware/fsys/mnttypes.h 2013-08-12 15:39:16.063764218 +0200
|
||||||
|
@@ -142,6 +142,12 @@
|
||||||
|
#ifndef MNTTYPE_CVFS
|
||||||
|
#define MNTTYPE_CVFS "cvfs"
|
||||||
|
#endif
|
||||||
|
+#ifndef MNTTYPE_SIMFS
|
||||||
|
+#define MNTTYPE_SIMFS "simfs"
|
||||||
|
+#endif
|
||||||
|
+#ifndef MNTTYPE_VZFS
|
||||||
|
+#define MNTTYPE_VZFS "vzfs"
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File systems to skip
|
|
@ -0,0 +1,146 @@
|
||||||
|
1072092 - net-snmp: denial of service flaw in Linux implementation of ICMP-MIB
|
||||||
|
|
||||||
|
commit 8407b6ce46ca7159b3c816d1024e20a53f9a1c6c
|
||||||
|
Author: Wes Hardaker <hardaker@users.sourceforge.net>
|
||||||
|
Date: Wed Feb 19 15:21:57 2014 -0800
|
||||||
|
|
||||||
|
bug fix from fenner: fix ICMP mib table handling on linux
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/mibII/icmp.c b/agent/mibgroup/mibII/icmp.c
|
||||||
|
index 14c73a6..6d10426 100644
|
||||||
|
--- a/agent/mibgroup/mibII/icmp.c
|
||||||
|
+++ b/agent/mibgroup/mibII/icmp.c
|
||||||
|
@@ -106,10 +106,20 @@ struct icmp_msg_stats_table_entry {
|
||||||
|
int flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
+#ifdef linux
|
||||||
|
+/* Linux keeps track of all possible message types */
|
||||||
|
+#define ICMP_MSG_STATS_IPV4_COUNT 256
|
||||||
|
+#else
|
||||||
|
#define ICMP_MSG_STATS_IPV4_COUNT 11
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
#ifdef NETSNMP_ENABLE_IPV6
|
||||||
|
+#ifdef linux
|
||||||
|
+/* Linux keeps track of all possible message types */
|
||||||
|
+#define ICMP_MSG_STATS_IPV6_COUNT 256
|
||||||
|
+#else
|
||||||
|
#define ICMP_MSG_STATS_IPV6_COUNT 14
|
||||||
|
+#endif
|
||||||
|
#else
|
||||||
|
#define ICMP_MSG_STATS_IPV6_COUNT 0
|
||||||
|
#endif /* NETSNMP_ENABLE_IPV6 */
|
||||||
|
@@ -177,7 +187,7 @@ icmp_msg_stats_load(netsnmp_cache *cache, void *vmagic)
|
||||||
|
inc = 0;
|
||||||
|
linux_read_icmp_msg_stat(&v4icmp, &v4icmpmsg, &flag);
|
||||||
|
if (flag) {
|
||||||
|
- while (254 != k) {
|
||||||
|
+ while (255 >= k) {
|
||||||
|
if (v4icmpmsg.vals[k].InType) {
|
||||||
|
icmp_msg_stats_table[i].ipVer = 1;
|
||||||
|
icmp_msg_stats_table[i].icmpMsgStatsType = k;
|
||||||
|
@@ -267,7 +277,7 @@ icmp_msg_stats_load(netsnmp_cache *cache, void *vmagic)
|
||||||
|
inc = 0;
|
||||||
|
linux_read_icmp6_msg_stat(&v6icmp, &v6icmpmsg, &flag);
|
||||||
|
if (flag) {
|
||||||
|
- while (254 != k) {
|
||||||
|
+ while (255 >= k) {
|
||||||
|
if (v6icmpmsg.vals[k].InType) {
|
||||||
|
icmp_msg_stats_table[i].ipVer = 2;
|
||||||
|
icmp_msg_stats_table[i].icmpMsgStatsType = k;
|
||||||
|
@@ -1050,6 +1060,12 @@ icmp_stats_table_handler(netsnmp_mib_handler *handler,
|
||||||
|
continue;
|
||||||
|
table_info = netsnmp_extract_table_info(request);
|
||||||
|
subid = table_info->colnum;
|
||||||
|
+ DEBUGMSGTL(( "mibII/icmpStatsTable", "oid: " ));
|
||||||
|
+ DEBUGMSGOID(( "mibII/icmpStatsTable", request->requestvb->name,
|
||||||
|
+ request->requestvb->name_length ));
|
||||||
|
+ DEBUGMSG(( "mibII/icmpStatsTable", " In %d InErr %d Out %d OutErr %d\n",
|
||||||
|
+ entry->icmpStatsInMsgs, entry->icmpStatsInErrors,
|
||||||
|
+ entry->icmpStatsOutMsgs, entry->icmpStatsOutErrors ));
|
||||||
|
|
||||||
|
switch (subid) {
|
||||||
|
case ICMP_STAT_INMSG:
|
||||||
|
@@ -1117,6 +1133,11 @@ icmp_msg_stats_table_handler(netsnmp_mib_handler *handler,
|
||||||
|
continue;
|
||||||
|
table_info = netsnmp_extract_table_info(request);
|
||||||
|
subid = table_info->colnum;
|
||||||
|
+ DEBUGMSGTL(( "mibII/icmpMsgStatsTable", "oid: " ));
|
||||||
|
+ DEBUGMSGOID(( "mibII/icmpMsgStatsTable", request->requestvb->name,
|
||||||
|
+ request->requestvb->name_length ));
|
||||||
|
+ DEBUGMSG(( "mibII/icmpMsgStatsTable", " In %d Out %d Flags 0x%x\n",
|
||||||
|
+ entry->icmpMsgStatsInPkts, entry->icmpMsgStatsOutPkts, entry->flags ));
|
||||||
|
|
||||||
|
switch (subid) {
|
||||||
|
case ICMP_MSG_STAT_IN_PKTS:
|
||||||
|
diff --git a/agent/mibgroup/mibII/kernel_linux.c b/agent/mibgroup/mibII/kernel_linux.c
|
||||||
|
index b21a166..ba320c7 100644
|
||||||
|
--- a/agent/mibgroup/mibII/kernel_linux.c
|
||||||
|
+++ b/agent/mibgroup/mibII/kernel_linux.c
|
||||||
|
@@ -81,9 +81,9 @@ decode_icmp_msg(char *line, char *data, struct icmp4_msg_mib *msg)
|
||||||
|
index = strtol(token, &delim, 0);
|
||||||
|
if (ERANGE == errno) {
|
||||||
|
continue;
|
||||||
|
- } else if (index > LONG_MAX) {
|
||||||
|
+ } else if (index > 255) {
|
||||||
|
continue;
|
||||||
|
- } else if (index < LONG_MIN) {
|
||||||
|
+ } else if (index < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (NULL == (token = strtok_r(dataptr, " ", &saveptr1)))
|
||||||
|
@@ -94,9 +94,9 @@ decode_icmp_msg(char *line, char *data, struct icmp4_msg_mib *msg)
|
||||||
|
index = strtol(token, &delim, 0);
|
||||||
|
if (ERANGE == errno) {
|
||||||
|
continue;
|
||||||
|
- } else if (index > LONG_MAX) {
|
||||||
|
+ } else if (index > 255) {
|
||||||
|
continue;
|
||||||
|
- } else if (index < LONG_MIN) {
|
||||||
|
+ } else if (index < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(NULL == (token = strtok_r(dataptr, " ", &saveptr1)))
|
||||||
|
@@ -426,14 +426,21 @@ linux_read_icmp6_parse(struct icmp6_mib *icmp6stat,
|
||||||
|
|
||||||
|
vals = name;
|
||||||
|
if (NULL != icmp6msgstat) {
|
||||||
|
+ int type;
|
||||||
|
if (0 == strncmp(name, "Icmp6OutType", 12)) {
|
||||||
|
strsep(&vals, "e");
|
||||||
|
- icmp6msgstat->vals[atoi(vals)].OutType = stats;
|
||||||
|
+ type = atoi(vals);
|
||||||
|
+ if ( type < 0 || type > 255 )
|
||||||
|
+ continue;
|
||||||
|
+ icmp6msgstat->vals[type].OutType = stats;
|
||||||
|
*support = 1;
|
||||||
|
continue;
|
||||||
|
} else if (0 == strncmp(name, "Icmp6InType", 11)) {
|
||||||
|
strsep(&vals, "e");
|
||||||
|
- icmp6msgstat->vals[atoi(vals)].InType = stats;
|
||||||
|
+ type = atoi(vals);
|
||||||
|
+ if ( type < 0 || type > 255 )
|
||||||
|
+ continue;
|
||||||
|
+ icmp6msgstat->vals[type].InType = stats;
|
||||||
|
*support = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
diff --git a/agent/mibgroup/mibII/kernel_linux.h b/agent/mibgroup/mibII/kernel_linux.h
|
||||||
|
index 6bf5d47..c6dfca9 100644
|
||||||
|
--- a/agent/mibgroup/mibII/kernel_linux.h
|
||||||
|
+++ b/agent/mibgroup/mibII/kernel_linux.h
|
||||||
|
@@ -121,11 +121,11 @@ struct icmp_msg_mib {
|
||||||
|
|
||||||
|
/* Lets use wrapper structures for future expansion */
|
||||||
|
struct icmp4_msg_mib {
|
||||||
|
- struct icmp_msg_mib vals[255];
|
||||||
|
+ struct icmp_msg_mib vals[256];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct icmp6_msg_mib {
|
||||||
|
- struct icmp_msg_mib vals[255];
|
||||||
|
+ struct icmp_msg_mib vals[256];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct udp_mib {
|
|
@ -0,0 +1,203 @@
|
||||||
|
1212408 - net-snmp: snmp_pdu_parse() incompletely parsed varBinds left in list of variables
|
||||||
|
1248412 - net-snmp: snmp_pdu_parse() incompletely parsed varBinds left in list of variables [rhel-7.1.z]
|
||||||
|
|
||||||
|
Backported from:
|
||||||
|
|
||||||
|
commit f23bcd3ac6ddee5d0a48f9703007ccc738914791
|
||||||
|
Author: Robert Story <rstory@localhost>
|
||||||
|
Date: Sat Apr 11 18:49:02 2015 -0400
|
||||||
|
|
||||||
|
CHANGES: BUG: #2615: Don't return incompletely parsed varbinds
|
||||||
|
|
||||||
|
|
||||||
|
diff -up net-snmp-5.5/snmplib/snmp_api.c.incomplete-parse net-snmp-5.5/snmplib/snmp_api.c
|
||||||
|
--- net-snmp-5.5/snmplib/snmp_api.c.incomplete-parse 2015-07-30 12:10:31.495801514 +0200
|
||||||
|
+++ net-snmp-5.5/snmplib/snmp_api.c 2015-07-30 12:11:43.087038548 +0200
|
||||||
|
@@ -4508,10 +4508,9 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
|
||||||
|
u_char type;
|
||||||
|
u_char msg_type;
|
||||||
|
u_char *var_val;
|
||||||
|
- int badtype = 0;
|
||||||
|
size_t len;
|
||||||
|
size_t four;
|
||||||
|
- netsnmp_variable_list *vp = NULL;
|
||||||
|
+ netsnmp_variable_list *vp = NULL, *vplast = NULL;
|
||||||
|
oid objid[MAX_OID_LEN];
|
||||||
|
u_char *p;
|
||||||
|
|
||||||
|
@@ -4647,38 +4646,24 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
|
||||||
|
(ASN_SEQUENCE | ASN_CONSTRUCTOR),
|
||||||
|
"varbinds");
|
||||||
|
if (data == NULL)
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get each varBind sequence
|
||||||
|
*/
|
||||||
|
while ((int) *length > 0) {
|
||||||
|
- netsnmp_variable_list *vptemp;
|
||||||
|
- vptemp = (netsnmp_variable_list *) malloc(sizeof(*vptemp));
|
||||||
|
- if (NULL == vptemp) {
|
||||||
|
- return -1;
|
||||||
|
- }
|
||||||
|
- if (NULL == vp) {
|
||||||
|
- pdu->variables = vptemp;
|
||||||
|
- } else {
|
||||||
|
- vp->next_variable = vptemp;
|
||||||
|
- }
|
||||||
|
- vp = vptemp;
|
||||||
|
-
|
||||||
|
- vp->next_variable = NULL;
|
||||||
|
- vp->val.string = NULL;
|
||||||
|
+ vp = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);
|
||||||
|
+ if (NULL == vp)
|
||||||
|
+ goto fail;
|
||||||
|
+
|
||||||
|
vp->name_length = MAX_OID_LEN;
|
||||||
|
- vp->name = NULL;
|
||||||
|
- vp->index = 0;
|
||||||
|
- vp->data = NULL;
|
||||||
|
- vp->dataFreeHook = NULL;
|
||||||
|
DEBUGDUMPSECTION("recv", "VarBind");
|
||||||
|
data = snmp_parse_var_op(data, objid, &vp->name_length, &vp->type,
|
||||||
|
&vp->val_len, &var_val, length);
|
||||||
|
if (data == NULL)
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
if (snmp_set_var_objid(vp, objid, vp->name_length))
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
|
||||||
|
len = MAX_PACKET_LENGTH;
|
||||||
|
DEBUGDUMPHEADER("recv", "Value");
|
||||||
|
@@ -4690,7 +4675,7 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
|
||||||
|
(long *) vp->val.integer,
|
||||||
|
sizeof(*vp->val.integer));
|
||||||
|
if (!p)
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
break;
|
||||||
|
case ASN_COUNTER:
|
||||||
|
case ASN_GAUGE:
|
||||||
|
@@ -4702,7 +4687,7 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
|
||||||
|
(u_long *) vp->val.integer,
|
||||||
|
vp->val_len);
|
||||||
|
if (!p)
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
break;
|
||||||
|
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||||
|
case ASN_OPAQUE_COUNTER64:
|
||||||
|
@@ -4715,7 +4700,7 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
|
||||||
|
(struct counter64 *) vp->val.
|
||||||
|
counter64, vp->val_len);
|
||||||
|
if (!p)
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
break;
|
||||||
|
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||||
|
case ASN_OPAQUE_FLOAT:
|
||||||
|
@@ -4724,7 +4709,7 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
|
||||||
|
p = asn_parse_float(var_val, &len, &vp->type,
|
||||||
|
vp->val.floatVal, vp->val_len);
|
||||||
|
if (!p)
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
break;
|
||||||
|
case ASN_OPAQUE_DOUBLE:
|
||||||
|
vp->val.doubleVal = (double *) vp->buf;
|
||||||
|
@@ -4732,7 +4717,7 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
|
||||||
|
p = asn_parse_double(var_val, &len, &vp->type,
|
||||||
|
vp->val.doubleVal, vp->val_len);
|
||||||
|
if (!p)
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
break;
|
||||||
|
case ASN_OPAQUE_I64:
|
||||||
|
vp->val.counter64 = (struct counter64 *) vp->buf;
|
||||||
|
@@ -4742,12 +4727,12 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
|
||||||
|
sizeof(*vp->val.counter64));
|
||||||
|
|
||||||
|
if (!p)
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
break;
|
||||||
|
#endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
|
||||||
|
case ASN_IPADDRESS:
|
||||||
|
if (vp->val_len != 4)
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
/* fallthrough */
|
||||||
|
case ASN_OCTET_STR:
|
||||||
|
case ASN_OPAQUE:
|
||||||
|
@@ -4758,22 +4743,22 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
|
||||||
|
vp->val.string = (u_char *) malloc(vp->val_len);
|
||||||
|
}
|
||||||
|
if (vp->val.string == NULL) {
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
}
|
||||||
|
p = asn_parse_string(var_val, &len, &vp->type, vp->val.string,
|
||||||
|
&vp->val_len);
|
||||||
|
if (!p)
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
break;
|
||||||
|
case ASN_OBJECT_ID:
|
||||||
|
vp->val_len = MAX_OID_LEN;
|
||||||
|
p = asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
|
||||||
|
if (!p)
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
vp->val_len *= sizeof(oid);
|
||||||
|
vp->val.objid = (oid *) malloc(vp->val_len);
|
||||||
|
if (vp->val.objid == NULL) {
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
}
|
||||||
|
memmove(vp->val.objid, objid, vp->val_len);
|
||||||
|
break;
|
||||||
|
@@ -4785,21 +4770,38 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
|
||||||
|
case ASN_BIT_STR:
|
||||||
|
vp->val.bitstring = (u_char *) malloc(vp->val_len);
|
||||||
|
if (vp->val.bitstring == NULL) {
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
}
|
||||||
|
p = asn_parse_bitstring(var_val, &len, &vp->type,
|
||||||
|
vp->val.bitstring, &vp->val_len);
|
||||||
|
if (!p)
|
||||||
|
- return -1;
|
||||||
|
+ goto fail;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
snmp_log(LOG_ERR, "bad type returned (%x)\n", vp->type);
|
||||||
|
- badtype = -1;
|
||||||
|
+ goto fail;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DEBUGINDENTADD(-4);
|
||||||
|
+
|
||||||
|
+ if (NULL == vplast) {
|
||||||
|
+ pdu->variables = vp;
|
||||||
|
+ } else {
|
||||||
|
+ vplast->next_variable = vp;
|
||||||
|
+ }
|
||||||
|
+ vplast = vp;
|
||||||
|
+ vp = NULL;
|
||||||
|
+
|
||||||
|
}
|
||||||
|
- return badtype;
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+fail:
|
||||||
|
+ DEBUGMSGTL(("recv", "error while parsing VarBindList\n"));
|
||||||
|
+ /** if we were parsing a var, remove it from the pdu and free it */
|
||||||
|
+ if (vp)
|
||||||
|
+ snmp_free_var(vp);
|
||||||
|
+
|
||||||
|
+ return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
|
@ -0,0 +1,346 @@
|
||||||
|
diff -urNp old/agent/mibgroup/ip-mib/data_access/ipaddress_common.c new/agent/mibgroup/ip-mib/data_access/ipaddress_common.c
|
||||||
|
--- old/agent/mibgroup/ip-mib/data_access/ipaddress_common.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ new/agent/mibgroup/ip-mib/data_access/ipaddress_common.c 2017-04-04 11:02:42.391951747 +0200
|
||||||
|
@@ -67,6 +67,7 @@ netsnmp_container *
|
||||||
|
netsnmp_access_ipaddress_container_init(u_int flags)
|
||||||
|
{
|
||||||
|
netsnmp_container *container1;
|
||||||
|
+ int rc;
|
||||||
|
|
||||||
|
DEBUGMSGTL(("access:ipaddress:container", "init\n"));
|
||||||
|
|
||||||
|
@@ -80,6 +81,7 @@ netsnmp_access_ipaddress_container_init(
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
container1->container_name = strdup("ia_index");
|
||||||
|
+ CONTAINER_SET_OPTIONS(container1, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
|
||||||
|
|
||||||
|
if (flags & NETSNMP_ACCESS_IPADDRESS_INIT_ADDL_IDX_BY_ADDR) {
|
||||||
|
netsnmp_container *container2 =
|
||||||
|
@@ -92,6 +94,13 @@ netsnmp_access_ipaddress_container_init(
|
||||||
|
|
||||||
|
container2->compare = _access_ipaddress_entry_compare_addr;
|
||||||
|
container2->container_name = strdup("ia_addr");
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * With allowed duplicates, CONTAINER_INSERT does not need to sort whole
|
||||||
|
+ * container and check for duplicates. We remove duplicates manually in
|
||||||
|
+ * netsnmp_access_ipaddress_container_load.
|
||||||
|
+ */
|
||||||
|
+ CONTAINER_SET_OPTIONS(container2, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
|
||||||
|
|
||||||
|
netsnmp_container_add_index(container1, container2);
|
||||||
|
}
|
||||||
|
@@ -100,6 +109,53 @@ netsnmp_access_ipaddress_container_init(
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
+ * Remove duplicate entries from the container.
|
||||||
|
+ * This function returns new copy of the container and destroys
|
||||||
|
+ * the original one. Use like this:
|
||||||
|
+ * c = _remove_duplicates(c, flags);
|
||||||
|
+ */
|
||||||
|
+static netsnmp_container *
|
||||||
|
+_remove_duplicates(netsnmp_container *container, u_int container_flags)
|
||||||
|
+{
|
||||||
|
+ netsnmp_container *c;
|
||||||
|
+ netsnmp_iterator *it;
|
||||||
|
+ netsnmp_container *ret;
|
||||||
|
+ netsnmp_ipaddress_entry *entry, *prev_entry;
|
||||||
|
+
|
||||||
|
+ if (! (container_flags & NETSNMP_ACCESS_IPADDRESS_INIT_ADDL_IDX_BY_ADDR)) {
|
||||||
|
+ /* We don't have address index, we can't detect duplicates */
|
||||||
|
+ return container;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ret = netsnmp_access_ipaddress_container_init(container_flags);
|
||||||
|
+
|
||||||
|
+ /* use the IpAddress index */
|
||||||
|
+ c = container->next;
|
||||||
|
+ it = CONTAINER_ITERATOR(c);
|
||||||
|
+ /* Sort the address index */
|
||||||
|
+ CONTAINER_FIND(c, ITERATOR_FIRST(it));
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * Sequentially iterate over sorted container and add only unique entries
|
||||||
|
+ * to 'ret'
|
||||||
|
+ */
|
||||||
|
+ prev_entry = NULL;
|
||||||
|
+ for (entry = ITERATOR_FIRST(it); entry; entry = ITERATOR_NEXT(it)) {
|
||||||
|
+ if (prev_entry && _access_ipaddress_entry_compare_addr(prev_entry, entry) == 0) {
|
||||||
|
+ /* 'entry' is duplicate of the previous one -> delete it */
|
||||||
|
+ netsnmp_access_ipaddress_entry_free(entry);
|
||||||
|
+ } else {
|
||||||
|
+ CONTAINER_INSERT(ret, entry);
|
||||||
|
+ prev_entry = entry;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ CONTAINER_FREE(container);
|
||||||
|
+ free(it);
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
* @retval NULL error
|
||||||
|
* @retval !NULL pointer to container
|
||||||
|
*/
|
||||||
|
@@ -112,9 +168,10 @@ netsnmp_access_ipaddress_container_load(
|
||||||
|
|
||||||
|
DEBUGMSGTL(("access:ipaddress:container", "load\n"));
|
||||||
|
|
||||||
|
+ if (load_flags & NETSNMP_ACCESS_IPADDRESS_LOAD_ADDL_IDX_BY_ADDR)
|
||||||
|
+ container_flags |= NETSNMP_ACCESS_IPADDRESS_INIT_ADDL_IDX_BY_ADDR;
|
||||||
|
+
|
||||||
|
if (NULL == container) {
|
||||||
|
- if (load_flags & NETSNMP_ACCESS_IPADDRESS_LOAD_ADDL_IDX_BY_ADDR)
|
||||||
|
- container_flags |= NETSNMP_ACCESS_IPADDRESS_INIT_ADDL_IDX_BY_ADDR;
|
||||||
|
container = netsnmp_access_ipaddress_container_init(container_flags);
|
||||||
|
}
|
||||||
|
if (NULL == container) {
|
||||||
|
@@ -129,6 +186,9 @@ netsnmp_access_ipaddress_container_load(
|
||||||
|
container = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (container)
|
||||||
|
+ container = _remove_duplicates(container, container_flags);
|
||||||
|
+
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff -urNp old/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c new/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c
|
||||||
|
--- old/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ new/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c 2017-04-04 13:26:34.332529808 +0200
|
||||||
|
@@ -137,6 +137,13 @@ ipAddressTable_container_init(netsnmp_co
|
||||||
|
*container_ptr_ptr =
|
||||||
|
netsnmp_container_find("ipAddressTable:table_container");
|
||||||
|
if (NULL != *container_ptr_ptr) {
|
||||||
|
+ /*
|
||||||
|
+ * The container has ALLOW_DUPLICATES flag to speed up CONTAINER_INSERT
|
||||||
|
+ * operations (it does not need to check for duplicates), however we
|
||||||
|
+ * (manually) ensure that we won't insert any duplicates there.
|
||||||
|
+ */
|
||||||
|
+ int rc;
|
||||||
|
+ CONTAINER_SET_OPTIONS(*container_ptr_ptr, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
|
||||||
|
(*container_ptr_ptr)->container_name = strdup("ipAddressTable");
|
||||||
|
ipAddressTable_container_load(*container_ptr_ptr);
|
||||||
|
CONTAINER_FOR_EACH(*container_ptr_ptr,
|
||||||
|
@@ -205,8 +212,9 @@ static void
|
||||||
|
_check_entry_for_updates(ipAddressTable_rowreq_ctx * rowreq_ctx,
|
||||||
|
void **magic)
|
||||||
|
{
|
||||||
|
- netsnmp_container *ipaddress_container = (netsnmp_container*)magic[0];
|
||||||
|
+ netsnmp_container *ipaddress_container = magic[0];
|
||||||
|
netsnmp_container *to_delete = (netsnmp_container*)magic[1];
|
||||||
|
+ netsnmp_container *to_ignore = (netsnmp_container *) magic[2];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* check for matching entry using secondary index.
|
||||||
|
@@ -234,10 +242,21 @@ _check_entry_for_updates(ipAddressTable_
|
||||||
|
rowreq_ctx->ipAddressLastChanged = netsnmp_get_agent_uptime();
|
||||||
|
|
||||||
|
/*
|
||||||
|
- * remove entry from ifcontainer
|
||||||
|
+ * Remember not to add this entry from 'ipaddress_container' to 'container' later.
|
||||||
|
+ * Simple CONTAINER_REMOVE(ipaddress_container, ..) would be slow.
|
||||||
|
*/
|
||||||
|
- CONTAINER_REMOVE(ipaddress_container, ipaddress_entry);
|
||||||
|
- netsnmp_access_ipaddress_entry_free(ipaddress_entry);
|
||||||
|
+ if (NULL == to_ignore) {
|
||||||
|
+ magic[2] = to_ignore = netsnmp_container_find("access_ipaddress:table_container");
|
||||||
|
+ if (NULL == to_ignore) {
|
||||||
|
+ snmp_log(LOG_ERR, "couldn't create ignore container\n");
|
||||||
|
+ } else {
|
||||||
|
+ /* to speed up insertion */
|
||||||
|
+ int rc;
|
||||||
|
+ CONTAINER_SET_OPTIONS(to_ignore, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ if (NULL != to_ignore)
|
||||||
|
+ CONTAINER_INSERT(to_ignore, ipaddress_entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -246,8 +265,11 @@ _check_entry_for_updates(ipAddressTable_
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
_add_new_entry(netsnmp_ipaddress_entry *ipaddress_entry,
|
||||||
|
- netsnmp_container *container)
|
||||||
|
+ void **magic)
|
||||||
|
{
|
||||||
|
+ netsnmp_container *container = magic[0];
|
||||||
|
+ netsnmp_container *to_ignore = magic[2];
|
||||||
|
+
|
||||||
|
ipAddressTable_rowreq_ctx *rowreq_ctx;
|
||||||
|
|
||||||
|
DEBUGMSGTL(("ipAddressTable:access", "creating new entry\n"));
|
||||||
|
@@ -255,6 +277,11 @@ _add_new_entry(netsnmp_ipaddress_entry *
|
||||||
|
netsnmp_assert(NULL != ipaddress_entry);
|
||||||
|
netsnmp_assert(NULL != container);
|
||||||
|
|
||||||
|
+ if (to_ignore && CONTAINER_FIND(to_ignore, ipaddress_entry)) {
|
||||||
|
+ /* this entry already is in 'container', skip it */
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* allocate an row context and set the index(es)
|
||||||
|
*/
|
||||||
|
@@ -329,36 +356,44 @@ int
|
||||||
|
ipAddressTable_container_load(netsnmp_container *container)
|
||||||
|
{
|
||||||
|
netsnmp_container *ipaddress_container;
|
||||||
|
- void *tmp_ptr[2];
|
||||||
|
+ void *tmp_ptr[3];
|
||||||
|
|
||||||
|
DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_cache_load",
|
||||||
|
"called\n"));
|
||||||
|
|
||||||
|
/*
|
||||||
|
- * TODO:351:M: |-> Load/update data in the ipAddressTable container.
|
||||||
|
+ * Load/update data in the ipAddressTable container.
|
||||||
|
* loop over your ipAddressTable data, allocate a rowreq context,
|
||||||
|
* set the index(es) [and data, optionally] and insert into
|
||||||
|
* the container.
|
||||||
|
*/
|
||||||
|
+ /*
|
||||||
|
+ * netsnmp_access_ipaddress_container_load makes sure that
|
||||||
|
+ * ipaddress_container does not contain any duplicate entries,
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
ipaddress_container =
|
||||||
|
netsnmp_access_ipaddress_container_load(NULL,
|
||||||
|
NETSNMP_ACCESS_IPADDRESS_LOAD_ADDL_IDX_BY_ADDR);
|
||||||
|
/*
|
||||||
|
* we just got a fresh copy of interface data. compare it to
|
||||||
|
* what we've already got, and make any adjustments, saving
|
||||||
|
- * missing addresses to be deleted.
|
||||||
|
+ * missing addresses to be deleted. Also, prune interfaces in
|
||||||
|
+ * ipaddress_container, so only the new interfaces remain.
|
||||||
|
*/
|
||||||
|
tmp_ptr[0] = ipaddress_container->next;
|
||||||
|
- tmp_ptr[1] = NULL;
|
||||||
|
+ tmp_ptr[1] = NULL; /* list of interfaces to be removed from 'container' */
|
||||||
|
+ tmp_ptr[2] = NULL; /* list of interfaces to be ignored in ipaddress_container */
|
||||||
|
CONTAINER_FOR_EACH(container, (netsnmp_container_obj_func *)
|
||||||
|
_check_entry_for_updates, tmp_ptr);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* now add any new interfaces
|
||||||
|
*/
|
||||||
|
+ tmp_ptr[0] = container;
|
||||||
|
CONTAINER_FOR_EACH(ipaddress_container,
|
||||||
|
(netsnmp_container_obj_func *) _add_new_entry,
|
||||||
|
- container);
|
||||||
|
+ tmp_ptr);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* free the container. we've either claimed each entry, or released it,
|
||||||
|
@@ -396,6 +431,19 @@ ipAddressTable_container_load(netsnmp_co
|
||||||
|
*/
|
||||||
|
CONTAINER_REMOVE(tmp_container, NULL);
|
||||||
|
}
|
||||||
|
+ CONTAINER_FREE(tmp_container);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (NULL != tmp_ptr[2]) {
|
||||||
|
+ /* list of interfaces to be ignored in ipaddress_container - free it */
|
||||||
|
+ netsnmp_container *to_ignore = (netsnmp_container *) tmp_ptr[2];
|
||||||
|
+ netsnmp_ipaddress_entry *ipaddress_entry;
|
||||||
|
+ while (CONTAINER_SIZE(to_ignore)) {
|
||||||
|
+ ipaddress_entry = (netsnmp_ipaddress_entry*)CONTAINER_FIRST(to_ignore);
|
||||||
|
+ CONTAINER_REMOVE(to_ignore, ipaddress_entry);
|
||||||
|
+ netsnmp_access_ipaddress_entry_free(ipaddress_entry);
|
||||||
|
+ }
|
||||||
|
+ CONTAINER_FREE(to_ignore);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUGMSGT(("verbose:ipAddressTable:ipAddressTable_cache_load",
|
||||||
|
diff -urNp old/agent/mibgroup/mibII/ipAddr.c new/agent/mibgroup/mibII/ipAddr.c
|
||||||
|
--- old/agent/mibgroup/mibII/ipAddr.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ new/agent/mibgroup/mibII/ipAddr.c 2017-04-04 13:28:56.547268946 +0200
|
||||||
|
@@ -493,14 +493,16 @@ Address_Scan_Next(Index, Retin_ifaddr)
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(linux)
|
||||||
|
+#include <errno.h>
|
||||||
|
static struct ifreq *ifr;
|
||||||
|
static int ifr_counter;
|
||||||
|
|
||||||
|
static void
|
||||||
|
Address_Scan_Init(void)
|
||||||
|
{
|
||||||
|
- int num_interfaces = 0;
|
||||||
|
+ int i;
|
||||||
|
int fd;
|
||||||
|
+ int lastlen = 0;
|
||||||
|
|
||||||
|
/* get info about all interfaces */
|
||||||
|
|
||||||
|
@@ -508,30 +510,45 @@ Address_Scan_Init(void)
|
||||||
|
SNMP_FREE(ifc.ifc_buf);
|
||||||
|
ifr_counter = 0;
|
||||||
|
|
||||||
|
- do
|
||||||
|
+ if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||||
|
{
|
||||||
|
- if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||||
|
- {
|
||||||
|
- DEBUGMSGTL(("snmpd", "socket open failure in Address_Scan_Init\n"));
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
- num_interfaces += 16;
|
||||||
|
-
|
||||||
|
- ifc.ifc_len = sizeof(struct ifreq) * num_interfaces;
|
||||||
|
- ifc.ifc_buf = (char*) realloc(ifc.ifc_buf, ifc.ifc_len);
|
||||||
|
-
|
||||||
|
- if (ioctl(fd, SIOCGIFCONF, &ifc) < 0)
|
||||||
|
- {
|
||||||
|
- ifr=NULL;
|
||||||
|
- close(fd);
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
- close(fd);
|
||||||
|
+ DEBUGMSGTL(("snmpd", "socket open failure in Address_Scan_Init\n"));
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * Cope with lots of interfaces and brokenness of ioctl SIOCGIFCONF
|
||||||
|
+ * on some platforms; see W. R. Stevens, ``Unix Network Programming
|
||||||
|
+ * Volume I'', p.435...
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+ for (i = 8;; i *= 2) {
|
||||||
|
+ ifc.ifc_len = sizeof(struct ifreq) * i;
|
||||||
|
+ ifc.ifc_req = calloc(i, sizeof(struct ifreq));
|
||||||
|
+
|
||||||
|
+ if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) {
|
||||||
|
+ if (errno != EINVAL || lastlen != 0) {
|
||||||
|
+ /*
|
||||||
|
+ * Something has gone genuinely wrong...
|
||||||
|
+ */
|
||||||
|
+ snmp_log(LOG_ERR, "bad rc from ioctl, errno %d", errno);
|
||||||
|
+ SNMP_FREE(ifc.ifc_buf);
|
||||||
|
+ close(fd);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ if (ifc.ifc_len == lastlen) {
|
||||||
|
+ /*
|
||||||
|
+ * The length is the same as the last time; we're done...
|
||||||
|
+ */
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ lastlen = ifc.ifc_len;
|
||||||
|
+ }
|
||||||
|
+ free(ifc.ifc_buf); /* no SNMP_FREE, getting ready to reassign */
|
||||||
|
}
|
||||||
|
- while (ifc.ifc_len >= (sizeof(struct ifreq) * num_interfaces));
|
||||||
|
-
|
||||||
|
- ifr = ifc.ifc_req;
|
||||||
|
close(fd);
|
||||||
|
+ ifr = ifc.ifc_req;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
|
@ -0,0 +1,131 @@
|
||||||
|
1172013 - NetworkManager causes snmp OID not increasing
|
||||||
|
|
||||||
|
commit 664ed943f63dfe9393e959840ecd23c31c9d8f89
|
||||||
|
Author: Bill Fenner <fenner@gmail.com>
|
||||||
|
Date: Wed Aug 27 16:02:57 2014 -0400
|
||||||
|
|
||||||
|
Handle duplicates in a binary_array container
|
||||||
|
|
||||||
|
The CONTAINER_KEY_ALLOW_DUPLICATES setting is fundamentally flawed;
|
||||||
|
it really effectively meant "I promise I won't insert duplicates
|
||||||
|
so don't check at insert time". However, the ip-forward-mib
|
||||||
|
sets this flag but relies on the duplicate prevention at insert
|
||||||
|
time under certain scenarios (e.g., multiple attachments to the
|
||||||
|
same subnet on MacOS), resulting in a loop in ip-forward-mib
|
||||||
|
in these scenarios. So, now it means "check for duplicates at
|
||||||
|
getnext time" - the binary search will find an arbitrary one
|
||||||
|
of the entries with the same key, and when we've incremented
|
||||||
|
we have to check whether or not we've actually incremented past
|
||||||
|
any duplicates. This costs an extra key compare per getnext.
|
||||||
|
|
||||||
|
If there's a scenario in the future where a MIB implementation
|
||||||
|
can really guarantee that it isn't inserting duplicates, we
|
||||||
|
might want to add a "CONTAINER_KEY_I_PROMISE_I_WONT_INSERT_DUPLICATES",
|
||||||
|
that disables the insertion check but doesn't perform the getnext
|
||||||
|
check.
|
||||||
|
|
||||||
|
diff --git a/snmplib/container_binary_array.c b/snmplib/container_binary_array.c
|
||||||
|
index 249a3a9..10ae67f 100644
|
||||||
|
--- a/snmplib/container_binary_array.c
|
||||||
|
+++ b/snmplib/container_binary_array.c
|
||||||
|
@@ -284,6 +284,22 @@ netsnmp_binary_array_get(netsnmp_container *c, const void *key, int exact)
|
||||||
|
if (key) {
|
||||||
|
if ((index = binary_search(key, c, exact)) == -1)
|
||||||
|
return NULL;
|
||||||
|
+ if (!exact &&
|
||||||
|
+ c->flags & CONTAINER_KEY_ALLOW_DUPLICATES) {
|
||||||
|
+ int result;
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * If duplicates are allowed, we have to be extra
|
||||||
|
+ * sure that we didn't just increment to a duplicate,
|
||||||
|
+ * thus causing a getnext loop.
|
||||||
|
+ */
|
||||||
|
+ result = c->compare(t->data[index], key);
|
||||||
|
+ while (result == 0) {
|
||||||
|
+ if (++index == t->count)
|
||||||
|
+ return NULL;
|
||||||
|
+ result = c->compare(t->data[index], key);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
return t->data[index];
|
||||||
|
diff --git a/testing/fulltests/unit-tests/T021binary_array_oid_duplicates_clib.c b/testing/fulltests/unit-tests/T021binary_array_oid_duplicates_clib.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..c027329
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/testing/fulltests/unit-tests/T021binary_array_oid_duplicates_clib.c
|
||||||
|
@@ -0,0 +1,72 @@
|
||||||
|
+/* HEADER Testing duplicate handling in binary OID array */
|
||||||
|
+
|
||||||
|
+/* Much copied from T012 */
|
||||||
|
+static const char test_name[] = "binary-array-of-OIDs-duplicate-test";
|
||||||
|
+oid o1 = 1;
|
||||||
|
+oid o2 = 2;
|
||||||
|
+oid o3 = 6;
|
||||||
|
+oid o4 = 8;
|
||||||
|
+oid o5 = 9;
|
||||||
|
+oid ox = 7;
|
||||||
|
+oid oy = 10;
|
||||||
|
+netsnmp_index i1, i2, i3, i4, i5, ix, iy, *ip;
|
||||||
|
+netsnmp_index *b[] = { &i4, &i2, &i3, &i1, &i5 };
|
||||||
|
+netsnmp_container *c;
|
||||||
|
+int i;
|
||||||
|
+
|
||||||
|
+init_snmp(test_name);
|
||||||
|
+
|
||||||
|
+c = netsnmp_container_get_binary_array();
|
||||||
|
+c->compare = netsnmp_compare_netsnmp_index;
|
||||||
|
+netsnmp_binary_array_options_set(c, 1,
|
||||||
|
+ CONTAINER_KEY_ALLOW_DUPLICATES);
|
||||||
|
+
|
||||||
|
+i1.oids = &o1;
|
||||||
|
+i2.oids = &o2;
|
||||||
|
+i3.oids = &o3;
|
||||||
|
+i4.oids = &o4;
|
||||||
|
+i5.oids = &o5;
|
||||||
|
+ix.oids = &ox;
|
||||||
|
+iy.oids = &oy;
|
||||||
|
+i1.len = i2.len = i3.len = i4.len = i5.len = ix.len = iy.len = 1;
|
||||||
|
+
|
||||||
|
+for (i = 0; i < sizeof(b)/sizeof(b[0]); ++i)
|
||||||
|
+ CONTAINER_INSERT(c, b[i]);
|
||||||
|
+
|
||||||
|
+#define MAX_ROUNDS 6
|
||||||
|
+/* Insert some duplicates of i4; also insert a duplicate of
|
||||||
|
+ * i1 to move the contents of the array around. */
|
||||||
|
+for (i = 0; i < MAX_ROUNDS; ++i) {
|
||||||
|
+ switch (i) {
|
||||||
|
+ case 0:
|
||||||
|
+ /* First round: no insert */
|
||||||
|
+ break;
|
||||||
|
+ case 1:
|
||||||
|
+ case 2:
|
||||||
|
+ case 4:
|
||||||
|
+ case 5:
|
||||||
|
+ /* Insert another duplicate of our target object */
|
||||||
|
+ CONTAINER_INSERT(c, &i4);
|
||||||
|
+ break;
|
||||||
|
+ case 3:
|
||||||
|
+ /* Insert a dulicate of an earlier OID, so that it
|
||||||
|
+ * changes the binary search behavior */
|
||||||
|
+ CONTAINER_INSERT(c, &i1);
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ /* Primary requirement: getnext returns the next value! */
|
||||||
|
+ ip = CONTAINER_FIND(c, &i4);
|
||||||
|
+ OKF(ip, ("FIND returned a value"));
|
||||||
|
+ OKF(c->compare(&i4, ip) == 0,
|
||||||
|
+ ("FIND returned oid %" NETSNMP_PRIo "d", ip->oids[0]));
|
||||||
|
+ ip = CONTAINER_NEXT(c, &i4);
|
||||||
|
+ OKF(ip, ("NEXT returned a value"));
|
||||||
|
+ OKF(c->compare(&i5, ip) == 0,
|
||||||
|
+ ("NEXT returned index 5 = %" NETSNMP_PRIo "d", i5.oids[0]));
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+while ((ip = CONTAINER_FIRST(c)))
|
||||||
|
+ CONTAINER_REMOVE(c, ip);
|
||||||
|
+CONTAINER_FREE(c);
|
||||||
|
+
|
||||||
|
+snmp_shutdown(test_name);
|
|
@ -0,0 +1,14 @@
|
||||||
|
diff -urNp old/agent/mibgroup/host/data_access/swrun.c new/agent/mibgroup/host/data_access/swrun.c
|
||||||
|
--- old/agent/mibgroup/host/data_access/swrun.c 2017-07-18 09:44:00.626109526 +0200
|
||||||
|
+++ new/agent/mibgroup/host/data_access/swrun.c 2017-07-19 15:27:50.452255836 +0200
|
||||||
|
@@ -102,6 +102,10 @@ swrun_count_processes_by_name( char *nam
|
||||||
|
return 0; /* or -1 */
|
||||||
|
|
||||||
|
it = CONTAINER_ITERATOR( swrun_container );
|
||||||
|
+ if((entry = (netsnmp_swrun_entry*)ITERATOR_FIRST( it )) != NULL) {
|
||||||
|
+ if (0 == strcmp( entry->hrSWRunName, name ))
|
||||||
|
+ i++;
|
||||||
|
+ }
|
||||||
|
while ((entry = (netsnmp_swrun_entry*)ITERATOR_NEXT( it )) != NULL) {
|
||||||
|
if (0 == strcmp( entry->hrSWRunName, name ))
|
||||||
|
i++;
|
|
@ -0,0 +1,41 @@
|
||||||
|
979329 - hrSWRunTable does not show kernel threads
|
||||||
|
|
||||||
|
commit c655fce784532a523f7db582d0cd07dee4ad7ac5
|
||||||
|
Author: Niels Baggesen <nba@users.sourceforge.net>
|
||||||
|
Date: Mon Oct 22 16:25:59 2012 +0200
|
||||||
|
|
||||||
|
Try to better classify Linux kernel threads as hrSWRunType=Os
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/host/data_access/swrun_procfs_status.c b/agent/mibgroup/host/data_access/swrun_procfs_status.c
|
||||||
|
index 80182d0..61c5e3a 100644
|
||||||
|
--- a/agent/mibgroup/host/data_access/swrun_procfs_status.c
|
||||||
|
+++ b/agent/mibgroup/host/data_access/swrun_procfs_status.c
|
||||||
|
@@ -122,11 +122,11 @@ netsnmp_arch_swrun_container_load( netsnmp_container *container, u_int flags)
|
||||||
|
continue; /* file (process) probably went away */
|
||||||
|
}
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
- if ((cp = fgets( buf, BUFSIZ-1, fp )) == NULL) {
|
||||||
|
- fclose(fp);
|
||||||
|
- netsnmp_swrun_entry_free(entry);
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
+ entry->hrSWRunType = HRSWRUNTYPE_APPLICATION;
|
||||||
|
+ if ((cp = fgets( buf, sizeof(buf)-1, fp )) == NULL) {
|
||||||
|
+ entry->hrSWRunType = HRSWRUNTYPE_OPERATINGSYSTEM;
|
||||||
|
+ buf[0] = '\0';
|
||||||
|
+ }
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ -151,11 +151,6 @@ netsnmp_arch_swrun_container_load( netsnmp_container *container, u_int flags)
|
||||||
|
buf + entry->hrSWRunPath_len + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
- * XXX - No information regarding system processes vs applications
|
||||||
|
- */
|
||||||
|
- entry->hrSWRunType = HRSWRUNTYPE_APPLICATION;
|
||||||
|
-
|
||||||
|
- /*
|
||||||
|
* {xxx} {xxx} STATUS {xxx}*10 UTIME STIME {xxx}*8 RSS
|
||||||
|
*/
|
||||||
|
snprintf( buf, BUFSIZ, "/proc/%d/stat", pid );
|
|
@ -0,0 +1,215 @@
|
||||||
|
diff -urNp old/include/net-snmp/library/large_fd_set.h new/include/net-snmp/library/large_fd_set.h
|
||||||
|
--- old/include/net-snmp/library/large_fd_set.h 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ new/include/net-snmp/library/large_fd_set.h 2017-04-04 14:36:27.307180033 +0200
|
||||||
|
@@ -55,8 +55,9 @@ extern "C" {
|
||||||
|
* Number of bytes needed to store a number of file descriptors as a
|
||||||
|
* struct fd_set.
|
||||||
|
*/
|
||||||
|
-#define NETSNMP_FD_SET_BYTES(setsize) \
|
||||||
|
- (sizeof(fd_set) + ((setsize) - FD_SETSIZE) * sizeof(SOCKET))
|
||||||
|
+#define NETSNMP_FD_SET_BYTES(setsize) \
|
||||||
|
+ (sizeof(fd_set) + ((setsize) > FD_SETSIZE ? \
|
||||||
|
+ ((setsize) - FD_SETSIZE) * sizeof(SOCKET) : 0))
|
||||||
|
|
||||||
|
/** Remove all sockets from the set *fdset. */
|
||||||
|
#define NETSNMP_LARGE_FD_ZERO(fdset) \
|
||||||
|
@@ -91,9 +92,10 @@ int netsnmp_large_fd_is_set(SOCKET fd
|
||||||
|
* Number of bytes needed to store a number of file descriptors as a
|
||||||
|
* struct fd_set.
|
||||||
|
*/
|
||||||
|
-#define NETSNMP_FD_SET_BYTES(setsize) \
|
||||||
|
- (sizeof(fd_set) + NETSNMP_FD_SET_ELEM_COUNT((setsize) - FD_SETSIZE) \
|
||||||
|
- * NETSNMP_FD_MASK_SIZE)
|
||||||
|
+#define NETSNMP_FD_SET_BYTES(setsize) \
|
||||||
|
+ (sizeof(fd_set) + ((setsize) > FD_SETSIZE ? \
|
||||||
|
+ NETSNMP_FD_SET_ELEM_COUNT((setsize) - FD_SETSIZE) \
|
||||||
|
+ * NETSNMP_FD_MASK_SIZE : 0))
|
||||||
|
|
||||||
|
/** Remove all file descriptors from the set *fdset. */
|
||||||
|
#define NETSNMP_LARGE_FD_ZERO(fdset) \
|
||||||
|
diff -urNp old/snmplib/large_fd_set.c new/snmplib/large_fd_set.c
|
||||||
|
--- old/snmplib/large_fd_set.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ new/snmplib/large_fd_set.c 2017-04-04 15:03:20.580810774 +0200
|
||||||
|
@@ -21,6 +21,10 @@
|
||||||
|
|
||||||
|
#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
|
||||||
|
|
||||||
|
+#define LFD_SET(n, p) FD_SET(n, p)
|
||||||
|
+#define LFD_CLR(n, p) FD_CLR(n, p)
|
||||||
|
+#define LFD_ISSET(n, p) FD_ISSET(n, p)
|
||||||
|
+
|
||||||
|
void
|
||||||
|
netsnmp_large_fd_setfd(SOCKET fd, netsnmp_large_fd_set * fdset)
|
||||||
|
{
|
||||||
|
@@ -28,18 +32,18 @@ netsnmp_large_fd_setfd(SOCKET fd, netsnm
|
||||||
|
|
||||||
|
netsnmp_assert(fd != INVALID_SOCKET);
|
||||||
|
|
||||||
|
- if (fdset->lfs_set.fd_count == fdset->lfs_setsize)
|
||||||
|
+ if (fdset->lfs_setptr->fd_count == fdset->lfs_setsize)
|
||||||
|
netsnmp_large_fd_set_resize(fdset, 2 * (fdset->lfs_setsize + 1));
|
||||||
|
|
||||||
|
- for (i = 0; i < fdset->lfs_set.fd_count; i++) {
|
||||||
|
- if (fdset->lfs_set.fd_array[i] == (SOCKET) (fd))
|
||||||
|
+ for (i = 0; i < fdset->lfs_setptr->fd_count; i++) {
|
||||||
|
+ if (fdset->lfs_setptr->fd_array[i] == fd)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (i == fdset->lfs_set.fd_count
|
||||||
|
- && fdset->lfs_set.fd_count < fdset->lfs_setsize) {
|
||||||
|
- fdset->lfs_set.fd_count++;
|
||||||
|
- fdset->lfs_set.fd_array[i] = fd;
|
||||||
|
+ if (i == fdset->lfs_setptr->fd_count &&
|
||||||
|
+ fdset->lfs_setptr->fd_count < fdset->lfs_setsize) {
|
||||||
|
+ fdset->lfs_setptr->fd_count++;
|
||||||
|
+ fdset->lfs_setptr->fd_array[i] = fd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -50,14 +54,14 @@ netsnmp_large_fd_clr(SOCKET fd, netsnmp_
|
||||||
|
|
||||||
|
netsnmp_assert(fd != INVALID_SOCKET);
|
||||||
|
|
||||||
|
- for (i = 0; i < fdset->lfs_set.fd_count; i++) {
|
||||||
|
- if (fdset->lfs_set.fd_array[i] == fd) {
|
||||||
|
- while (i < fdset->lfs_set.fd_count - 1) {
|
||||||
|
- fdset->lfs_set.fd_array[i] =
|
||||||
|
- fdset->lfs_set.fd_array[i + 1];
|
||||||
|
+ for (i = 0; i < fdset->lfs_setptr->fd_count; i++) {
|
||||||
|
+ if (fdset->lfs_setptr->fd_array[i] == fd) {
|
||||||
|
+ while (i < fdset->lfs_setptr->fd_count - 1) {
|
||||||
|
+ fdset->lfs_setptr->fd_array[i] =
|
||||||
|
+ fdset->lfs_setptr->fd_array[i + 1];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
- fdset->lfs_set.fd_count--;
|
||||||
|
+ fdset->lfs_setptr->fd_count--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -70,8 +74,8 @@ netsnmp_large_fd_is_set(SOCKET fd, netsn
|
||||||
|
|
||||||
|
netsnmp_assert(fd != INVALID_SOCKET);
|
||||||
|
|
||||||
|
- for (i = 0; i < fdset->lfs_set.fd_count; i++) {
|
||||||
|
- if (fdset->lfs_set.fd_array[i] == fd)
|
||||||
|
+ for (i = 0; i < fdset->lfs_setptr->fd_count; i++) {
|
||||||
|
+ if (fdset->lfs_setptr->fd_array[i] == fd)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
@@ -79,6 +83,43 @@ netsnmp_large_fd_is_set(SOCKET fd, netsn
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
+ /*
|
||||||
|
+ * Recent versions of glibc trigger abort() if FD_SET(), FD_CLR() or
|
||||||
|
+ * FD_ISSET() is invoked with n >= FD_SETSIZE. Hence these replacement
|
||||||
|
+ * functions. However, since NFDBITS != 8 * sizeof(fd_set.fds_bits[0]) for at
|
||||||
|
+ * least HP-UX on ia64 and since that combination uses big endian, use the
|
||||||
|
+ * macros from <sys/select.h> on such systems.
|
||||||
|
+ */
|
||||||
|
+NETSNMP_STATIC_INLINE void LFD_SET(unsigned n, fd_set *p)
|
||||||
|
+{
|
||||||
|
+ enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
|
||||||
|
+
|
||||||
|
+ if (nfdbits == NFDBITS)
|
||||||
|
+ p->fds_bits[n / nfdbits] |= (1ULL << (n % nfdbits));
|
||||||
|
+ else
|
||||||
|
+ FD_SET(n, p);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+NETSNMP_STATIC_INLINE void LFD_CLR(unsigned n, fd_set *p)
|
||||||
|
+{
|
||||||
|
+ enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
|
||||||
|
+
|
||||||
|
+ if (nfdbits == NFDBITS)
|
||||||
|
+ p->fds_bits[n / nfdbits] &= ~(1ULL << (n % nfdbits));
|
||||||
|
+ else
|
||||||
|
+ FD_CLR(n, p);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+NETSNMP_STATIC_INLINE unsigned LFD_ISSET(unsigned n, const fd_set *p)
|
||||||
|
+{
|
||||||
|
+ enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
|
||||||
|
+
|
||||||
|
+ if (nfdbits == NFDBITS)
|
||||||
|
+ return (p->fds_bits[n / nfdbits] & (1ULL << (n % nfdbits))) != 0;
|
||||||
|
+ else
|
||||||
|
+ return FD_ISSET(n, p) != 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
netsnmp_large_fd_setfd(int fd, netsnmp_large_fd_set * fdset)
|
||||||
|
{
|
||||||
|
@@ -87,7 +128,7 @@ netsnmp_large_fd_setfd(int fd, netsnmp_l
|
||||||
|
while (fd >= (int)fdset->lfs_setsize)
|
||||||
|
netsnmp_large_fd_set_resize(fdset, 2 * (fdset->lfs_setsize + 1));
|
||||||
|
|
||||||
|
- FD_SET(fd, fdset->lfs_setptr);
|
||||||
|
+ LFD_SET(fd, fdset->lfs_setptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -96,7 +137,7 @@ netsnmp_large_fd_clr(int fd, netsnmp_lar
|
||||||
|
netsnmp_assert(fd >= 0);
|
||||||
|
|
||||||
|
if ((unsigned)fd < fdset->lfs_setsize)
|
||||||
|
- FD_CLR(fd, fdset->lfs_setptr);
|
||||||
|
+ LFD_CLR(fd, fdset->lfs_setptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
@@ -104,7 +145,7 @@ netsnmp_large_fd_is_set(int fd, netsnmp_
|
||||||
|
{
|
||||||
|
netsnmp_assert(fd >= 0);
|
||||||
|
|
||||||
|
- return (unsigned)fd < fdset->lfs_setsize && FD_ISSET(fd, fdset->lfs_setptr);
|
||||||
|
+ return ((unsigned)fd < fdset->lfs_setsize && LFD_ISSET(fd, fdset->lfs_setptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -174,22 +215,24 @@ netsnmp_large_fd_set_resize(netsnmp_larg
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(cygwin) || !defined(HAVE_WINSOCK_H)
|
||||||
|
- {
|
||||||
|
+ /*
|
||||||
|
+ * Unix: when enlarging, clear the file descriptors defined in the
|
||||||
|
+ * resized *fdset but that were not defined in the original *fdset.
|
||||||
|
+ */
|
||||||
|
+ if ( fdset->lfs_setsize == 0 && setsize == FD_SETSIZE ) {
|
||||||
|
+ /* In this case we can use the OS's FD_ZERO */
|
||||||
|
+ FD_ZERO(fdset->lfs_setptr);
|
||||||
|
+ } else {
|
||||||
|
int i;
|
||||||
|
-
|
||||||
|
- /*
|
||||||
|
- * Unix: when enlarging, clear the file descriptors defined in the
|
||||||
|
- * resized *fdset but that were not defined in the original *fdset.
|
||||||
|
- */
|
||||||
|
for (i = fdset->lfs_setsize; i < setsize; i++)
|
||||||
|
- FD_CLR(i, fdset->lfs_setptr);
|
||||||
|
+ LFD_CLR(i, fdset->lfs_setptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fdset->lfs_setsize = setsize;
|
||||||
|
#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
|
||||||
|
- if (setsize < fdset->lfs_set.fd_count)
|
||||||
|
- fdset->lfs_set.fd_count = setsize;
|
||||||
|
+ if (setsize < fdset->lfs_setptr->fd_count)
|
||||||
|
+ fdset->lfs_setptr->fd_count = setsize;
|
||||||
|
#endif
|
||||||
|
success:
|
||||||
|
return 1;
|
||||||
|
@@ -197,7 +240,7 @@ success:
|
||||||
|
out_of_mem:
|
||||||
|
fdset->lfs_setsize = 0;
|
||||||
|
#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
|
||||||
|
- fdset->lfs_set.fd_count = 0;
|
||||||
|
+ fdset->lfs_setptr->fd_count = 0;
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
diff -up net-snmp-5.7.2/snmplib/snmp_api.c.original net-snmp-5.7.2/snmplib/snmp_api.c
|
||||||
|
--- net-snmp-5.7.2/snmplib/snmp_api.c.original 2018-01-12 17:46:47.534166712 +0900
|
||||||
|
+++ net-snmp-5.7.2/snmplib/snmp_api.c 2018-01-12 17:48:09.420911255 +0900
|
||||||
|
@@ -4974,6 +4974,9 @@ _sess_async_send(void *sessp,
|
||||||
|
|
||||||
|
reqid = pdu->reqid;
|
||||||
|
|
||||||
|
+ if (0 == reqid && (SNMPERR_SUCCESS == session->s_snmp_errno))
|
||||||
|
+ ++reqid;
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Add to pending requests list if we expect a response.
|
||||||
|
*/
|
||||||
|
diff -up net-snmp-5.7.2/snmplib/snmp_client.c.original net-snmp-5.7.2/snmplib/snmp_client.c
|
||||||
|
--- net-snmp-5.7.2/snmplib/snmp_client.c.original 2018-01-12 17:48:21.814721234 +0900
|
||||||
|
+++ net-snmp-5.7.2/snmplib/snmp_client.c 2018-01-12 18:33:55.779642445 +0900
|
||||||
|
@@ -1044,11 +1044,13 @@ snmp_synch_response_cb(netsnmp_session *
|
||||||
|
ss->callback = pcb;
|
||||||
|
ss->callback_magic = (void *) state;
|
||||||
|
|
||||||
|
- if ((state->reqid = snmp_send(ss, pdu)) == 0) {
|
||||||
|
+ if (snmp_send(ss, pdu) == 0) {
|
||||||
|
snmp_free_pdu(pdu);
|
||||||
|
state->status = STAT_ERROR;
|
||||||
|
- } else
|
||||||
|
+ } else {
|
||||||
|
+ state->reqid = pdu->reqid;
|
||||||
|
state->waiting = 1;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
while (state->waiting) {
|
||||||
|
numfds = 0;
|
||||||
|
@@ -1136,11 +1138,13 @@ snmp_sess_synch_response(void *sessp,
|
||||||
|
ss->callback = snmp_synch_input;
|
||||||
|
ss->callback_magic = (void *) state;
|
||||||
|
|
||||||
|
- if ((state->reqid = snmp_sess_send(sessp, pdu)) == 0) {
|
||||||
|
+ if (snmp_sess_send(sessp, pdu) == 0) {
|
||||||
|
snmp_free_pdu(pdu);
|
||||||
|
state->status = STAT_ERROR;
|
||||||
|
- } else
|
||||||
|
+ } else {
|
||||||
|
+ state->reqid = pdu->reqid;
|
||||||
|
state->waiting = 1;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
while (state->waiting) {
|
||||||
|
numfds = 0;
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
diff -Npru old/agent/mibgroup/agentx/protocol.c new/agent/mibgroup/agentx/protocol.c
|
||||||
|
--- old/agent/mibgroup/agentx/protocol.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ new/agent/mibgroup/agentx/protocol.c 2017-01-16 10:05:24.419201871 +0100
|
||||||
|
@@ -1550,7 +1550,7 @@ agentx_parse(netsnmp_session * session,
|
||||||
|
size_t len)
|
||||||
|
{
|
||||||
|
register u_char *bufp = data;
|
||||||
|
- u_char buffer[SNMP_MAX_MSG_SIZE];
|
||||||
|
+ u_char buffer[65535];
|
||||||
|
oid oid_buffer[MAX_OID_LEN], end_oid_buf[MAX_OID_LEN];
|
||||||
|
size_t buf_len = sizeof(buffer);
|
||||||
|
size_t oid_buf_len = MAX_OID_LEN;
|
|
@ -0,0 +1,24 @@
|
||||||
|
diff -up net-snmp-5.7.2/agent/Makefile.in.pie net-snmp-5.7.2/agent/Makefile.in
|
||||||
|
--- net-snmp-5.7.2/agent/Makefile.in.pie 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/Makefile.in 2012-10-18 09:45:13.298613099 +0200
|
||||||
|
@@ -294,7 +294,7 @@ getmibstat.o: mibgroup/kernel_sunos5.c
|
||||||
|
$(CC) $(CFLAGS) -o $@ -D_GETMIBSTAT_TEST -DDODEBUG -c $?
|
||||||
|
|
||||||
|
snmpd$(EXEEXT): ${LAGENTOBJS} $(USELIBS) $(AGENTLIB) $(HELPERLIB) $(MIBLIB) $(LIBTARG)
|
||||||
|
- $(LINK) $(CFLAGS) -o $@ ${LAGENTOBJS} ${LDFLAGS} ${OUR_AGENT_LIBS}
|
||||||
|
+ $(LINK) $(CFLAGS) -o $@ -pie ${LAGENTOBJS} ${LDFLAGS} ${OUR_AGENT_LIBS}
|
||||||
|
|
||||||
|
libnetsnmpagent.$(LIB_EXTENSION)$(LIB_VERSION): ${LLIBAGENTOBJS} $(USELIBS)
|
||||||
|
$(LIB_LD_CMD) $(AGENTLIB) ${LLIBAGENTOBJS} $(USELIBS) ${LAGENTLIBS} @LD_NO_UNDEFINED@ $(LDFLAGS) $(PERLLDOPTS_FOR_LIBS) $(LIB_LD_LIBS) @AGENTLIBS@
|
||||||
|
diff -up net-snmp-5.7.2/apps/Makefile.in.pie net-snmp-5.7.2/apps/Makefile.in
|
||||||
|
--- net-snmp-5.7.2/apps/Makefile.in.pie 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ net-snmp-5.7.2/apps/Makefile.in 2012-10-18 09:44:27.827774580 +0200
|
||||||
|
@@ -170,7 +170,7 @@ snmptest$(EXEEXT): snmptest.$(OSUFFIX
|
||||||
|
$(LINK) ${CFLAGS} -o $@ snmptest.$(OSUFFIX) ${LDFLAGS} ${LIBS}
|
||||||
|
|
||||||
|
snmptrapd$(EXEEXT): $(TRAPD_OBJECTS) $(USETRAPLIBS) $(INSTALLLIBS)
|
||||||
|
- $(LINK) ${CFLAGS} -o $@ $(TRAPD_OBJECTS) $(INSTALLLIBS) ${LDFLAGS} ${TRAPLIBS}
|
||||||
|
+ $(LINK) ${CFLAGS} -o $@ -pie $(TRAPD_OBJECTS) $(INSTALLLIBS) ${LDFLAGS} ${TRAPLIBS}
|
||||||
|
|
||||||
|
snmptrap$(EXEEXT): snmptrap.$(OSUFFIX) $(USELIBS)
|
||||||
|
$(LINK) ${CFLAGS} -o $@ snmptrap.$(OSUFFIX) ${LDFLAGS} ${LIBS}
|
|
@ -0,0 +1,16 @@
|
||||||
|
1087801 - proxied OIDs unspecified in proxy statement in snmpd.conf
|
||||||
|
|
||||||
|
From RHEL 6 patch.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/ucd-snmp/proxy.c.test2 net-snmp-5.7.2/agent/mibgroup/ucd-snmp/proxy.c
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/ucd-snmp/proxy.c.test2 2014-04-14 14:24:00.146782548 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/ucd-snmp/proxy.c 2014-04-14 14:24:20.416760913 +0200
|
||||||
|
@@ -412,7 +412,7 @@ proxy_handler(netsnmp_mib_handler *handl
|
||||||
|
if (sp->base_len &&
|
||||||
|
reqinfo->mode == MODE_GETNEXT &&
|
||||||
|
(snmp_oid_compare(ourname, ourlength,
|
||||||
|
- sp->base, sp->base_len) < 0)) {
|
||||||
|
+ sp->name, sp->name_len) < 0)) {
|
||||||
|
DEBUGMSGTL(( "proxy", "request is out of registered range\n"));
|
||||||
|
/*
|
||||||
|
* Create GETNEXT request with an OID so the
|
|
@ -0,0 +1,59 @@
|
||||||
|
1100099 - net-snmp-python adds zeros to end of IP address (IPADDR type), which is not valid
|
||||||
|
|
||||||
|
commit 1bc799de6cab010b25c0c4d3f5155b5fbaf527f0
|
||||||
|
Author: Bart Van Assche <bvanassche@acm.org>
|
||||||
|
Date: Thu Feb 21 20:05:14 2013 +0100
|
||||||
|
|
||||||
|
Python bindings: Fix the out-of-bounds write
|
||||||
|
|
||||||
|
See also commit 234158b8e84cc204cbac96e6e9be6959635404b8
|
||||||
|
|
||||||
|
diff --git a/python/netsnmp/client_intf.c b/python/netsnmp/client_intf.c
|
||||||
|
index 3eda804..d188e65 100644
|
||||||
|
--- a/python/netsnmp/client_intf.c
|
||||||
|
+++ b/python/netsnmp/client_intf.c
|
||||||
|
@@ -822,14 +822,18 @@ OCT:
|
||||||
|
|
||||||
|
case TYPE_IPADDR:
|
||||||
|
vars->type = ASN_IPADDRESS;
|
||||||
|
- vars->val.integer = (in_addr_t *)malloc(sizeof(in_addr_t));
|
||||||
|
- if (val)
|
||||||
|
- *(vars->val.integer) = inet_addr(val);
|
||||||
|
- else {
|
||||||
|
- ret = FAILURE;
|
||||||
|
- *(vars->val.integer) = 0;
|
||||||
|
+ {
|
||||||
|
+ in_addr_t addr;
|
||||||
|
+
|
||||||
|
+ if (val)
|
||||||
|
+ addr = inet_addr(val);
|
||||||
|
+ else {
|
||||||
|
+ ret = FAILURE;
|
||||||
|
+ addr = 0;
|
||||||
|
+ }
|
||||||
|
+ memdup(&vars->val.integer, &addr, sizeof(addr));
|
||||||
|
+ vars->val_len = sizeof(addr);
|
||||||
|
}
|
||||||
|
- vars->val_len = sizeof(in_addr_t);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE_OBJID:
|
||||||
|
commit d9789f2570452b54112443f3b8a32cf22a4ec783
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Fri Feb 27 13:55:07 2015 +0100
|
||||||
|
|
||||||
|
Fixed compiler warning.
|
||||||
|
|
||||||
|
diff --git a/python/netsnmp/client_intf.c b/python/netsnmp/client_intf.c
|
||||||
|
index 7fc74dc..db5db75 100644
|
||||||
|
--- a/python/netsnmp/client_intf.c
|
||||||
|
+++ b/python/netsnmp/client_intf.c
|
||||||
|
@@ -833,7 +833,7 @@ OCT:
|
||||||
|
ret = FAILURE;
|
||||||
|
addr = 0;
|
||||||
|
}
|
||||||
|
- memdup(&vars->val.integer, &addr, sizeof(addr));
|
||||||
|
+ memdup((u_char**) &vars->val.integer, &addr, sizeof(addr));
|
||||||
|
vars->val_len = sizeof(addr);
|
||||||
|
}
|
||||||
|
break;
|
|
@ -0,0 +1,23 @@
|
||||||
|
895357 - net-snmp-python adds zeros to end of IP address (IPADDR type), which is not valid
|
||||||
|
|
||||||
|
Source: upstream commit 234158b8e84cc204cbac96e6e9be6959635404b8
|
||||||
|
|
||||||
|
--- a/python/netsnmp/client_intf.c
|
||||||
|
+++ a/python/netsnmp/client_intf.c
|
||||||
|
@@ -821,14 +821,14 @@ OCT:
|
||||||
|
|
||||||
|
case TYPE_IPADDR:
|
||||||
|
vars->type = ASN_IPADDRESS;
|
||||||
|
- vars->val.integer = (long *)malloc(sizeof(long));
|
||||||
|
+ vars->val.integer = (in_addr_t *)malloc(sizeof(in_addr_t));
|
||||||
|
if (val)
|
||||||
|
*(vars->val.integer) = inet_addr(val);
|
||||||
|
else {
|
||||||
|
ret = FAILURE;
|
||||||
|
*(vars->val.integer) = 0;
|
||||||
|
}
|
||||||
|
- vars->val_len = sizeof(long);
|
||||||
|
+ vars->val_len = sizeof(in_addr_t);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE_OBJID:
|
|
@ -0,0 +1,12 @@
|
||||||
|
diff -urNp old/snmplib/snmp_api.c new/snmplib/snmp_api.c
|
||||||
|
--- old/snmplib/snmp_api.c 2017-01-16 10:11:37.951994525 +0100
|
||||||
|
+++ new/snmplib/snmp_api.c 2017-01-16 10:18:42.284631137 +0100
|
||||||
|
@@ -4931,7 +4931,7 @@ _sess_async_send(void *sessp,
|
||||||
|
* specified in the received PDU.
|
||||||
|
*/
|
||||||
|
|
||||||
|
- if (session->sndMsgMaxSize != 0 && length > session->sndMsgMaxSize) {
|
||||||
|
+ if (pdu->version == SNMP_VERSION_3 && session->sndMsgMaxSize != 0 && length > session->sndMsgMaxSize) {
|
||||||
|
DEBUGMSGTL(("sess_async_send",
|
||||||
|
"length of packet (%lu) exceeds session maximum (%lu)\n",
|
||||||
|
(unsigned long)length, (unsigned long)session->sndMsgMaxSize));
|
|
@ -0,0 +1,25 @@
|
||||||
|
1140236 - Segfault when starting snmpd
|
||||||
|
|
||||||
|
commit 95b87c7fe990869f6b4ce62c0b2f0382e47699a5
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Thu Feb 19 15:14:10 2015 +0100
|
||||||
|
|
||||||
|
Add extra check to throw away invalid SMUX messages.
|
||||||
|
|
||||||
|
Otherwise snmpd crashes on NULL pointer dereference.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/smux/smux.c b/agent/mibgroup/smux/smux.c
|
||||||
|
index fd96710..02d02d2 100644
|
||||||
|
--- a/agent/mibgroup/smux/smux.c
|
||||||
|
+++ b/agent/mibgroup/smux/smux.c
|
||||||
|
@@ -752,6 +752,10 @@ smux_pdu_process(int fd, u_char * data, size_t length)
|
||||||
|
while (error == 0 && ptr != NULL && ptr < data + length) {
|
||||||
|
len = length - (ptr - data);
|
||||||
|
ptr = asn_parse_header(ptr, &len, &type);
|
||||||
|
+ if (ptr == NULL) {
|
||||||
|
+ DEBUGMSGTL(("smux", "[smux_pdu_process] cannot parse header\n"));
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
DEBUGMSGTL(("smux", "[smux_pdu_process] type is %d\n",
|
||||||
|
(int) type));
|
||||||
|
switch (type) {
|
|
@ -0,0 +1,88 @@
|
||||||
|
Bug 1140234 - unexpected messages in log while smux processing
|
||||||
|
Bug 1189393 - unexpected messages in log while smux processing
|
||||||
|
|
||||||
|
Backported from:
|
||||||
|
|
||||||
|
commit 75d17a242e524e66b6c8214f68dc9920d5bd59df
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Fri Jan 30 11:29:53 2015 +0100
|
||||||
|
|
||||||
|
CHANGES: snmpd: Remove some log messages from SMUX processing.
|
||||||
|
|
||||||
|
These messages are not useful to system admin and only makes system log unreadable. Let's move them to debug level.
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/agent/mibgroup/smux/smux.c.smux-logging net-snmp-5.7.2/agent/mibgroup/smux/smux.c
|
||||||
|
--- net-snmp-5.7.2/agent/mibgroup/smux/smux.c.smux-logging 2015-06-18 10:49:01.165899644 +0200
|
||||||
|
+++ net-snmp-5.7.2/agent/mibgroup/smux/smux.c 2015-06-18 10:50:01.650157657 +0200
|
||||||
|
@@ -536,8 +536,8 @@ var_smux_write(int action,
|
||||||
|
|
||||||
|
if (buf[0] == SMUX_TRAP) {
|
||||||
|
DEBUGMSGTL(("smux", "[var_smux_write] Received trap\n"));
|
||||||
|
- snmp_log(LOG_INFO, "Got trap from peer on fd %d\n",
|
||||||
|
- rptr->sr_fd);
|
||||||
|
+ DEBUGMSGTL(("smux", "Got trap from peer on fd %d\n",
|
||||||
|
+ rptr->sr_fd));
|
||||||
|
ptr = asn_parse_header(buf, &len, &type);
|
||||||
|
smux_trap_process(ptr, &len);
|
||||||
|
|
||||||
|
@@ -646,9 +646,9 @@ smux_accept(int sd)
|
||||||
|
snmp_log_perror("[smux_accept] accept failed");
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
- snmp_log(LOG_INFO, "[smux_accept] accepted fd %d from %s:%d\n",
|
||||||
|
+ DEBUGMSGTL(("smux", "[smux_accept] accepted fd %d from %s:%d\n",
|
||||||
|
fd, inet_ntoa(in_socket.sin_addr),
|
||||||
|
- ntohs(in_socket.sin_port));
|
||||||
|
+ ntohs(in_socket.sin_port)));
|
||||||
|
if (npeers + 1 == SMUXMAXPEERS) {
|
||||||
|
snmp_log(LOG_ERR,
|
||||||
|
"[smux_accept] denied peer on fd %d, limit %d reached",
|
||||||
|
@@ -747,7 +747,8 @@ smux_process(int fd)
|
||||||
|
|
||||||
|
if (length <= 0)
|
||||||
|
{
|
||||||
|
- snmp_log_perror("[smux_process] peek failed");
|
||||||
|
+ if (length < 0)
|
||||||
|
+ snmp_log_perror("[smux_process] peek failed");
|
||||||
|
smux_peer_cleanup(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
@@ -837,7 +838,7 @@ smux_pdu_process(int fd, u_char * data,
|
||||||
|
DEBUGMSGTL(("smux", "This shouldn't have happened!\n"));
|
||||||
|
break;
|
||||||
|
case SMUX_TRAP:
|
||||||
|
- snmp_log(LOG_INFO, "Got trap from peer on fd %d\n", fd);
|
||||||
|
+ DEBUGMSGTL(("smux", "Got trap from peer on fd %d\n", fd));
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
DEBUGMSGTL(("smux", "[smux_pdu_process] call smux_trap_process.\n"));
|
||||||
|
@@ -943,9 +944,9 @@ smux_open_process(int fd, u_char * ptr,
|
||||||
|
*fail = TRUE;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
- snmp_log(LOG_INFO,
|
||||||
|
+ DEBUGMSGTL(("smux",
|
||||||
|
"accepted smux peer: oid %s, descr %s\n",
|
||||||
|
- oid_print, descr);
|
||||||
|
+ oid_print, descr));
|
||||||
|
*fail = FALSE;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
@@ -1538,7 +1539,7 @@ smux_snmp_process(int exact,
|
||||||
|
|
||||||
|
if (result[0] == SMUX_TRAP) {
|
||||||
|
DEBUGMSGTL(("smux", "[smux_snmp_process] Received trap\n"));
|
||||||
|
- snmp_log(LOG_INFO, "Got trap from peer on fd %d\n", sd);
|
||||||
|
+ DEBUGMSGTL(("smux", "Got trap from peer on fd %d\n", sd));
|
||||||
|
ptr = asn_parse_header(result, (size_t *) &length, &type);
|
||||||
|
smux_trap_process(ptr, (size_t *) &length);
|
||||||
|
|
||||||
|
@@ -1906,7 +1907,7 @@ smux_peer_cleanup(int sd)
|
||||||
|
Auths[i]->sa_active_fd = -1;
|
||||||
|
snprint_objid(oid_name, sizeof(oid_name), Auths[i]->sa_oid,
|
||||||
|
Auths[i]->sa_oid_len);
|
||||||
|
- snmp_log(LOG_INFO, "peer disconnected: %s\n", oid_name);
|
||||||
|
+ DEBUGMSGTL(("smux", "peer disconnected: %s\n", oid_name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
969061 - net-snmpd crash on time out
|
||||||
|
|
||||||
|
We need to bump soname because net-snmp-5.7.2-agentx-disconnect-crash.patch
|
||||||
|
changes ABI (sizeof(netsnmp_agent_session)).
|
||||||
|
diff -up net-snmp-5.7.2/Makefile.top.tst net-snmp-5.7.2/Makefile.top
|
||||||
|
--- net-snmp-5.7.2/Makefile.top.tst 2013-07-12 13:54:36.646160556 +0200
|
||||||
|
+++ net-snmp-5.7.2/Makefile.top 2013-07-12 13:54:40.678146522 +0200
|
||||||
|
@@ -79,7 +79,7 @@ LINKCC = @LINKCC@
|
||||||
|
# 5.3 was at 10, 5.4 is at 15, ... This leaves some room for needed
|
||||||
|
# changes for past releases if absolutely necessary.
|
||||||
|
#
|
||||||
|
-LIBCURRENT = 30
|
||||||
|
+LIBCURRENT = 31
|
||||||
|
LIBAGE = 0
|
||||||
|
LIBREVISION = 2
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
diff -urNp old/agent/mibgroup/host/data_access/swinst_rpm.c new/agent/mibgroup/host/data_access/swinst_rpm.c
|
||||||
|
--- old/agent/mibgroup/host/data_access/swinst_rpm.c 2012-10-10 00:28:58.000000000 +0200
|
||||||
|
+++ new/agent/mibgroup/host/data_access/swinst_rpm.c 2017-03-23 13:39:44.695386498 +0100
|
||||||
|
@@ -129,7 +129,7 @@ netsnmp_swinst_arch_load( netsnmp_contai
|
||||||
|
"%s-%s-%s", n, v, r);
|
||||||
|
if (entry->swName_len > sizeof(entry->swName))
|
||||||
|
entry->swName_len = sizeof(entry->swName);
|
||||||
|
- entry->swType = (NULL != strstr( g, "System Environment"))
|
||||||
|
+ entry->swType = (g != NULL && NULL != strstr( g, "System Environment"))
|
||||||
|
? 2 /* operatingSystem */
|
||||||
|
: 4; /* application */
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,58 @@
|
||||||
|
1235697 - ipSystemStatsInOctets & ipSystemStatsHCInOctets for IPV4 not implemented with net-snmp in RHEL 7
|
||||||
|
|
||||||
|
commit b4caf543cff7dba8f9acca2b9ea88c9b79dc39ee
|
||||||
|
Author: Niels Baggesen <nba@users.sourceforge.net>
|
||||||
|
Date: Mon Oct 22 16:32:12 2012 +0200
|
||||||
|
|
||||||
|
Pick up HC octets and McastOctets from /proc/net/netstat of current RHEL6
|
||||||
|
and Fedora kernels.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
|
||||||
|
index fbfd8a2..3ba8646 100644
|
||||||
|
--- a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
|
||||||
|
+++ b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
|
||||||
|
@@ -271,7 +271,7 @@ _additional_systemstats_v4(netsnmp_systemstats_entry* entry,
|
||||||
|
FILE *devin;
|
||||||
|
char line[1024];
|
||||||
|
int scan_count;
|
||||||
|
- unsigned long long scan_vals[6];
|
||||||
|
+ unsigned long long scan_vals[12];
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
|
DEBUGMSGTL(("access:systemstats:container:arch",
|
||||||
|
@@ -301,9 +301,11 @@ _additional_systemstats_v4(netsnmp_systemstats_entry* entry,
|
||||||
|
memset(scan_vals, 0x0, sizeof(scan_vals));
|
||||||
|
scan_count = sscanf(line,
|
||||||
|
"%*s" /* ignore `IpExt:' */
|
||||||
|
- "%llu %llu %llu %llu %llu %llu",
|
||||||
|
+ "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu",
|
||||||
|
&scan_vals[0], &scan_vals[1], &scan_vals[2],
|
||||||
|
- &scan_vals[3], &scan_vals[4], &scan_vals[5]);
|
||||||
|
+ &scan_vals[3], &scan_vals[4], &scan_vals[5],
|
||||||
|
+ &scan_vals[6], &scan_vals[7], &scan_vals[8],
|
||||||
|
+ &scan_vals[9], &scan_vals[10], &scan_vals[11]);
|
||||||
|
if (scan_count < 6) {
|
||||||
|
snmp_log(LOG_ERR,
|
||||||
|
"error scanning addtional systemstats data"
|
||||||
|
@@ -331,6 +333,21 @@ _additional_systemstats_v4(netsnmp_systemstats_entry* entry,
|
||||||
|
entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTPKTS] = 1;
|
||||||
|
entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINBCASTPKTS] = 1;
|
||||||
|
entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTBCASTPKTS] = 1;
|
||||||
|
+ if (scan_count >= 12) {
|
||||||
|
+ entry->stats.HCInOctets.low = scan_vals[6] & 0xffffffff;
|
||||||
|
+ entry->stats.HCInOctets.high = scan_vals[6] >> 32;
|
||||||
|
+ entry->stats.HCOutOctets.low = scan_vals[7] & 0xffffffff;
|
||||||
|
+ entry->stats.HCOutOctets.high = scan_vals[7] >> 32;
|
||||||
|
+ entry->stats.HCInMcastOctets.low = scan_vals[8] & 0xffffffff;
|
||||||
|
+ entry->stats.HCInMcastOctets.high = scan_vals[8] >> 32;
|
||||||
|
+ entry->stats.HCOutMcastOctets.low = scan_vals[9] & 0xffffffff;
|
||||||
|
+ entry->stats.HCOutMcastOctets.high = scan_vals[9] >> 32;
|
||||||
|
+ /* 10 and 11 are In/OutBcastOctets */
|
||||||
|
+ entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINOCTETS] = 1;
|
||||||
|
+ entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTOCTETS] = 1;
|
||||||
|
+ entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCINMCASTOCTETS] = 1;
|
||||||
|
+ entry->stats.columnAvail[IPSYSTEMSTATSTABLE_HCOUTMCASTOCTETS] = 1;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,474 @@
|
||||||
|
commit 7f4a7b891332899cea26e95be0337aae01648742
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Thu Jul 31 13:46:49 2014 +0200
|
||||||
|
|
||||||
|
Added checks for printing variables with wrong types.
|
||||||
|
|
||||||
|
When -OQ command line argument is used, variable formatter preffers the type
|
||||||
|
of the varible parsed from a MIB file instead of checking type of the variable
|
||||||
|
as parsed from SNMP message.
|
||||||
|
|
||||||
|
This can lead to crashes when incoming packets contains a variable with
|
||||||
|
NULL type, while the MIB says the variable should be non-NULL, like Integer.
|
||||||
|
The formatter then tries to interpret the NULL (from packet) as Integer (from
|
||||||
|
MIB file).
|
||||||
|
|
||||||
|
diff --git a/snmplib/mib.c b/snmplib/mib.c
|
||||||
|
index 9d3ca41..c6e0010 100644
|
||||||
|
--- a/snmplib/mib.c
|
||||||
|
+++ b/snmplib/mib.c
|
||||||
|
@@ -439,17 +439,16 @@ sprint_realloc_octet_string(u_char ** buf, size_t * buf_len,
|
||||||
|
u_char *cp;
|
||||||
|
int output_format, cnt;
|
||||||
|
|
||||||
|
- if ((var->type != ASN_OCTET_STR) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- const char str[] = "Wrong Type (should be OCTET STRING): ";
|
||||||
|
- if (snmp_cstrcat
|
||||||
|
- (buf, buf_len, out_len, allow_realloc, str)) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_OCTET_STR) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ const char str[] = "Wrong Type (should be OCTET STRING): ";
|
||||||
|
+ if (!snmp_cstrcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -702,16 +701,16 @@ sprint_realloc_float(u_char ** buf, size_t * buf_len,
|
||||||
|
const struct enum_list *enums,
|
||||||
|
const char *hint, const char *units)
|
||||||
|
{
|
||||||
|
- if ((var->type != ASN_OPAQUE_FLOAT) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
|
||||||
|
- "Wrong Type (should be Float): ")) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_OPAQUE_FLOAT) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be Float): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
||||||
|
@@ -772,17 +771,16 @@ sprint_realloc_double(u_char ** buf, size_t * buf_len,
|
||||||
|
const struct enum_list *enums,
|
||||||
|
const char *hint, const char *units)
|
||||||
|
{
|
||||||
|
- if ((var->type != ASN_OPAQUE_DOUBLE) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- if (snmp_cstrcat
|
||||||
|
- (buf, buf_len, out_len, allow_realloc,
|
||||||
|
- "Wrong Type (should be Double): ")) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_OPAQUE_DOUBLE) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be Double): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
||||||
|
@@ -847,20 +845,21 @@ sprint_realloc_counter64(u_char ** buf, size_t * buf_len, size_t * out_len,
|
||||||
|
{
|
||||||
|
char a64buf[I64CHARSZ + 1];
|
||||||
|
|
||||||
|
- if ((var->type != ASN_COUNTER64
|
||||||
|
+ if (var->type != ASN_COUNTER64
|
||||||
|
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||||
|
&& var->type != ASN_OPAQUE_COUNTER64
|
||||||
|
&& var->type != ASN_OPAQUE_I64 && var->type != ASN_OPAQUE_U64
|
||||||
|
#endif
|
||||||
|
- ) && (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
|
||||||
|
- "Wrong Type (should be Counter64): ")) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ ) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be Counter64): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
||||||
|
@@ -948,23 +947,25 @@ sprint_realloc_opaque(u_char ** buf, size_t * buf_len,
|
||||||
|
const struct enum_list *enums,
|
||||||
|
const char *hint, const char *units)
|
||||||
|
{
|
||||||
|
- if ((var->type != ASN_OPAQUE
|
||||||
|
+ if (var->type != ASN_OPAQUE
|
||||||
|
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||||
|
&& var->type != ASN_OPAQUE_COUNTER64
|
||||||
|
&& var->type != ASN_OPAQUE_U64
|
||||||
|
&& var->type != ASN_OPAQUE_I64
|
||||||
|
&& var->type != ASN_OPAQUE_FLOAT && var->type != ASN_OPAQUE_DOUBLE
|
||||||
|
#endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
|
||||||
|
- ) && (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
|
||||||
|
- "Wrong Type (should be Opaque): ")) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ ) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be Opaque): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
+
|
||||||
|
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||||
|
switch (var->type) {
|
||||||
|
case ASN_OPAQUE_COUNTER64:
|
||||||
|
@@ -1040,17 +1041,16 @@ sprint_realloc_object_identifier(u_char ** buf, size_t * buf_len,
|
||||||
|
{
|
||||||
|
int buf_overflow = 0;
|
||||||
|
|
||||||
|
- if ((var->type != ASN_OBJECT_ID) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- u_char str[] =
|
||||||
|
- "Wrong Type (should be OBJECT IDENTIFIER): ";
|
||||||
|
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_OBJECT_ID) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be OBJECT IDENTIFIER): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
||||||
|
@@ -1110,16 +1110,16 @@ sprint_realloc_timeticks(u_char ** buf, size_t * buf_len, size_t * out_len,
|
||||||
|
{
|
||||||
|
char timebuf[40];
|
||||||
|
|
||||||
|
- if ((var->type != ASN_TIMETICKS) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- u_char str[] = "Wrong Type (should be Timeticks): ";
|
||||||
|
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_TIMETICKS) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be Timeticks): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS)) {
|
||||||
|
@@ -1277,17 +1277,18 @@ sprint_realloc_integer(u_char ** buf, size_t * buf_len, size_t * out_len,
|
||||||
|
{
|
||||||
|
char *enum_string = NULL;
|
||||||
|
|
||||||
|
- if ((var->type != ASN_INTEGER) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- u_char str[] = "Wrong Type (should be INTEGER): ";
|
||||||
|
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_INTEGER) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be INTEGER): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
+
|
||||||
|
for (; enums; enums = enums->next) {
|
||||||
|
if (enums->value == *var->val.integer) {
|
||||||
|
enum_string = enums->label;
|
||||||
|
@@ -1380,16 +1381,16 @@ sprint_realloc_uinteger(u_char ** buf, size_t * buf_len, size_t * out_len,
|
||||||
|
{
|
||||||
|
char *enum_string = NULL;
|
||||||
|
|
||||||
|
- if ((var->type != ASN_UINTEGER) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- u_char str[] = "Wrong Type (should be UInteger32): ";
|
||||||
|
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_UINTEGER) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be UInteger32): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; enums; enums = enums->next) {
|
||||||
|
@@ -1477,17 +1478,16 @@ sprint_realloc_gauge(u_char ** buf, size_t * buf_len, size_t * out_len,
|
||||||
|
{
|
||||||
|
char tmp[32];
|
||||||
|
|
||||||
|
- if ((var->type != ASN_GAUGE) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- u_char str[] =
|
||||||
|
- "Wrong Type (should be Gauge32 or Unsigned32): ";
|
||||||
|
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_GAUGE) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be Gauge32 or Unsigned32): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
||||||
|
@@ -1550,16 +1550,16 @@ sprint_realloc_counter(u_char ** buf, size_t * buf_len, size_t * out_len,
|
||||||
|
{
|
||||||
|
char tmp[32];
|
||||||
|
|
||||||
|
- if ((var->type != ASN_COUNTER) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- u_char str[] = "Wrong Type (should be Counter32): ";
|
||||||
|
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_COUNTER) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be Counter32): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
||||||
|
@@ -1613,16 +1613,16 @@ sprint_realloc_networkaddress(u_char ** buf, size_t * buf_len,
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
- if ((var->type != ASN_IPADDRESS) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- u_char str[] = "Wrong Type (should be NetworkAddress): ";
|
||||||
|
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_IPADDRESS) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be NetworkAddress): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
||||||
|
@@ -1679,16 +1679,16 @@ sprint_realloc_ipaddress(u_char ** buf, size_t * buf_len, size_t * out_len,
|
||||||
|
{
|
||||||
|
u_char *ip = var->val.string;
|
||||||
|
|
||||||
|
- if ((var->type != ASN_IPADDRESS) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- u_char str[] = "Wrong Type (should be IpAddress): ";
|
||||||
|
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_IPADDRESS) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be IpAddress): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
||||||
|
@@ -1737,20 +1737,20 @@ sprint_realloc_null(u_char ** buf, size_t * buf_len, size_t * out_len,
|
||||||
|
const struct enum_list *enums,
|
||||||
|
const char *hint, const char *units)
|
||||||
|
{
|
||||||
|
- if ((var->type != ASN_NULL) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- u_char str[] = "Wrong Type (should be NULL): ";
|
||||||
|
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_NULL) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be NULL): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
- } else {
|
||||||
|
- u_char str[] = "NULL";
|
||||||
|
- return snmp_strcat(buf, buf_len, out_len, allow_realloc, str);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ u_char str[] = "NULL";
|
||||||
|
+ return snmp_strcat(buf, buf_len, out_len, allow_realloc, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1785,16 +1785,16 @@ sprint_realloc_bitstring(u_char ** buf, size_t * buf_len, size_t * out_len,
|
||||||
|
u_char *cp;
|
||||||
|
char *enum_string;
|
||||||
|
|
||||||
|
- if ((var->type != ASN_BIT_STR && var->type != ASN_OCTET_STR) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- u_char str[] = "Wrong Type (should be BITS): ";
|
||||||
|
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_BIT_STR && var->type != ASN_OCTET_STR) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be BITS): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
||||||
|
@@ -1869,16 +1869,16 @@ sprint_realloc_nsapaddress(u_char ** buf, size_t * buf_len,
|
||||||
|
const struct enum_list *enums, const char *hint,
|
||||||
|
const char *units)
|
||||||
|
{
|
||||||
|
- if ((var->type != ASN_NSAP) &&
|
||||||
|
- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
|
||||||
|
- u_char str[] = "Wrong Type (should be NsapAddress): ";
|
||||||
|
- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
|
||||||
|
- return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
+ if (var->type != ASN_NSAP) {
|
||||||
|
+ if (!netsnmp_ds_get_boolean(
|
||||||
|
+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
+ u_char str[] = "Wrong Type (should be NsapAddress): ";
|
||||||
|
+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ return sprint_realloc_by_type(buf, buf_len, out_len,
|
||||||
|
allow_realloc, var, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
- } else {
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
|
||||||
|
|
||||||
|
commit 3da0c378b5cb1bbf35d05a6212a483abda84a201
|
||||||
|
Author: Niels Baggesen <nba@users.sourceforge.net>
|
||||||
|
Date: Mon Sep 1 08:59:04 2014 +0200
|
||||||
|
|
||||||
|
Fix commit 7f4a7b891332899cea26e95be0337aae01648742: dont mix code and declarations.
|
||||||
|
|
||||||
|
diff --git a/snmplib/mib.c b/snmplib/mib.c
|
||||||
|
index c6e0010..7dcf3d0 100644
|
||||||
|
--- a/snmplib/mib.c
|
||||||
|
+++ b/snmplib/mib.c
|
||||||
|
@@ -1737,6 +1737,8 @@ sprint_realloc_null(u_char ** buf, size_t * buf_len, size_t * out_len,
|
||||||
|
const struct enum_list *enums,
|
||||||
|
const char *hint, const char *units)
|
||||||
|
{
|
||||||
|
+ u_char str[] = "NULL";
|
||||||
|
+
|
||||||
|
if (var->type != ASN_NULL) {
|
||||||
|
if (!netsnmp_ds_get_boolean(
|
||||||
|
NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
|
||||||
|
@@ -1749,7 +1751,6 @@ sprint_realloc_null(u_char ** buf, size_t * buf_len, size_t * out_len,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
- u_char str[] = "NULL";
|
||||||
|
return snmp_strcat(buf, buf_len, out_len, allow_realloc, str);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
1050971 - snmpd segfault with entry->sysUpTime = *sysUT_var.val.integer
|
||||||
|
|
||||||
|
commit 9f4c572614091404decba0d4ef1a4cbaf9fc5bd2
|
||||||
|
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
||||||
|
Date: Thu Jan 9 13:35:27 2014 +0100
|
||||||
|
|
||||||
|
CHANGES: snmpd: Fixed monitoring based on non-delta trigger.
|
||||||
|
|
||||||
|
snmpd crashed wit following snmpd.conf:
|
||||||
|
monitor -s -D -r 10 -e LOGMATCH -o logMatchCurrentCount "Log Match" != logMatchCurrentCount
|
||||||
|
logmatch LoginFailure1 /var/log/secure 10 su: .*fail.*
|
||||||
|
|
||||||
|
The reason was unitialized variable sysUT_var in mteTrigger_run(), it was
|
||||||
|
filled only if the trigger was delta-valued, while its value was used for all
|
||||||
|
triggers.
|
||||||
|
|
||||||
|
With this patch, sysUT_var is filled for all code branches where it is needed.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/disman/event/mteTrigger.c b/agent/mibgroup/disman/event/mteTrigger.c
|
||||||
|
index bb585ed..11cb5b7 100644
|
||||||
|
--- a/agent/mibgroup/disman/event/mteTrigger.c
|
||||||
|
+++ b/agent/mibgroup/disman/event/mteTrigger.c
|
||||||
|
@@ -533,6 +533,13 @@ mteTrigger_run( unsigned int reg, void *clientarg)
|
||||||
|
} /* !old_results - end of else block */
|
||||||
|
} /* MTE_TRIGGER_EXISTENCE */
|
||||||
|
|
||||||
|
+ /*
|
||||||
|
+ * We'll need sysUpTime.0 regardless...
|
||||||
|
+ */
|
||||||
|
+ DEBUGMSGTL(("disman:event:delta", "retrieve sysUpTime.0\n"));
|
||||||
|
+ memset( &sysUT_var, 0, sizeof( netsnmp_variable_list ));
|
||||||
|
+ snmp_set_var_objid( &sysUT_var, _sysUpTime_instance, _sysUpTime_inst_len );
|
||||||
|
+ netsnmp_query_get( &sysUT_var, entry->session );
|
||||||
|
|
||||||
|
if (( entry->mteTriggerTest & MTE_TRIGGER_BOOLEAN ) ||
|
||||||
|
( entry->mteTriggerTest & MTE_TRIGGER_THRESHOLD )) {
|
||||||
|
@@ -582,14 +589,6 @@ mteTrigger_run( unsigned int reg, void *clientarg)
|
||||||
|
* (including sysUpTime.0 if not specified explicitly).
|
||||||
|
*/
|
||||||
|
if ( entry->flags & MTE_TRIGGER_FLAG_DELTA ) {
|
||||||
|
- /*
|
||||||
|
- * We'll need sysUpTime.0 regardless...
|
||||||
|
- */
|
||||||
|
- DEBUGMSGTL(("disman:event:delta", "retrieve sysUpTime.0\n"));
|
||||||
|
- memset( &sysUT_var, 0, sizeof( netsnmp_variable_list ));
|
||||||
|
- snmp_set_var_objid( &sysUT_var, _sysUpTime_instance,
|
||||||
|
- _sysUpTime_inst_len );
|
||||||
|
- netsnmp_query_get( &sysUT_var, entry->session );
|
||||||
|
|
||||||
|
if (!(entry->flags & MTE_TRIGGER_FLAG_SYSUPT)) {
|
||||||
|
/*
|
|
@ -0,0 +1,78 @@
|
||||||
|
1190679 - In IPv6, snmp packet does not send from specified interface assigned by clientaddr option in snmpd.conf
|
||||||
|
|
||||||
|
commit a92628a163ebf1ea62220684736300461c003875
|
||||||
|
Author: Niels Baggesen <nba@users.sourceforge.net>
|
||||||
|
Date: Mon Jan 26 20:26:06 2015 +0100
|
||||||
|
|
||||||
|
BUG#a2584: Fix snmptrap to use clientaddr from snmp.conf. Thanks to rizwan
|
||||||
|
|
||||||
|
+ restore clientaddrUsesPort functionality for UDPv6
|
||||||
|
|
||||||
|
diff -up net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c.udp6-clientaddr net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c
|
||||||
|
--- net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c.udp6-clientaddr 2015-06-17 15:00:50.178122151 +0200
|
||||||
|
+++ net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c 2015-06-17 15:01:09.203194870 +0200
|
||||||
|
@@ -284,6 +284,27 @@ netsnmp_udp6_transport(struct sockaddr_i
|
||||||
|
return NULL;
|
||||||
|
#endif /* NETSNMP_NO_LISTEN_SUPPORT */
|
||||||
|
} else {
|
||||||
|
+ char *client_socket = NULL;
|
||||||
|
+ /*
|
||||||
|
+ * This is a client session. If we've been given a
|
||||||
|
+ * client address to send from, then bind to that.
|
||||||
|
+ * Otherwise the send will use "something sensible".
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+ client_socket = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
|
||||||
|
+ NETSNMP_DS_LIB_CLIENT_ADDR);
|
||||||
|
+ if (client_socket) {
|
||||||
|
+ struct sockaddr_in6 client_addr;
|
||||||
|
+ netsnmp_sockaddr_in6_2(&client_addr, client_socket, NULL);
|
||||||
|
+ rc = bind(t->sock, (struct sockaddr *)&client_addr,
|
||||||
|
+ sizeof(struct sockaddr_in6));
|
||||||
|
+ if ( rc != 0 ) {
|
||||||
|
+ DEBUGMSGTL(("netsnmp_udp6", "failed to bind for clientaddr: %d %s\n",
|
||||||
|
+ errno, strerror(errno)));
|
||||||
|
+ netsnmp_socketbase_close(t);
|
||||||
|
+ netsnmp_transport_free(t);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
/*
|
||||||
|
* This is a client session. Save the address in the
|
||||||
|
* transport-specific data pointer for later use by netsnmp_udp6_send.
|
||||||
|
diff -up net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c.old net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c
|
||||||
|
--- net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c.old 2015-06-17 16:34:09.120181912 +0200
|
||||||
|
+++ net-snmp-5.7.2/snmplib/transports/snmpUDPIPv6Domain.c 2015-06-17 16:35:29.803192111 +0200
|
||||||
|
@@ -294,8 +294,13 @@ netsnmp_udp6_transport(struct sockaddr_i
|
||||||
|
client_socket = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
|
||||||
|
NETSNMP_DS_LIB_CLIENT_ADDR);
|
||||||
|
if (client_socket) {
|
||||||
|
+ int uses_port = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
|
||||||
|
+ NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
|
||||||
|
struct sockaddr_in6 client_addr;
|
||||||
|
netsnmp_sockaddr_in6_2(&client_addr, client_socket, NULL);
|
||||||
|
+ if (uses_port == 0) {
|
||||||
|
+ client_addr.sin6_port = 0;
|
||||||
|
+ }
|
||||||
|
rc = bind(t->sock, (struct sockaddr *)&client_addr,
|
||||||
|
sizeof(struct sockaddr_in6));
|
||||||
|
if ( rc != 0 ) {
|
||||||
|
commit 1ee72102fbe722d232d74abc4660a8b134cec8d6
|
||||||
|
Author: Bart Van Assche <bvanassche@acm.org>
|
||||||
|
Date: Sat May 23 07:32:53 2015 +0200
|
||||||
|
|
||||||
|
snmplib, UDPIPv6 transport: Add a missing return statement
|
||||||
|
|
||||||
|
Detected by Coverity.
|
||||||
|
|
||||||
|
diff --git a/snmplib/transports/snmpUDPIPv6Domain.c b/snmplib/transports/snmpUDPIPv6Domain.c
|
||||||
|
index 029b164..11c39bb 100644
|
||||||
|
--- a/snmplib/transports/snmpUDPIPv6Domain.c
|
||||||
|
+++ b/snmplib/transports/snmpUDPIPv6Domain.c
|
||||||
|
@@ -285,6 +285,7 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
|
||||||
|
errno, strerror(errno)));
|
||||||
|
netsnmp_socketbase_close(t);
|
||||||
|
netsnmp_transport_free(t);
|
||||||
|
+ return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
|
@ -0,0 +1,21 @@
|
||||||
|
Bug 1184433 - udpTable has wrong indices
|
||||||
|
|
||||||
|
commit c5c435658032c26fde69978e2610c879b3a4bcc8
|
||||||
|
Author: Niels Baggesen <nba@users.sourceforge.net>
|
||||||
|
Date: Thu Apr 16 18:56:55 2015 +0200
|
||||||
|
|
||||||
|
Patch #1300: Fix big endian / 64bit problem with Sparc by properly typing. Thanks to Eric Snowberg.
|
||||||
|
|
||||||
|
diff --git a/agent/mibgroup/mibII/udpTable.c b/agent/mibgroup/mibII/udpTable.c
|
||||||
|
index 57e967c..cc00b13 100644
|
||||||
|
--- a/agent/mibgroup/mibII/udpTable.c
|
||||||
|
+++ b/agent/mibgroup/mibII/udpTable.c
|
||||||
|
@@ -368,7 +368,7 @@ udpTable_next_entry( void **loop_context,
|
||||||
|
{
|
||||||
|
UDPTABLE_ENTRY_TYPE *entry = (UDPTABLE_ENTRY_TYPE *)*loop_context;
|
||||||
|
long port;
|
||||||
|
- long addr;
|
||||||
|
+ in_addr_t addr;
|
||||||
|
|
||||||
|
if (!entry)
|
||||||
|
return NULL;
|
|
@ -0,0 +1,13 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Simple Network Management Protocol (SNMP) Daemon.
|
||||||
|
After=syslog.target network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=notify
|
||||||
|
Environment=OPTIONS="-LS0-6d"
|
||||||
|
EnvironmentFile=-/etc/sysconfig/snmpd
|
||||||
|
ExecStart=/usr/sbin/snmpd $OPTIONS -f
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue