diff mbox series

[net-next,2/2] tc vlan: adjust network header in tcf_vlan_act

Message ID 20240711070828.2741351-3-boris.sukholitko@broadcom.com (mailing list archive)
State Deferred
Delegated to: Netdev Maintainers
Headers show
Series tc: adjust network header after second vlan push | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 816 this patch: 816
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 821 this patch: 821
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 821 this patch: 821
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-07-11--18-00 (tests: 696)

Commit Message

Boris Sukholitko July 11, 2024, 7:08 a.m. UTC
When double-tagged VLAN packet enters Linux network stack the outer
vlan is stripped and copied to the skb. As a result, skb->data points
to the inner vlan.

When second vlan is pushed by tcf_vlan_act, skb->mac_len will be advanced
by skb_vlan_push. As a result, the final skb_pull_rcsum will have
network header pointing to the inner protocol header (e.g. IP) rather than
inner vlan as expected. This causes a problem with further TC processing
as __skb_flow_dissect expects the network header to point to the inner
vlan.

To fix this problem, we disable skb->mac_len advancement and reset
network header and mac_len at the end of tcf_vlan_act.

Signed-off-by: Boris Sukholitko <boris.sukholitko@broadcom.com>
---
 net/sched/act_vlan.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c
index f60cf7062572..8de6f363885b 100644
--- a/net/sched/act_vlan.c
+++ b/net/sched/act_vlan.c
@@ -51,7 +51,7 @@  TC_INDIRECT_SCOPE int tcf_vlan_act(struct sk_buff *skb,
 	case TCA_VLAN_ACT_PUSH:
 		err = skb_vlan_push(skb, p->tcfv_push_proto, p->tcfv_push_vid |
 				    (p->tcfv_push_prio << VLAN_PRIO_SHIFT),
-				    VLAN_HLEN);
+				    0);
 		if (err)
 			goto drop;
 		break;
@@ -94,8 +94,11 @@  TC_INDIRECT_SCOPE int tcf_vlan_act(struct sk_buff *skb,
 	}
 
 out:
-	if (skb_at_tc_ingress(skb))
+	if (skb_at_tc_ingress(skb)) {
 		skb_pull_rcsum(skb, skb->mac_len);
+		skb_reset_network_header(skb);
+		skb_reset_mac_len(skb);
+	}
 
 	return action;