Skip to content

Fix nxos sh lldp nei with multiline data - #2357

Draft
mjbear wants to merge 5 commits into
networktocode:masterfrom
mjbear:nxos_sh_lldp_nei_multiline-fix
Draft

mjbear wants to merge 5 commits into
networktocode:masterfrom
mjbear:nxos_sh_lldp_nei_multiline-fix

Conversation

@mjbear

@mjbear mjbear commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Bug located when reviewing PR #2356

LLDP neighbors with a long name cause the data to be split over two lines.
Because there can be trailing spaces after the long name, the line pattern needed adjusted so it would match correctly and capture the name.

jacqueswindt-gif and others added 5 commits August 27, 2026 13:26
`show lldp neighbors` silently dropped any neighbour whose LLDP system name
contains a space. `NEIGHBOR_NAME` is `(\S+)`, so on a row reading
`Office Access Point  Eth1/5  120  BR  wlan0` the record rule cannot match:
`Office` is taken as the name, `Access` as the local interface, and the
`\s+\d+` that follows then meets `Point` instead of a hold-time. The bare-name
rule does not match either, the line being more than one token, so the row is
discarded. Every other neighbour parses, so the result is a short list rather
than an error -- on the switch where this was found, 17 of 18 came back.

Two changes, and both are needed.

`NEIGHBOR_NAME` becomes `(\S+(?:\s\S+)*?)`, one or more whitespace-separated
tokens, non-greedy. The record rules anchor on the hold-time digits after the
local interface, which is what stops the name swallowing the rest of the line.
The group is non-capturing so `test_unused_capture_group` stays satisfied.

A rule consuming `Total entries displayed` is added at the top of the LLDP
state, and that one is not cosmetic. `Total entries displayed: 2` is also a
line of words, so with a permissive name it matches the bare-name rule, fills
NEIGHBOR_NAME after the last Record, and TextFSM's implicit EOF rule emits it
as an extra row. The name change alone regresses both existing fixtures;
consuming that line first is what makes it safe.

The wrapped-name rules are untouched, and the `multiline` fixture that covers
them parses byte-identically -- 15 rows before and after, as does the other
fixture at 3.
Part of the regex had an asterisk (zero or more) so it does
not need a question mark to make it optional (it is already
optional at zero or more).
* Add Error directive
* Fix neighbor name pattern when name and other data are on
  two different lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants