From 686bbe46b04310c5cac955f132958727c1e45b9e Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Mon, 23 Jun 2025 20:47:18 +0200 Subject: [PATCH] Add IF-MIB::ifHighSpeed for >2.5Gbps interfaces Cut a Debian release. --- debian/changelog | 9 +++++++++ src/ifmib/ifmib.go | 30 +++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8868d7b..1797883 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +govpp-snmp-agentx (1.1.1-1) bookworm; urgency=medium + + * Add IF-MIB::ifHighSpeed field (OID 1.3.6.1.2.1.31.1.1.1.15) + * Populate ifHighSpeed with interface speed in Megabits per second + * Implement conditional ifSpeed population (skip for speeds > 2.5Gbps) + * Improve SNMP compliance for high-speed interface reporting + + -- Pim van Pelt Sun, 23 Jun 2025 00:10:00 +0000 + govpp-snmp-agentx (1.1.0-1) bookworm; urgency=medium * Add interface event monitoring with VPP API integration diff --git a/src/ifmib/ifmib.go b/src/ifmib/ifmib.go index 107f003..92ca193 100644 --- a/src/ifmib/ifmib.go +++ b/src/ifmib/ifmib.go @@ -60,6 +60,7 @@ import ( // ifHCOutUcastPkts .11 - Counter64 // ifHCOutMulticastPkts .12 - Counter64 // ifHCOutBroadcastPkts .13 - Counter64 +// ifHighSpeed .15 - Gauge32 (interface speed in Mbps) // ifAlias .18 - DisplayString const ifEntryOID = "1.3.6.1.2.1.2.2.1" @@ -231,14 +232,19 @@ func (m *InterfaceMIB) addIfEntry(iface *api.InterfaceCounters, idx int) { item.Type = pdu.VariableTypeInteger item.Value = mtu - // ifSpeed (.5) - Use real speed if available, otherwise default to 1Gbps - speed := uint32(1000000000) - if details != nil && details.Speed > 0 { - speed = uint32(details.Speed) + // ifSpeed (.5) - Only populate for speeds <= 2.5Gbps (legacy field limitation) + if details != nil && details.Speed > 0 && details.Speed <= 2500000000 { + // Use real speed for interfaces <= 2.5Gbps + item = m.handler.Add(fmt.Sprintf("%s.5.%d", ifEntryOID, idx)) + item.Type = pdu.VariableTypeGauge32 + item.Value = uint32(details.Speed) + } else if details == nil || details.Speed == 0 { + // Default to 1Gbps when speed is unknown + item = m.handler.Add(fmt.Sprintf("%s.5.%d", ifEntryOID, idx)) + item.Type = pdu.VariableTypeGauge32 + item.Value = uint32(1000000000) } - item = m.handler.Add(fmt.Sprintf("%s.5.%d", ifEntryOID, idx)) - item.Type = pdu.VariableTypeGauge32 - item.Value = speed + // For speeds > 2.5Gbps, don't populate ifSpeed field at all // ifPhysAddress (.6) - Use real MAC address if available macAddr := "" @@ -411,6 +417,16 @@ func (m *InterfaceMIB) addIfXTable(iface *api.InterfaceCounters, idx int) { item.Type = pdu.VariableTypeCounter64 item.Value = iface.TxBroadcast.Packets + // ifHighSpeed (.15) - Interface speed in Megabits per second + details := m.interfaceDetails[iface.InterfaceIndex] + speedMbps := uint32(1000) // default 1 Gbps = 1000 Mbps + if details != nil && details.Speed > 0 { + speedMbps = uint32(details.Speed / 1000000) // Convert bps to Mbps + } + item = m.handler.Add(fmt.Sprintf("%s.15.%d", ifXTableOID, idx)) + item.Type = pdu.VariableTypeGauge32 + item.Value = speedMbps + // ifAlias (.18) - Interface description/alias item = m.handler.Add(fmt.Sprintf("%s.18.%d", ifXTableOID, idx)) item.Type = pdu.VariableTypeOctetString