diff mbox series

net: bridge: set skb->protocol for 802.1Q VLAN packets

Message ID tencent_4B358ADB8A54F04A32CD9933114B8B383606@qq.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: bridge: set skb->protocol for 802.1Q VLAN packets | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be 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: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 5 maintainers not CCed: edumazet@google.com pabeni@redhat.com horms@kernel.org kuba@kernel.org idosch@nvidia.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
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: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 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-2025-03-27--00-00 (tests: 896)

Commit Message

inuc@qq.com March 26, 2025, 6:11 p.m. UTC
From: Liu Jie <inuc@qq.com>

When bridging locally originated VLAN-tagged packets, we must ensure
skb->protocol is properly set to ETH_P_8021Q. Currently, if this field
remains unset, br_allowed_ingress() may incorrectly drop valid VLAN
packets during the bridge transmission path.

Fix this by explicitly checking eth_hdr(skb)->h_proto for VLAN tags when
handling locally generated packets.

Signed-off-by: Liu Jie <inuc@qq.com>
---
 net/bridge/br_device.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Nikolay Aleksandrov March 27, 2025, 10:45 p.m. UTC | #1
On 3/26/25 20:11, inuc@qq.com wrote:
> From: Liu Jie <inuc@qq.com>
> 
> When bridging locally originated VLAN-tagged packets, we must ensure
> skb->protocol is properly set to ETH_P_8021Q. Currently, if this field
> remains unset, br_allowed_ingress() may incorrectly drop valid VLAN
> packets during the bridge transmission path.
> 
> Fix this by explicitly checking eth_hdr(skb)->h_proto for VLAN tags when
> handling locally generated packets.
> 
> Signed-off-by: Liu Jie <inuc@qq.com>
> ---
>   net/bridge/br_device.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
> index 0ab4613aa..9094ba7e4 100644
> --- a/net/bridge/br_device.c
> +++ b/net/bridge/br_device.c
> @@ -63,6 +63,9 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
>   	skb_reset_mac_header(skb);
>   	skb_pull(skb, ETH_HLEN);
>   
> +	if (eth_hdr(skb)->h_proto == htons(ETH_P_8021Q))
> +		skb->protocol = htons(ETH_P_8021Q);
> +
>   	if (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, &vid,
>   				&state, &vlan))
>   		goto out;

Why do you think the protocol is incorrect? Did you see a problem with
some particular setup?
diff mbox series

Patch

diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 0ab4613aa..9094ba7e4 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -63,6 +63,9 @@  netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
 	skb_reset_mac_header(skb);
 	skb_pull(skb, ETH_HLEN);
 
+	if (eth_hdr(skb)->h_proto == htons(ETH_P_8021Q))
+		skb->protocol = htons(ETH_P_8021Q);
+
 	if (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, &vid,
 				&state, &vlan))
 		goto out;