Skip to content

[NX-OS] Bug: show ip mroute summary parser fails on mbps/kbps/gbps bitrate units #970

@bigevilbeard

Description

@bigevilbeard

Description

The parser for show ip mroute summary fails when bitrate values are displayed in units other than "bps" (e.g., mbps, kbps, gbps).

Problem

Pattern p8 in ShowIpMrouteSummary class hardcodes "bps" in the regex and in the dictionary update, causing schema validation failures when NX-OS displays high-traffic multicast routes with "mbps" or other units.

Environment

  • Device: Nexus 9000 switches (VXLAN fabric and non-VXLAN)
  • pyATS version: 25.9
  • genie.libs.parser version: 25.9
  • Parser file: genieparser/src/genie/libs/parser/nxos/show_mcast.py
  • Parser class: ShowIpMrouteSummary

Error Message

Traceback (most recent call last):
  File "src/genie/cli/commands/parser.py", line 339, in genie.cli.commands.parser.ParserCommand.parse
  File "src/genie/conf/base/device.py", line 536, in genie.conf.base.device.Device.parse
  File "src/genie/conf/base/device.py", line 576, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/conf/base/device.py", line 574, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/metaparser/_metaparser.py", line 342, in genie.metaparser._metaparser.MetaParser.parse
  File "src/genie/metaparser/_metaparser.py", line 322, in genie.metaparser._metaparser.MetaParser.parse
  File "src/genie/metaparser/util/schemaengine.py", line 419, in genie.metaparser.util.schemaengine.Schema.validate

genie.metaparser.util.exceptions.SchemaMissingKeyError: Missing keys: [['vrf', 'vrf_prod_1', 'address_family', 'ipv4', 'groups', '239.1.1.32/32', 'source'], ['vrf', 'vrf_prod_1', 'address_family', 'ipv4', 'groups', '239.1.1.33/32', 'source'], ... (47 groups total)]

Reproduction Steps

  1. Run show ip mroute summary vrf <vrf_name> on a VRF with high bitrate multicast traffic
  2. Output shows bitrate as "26.173 mbps" instead of "27.200 bps"
  3. Pattern p8 fails to match the source line because it expects literal "bps"
  4. No source dictionary is created for the group
  5. Parser fails with SchemaMissingKeyError

Root Cause Analysis

The parser works correctly on:

  • VRFs with low traffic (displays as "bps")
  • VRFs with no active sources (displays as "0.000 bps")

Pattern p8 (line ~85):

p8 = re.compile(r'^\s*(?P\S+) +(?P[0-9]+) +(?P[0-9]+) +(?P[0-9]+) +(?P[0-9]+) +'
                r'(?P[0-9.]+) +bps +(?P[0-9]+)$')
                                        ^^^
                                        Hardcoded "bps" - cannot match "mbps"

Expected Behavior

Parser should handle all bitrate units that NX-OS can display:

  • bps (bits per second)
  • kbps (kilobits per second)
  • mbps (megabits per second)
  • gbps (gigabits per second)
  • tbps (terabits per second)

Proposed Fix

  1. Update pattern p8 to capture the bitrate unit dynamically:
   p8 = re.compile(r'^\s*(?P\S+) +(?P[0-9]+) +(?P[0-9]+) +(?P[0-9]+) +(?P[0-9]+) +'
                   r'(?P[0-9.]+) +(?P[kmgt]?bps) +(?P[0-9]+)$')
  1. Add conversion logic to normalize all bitrates to bps for consistency:
   conversion_factors = {
       'bps': 1,
       'kbps': 1000,
       'mbps': 1000000,
       'gbps': 1000000000,
       'tbps': 1000000000000
   }
   bitrate_in_bps = bitrate_value * conversion_factors.get(bitrate_unit, 1)
  1. Store normalized value while maintaining schema compatibility:
   'bitrate': bitrate_in_bps,
   'bitrate_unit': 'bps'

Testing Performed

  • Tested after clear ip mroute statistics (0.000 bps) - works
  • Tested with low traffic VRFs (27.200 bps) - works
  • Tested with high traffic VRFs (26.173 mbps) - fails without fix, works with fix
  • Verified same switch, different VRFs behave differently based on traffic levels

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions