Support also transmitting frames using the custom "8899 A"
4 byte tag.
Qingfang came up with the solution: we need to pad the
ethernet frame to 60 bytes using eth_skb_pad(), then the
switch will happily accept frames with custom tags.
Cc: Mauri Sandberg <redacted>
Reported-by: DENG Qingfang <dqfext@gmail.com>
Fixes: efd7fe68f0c6 ("net: dsa: tag_rtl4_a: Implement Realtek 4 byte A tag")
Signed-off-by: Linus Walleij <redacted>
---
net/dsa/tag_rtl4_a.c | 43 +++++++++++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 14 deletions(-)
@@ -36,17 +34,34 @@staticstructsk_buff*rtl4a_tag_xmit(structsk_buff*skb,structnet_device*dev){-/*-*Justletitpassthru,wedon'tknowifitispossible-*totagaframewiththe0x8899ethertypeanddirectit-*toaspecificport,allattemptsatreverse-engineeringhave-*endedupwiththeframesgettingdropped.-*-*TheVLANset-upneedstorestricttheframestotherightport.-*-*IfyouhavedocumentationonthetaggingformatforRTL8366RB-*(tagtypeA)thenpleasecontribute.-*/+structdsa_port*dp=dsa_slave_to_port(dev);+u8*tag;+u16*p;+u16out;++/* Pad out to at least 60 bytes */+if(unlikely(eth_skb_pad(skb)))+returnNULL;+if(skb_cow_head(skb,RTL4_A_HDR_LEN)<0)+returnNULL;++netdev_dbg(dev,"add realtek tag to package to port %d\n",+dp->index);+skb_push(skb,RTL4_A_HDR_LEN);++memmove(skb->data,skb->data+RTL4_A_HDR_LEN,2*ETH_ALEN);+tag=skb->data+2*ETH_ALEN;++/* Set Ethertype */+p=(u16*)tag;+*p=htons(RTL4_A_ETHERTYPE);++out=(RTL4_A_PROTOCOL_RTL8366RB<<12)|(2<<8);+/* The lower bits is the port numer */+out|=(u8)dp->index;+p=(u16*)(tag+2);+*p=htons(out);+returnskb;}
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Wed, 17 Feb 2021 00:55:42 +0100 you wrote:
Support also transmitting frames using the custom "8899 A"
4 byte tag.
Qingfang came up with the solution: we need to pad the
ethernet frame to 60 bytes using eth_skb_pad(), then the
switch will happily accept frames with custom tags.
[...]
On 2/16/2021 5:00 PM, patchwork-bot+netdevbpf@kernel.org wrote:
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Wed, 17 Feb 2021 00:55:42 +0100 you wrote:
quoted
Support also transmitting frames using the custom "8899 A"
4 byte tag.
Qingfang came up with the solution: we need to pad the
ethernet frame to 60 bytes using eth_skb_pad(), then the
switch will happily accept frames with custom tags.
[...]
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-02-17 03:30:03
On Wed, Feb 17, 2021 at 12:55:42AM +0100, Linus Walleij wrote:
quoted hunk
Support also transmitting frames using the custom "8899 A"
4 byte tag.
Qingfang came up with the solution: we need to pad the
ethernet frame to 60 bytes using eth_skb_pad(), then the
switch will happily accept frames with custom tags.
Cc: Mauri Sandberg <redacted>
Reported-by: DENG Qingfang <dqfext@gmail.com>
Fixes: efd7fe68f0c6 ("net: dsa: tag_rtl4_a: Implement Realtek 4 byte A tag")
Signed-off-by: Linus Walleij <redacted>
---
net/dsa/tag_rtl4_a.c | 43 +++++++++++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 14 deletions(-)
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-02-17 11:38:43
On Wed, Feb 17, 2021 at 12:55:42AM +0100, Linus Walleij wrote:
Support also transmitting frames using the custom "8899 A"
4 byte tag.
Qingfang came up with the solution: we need to pad the
ethernet frame to 60 bytes using eth_skb_pad(), then the
switch will happily accept frames with custom tags.
I think it's pretty frustrating to realize that 'it didn't werk' because
you only tested with ping.
Cc: Mauri Sandberg <redacted>
Reported-by: DENG Qingfang <dqfext@gmail.com>
Reported-by seems like a bit of an understatement. Suggested-by maybe?
@@ -36,17 +34,34 @@staticstructsk_buff*rtl4a_tag_xmit(structsk_buff*skb,structnet_device*dev){-/*-*Justletitpassthru,wedon'tknowifitispossible-*totagaframewiththe0x8899ethertypeanddirectit-*toaspecificport,allattemptsatreverse-engineeringhave-*endedupwiththeframesgettingdropped.-*-*TheVLANset-upneedstorestricttheframestotherightport.-*-*IfyouhavedocumentationonthetaggingformatforRTL8366RB-*(tagtypeA)thenpleasecontribute.-*/+structdsa_port*dp=dsa_slave_to_port(dev);+u8*tag;+u16*p;+u16out;++/* Pad out to at least 60 bytes */+if(unlikely(eth_skb_pad(skb)))+returnNULL;+if(skb_cow_head(skb,RTL4_A_HDR_LEN)<0)+returnNULL;++netdev_dbg(dev,"add realtek tag to package to port %d\n",+dp->index);
You should probably remove any sort of printing from the hot path.
+ skb_push(skb, RTL4_A_HDR_LEN);
+
+ memmove(skb->data, skb->data + RTL4_A_HDR_LEN, 2 * ETH_ALEN);
+ tag = skb->data + 2 * ETH_ALEN;
+
+ /* Set Ethertype */
+ p = (u16 *)tag;
+ *p = htons(RTL4_A_ETHERTYPE);
+
+ out = (RTL4_A_PROTOCOL_RTL8366RB << 12) | (2 << 8);
+ /* The lower bits is the port numer */
+ out |= (u8)dp->index;
+ p = (u16 *)(tag + 2);
+ *p = htons(out);
+
return skb;
}
--
2.29.2
From: DENG Qingfang <dqfext@gmail.com> Date: 2021-02-17 12:39:45
On Wed, Feb 17, 2021 at 7:55 AM Linus Walleij [off-list ref] wrote:
+
+ /* Pad out to at least 60 bytes */
+ if (unlikely(eth_skb_pad(skb)))
+ return NULL;
I just found that this will cause double free (eth_skb_pad will free
the skb if allocation fails, and dsa_slave_xmit will still try to free
it because it returns NULL.
Replace eth_skb_pad(skb) with __skb_put_padto(skb, ETH_ZLEN, false) to
avoid that.
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-02-17 12:44:21
On Wed, Feb 17, 2021 at 08:38:30PM +0800, DENG Qingfang wrote:
On Wed, Feb 17, 2021 at 7:55 AM Linus Walleij [off-list ref] wrote:
quoted
+
+ /* Pad out to at least 60 bytes */
+ if (unlikely(eth_skb_pad(skb)))
+ return NULL;
I just found that this will cause double free (eth_skb_pad will free
the skb if allocation fails, and dsa_slave_xmit will still try to free
it because it returns NULL.
Replace eth_skb_pad(skb) with __skb_put_padto(skb, ETH_ZLEN, false) to
avoid that.
On Wed, Feb 17, 2021 at 08:38:30PM +0800, DENG Qingfang wrote:
quoted
On Wed, Feb 17, 2021 at 7:55 AM Linus Walleij [off-list ref] wrote:
quoted
+
+ /* Pad out to at least 60 bytes */
+ if (unlikely(eth_skb_pad(skb)))
+ return NULL;
I just found that this will cause double free (eth_skb_pad will free
the skb if allocation fails, and dsa_slave_xmit will still try to free
it because it returns NULL.
Replace eth_skb_pad(skb) with __skb_put_padto(skb, ETH_ZLEN, false) to
avoid that.
That's really a pitfall. I had to do the same in r8169:
cc6528bc9a0c ("r8169: fix potential skb double free in an error path")