Page MenuHomeFreeBSD

bridge: add vlan filtering support
ClosedPublic

Authored by ivy on May 23 2025, 11:55 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jul 10, 9:30 AM
Unknown Object (File)
Mon, Jul 7, 11:33 AM
Unknown Object (File)
Sun, Jul 6, 5:38 PM
Unknown Object (File)
Sun, Jul 6, 12:21 PM
Unknown Object (File)
Sat, Jul 5, 3:19 PM
Unknown Object (File)
Sat, Jul 5, 7:38 AM
Unknown Object (File)
Fri, Jul 4, 4:52 PM
Unknown Object (File)
Fri, Jul 4, 2:48 PM

Details

Summary

The new ifconfig options 'ifvlan', '+ifvlans' and '-ifvlans' allow the
vlan access list of a bridge port to be configured.

Incoming tagged frames will be dropped if the incoming vlan tag isn't
in the port's access list.

Outgoing frames will be dropped if the outgoing vlan ID isn't in the
port's access list (e.g., for BUM traffic).

This is only enabled if the port's pvid is set to something other than
zero, which is treated as the flag to enable vlan filtering.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ivy requested review of this revision.May 23 2025, 11:55 PM
sbin/ifconfig/ifbridge.c
160

Declaration needs to move up to the top of this block at a minimum, when someone provides more useful feedback to warrant another iteration.

sbin/ifconfig/ifbridge.c
160

i keep forgetting we're not allowed to do this. i'll fix it in my local branch.

ivy marked an inline comment as done.May 24 2025, 12:16 AM
kp added inline comments.
sbin/ifconfig/ifbridge.c
154

Maybe <= DOT1Q_VID_MAX ?

sys/net/if_bridge.c
1943

(Random example picked)

This might be easier if you used BITSET(9). It has macros for bitwise AND/OR/XOR/.. on the entire set at once.

This revision is now accepted and ready to land.May 27 2025, 9:08 AM

update for new vlan filtering behaviour

This revision now requires review to proceed.May 28 2025, 9:32 AM
sbin/ifconfig/ifbridge.c
154

we can't use DOT1Q_VID_* here since they're behind _KERNEL. i've been meaning to fix that and move them to a different header, but i might do that in a followup commit (and fix this at the same time) rather than adding more commits to this stack.

sys/net/if_bridge.c
1943

according to the manual page, bitset(9) isn't available to userland unless _WANT_FREEBSD_BITSET is defined, which means every userland program that includes if_bridgevar.h would have to do that. i'm not very fond of that since it makes the header unnecessarily difficult to use.

sbin/ifconfig/ifbridge.c
154

i decided to just do this: D50570. i'll fix this if that's approved.

use DOT1Q_VID_* constants consistently, now they're available to userland.

also neaten up parse_vlans() a little.

kp added inline comments.
sbin/ifconfig/ifbridge.c
765

We have three near-identical functions here. It might be worth doing something like

static void
setbridge_tagged(if_ctx *ctx, const char *ifn, const char *vlans, int cmd)
...

static void
addbridge_tagged(if_ctx *ctx, const char *ifn, const char *vlans)
{
    setbridge_tagged(ctx, ifn, vlans, BRDG_VLAN_OP_SET);
}
This revision is now accepted and ready to land.May 28 2025, 7:54 PM
  • remove some redundant code in ifconfig
  • use bitset(9) for ifbvlan_set_t instead of rolling our own
This revision now requires review to proceed.May 29 2025, 2:33 AM
This revision is now accepted and ready to land.Tue, Jun 24, 5:38 AM
des added inline comments.
lib/libifconfig/libifconfig_bridge.c
122
132
135
sbin/ifconfig/ifbridge.c
767

(or you can initialize to { 0 })

This revision was automatically updated to reflect the committed changes.