Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T6456: Convert "monitor traffic" to modern op-mode wrapper #3601

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

talmakion
Copy link
Contributor

Change Summary

The old "monitor traffic" definition had misaligned arguments under the verbose node and manually offered the same parameter keyword in multiple positions to emulate flexible parameters.

I've wrapped tcpdump for op-mode Python and replicated the "varargs" style from mtr.py/mtr.xml.in to present a few more parameters in a more flexible manner.

Changes to the Makefile were required for recursive varargs lookup.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

Component(s) name

  • op_mode

Proposed changes

The old "monitor traffic" op-mode definition called tcpdump directly, arguments passed through under the uppermost "verbose" node were off by one, so tcpdump would not work properly with verbose + any other following param.

I've adapted the mtr.xml.in/mtr.py op_mode varargs style for monitor traffic, allowing flexible parameter ordering and adding a few more flags (such as hexdump) without an exponential increase in XML complexity.

The previous options available are still intact and will work the same way as before - verbose, save and filter, but they may also be used flexibly in any order. The current documentation for "monitor traffic" is still applicable.

How to test

Running through many variations of each flag, for example:

$ monitor traffic interface eth0.12 numeric hexdump filter 'port ! 22' 
COMMAND: "sudo /usr/bin/tcpdump -nn -X 'port ! 22' -i eth0.12"
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0.12, link-type EN10MB (Ethernet), snapshot length 262144 bytes
01:35:23.644834 STP 802.1d, Config, Flags [none], bridge-id 8000.26:5e:b2:81:0d:28.8001, length 35
        0x0000:  0000 0000 0080 0026 5eb2 810d 2800 0000  .......&^...(...
        0x0010:  0080 0026 5eb2 810d 2880 0100 0014 0002  ...&^...(.......
        0x0020:  000f 0000 0000 00                        .......

(Example shows some debug output I added while working on it: this is removed in the final PR)

Smoketest result

No smoketests appear to apply to individual op_mode changes.

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

The old "monitor traffic" definition had misaligned arguments under the verbose node
and manually offered the same parameter keyword in multiple positions to emulate
flexible parameters.

I've wrapped tcpdump for op-mode and replicated the "varargs" style from mtr.py/mtr.xml.in
to present a few more parameters in a more flexible manner.

Changes to the Makefile were required for recursive varargs lookup.
Copy link

👍
No issues in PR Title / Commit Title

@dmbaturin dmbaturin merged commit e1916a1 into vyos:current Jun 13, 2024
8 checks passed
@talmakion talmakion deleted the bugfix/T6456 branch June 13, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants