Skip to content

Implement strict VLAN validation in sdx-lib to prevent invalid L2VPNs#87

Open
gretelliz wants to merge 2 commits intomainfrom
validate_vlan
Open

Implement strict VLAN validation in sdx-lib to prevent invalid L2VPNs#87
gretelliz wants to merge 2 commits intomainfrom
validate_vlan

Conversation

@gretelliz
Copy link

@gretelliz gretelliz commented Feb 10, 2026

What this PR does

  • Adds validation in sdxlib/validator.py for VLAN values, addressing the issues described in Reject unsupported VLAN keyword “all” client-side and normalize “any” / “untagged” with consistent endpoint checks sdx-controller#496

  • Rejects unsupported "all" keyword

  • Enforces consistency when using special keywords ("any" or "untagged")

  • Prevents mixing special keywords with explicit VLAN IDs

  • Validates numeric VLANs are within the valid range (1–4094)

  • Integrated the validation into create_l2vpn()

  • Added unit tests covering all critical cases:

    • explicit same VLAN → success
    • any + any → success
    • untagged + untagged → success
    • any + explicit → mismatch error
    • untagged + any → mismatch error
    • all + all → unsupported error
    • all + explicit → unsupported error

Related issue

Closes atlanticwave-sdx/sdx-controller#496

Testing

  • All existing tests pass
  • New parametrized tests added in tests/test_validator.py specifically verify the 7 required cases
  • Coverage increased in validator.py and l2vpn.py

To run only the new tests (ignoring the old ones in old_tests/):

pytest --cov=sdxlib --cov-report=term-missing -v tests/

@gretelliz gretelliz requested a review from lmarinve February 10, 2026 22:39
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.

Reject unsupported VLAN keyword “all” client-side and normalize “any” / “untagged” with consistent endpoint checks

1 participant