Skip to content

tcprewrite - fix adding vlan tag with missing options - #994

Merged
fklassen merged 1 commit into
appneta:v4.5.3-beta1from
GabrielGanne:tcprewrite-vlan-tag-fix
Jul 17, 2026
Merged

tcprewrite - fix adding vlan tag with missing options#994
fklassen merged 1 commit into
appneta:v4.5.3-beta1from
GabrielGanne:tcprewrite-vlan-tag-fix

Conversation

@GabrielGanne

Copy link
Copy Markdown
Contributor

Fix an issue where using tcprewrite to add a vlan tag to untagged packets, and omitting either the --enet-vlan-cfi, or the --enet-vlan-pri option, the resulting pcap is truncated by 4 bytes (size of vlan header).

This also changes the following so that the vlan tag value is manatory, but the priority and the format are optional:

  • Both options --enet-vlan-pri/--enet-vlan-cfi now explicitly default to 0
  • Add a one-time warning if either option is missing, then proceed and use default
  • update the doc so that --enet-vlan-tag option is marked as mandatory when adding a vlan tag.

The conditions for the issue to happen are a tiny bit more narrow than in the linked issue: for example if the packet is already vlan-tagged, we're not taking the same branch and have no issue (eg. feed the output of the buggy tcprewrite command to itself). Because of this (and following LLM-assisted review advice) I added comments on the branch to explicit the else branches to make it clear this branch is already handled and a warning has been sent during option parsing.

Fixes: #990
Assisted-by: Claude Opus 4.8

Fix an issue where using tcprewrite to add a vlan tag to untagged
packets, and omitting either the --enet-vlan-cfi, or the --enet-vlan-pri
option, the resulting pcap is truncated by 4 bytes (size of vlan
header).

This also changes the following so that the vlan tag value is manatory,
but the priority and the format are optional:
* Both options --enet-vlan-pri/--enet-vlan-cfi now explicitly default to 0
* Add a one-time warning if either option is missing, then proceed and use default
* update the doc so that --enet-vlan-tag option is marked as mandatory
  when adding a vlan tag.

Fixes: appneta#990
Assisted-by: Claude Opus 4.8
Signed-off-by: Gabriel Ganne <gabriel.ganne@gmail.com>
@fklassen
fklassen changed the base branch from master to v4.5.3-beta1 July 17, 2026 12:29
fklassen pushed a commit that referenced this pull request Jul 17, 2026
Credits GabrielGanne's fix (#994) for the silent output truncation
reported in #990.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@fklassen
fklassen merged commit 33a0c1f into appneta:v4.5.3-beta1 Jul 17, 2026
3 checks passed
@GabrielGanne
GabrielGanne deleted the tcprewrite-vlan-tag-fix branch July 28, 2026 07:50
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.

[Bug] tcprewrite adding vlan tag with missing options results in broken output

2 participants