Conversation
`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
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.
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.