Skip to content

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

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

[Nexthop][fboss2-dev] fboss2-dev switchport access vlan: validate VLAN exists before commit#1179
hillol-nexthop wants to merge 2 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(). 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 that the VLAN exists 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.
  • CmdConfigInterfaceSwitchportAccessVlanTest.cpp: fixture now seeds sw.vlans; added a negative test for the rejection path and assert the running config is unchanged after the throw.

Note: the redundant ConfigSessionRestartTest removal that previously rode along with this PR has been split out into #1202.

Test plan

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

@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
@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
mabel-bot Bot and others added 2 commits May 18, 2026 10:30
Signed-off-by: mabel-bot[bot] <266911995+mabel-bot[bot]@users.noreply.github.com>
@hillol-nexthop hillol-nexthop force-pushed the fboss2-dev-switchport-access-vlan branch from af1d442 to d7f89e2 Compare May 18, 2026 10:30
@hillol-nexthop hillol-nexthop force-pushed the fboss2-dev-switchport-access-vlan branch from d7f89e2 to 041142e Compare May 18, 2026 17:35
meta-codesync Bot pushed a commit that referenced this pull request May 18, 2026
Summary:
Remove `fboss/cli/fboss2/test/integration_test/ConfigSessionRestartTest.cpp` and its references in the cmake and BUCK file lists. This test is redundant — feature-specific integration tests (e.g. the switchport access vlan test) exercise the same config-session restart path.

Split out from #1179 so the cleanup can land independently of the VLAN validation change.

- `cmake/CliFboss2TestIntegrationTest.cmake`: drop entry.
- `fboss/cli/fboss2/test/integration_test/BUCK`: drop entry.
- `fboss/cli/fboss2/test/integration_test/ConfigSessionRestartTest.cpp`: delete.

Pull Request resolved: #1202

Test Plan:
- [x] `pre-commit run`
- [x] Build still succeeds with the file and references removed.

Differential Revision: D105598823

Pulled By: joseph5wu

fbshipit-source-id: c9b34b7b5e95d23a2bbc6ca8251aa6221b368dbb
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 21, 2026

@joseph5wu has imported this pull request. If you are a Meta employee, you can view this in D105998364.

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 21, 2026

@joseph5wu merged this pull request in 3132703.

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