lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220511151431.780120-5-vladimir.oltean@nxp.com>
Date:   Wed, 11 May 2022 18:14:30 +0300
From:   Vladimir Oltean <vladimir.oltean@....com>
To:     netdev@...r.kernel.org
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Vladimir Oltean <olteanv@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>
Subject: [PATCH net-next 4/5] net: dsa: tag_brcm: eliminate conditional based on offset from brcm_tag_xmit_ll

Simplify the low-level, common tag insertion procedure by handling the
differences between prepended headers and Ethertype headers outside it.
With this, the prepended header no longer has the check whether to call
dsa_alloc_etype_header() in its code path.

Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
---
 net/dsa/tag_brcm.c | 41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c
index c2610d34386d..ac9cfd418948 100644
--- a/net/dsa/tag_brcm.c
+++ b/net/dsa/tag_brcm.c
@@ -78,27 +78,10 @@
 
 static struct sk_buff *brcm_tag_xmit_ll(struct sk_buff *skb,
 					struct net_device *dev,
-					unsigned int offset)
+					u8 *brcm_tag)
 {
 	struct dsa_port *dp = dsa_slave_to_port(dev);
 	u16 queue = skb_get_queue_mapping(skb);
-	u8 *brcm_tag;
-
-	/* The Ethernet switch we are interfaced with needs packets to be at
-	 * least 64 bytes (including FCS) otherwise they will be discarded when
-	 * they enter the switch port logic. When Broadcom tags are enabled, we
-	 * need to make sure that packets are at least 68 bytes
-	 * (including FCS and tag) because the length verification is done after
-	 * the Broadcom tag is stripped off the ingress packet.
-	 */
-	eth_skb_pad(skb);
-
-	skb_push(skb, BRCM_TAG_LEN);
-
-	if (offset)
-		dsa_alloc_etype_header(skb, BRCM_TAG_LEN);
-
-	brcm_tag = skb->data + offset;
 
 	/* Set the ingress opcode, traffic class, tag enforcment is
 	 * deprecated
@@ -173,10 +156,21 @@ static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb,
 static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb,
 				     struct net_device *dev)
 {
+	/* The Ethernet switch we are interfaced with needs packets to be at
+	 * least 64 bytes (including FCS) otherwise they will be discarded when
+	 * they enter the switch port logic. When Broadcom tags are enabled, we
+	 * need to make sure that packets are at least 68 bytes
+	 * (including FCS and tag) because the length verification is done after
+	 * the Broadcom tag is stripped off the ingress packet.
+	 */
+	eth_skb_pad(skb);
+
 	/* Build the tag after the MAC Source Address */
-	return brcm_tag_xmit_ll(skb, dev, 2 * ETH_ALEN);
-}
+	skb_push(skb, BRCM_TAG_LEN);
+	dsa_alloc_etype_header(skb, BRCM_TAG_LEN);
 
+	return brcm_tag_xmit_ll(skb, dev, dsa_etype_header_pos_tx(skb));
+}
 
 static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev)
 {
@@ -282,8 +276,13 @@ MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_BRCM_LEGACY);
 static struct sk_buff *brcm_tag_xmit_prepend(struct sk_buff *skb,
 					     struct net_device *dev)
 {
+	/* See the padding comment in brcm_tag_xmit() */
+	eth_skb_pad(skb);
+
 	/* tag is prepended to the packet */
-	return brcm_tag_xmit_ll(skb, dev, 0);
+	skb_push(skb, BRCM_TAG_LEN);
+
+	return brcm_tag_xmit_ll(skb, dev, skb->data);
 }
 
 static struct sk_buff *brcm_tag_rcv_prepend(struct sk_buff *skb,
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ