aboutsummaryrefslogtreecommitdiff
path: root/contrib/bsnmp
diff options
context:
space:
mode:
authorHartmut Brandt <harti@FreeBSD.org>2016-01-21 16:11:20 +0000
committerHartmut Brandt <harti@FreeBSD.org>2016-01-21 16:11:20 +0000
commit5edd0d3a4d123b7ef102fcef688f950af00f6e78 (patch)
tree4d51c55ca0675baf4673ad2810858addce99e2cb /contrib/bsnmp
parent9e055ad144c46cbbc5caa1ec1617e4a43ecdcadc (diff)
downloadsrc-5edd0d3a4d123b7ef102fcef688f950af00f6e78.tar.gz
src-5edd0d3a4d123b7ef102fcef688f950af00f6e78.zip
Fill the ifAlias leaf of the ifXTable with the interface description
if there is one available and it fits into the maximum size (64 characters).
Notes
Notes: svn path=/head/; revision=294507
Diffstat (limited to 'contrib/bsnmp')
-rw-r--r--contrib/bsnmp/snmp_mibII/mibII.c13
-rw-r--r--contrib/bsnmp/snmp_mibII/mibII.h6
-rw-r--r--contrib/bsnmp/snmp_mibII/mibII_interfaces.c2
3 files changed, 20 insertions, 1 deletions
diff --git a/contrib/bsnmp/snmp_mibII/mibII.c b/contrib/bsnmp/snmp_mibII/mibII.c
index d3fe27a8ac3c..b62ee66d6d61 100644
--- a/contrib/bsnmp/snmp_mibII/mibII.c
+++ b/contrib/bsnmp/snmp_mibII/mibII.c
@@ -443,6 +443,7 @@ mib_fetch_ifmib(struct mibif *ifp)
size_t len;
void *newmib;
struct ifmibdata oldmib = ifp->mib;
+ struct ifreq irr;
if (fetch_generic_mib(ifp, &oldmib) == -1)
return (-1);
@@ -514,6 +515,18 @@ mib_fetch_ifmib(struct mibif *ifp)
}
out:
+ strncpy(irr.ifr_name, ifp->name, sizeof(irr.ifr_name));
+ irr.ifr_buffer.buffer = MIBIF_PRIV(ifp)->alias;
+ irr.ifr_buffer.length = sizeof(MIBIF_PRIV(ifp)->alias);
+ if (ioctl(mib_netsock, SIOCGIFDESCR, &irr) == -1) {
+ MIBIF_PRIV(ifp)->alias[0] = 0;
+ if (errno != ENOMSG)
+ syslog(LOG_WARNING, "SIOCGIFDESCR (%s): %m", ifp->name);
+ } else if (irr.ifr_buffer.buffer == NULL) {
+ MIBIF_PRIV(ifp)->alias[0] = 0;
+ syslog(LOG_WARNING, "SIOCGIFDESCR (%s): too long (%zu)",
+ ifp->name, irr.ifr_buffer.length);
+ }
ifp->mibtick = get_ticks();
return (0);
}
diff --git a/contrib/bsnmp/snmp_mibII/mibII.h b/contrib/bsnmp/snmp_mibII/mibII.h
index 8d50528c53d6..d47bc0bf470f 100644
--- a/contrib/bsnmp/snmp_mibII/mibII.h
+++ b/contrib/bsnmp/snmp_mibII/mibII.h
@@ -57,6 +57,9 @@
#include "snmp_mibII.h"
#include "mibII_tree.h"
+/* maximum size of the interface alias */
+static const u_int MIBIF_ALIAS_SIZE = 64 + 1;
+
/*
* Interface list and flags.
*/
@@ -77,6 +80,9 @@ struct mibif_private {
uint64_t hc_opackets;
uint64_t hc_imcasts;
uint64_t hc_ipackets;
+
+ /* this should be made public */
+ char alias[MIBIF_ALIAS_SIZE];
};
#define MIBIF_PRIV(IFP) ((struct mibif_private *)((IFP)->private))
diff --git a/contrib/bsnmp/snmp_mibII/mibII_interfaces.c b/contrib/bsnmp/snmp_mibII/mibII_interfaces.c
index f425a2703f29..654e9c310b50 100644
--- a/contrib/bsnmp/snmp_mibII/mibII_interfaces.c
+++ b/contrib/bsnmp/snmp_mibII/mibII_interfaces.c
@@ -528,7 +528,7 @@ op_ifxtable(struct snmp_context *ctx, struct snmp_value *value,
break;
case LEAF_ifAlias:
- ret = string_get(value, "", -1);
+ ret = string_get(value, MIBIF_PRIV(ifp)->alias, -1);
break;
case LEAF_ifCounterDiscontinuityTime: