fix: vlan id 4094 rejected and vlan 0 removable in vde_switch - #80
Merged
Merged
Conversation
vlancreate() bounded the id with 'vlan < NUMOFVLAN-1', which excludes 4094 even though only 4095 (NOVLAN) is reserved; vlanaddport() and vlandelport() had the same off-by-one. Use NUMOFVLAN as the bound. vlanremove() accepted vlan 0, the default untagged vlan: once removed, vlant[0].table is freed and portadd() dereferences it when a new port is created (crash reported in #23). Forbid removing vlan 0 and add a defensive NULL check at the portadd() site. Fixes #48, fixes #23.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
VLAN 4094 remains rejected by management print operations.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Fixes VLAN boundary handling and prevents removal of reserved VLAN 0.
Changes:
- Allows VLAN 4094 in create/add/delete operations.
- Rejects VLAN 0 removal and defensively checks its table.
| File | Description |
|---|---|
src/vde_switch/port.c |
Updates VLAN validation and protects default VLAN allocation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
vlanprint(), vlanprintall() (port.c) and fstprint() (fstp.c) capped the explicit vlan argument at NUMOFVLAN-1, so 'vlan/print 4094', 'vlan/allprint 4094' and 'fstp/print 4094' returned EINVAL for a valid VLAN, while the no-argument forms and the create path accepted it. Widen the bound to < NUMOFVLAN. Addresses Copilot review on PR #80.
rd235
approved these changes
Oct 3, 2026
rd235
left a comment
Member
There was a problem hiding this comment.
VLAN 4095 was erroneously forbidden, fix ok.
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.

Fixes #48, #23
Verified: host build passes.