Skip to content

Quick fix VLAN detection for named interfaces - #412

Open
LambdaLightSource wants to merge 1 commit into
Solvik:masterfrom
LambdaLightSource:upstream-named-vlan-fix
Open

Quick fix VLAN detection for named interfaces#412
LambdaLightSource wants to merge 1 commit into
Solvik:masterfrom
LambdaLightSource:upstream-named-vlan-fix

Conversation

@LambdaLightSource

Copy link
Copy Markdown

PR title

Fix VLAN detection for named interfaces

PR body

Summary

Fix VLAN detection for interfaces whose names do not end directly in a numeric VLAN ID, for example:

p6p3.vlan9

Problem

The current network interface scan assumes that anything after . can be converted directly to an integer VLAN ID:

vlan = None
if len(interface.split(".")) > 1:
    vlan = int(interface.split(".")[1])

This works for interface names such as eth0.9, but raises a ValueError for valid VLAN interface names such as p6p3.vlan9.

Linux exposes the actual VLAN ID in /proc/net/vlan/<interface>, for example:

p6p3.vlan9  VID: 9

Fix

The new VLAN detection helper:

  • reads the VLAN ID from /proc/net/vlan/<interface> when available
  • preserves existing support for numeric dotted names such as eth0.9
  • handles names such as p6p3.vlan9
  • returns no VLAN instead of raising an exception for unrelated dotted interface names
  • falls back safely if kernel VLAN metadata is unavailable or unusable

Tests

Added regression coverage for:

  • kernel-reported VLAN IDs such as p6p3.vlan9
  • existing numeric suffixes such as eth0.9 and eno1.50
  • non-numeric dotted interface names
  • unusable kernel VLAN metadata

Validation completed successfully:

4 VLAN regression tests passed
7 tests/network.py tests passed
ruff check passed
ruff format --check passed

@LambdaLightSource LambdaLightSource changed the title Fix VLAN detection for named interfaces Quick fix VLAN detection for named interfaces Sep 11, 2026
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.

1 participant