Skip to content

[Nexthop][fboss2-dev] fboss2-dev switchport access vlan: validate VLAN exists before commit#1179

Open
hillol-nexthop wants to merge 3 commits into
facebook:mainfrom
nexthop-ai:fboss2-dev-switchport-access-vlan
Open

[Nexthop][fboss2-dev] fboss2-dev switchport access vlan: validate VLAN exists before commit#1179
hillol-nexthop wants to merge 3 commits into
facebook:mainfrom
nexthop-ai:fboss2-dev-switchport-access-vlan

Conversation

@hillol-nexthop
Copy link
Copy Markdown
Contributor

@hillol-nexthop hillol-nexthop commented May 11, 2026

Pre-submission checklist

  • I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running pip install -r requirements-dev.txt && pre-commit install
  • pre-commit run

Summary

fboss2-dev config interface <name> switchport access vlan <id> blindly wrote ingressVlan on the port and rewrote the matching vlanPorts entry without checking that the target VLAN existed in config.sw()->vlans() or that it had a corresponding L3 interface in config.sw()->interfaces(). The CLI then printed Config session committed successfully and triggered a warmboot; fboss_sw_agent SIGABRTed during initialization with:

switch initialization failed: VLAN <id> has no interface, even when corresp port <port> is enabled

Validate both conditions up front in queryClient() and throw std::invalid_argument with a descriptive message before touching the config or saving.

  • CmdConfigInterfaceSwitchportAccessVlan.cpp: pre-flight check for VLAN existence + interface presence.
  • CmdConfigInterfaceSwitchportAccessVlanTest.cpp: fixture now seeds sw.vlans / sw.interfaces; added negative tests for both rejection paths and assert the running config is unchanged after the throw.

Also removing RestartTest because this is redundant as feature specific tests like access vlan test would do the same thing.

Test plan

  • Unit tests: queryClientThrowsWhenVlanDoesNotExist, queryClientThrowsWhenVlanHasNoInterface, plus updated positive case still passes against the seeded VLAN.

Signed-off-by: mabel-bot[bot] <266911995+mabel-bot[bot]@users.noreply.github.com>
@meta-cla meta-cla Bot added the CLA Signed label May 11, 2026
@hillol-nexthop hillol-nexthop changed the title fboss2-dev switchport access vlan: validate VLAN exists before commit [Nexthop][fboss2-dev] fboss2-dev switchport access vlan: validate VLAN exists before commit May 11, 2026
@hillol-nexthop hillol-nexthop marked this pull request as ready for review May 11, 2026 09:12
@hillol-nexthop hillol-nexthop requested a review from a team as a code owner May 11, 2026 09:12
@hillol-nexthop hillol-nexthop marked this pull request as draft May 11, 2026 13:27
@hillol-nexthop hillol-nexthop marked this pull request as ready for review May 11, 2026 14:15
Copy link
Copy Markdown
Contributor

@joseph5wu joseph5wu left a comment

Choose a reason for hiding this comment

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

The vlan existence check looks good to me but I'm not sure why do we need the vlan to have interfaces before you can set a port with an access vlan? Wouldn't this cli be used to assign the vlan to a port/interface?

@hillol-nexthop
Copy link
Copy Markdown
Contributor Author

The vlan existence check looks good to me but I'm not sure why do we need the vlan to have interfaces before you can set a port with an access vlan? Wouldn't this cli be used to assign the vlan to a port/interface?

Yes you are right. I have changed it.

@hillol-nexthop hillol-nexthop requested a review from joseph5wu May 13, 2026 05:50
Port upstream removal of fboss/cli/fboss2/test/integration_test/
ConfigSessionRestartTest.cpp and its references (cmake and BUCK file
lists) from facebook#1095.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hillol-nexthop hillol-nexthop requested a review from a team as a code owner May 13, 2026 07:34
@hillol-nexthop hillol-nexthop force-pushed the fboss2-dev-switchport-access-vlan branch from 0473660 to af1d442 Compare May 15, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants