Commit Graph

16 Commits

Author SHA1 Message Date
Andrey V. Elsukov
8581fc9ad5 Create 64bit mibII counters for all interfaces.
PR:		157015
Obtained from:	Yandex LLC
MFC after:	1 month
2019-04-02 13:38:00 +00:00
Eugene Grosbein
1a498d2e68 bsnmpd(8): fix and optimize interface description processing
* correctly prepare a buffer to obtain interface description from a kernel and
  truncate long description instead of dropping it altogether and
  spamming logs;
* skip calling strlen() for each description and each SNMP request
  for MIB-II/ifXTable's ifAlias.
* teach bsnmpd to allocate memory dynamically for interface descriptions
  to decrease memory usage for common case and not to break
  if long description occurs;

PR:			217763
Reviewed by:		harti and others
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D16459
2018-08-18 10:58:44 +00:00
Enji Cooper
02ff676c4d MIB-II: use strlcpy when copying interface names to .ifr_name
.ifra_name is assumed to be NUL terminated; using strlcpy(3)
ensures that it's indeed NUL terminated whereas strncpy does
not.

Tested and verified as follows with a combination of ifconfig,
snmpget, and snmpset:

  % ifconfig create lo1 127.0.0.2/8
  % SNMPARGS="-v 3 -n '' -u bsnmp -A bsnmptest -l authPriv -a sha -x des -X bsnmptest localhost"
  % snmpget $SNMPARGS IF-MIB::ifAdminStatus.4
  IF-MIB::ifAdminStatus.4 = INTEGER: up(1)
  % snmpset $SNMPARGS IF-MIB::ifAdminStatus.4 i 2
  IF-MIB::ifAdminStatus.4 = INTEGER: down(2)
  % snmpget $SNMPARGS IF-MIB::ifAdminStatus.4
  IF-MIB::ifAdminStatus.4 = INTEGER: down(2)
  % snmpset $SNMPARGS IF-MIB::ifAdminStatus.4 i 1
  IF-MIB::ifAdminStatus.4 = INTEGER: up(1)
  % snmpget $SNMPARGS IF-MIB::ifAdminStatus.4
  IF-MIB::ifAdminStatus.4 = INTEGER: up(1)

MFC after:	2 weeks
Reported by:	Coverity
CID:		1009652-1009656, 1349850
2016-12-31 11:50:36 +00:00
Enji Cooper
e1d581b289 style(9): clean up trailing whitespace
MFC after:	3 weeks
2016-12-27 23:32:54 +00:00
Enji Cooper
e9f8d18ebe Return ret in op_ifentry(..) to mute a -Wunused-but-set-variable warning
This will also now detect error conditions with
value->var.subs[sub - 1] == LEAF_ifPhysAddress where `string_get(..)`
could fail if iifp->physaddr and/or iifp->physaddrlen were deemed
invalid.

MFC after: 2 weeks
CID: 1006551
Reported by: Coverity, gcc
Sponsored by: EMC / Isilon Storage Division
2016-04-22 07:51:38 +00:00
Hartmut Brandt
5edd0d3a4d 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).
2016-01-21 16:11:20 +00:00
Ruslan Ermilov
87a5818245 Properly detect interface's state in the LINK_STATE_UNKNOWN case.
MFC after:	1 week
2011-05-03 10:11:44 +00:00
Hartmut Brandt
748b5b1ebd Virgin import of bsnmpd 1.12 2006-02-27 16:16:18 +00:00
Hartmut Brandt
c6a4e65805 Vendor fix: make mibII HC counters really 64-bit on 32-bit platforms by polling
the kernel periodically.

Submitted by:	glebius (partly)
2006-02-13 14:11:18 +00:00
Hartmut Brandt
361b40a30d Vendor patch: fix the reporting of ifOperStatus. We now consider an
interface up when it is running AND the link is not down (that is, it is
up or unknown). If the interface is running but the link is down, we return
state 'dormant', because we're waiting for an external event. Otherwise
the interface is 'down'.

Submitted by:	csjp
Reviewed by:	glebius
2005-11-02 14:05:49 +00:00
Hartmut Brandt
69292ced51 Virgin import of bsnmpd 1.10 2005-05-23 11:19:11 +00:00
Hartmut Brandt
94caccb357 Virgin import of bsnmpd 1.8 2005-02-28 17:27:11 +00:00
Hartmut Brandt
896052c10f Virgin import of bsnmpd 1.7 2004-08-06 13:38:30 +00:00
Hartmut Brandt
8eecd77ad5 Import of bsnmpd 1.6 2004-04-14 16:20:14 +00:00
Hartmut Brandt
70af00a124 Virgin import of bsnmpd 1.5a 2004-01-23 10:44:47 +00:00
Hartmut Brandt
f06ca4af18 Virgin import of bsnmp 1.4 2003-11-10 08:53:38 +00:00