diff mbox series

[net-next,1/9] net: vlan: don't adjust MAC header in __vlan_insert_inner_tag() unless set

Message ID 20230322233823.1806736-2-vladimir.oltean@nxp.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Remove skb_mac_header() dependency in DSA xmit path | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
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: 2561 this patch: 2561
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 526 this patch: 526
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: 2669 this patch: 2669
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0

Commit Message

Vladimir Oltean March 22, 2023, 11:38 p.m. UTC
This is a preparatory change for the deletion of skb_reset_mac_header(skb)
from __dev_queue_xmit(). After that deletion, skb_mac_header(skb) will
no longer be set in TX paths, from which __vlan_insert_inner_tag() can
still be called (perhaps indirectly).

If we don't make this change, then an unset MAC header (equal to ~0U)
will become set after the adjustment with VLAN_HLEN.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 include/linux/if_vlan.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Simon Horman March 23, 2023, 4:08 p.m. UTC | #1
On Thu, Mar 23, 2023 at 01:38:15AM +0200, Vladimir Oltean wrote:
> This is a preparatory change for the deletion of skb_reset_mac_header(skb)
> from __dev_queue_xmit(). After that deletion, skb_mac_header(skb) will
> no longer be set in TX paths, from which __vlan_insert_inner_tag() can
> still be called (perhaps indirectly).
> 
> If we don't make this change, then an unset MAC header (equal to ~0U)
> will become set after the adjustment with VLAN_HLEN.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Florian Fainelli March 23, 2023, 4:30 p.m. UTC | #2
On 3/22/23 16:38, Vladimir Oltean wrote:
> This is a preparatory change for the deletion of skb_reset_mac_header(skb)
> from __dev_queue_xmit(). After that deletion, skb_mac_header(skb) will
> no longer be set in TX paths, from which __vlan_insert_inner_tag() can
> still be called (perhaps indirectly).
> 
> If we don't make this change, then an unset MAC header (equal to ~0U)
> will become set after the adjustment with VLAN_HLEN.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
diff mbox series

Patch

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 6864b89ef868..90b76d63c11c 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -351,7 +351,8 @@  static inline int __vlan_insert_inner_tag(struct sk_buff *skb,
 	/* Move the mac header sans proto to the beginning of the new header. */
 	if (likely(mac_len > ETH_TLEN))
 		memmove(skb->data, skb->data + VLAN_HLEN, mac_len - ETH_TLEN);
-	skb->mac_header -= VLAN_HLEN;
+	if (skb_mac_header_was_set(skb))
+		skb->mac_header -= VLAN_HLEN;
 
 	veth = (struct vlan_ethhdr *)(skb->data + mac_len - ETH_HLEN);