Repository navigation
[IOS-XR] Accept hyphens and dots in next-hop VRF names in show route - #1009
Open
atishay-kasliwal wants to merge 1 commit into
Open
atishay-kasliwal wants to merge 1 commit into
atishay-kasliwal wants to merge 1 commit into
Conversation
ShowRouteIpv4 p2/p3 and ShowRouteIpv6 p3 matched "(nexthop in vrf NAME)" with \w+, so a route whose next hop is in a VRF such as ENS-PROD did not match. The route was dropped, and a following path line then used route_dict before it was set, which raised UnboundLocalError. Match any name up to the closing parenthesis instead, and add golden tests for hyphenated and dotted VRF names with multiple paths.
Sripadvallabh
approved these changes
Nov 13, 2026
Sripadvallabh
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the regex scope, schema compatibility, changelog, and IPv4/IPv6 coverage. The change accepts dotted and hyphenated next-hop VRF names without broadening past the closing parenthesis or whitespace.
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.
Description
Fixes #1007.
ShowRouteIpv4p2/p3 andShowRouteIpv6p3 match the optional(nexthop in vrf NAME)with\w+. IOS-XR VRF names can contain hyphens and dots (ENS-PROD,ens.mgmt), and for those the route line matched nothing:[200/0] via ... (nexthop in vrf ENS-PROD), ...) then matched p3 and usedroute_dictbefore any route had set it, which is thecannot access local variable 'route_dict'error in Issue parsing "show route vrf {vrf_name} ipv4 unicast for IOSXR #1007.The output pasted in the issue only shows
vrf defaultnext hops, which already parse; the crash needs a route whose next-hop VRF has a non-word character, which I reproduced with the same command and output shape.The VRF name is now matched as
[^\s)]+(anything up to the closing parenthesis) in those three patterns.ShowRouteIpv6still records it innexthop_in_vrf, now with the full name.Motivation and Context
show route vrf <vrf> ipv4 unicaston IOS-XR crashes or drops routes whenever a next hop is in a VRF with a hyphen or dot in its name.Impact (If any)
None expected. Names that matched
\w+before still match, and the schema is unchanged.Screenshots:
Golden tests, run with
tests/folder_parsing_job.py:ShowRouteIpv4golden19 (the issue's output plus a hyphenated VRF route with two paths and a dotted VRF route) andShowRouteIpv6golden_outpu_9 (hyphenated VRF on path lines). Both fail without the regex change and pass with it.Checklist: