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
F102941926: D39505.diff
Tue, Nov 19, 1:00 AM
Unknown Object (File)
Fri, Oct 25, 2:25 PM
Unknown Object (File)
Mon, Oct 21, 10:58 AM
Unknown Object (File)
Oct 9 2024, 1:58 PM
Unknown Object (File)
Oct 5 2024, 12:49 AM
Unknown Object (File)
Oct 2 2024, 4:27 AM
Unknown Object (File)
Sep 30 2024, 9:05 PM
Unknown Object (File)
Sep 17 2024, 8:00 AM

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 Skipped
Unit
Tests Skipped

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
1417

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.