158 lines
7.1 KiB
Diff
158 lines
7.1 KiB
Diff
386611: snmpd segfaults on xen network interfaces
|
|
Source: http://sourceforge.net/tracker/index.php?func=detail&aid=1794532&group_id=12694&atid=112694
|
|
Reviewed-By: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
Index: agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c
|
|
===================================================================
|
|
--- agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c (revision 16711)
|
|
+++ agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c (working copy)
|
|
@@ -258,9 +258,10 @@
|
|
if ((NULL != rowreq_ctx) &&
|
|
(MFD_SUCCESS ==
|
|
ipAddressTable_indexes_set(rowreq_ctx,
|
|
+ ipaddress_entry->ia_address_len + 1,
|
|
+ ipaddress_entry->ia_address,
|
|
ipaddress_entry->ia_address_len,
|
|
- ipaddress_entry->ia_address,
|
|
- ipaddress_entry->ia_address_len))) {
|
|
+ ipaddress_entry->if_index))) {
|
|
if (CONTAINER_INSERT(container, rowreq_ctx) < 0) {
|
|
DEBUGMSGTL (("ipAddressTable:access","container insert failed for new entry\n"));
|
|
ipAddressTable_release_rowreq_ctx(rowreq_ctx);
|
|
Index: agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c
|
|
===================================================================
|
|
--- agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c (revision 16711)
|
|
+++ agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c (working copy)
|
|
@@ -348,10 +348,18 @@
|
|
*mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV4;
|
|
break;
|
|
|
|
+ case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV4Z:
|
|
+ *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV4Z;
|
|
+ break;
|
|
+
|
|
case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6:
|
|
*mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV6;
|
|
break;
|
|
|
|
+ case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6Z:
|
|
+ *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV6Z;
|
|
+ break;
|
|
+
|
|
default:
|
|
snmp_log(LOG_ERR, "couldn't map value %ld for ipAddressAddrType\n",
|
|
raw_ipAddressAddrType_val);
|
|
@@ -382,8 +390,11 @@
|
|
ipAddressTable_indexes_set_tbl_idx(ipAddressTable_mib_index * tbl_idx,
|
|
u_long ipAddressAddrType_val,
|
|
char *ipAddressAddr_val_ptr,
|
|
- size_t ipAddressAddr_val_ptr_len)
|
|
+ size_t ipAddressAddr_val_ptr_len,
|
|
+ u_long ipAddressAddr_ifIndex)
|
|
{
|
|
+ uint32_t zone = htonl(ipAddressAddr_ifIndex);
|
|
+
|
|
DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_indexes_set_tbl_idx", "called\n"));
|
|
|
|
/*
|
|
@@ -409,6 +420,11 @@
|
|
memcpy(tbl_idx->ipAddressAddr, ipAddressAddr_val_ptr,
|
|
ipAddressAddr_val_ptr_len * sizeof(ipAddressAddr_val_ptr[0]));
|
|
|
|
+ /** zone */
|
|
+ tbl_idx->ipAddressAddr_len += sizeof(zone);
|
|
+ memcpy(&tbl_idx->ipAddressAddr[ipAddressAddr_val_ptr_len *
|
|
+ sizeof(ipAddressAddr_val_ptr[0])],
|
|
+ &zone, sizeof(zone));
|
|
|
|
return MFD_SUCCESS;
|
|
} /* ipAddressTable_indexes_set_tbl_idx */
|
|
@@ -430,7 +446,8 @@
|
|
ipAddressTable_indexes_set(ipAddressTable_rowreq_ctx * rowreq_ctx,
|
|
u_long ipAddressAddrType_val,
|
|
char *ipAddressAddr_val_ptr,
|
|
- size_t ipAddressAddr_val_ptr_len)
|
|
+ size_t ipAddressAddr_val_ptr_len,
|
|
+ u_long ipAddressAddr_ifIndex)
|
|
{
|
|
DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_indexes_set",
|
|
"called\n"));
|
|
@@ -439,7 +456,8 @@
|
|
ipAddressTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx,
|
|
ipAddressAddrType_val,
|
|
ipAddressAddr_val_ptr,
|
|
- ipAddressAddr_val_ptr_len))
|
|
+ ipAddressAddr_val_ptr_len,
|
|
+ ipAddressAddr_ifIndex))
|
|
return MFD_ERROR;
|
|
|
|
/*
|
|
Index: agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h
|
|
===================================================================
|
|
--- agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h (revision 16711)
|
|
+++ agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h (working copy)
|
|
@@ -106,7 +106,9 @@
|
|
* simplistic map of address length to type
|
|
*/
|
|
#define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV4 4
|
|
+#define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV4Z 5
|
|
#define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6 16
|
|
+#define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6Z 17
|
|
|
|
|
|
/*************************************************************
|
|
Index: agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h
|
|
===================================================================
|
|
--- agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h (revision 16711)
|
|
+++ agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h (working copy)
|
|
@@ -273,14 +273,16 @@
|
|
u_long ipAddressAddrType_val,
|
|
char *ipAddressAddr_val_ptr,
|
|
size_t
|
|
- ipAddressAddr_val_ptr_len);
|
|
+ ipAddressAddr_val_ptr_len,
|
|
+ u_long ipAddressAddr_ifIndex);
|
|
int ipAddressTable_indexes_set(ipAddressTable_rowreq_ctx *
|
|
rowreq_ctx,
|
|
u_long
|
|
ipAddressAddrType_val,
|
|
char *ipAddressAddr_val_ptr,
|
|
size_t
|
|
- ipAddressAddr_val_ptr_len);
|
|
+ ipAddressAddr_val_ptr_len,
|
|
+ u_long ipAddressAddr_ifIndex);
|
|
|
|
|
|
|
|
Index: agent/mibgroup/ip-mib/data_access/ipaddress_common.c
|
|
===================================================================
|
|
--- agent/mibgroup/ip-mib/data_access/ipaddress_common.c (revision 16711)
|
|
+++ agent/mibgroup/ip-mib/data_access/ipaddress_common.c (working copy)
|
|
@@ -411,6 +415,7 @@
|
|
{
|
|
const netsnmp_ipaddress_entry *lh = (const netsnmp_ipaddress_entry *)lhs;
|
|
const netsnmp_ipaddress_entry *rh = (const netsnmp_ipaddress_entry *)rhs;
|
|
+ int rc;
|
|
|
|
netsnmp_assert(NULL != lhs);
|
|
netsnmp_assert(NULL != rhs);
|
|
@@ -426,5 +431,17 @@
|
|
/*
|
|
* length equal, compare address
|
|
*/
|
|
- return memcmp(lh->ia_address, rh->ia_address, lh->ia_address_len);
|
|
+ rc = memcmp(lh->ia_address, rh->ia_address, lh->ia_address_len);
|
|
+ if (rc)
|
|
+ return rc;
|
|
+
|
|
+ /*
|
|
+ * address same, compare ifIndex
|
|
+ */
|
|
+ if (lh->if_index < rh->if_index)
|
|
+ return -1;
|
|
+ else if (lh->if_index > rh->if_index)
|
|
+ return 1;
|
|
+
|
|
+ return 0;
|
|
}
|