Page MenuHomeFreeBSD

net: Do not overwrite if_vlan's PCP
ClosedPublic

Authored by zlei on Apr 11 2023, 3:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 23 2023, 12:13 AM
Unknown Object (File)
Aug 23 2023, 6:26 AM
Unknown Object (File)
Aug 19 2023, 11:04 PM
Unknown Object (File)
Jul 25 2023, 12:48 AM
Unknown Object (File)
May 29 2023, 7:03 AM
Unknown Object (File)
May 3 2023, 6:34 PM

Details

Summary

In commit c7cffd65c5d8 the function ether_8021q_frame() was slightly
refactored to use pointer of struct ether_8021q_tag as parameter qtag to
include the new option proto.

It is wrong to write to qtag->pcp as it will effectively change the memory
that qtag point to. Unfortunately the transmit routine of if_vlan parses
pointer of the member ifv_qtag of its softc which stores vlan interface's
PCP internally, when transmitting mbufs that contains PCP the vlan
interface's PCP will get overwritten.

Fix by operating on local copy of qtag->pcp.

PR: 273304
Fixes: c7cffd65c5d85 Add support for stacked VLANs (IEEE 802.1ad, AKA Q-in-Q)
MFC after: 3 days

Test Plan
# ifconfig epair create
epair0a
# ifconfig epair0a.10 create vlanpcp 7 inet 192.0.2.1/24
# jail -ic vnet persist
1
# ifconfig epair0b vnet 1
# jexec 1 ifconfig epair0b up
# jexec 1 ifconfig epair0b.10 create inet 192.0.2.2/24
# ping -C1 -c1 -t1 -q 192.0.2.2
# ifconfig epair0a.10 | grep vlanpcp
	vlan: 10 vlanproto: 802.1q vlanpcp: 7 parent interface: epair0a

Diff Detail

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

Event Timeline

zlei requested review of this revision.Apr 11 2023, 3:35 PM

@melifaro Shall I create a PR for it ?

sys/net/if_ethersubr.c
1439

I'd rather move this per-flow PCP check out of ether_8021q_frame().
Although it will repeat a little but the logic will be much clear.

It is a simple quick fix, I'd like to commit this soon, if no objections.

kp added a subscriber: kp.

This looks sane to me. I wonder if we shouldn't mark 'struct ether_8021q_tag' as const here. That would have picked up this bug during compilation.

This revision is now accepted and ready to land.Aug 23 2023, 8:11 AM
In D39505#947049, @kp wrote:

This looks sane to me. I wonder if we shouldn't mark 'struct ether_8021q_tag' as const here. That would have picked up this bug during compilation.

Good catch !

This revision was automatically updated to reflect the committed changes.