Skip to content

fix: vlan id 4094 rejected and vlan 0 removable in vde_switch - #80

Merged
rd235 merged 2 commits into
masterfrom
vde-switch-vlan-fixes
Oct 3, 2026
Merged

rd235 merged 2 commits into
masterfrom
vde-switch-vlan-fixes

Conversation

@danielinux

Copy link
Copy Markdown
Member

Fixes #48, #23

  • Bound the vlan id at port.c:1141 with NUMOFVLAN (4094 was accepted and corrupted the vlan table).
  • Check the return value of vlanaddport().
  • Forbid removal of vlan 0; defensive NULL check at port.c:170.

Verified: host build passes.

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.
Copilot AI balanced review requested due to automatic review settings October 3, 2026 11:37
@danielinux danielinux linked an issue Oct 3, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

VLAN 4094 remains rejected by management print operations.

Review effort: Balanced
Findings: 1 Medium severity

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.

Comment thread src/vde_switch/port.c
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.
@danielinux
danielinux requested a balanced review from Copilot October 3, 2026 11:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@rd235 rd235 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VLAN 4095 was erroneously forbidden, fix ok.

@rd235
rd235 merged commit 5b95a81 into master Oct 3, 2026
2 checks passed
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.

vlancreate command returns EINVAL when vlan id is 4094 vde_switch crashes if vlan # 0 is removed

3 participants