Article View: linux.kernel.netdev
Article #14628[PATCH RFC net 2/3] openvswitch: preserve the L3 header after stacked VLAN pushes
From: Gabriel Goller
Date: Wed, 11 Nov 2026 17:37
Date: Wed, 11 Nov 2026 17:37
104 lines
11331 bytes
11331 bytes
A second VLAN push moves network_header to the in-band VLAN header.
Subsequent OVS set actions still expect it to point at IP, so they can
modify the wrong bytes and corrupt the packet.
OVS needs to retain the L3 header immediately after the push. Repairing
it only in validate_xmit_skb() is too late for intervening actions and
would not cover packets without CHECKSUM_PARTIAL. Keep this fix separate
from TX validation because it protects action execution, not just offload
preparation. Conversely, fixing OVS alone does not protect packets tagged
by tc or BPF before transmit.
The generic skb_vlan_push() layout is retained for tc classification.
The OVS push-then-set selftest fails without this fix and passes with it
in QEMU.
Fixes: 938863727076 ("tc: adjust network header after 2nd vlan push")
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
net/openvswitch/actions.c | 6 +++-
.../selftests/net/openvswitch/openvswitch.sh | 34 ++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 12e339cbf791..bf0bb5e6de2c 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -197,9 +197,10 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key *key)
static int push_vlan(struct sk_buff *skb, struct sw_flow_key *key,
const struct ovs_action_push_vlan *vlan)
{
+ bool tag_present = skb_vlan_tag_present(skb);
int err;
- if (skb_vlan_tag_present(skb)) {
+ if (tag_present) {
invalidate_flow_key(key);
} else {
key->eth.vlan.tci = vlan->vlan_tci;
@@ -207,6 +208,9 @@ static int push_vlan(struct sk_buff *skb, struct sw_flow_key *key,
}
err = skb_vlan_push(skb, vlan->vlan_tpid,
ntohs(vlan->vlan_tci) & ~VLAN_CFI_MASK);
+ /* OVS actions and TX offloads expect network_header to stay at L3. */
+ if (!err && tag_present)
+ skb->network_header += VLAN_HLEN;
skb_reset_mac_len(skb);
return err;
}
diff --git a/tools/testing/selftests/net/openvswitch/openvswitch.sh b/tools/testing/selftests/net/openvswitch/openvswitch.sh
index 21444657a040..339e3e09e643 100755
--- a/tools/testing/selftests/net/openvswitch/openvswitch.sh
+++ b/tools/testing/selftests/net/openvswitch/openvswitch.sh
@@ -28,6 +28,7 @@ tests="
tunnel_metadata ovs: test extraction of tunnel metadata
drop_reason drop: test drop reasons are emitted
pop_vlan vlan: POP_VLAN action strips tag
+ push_vlan_set vlan: SET after stacked VLAN pushes
dec_ttl ttl: dec_ttl decrements IP TTL
flow_set flow-set: Flow modify
action_set set: SET action rewrites fields
@@ -1501,6 +1502,39 @@ test_tunnel_metadata() {
return 0
}
+test_push_vlan_set() {
+ local sbx="test_push_vlan_set"
+ local actions
+
+ sbx_add "$sbx" || return $?
+ ovs_add_dp "$sbx" vlandp || return 1
+ ovs_add_netns_and_veths "$sbx" vlandp \
+ ns1 veth1 ns1veth 192.0.2.1/24 || return 1
+ ovs_add_netns_and_veths "$sbx" vlandp \
+ ns2 veth2 ns2veth 192.0.2.2/24 || return 1
+
+ ovs_add_flow "$sbx" vlandp \
+ 'in_port(1),eth(),eth_type(0x0806),arp()' '2' || return 1
+ ovs_add_flow "$sbx" vlandp \
+ 'in_port(2),eth(),eth_type(0x0806),arp()' '1' || return 1
+ ovs_add_flow "$sbx" vlandp \
+ 'in_port(2),eth(),eth_type(0x0800),ipv4()' '1' || return 1
+
+ # SET must address the IP header while both VLAN tags are present.
+ # Pop them afterwards so the receiver needs no VLAN configuration.
+ actions='push_vlan(vid=200,pcp=0,tpid=0x8100),'
+ actions+='push_vlan(vid=100,pcp=0,tpid=0x8100),'
+ actions+='set(ipv4(src=192.0.2.1,dst=192.0.2.2,'
+ actions+='proto=1,tos=0,ttl=63,frag=0)),pop_vlan,pop_vlan,2'
+ ovs_add_flow "$sbx" vlandp \
+ 'in_port(1),eth(),eth_type(0x0800),ipv4(proto=1),icmp()' \
+ "$actions" || return 1
+ ovs_sbx "$sbx" ip netns exec ns1 ping -c 3 -W 2 \
+ 192.0.2.2 || return 1
+
+ return 0
+}
+
test_pop_vlan() {
local sbx="test_pop_vlan"
sbx_add "$sbx" || return $?
--
2.47.3
Technical Details
Message-ID:
<20261111-net_restore_the-v1-2-6aaeffa601c9@proxmox.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361203-linux-kernel-netdev=dewy.ruReferences:
<20261111-net_restore_the-v1-0-6aaeffa601c9@proxmox.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361203-linux-kernel-netdev=dewy.ru From: g.goller@proxmox.com (Gabriel Goller) Newsgroups: linux.kernel.netdev Subject: [PATCH RFC net 2/3] openvswitch: preserve the L3 header after stacked VLAN pushes Date: Wed, 11 Nov 2026 18:37:50 +0100 Organization: Usenet Network Message-ID: <20261111-net_restore_the-v1-2-6aaeffa601c9@proxmox.com> References: <20261111-net_restore_the-v1-0-6aaeffa601c9@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="904511"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:07Kt+ZmFrYPCl8hdxlcBwrOxJz4= sha256:UnsDDXBwmH5Ovm1t/QPoYRRWF4ibmieSI2VMzoNHwXo= sha1:ySirES9V0s8u0rAUngZ1Qu1b0Vw= sha256:9vMd/7CDwvCccI2l914dbiTSpdSbxa0rXheEdZ6hnCE= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 480CD113F71; Wed, 11 Nov 2026 20:41:28 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b_I5XcuVAhk5; Wed, 11 Nov 2026 20:41:22 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-361203-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=proxmox.com X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 825CD113F6F; Wed, 11 Nov 2026 20:41:18 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id CA6E861AAEA; Wed, 11 Nov 2026 17:39:03 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794418729; b=rATs00NqTv1/fFgfhVK9JklGI4rgYDVPz4UpypSeJnsv4mD4MFWmdYx+FV0bdMYGmmm5 fyuh0oRx38iM3qnIC7KK5zdUB8wZzO8Qmrt+bvyYXBf1AE8Xs20O2qYOkK0xfplLn7r42 zMpUsdRF3YKU15r1ZCTSssNExd+sHQxeanUvyOQsnKTnVAauIGgjQYLyO9bYRRv5LF2xE tvuWxFWPjp7eCwL3ByZyWxwVeGF/C7rG6CECBJfppMezNeSpxZO+VMHBqA1Kxgy1/s1l2 jJFWOk2ZpTdTwmhaan2op0uMVjIIDsAzGH6zDxCCy1lpRVP0fRfUg1NV1VasgEqPcjQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794418729; h=X-Original-To:Received:DMARC-Filter:Received:From:Date:Subject: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Bm-Milter-Handled:X-Bm-Transport-Timestamp; bh=cUbc/Rqi/W6SjVjzL1aeId1mISnneHjYaqTJySRLtyM=; b=Kk3Lak+sSNiuNbqVU1sqALBQUB0Pd+99OTDhhXSef3ZCM4oQkgraHGjbhw0uGhc+QqcY KHOhvi/oZZdlsBpNAtUFHaKupG9+ayBzV4rlsp2JY1Kd3XMjB/32VVw5eX6Un28cvSu9q OzyoWXverXLGH3pZTE+EFK2bhwJ5qidA+vURmEXVYsLBxg9Xxkk6XqRxx8tXd6lRn85I9 oRFlR+b/RlRY+tOxqTDF20HbzusI0VWgJYY+t+esnbyXG8ATRwNI7wDUs77TOrNarwDGH yxS6qW7XrePyKCis0gK5/OW7HMRamhiDU5Y/U5au/BXq89WysqTzwpepsTeoz9q63cQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=proxmox.com; spf=pass smtp.mailfrom=proxmox.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66805606A894; Wed, 11 Nov 2026 17:38:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=94.136.29.106 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794418728; b=nj2uQXNjKRcz9ZlIzj8Pkj2Dy6HBatTjJcI6FUyQU99gnXU9z6oDjlLa0nHeEjhKkP3x H8+xP837SySzcEdY4p4CPjizGmky9DIVN83tEpPYLCggT2deLOvLRuVOSQWnn+Nw0sETe /fj7WOXJEW7gCkHn6okF8wuXzFI7tGj87JGHQjwsrgNWGuCVlGjQUNRSdf0TWvZjAnBht dLHBg1OU9XBuw3Q8efVe+p0RopdvFiGUrsJq+Nhl35B2vJ7hOdYpkR10meZeQ9zxS3Bhp JgC1NFwwOLuQCs4+Pov0KP+IxsqGi0cSte4c7GsZKGiP9ttsQwLrSlbqdHmH3fMfaPg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794418728; h=DMARC-Filter:Received:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Bm-Milter-Handled:X-Bm-Transport-Timestamp; bh=cUbc/Rqi/W6SjVjzL1aeId1mISnneHjYaqTJySRLtyM=; b=XGshcjWdbXoWWyzKU9tbZierIQ7QiXzkdJpHHKtY6+W/izZXAu2Rt/zbcE7O69CSvufu NaTKEpwvrkXDRGYQmXAp+U2IPW55mN3YHWPrfu8e9Jx91qYvgV8V31hmKp52arVbdi5gz 36RHqpCKs2L/+njmurw2NVu0xfsf117SCOTCdJVmzIF59rz3mAOnfFEixIM1zXA0Ysy8/ 5YOxkdY0iloGGGpsoe30B2wruBRYK/INmacHQl/7ZteezrcUscj9yZ593cdngQBN+fHH2 qgEmx+PuL0FJJDdF4CYIY42L57ce7vRxRXPtNqdXECHYq/nBN5jAz0FdrgNQ6RR+okg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=proxmox.com; spf=pass smtp.mailfrom=proxmox.com; arc=none smtp.remote-ip=94.136.29.106 X-Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B4A0606A326; Wed, 11 Nov 2026 17:38:46 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3B4A0606A326 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=proxmox.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proxmox.com X-Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E5405481CD; Wed, 11 Nov 2026 18:38:44 +0100 (CET) X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261111-net_restore_the-v1-0-6aaeffa601c9@proxmox.com> X-Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, dev@openvswitch.org, linux-kselftest@vger.kernel.org, Gabriel Goller <g.goller@proxmox.com> X-Mailer: b4 0.17-dev X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794418723621