[Nexthop] Guard getNonSflowSampledInterfacePort against an unconfigured management port#1377
Open
sazeed-nexthop wants to merge 1 commit into
Open
Conversation
…ent port
getNonSflowSampledInterfacePort() and getNonSflowSampledInterfacePortType()
index masterLogicalPortIds({PortType::MANAGEMENT_PORT})[0] whenever the ASIC
reports isSupported(HwAsic::Feature::MANAGEMENT_PORT). An ASIC can support the
management-port feature while a given platform configures no management port,
leaving that vector empty so [0] dereferences past the end and the test
crashes during setup.
Guard the management-port branch with !empty() and fall back to
masterLogicalInterfacePortIds()[0] -- the same path taken by platforms whose
ASIC does not support a management port.
Signed-off-by: sazeed-nexthop <sazeed@nexthop.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getNonSflowSampledInterfacePort()andgetNonSflowSampledInterfacePortType()indexmasterLogicalPortIds({cfg::PortType::MANAGEMENT_PORT})[0]whenever the ASIC reportsisSupported(HwAsic::Feature::MANAGEMENT_PORT). An ASIC can support the management-port feature while a given platform configures no management port, leaving that vector empty — so[0]dereferences past the end and the test crashes (SIGSEGV) during setup.Fix
Guard the management-port branch with
!empty()and fall back tomasterLogicalInterfacePortIds()[0]— the same path already taken by platforms whose ASIC does not support a management port. On platforms that do configure a management port there is no behavior change.Test Plan
On a Tomahawk5 / XGS platform that supports
MANAGEMENT_PORTbut configures none, theAgentSflowMirror*tests previously SIGSEGV'd at setup on both cold and warm boot; with this guard they pass. Platforms that configure a management port are unaffected.