Page MenuHomeFreeBSD

sys/net: move DOT1Q_VID_* constants to ethernet.h
ClosedPublic

Authored by ivy on May 28 2025, 10:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Aug 18, 11:57 AM
Unknown Object (File)
Fri, Aug 15, 12:38 AM
Unknown Object (File)
Thu, Aug 14, 10:29 PM
Unknown Object (File)
Sun, Aug 10, 12:54 PM
Unknown Object (File)
Fri, Aug 8, 3:10 PM
Unknown Object (File)
Tue, Jul 29, 12:57 AM
Unknown Object (File)
Mon, Jul 28, 7:02 PM
Unknown Object (File)
Mon, Jul 28, 4:02 PM

Details

Summary

These are generally useful to anything dealing with 802.1q and aren't
specific to if_vlan, so move them to <net/ethernet.h> and remove the
_KERNEL gate.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 64501
Build 61385: arc lint + arc unit

Event Timeline

ivy requested review of this revision.May 28 2025, 10:46 AM

specifically, i want to use these in ifconfig(8) for D50503.

There should be tab, and not space, between '#define' and the starting char of the symbol.

sys/net/ethernet.h
88

What do DEF_PVID and DEF_SR_PVID mean?

sys/net/ethernet.h
88

i had the same question, and it turns out these come from 802.1Q-2014 table 9-2:

  • 1 is "The default PVID value used for classifying frames on ingress through a Bridge Port."
  • 2 is "The default SR_PVID value used for SRP (35.2.1.4(i)) Stream related traffic."

i will add some comments for these.

add some comments.

also fix the value of DOT1Q_VID_MAX, which has been wrong since it was
introduced: it should be 0xffe (4094), not 0xfff (4095). it doesn't
seem to be used anywhere (yet) where this would have any actual impact.

In D50570#1154418, @kib wrote:

There should be tab, and not space, between '#define' and the starting char of the symbol.

they are tabs here. perhaps phabricator doesn't render them properly?

rebase on top of D50576. this moves the DOT1Q_VID_MAX fix to a separate commit so it can be MFC'd.

sys/net/ethernet.h
88

PVID and SR_PVID repeated in comments do not explain much.
My instance of 802.1Q pdf says

PVID port VLAN Identifier
SR_PVID Stream Reservation Port VLAN Identifier

And from what I understand, PVID is the vlan assigned to packets without vlan tag.

This revision is now accepted and ready to land.May 28 2025, 3:47 PM
sys/net/ethernet.h
88

i'm not sure we want to reproduce all of 802.1q in the comments :-) at least there's now enough information for an interested reader to look up more detail.

yes, PVID is the VLAN untagged packets go to, but DEF_PVID is only the default PVID, i.e., if the admin doesn't configure it. the default pvid in bridge(4) is effectively 0 (not 1) and we can't easily change that without breaking everyone's bridges, so i'm not sure we will ever use this... but it doesn't hurt to have it.

sys/net/ethernet.h
89
sys/net/ethernet.h
89

I think it's reasonable to expect that anyone reading this code already knows what a PVID is.