Netdev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH net v3] net: hsr: Reset MAC header for Tx path
@ 2021-04-06  7:35 Kurt Kanzenbach
  2021-04-06  8:42 ` Eric Dumazet
  2021-04-07 22:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Kurt Kanzenbach @ 2021-04-06  7:35 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Murali Karicheri, Taehee Yoo, Vladimir Oltean,
	George McCollister, Luc Van Oostenryck, Wang Hai,
	Daniel Borkmann, Jesper Dangaard Brouer, Eric Dumazet,
	Willem de Bruijn, Sebastian Andrzej Siewior, netdev,
	Kurt Kanzenbach

Reset MAC header in HSR Tx path. This is needed, because direct packet
transmission, e.g. by specifying PACKET_QDISC_BYPASS does not reset the MAC
header.

This has been observed using the following setup:

|$ ip link add name hsr0 type hsr slave1 lan0 slave2 lan1 supervision 45 version 1
|$ ifconfig hsr0 up
|$ ./test hsr0

The test binary is using mmap'ed sockets and is specifying the
PACKET_QDISC_BYPASS socket option.

This patch resolves the following warning on a non-patched kernel:

|[  112.725394] ------------[ cut here ]------------
|[  112.731418] WARNING: CPU: 1 PID: 257 at net/hsr/hsr_forward.c:560 hsr_forward_skb+0x484/0x568
|[  112.739962] net/hsr/hsr_forward.c:560: Malformed frame (port_src hsr0)

The warning can be safely removed, because the other call sites of
hsr_forward_skb() make sure that the skb is prepared correctly.

Fixes: d346a3fae3ff ("packet: introduce PACKET_QDISC_BYPASS socket option")
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---

Changes since v2:

 * Move skb_reset_mac_header() to hsr_dev_xmit()
 * Remove HSR malformed frame warning

Changes since v1:

 * Move skb_reset_mac_header() to __dev_direct_xmit()
 * Add Fixes tag
 * Target net tree

Previous versions:

 * https://lkml.kernel.org/netdev/20210329071716.12235-1-kurt@linutronix.de/
 * https://lkml.kernel.org/netdev/20210326154835.21296-1-kurt@linutronix.de/

net/hsr/hsr_device.c  | 1 +
 net/hsr/hsr_forward.c | 6 ------
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
index 7444ec6e298e..bfcdc75fc01e 100644
--- a/net/hsr/hsr_device.c
+++ b/net/hsr/hsr_device.c
@@ -217,6 +217,7 @@ static netdev_tx_t hsr_dev_xmit(struct sk_buff *skb, struct net_device *dev)
 	master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
 	if (master) {
 		skb->dev = master->dev;
+		skb_reset_mac_header(skb);
 		hsr_forward_skb(skb, master);
 	} else {
 		atomic_long_inc(&dev->tx_dropped);
diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
index ed82a470b6e1..b218e4594009 100644
--- a/net/hsr/hsr_forward.c
+++ b/net/hsr/hsr_forward.c
@@ -555,12 +555,6 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port)
 {
 	struct hsr_frame_info frame;
 
-	if (skb_mac_header(skb) != skb->data) {
-		WARN_ONCE(1, "%s:%d: Malformed frame (port_src %s)\n",
-			  __FILE__, __LINE__, port->dev->name);
-		goto out_drop;
-	}
-
 	if (fill_frame_info(&frame, skb, port) < 0)
 		goto out_drop;
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v3] net: hsr: Reset MAC header for Tx path
  2021-04-06  7:35 [PATCH net v3] net: hsr: Reset MAC header for Tx path Kurt Kanzenbach
@ 2021-04-06  8:42 ` Eric Dumazet
  2021-04-07 22:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2021-04-06  8:42 UTC (permalink / raw)
  To: Kurt Kanzenbach
  Cc: David S. Miller, Jakub Kicinski, Murali Karicheri, Taehee Yoo,
	Vladimir Oltean, George McCollister, Luc Van Oostenryck,
	Wang Hai, Daniel Borkmann, Jesper Dangaard Brouer,
	Willem de Bruijn, Sebastian Andrzej Siewior, netdev

On Tue, Apr 6, 2021 at 9:35 AM Kurt Kanzenbach <kurt@linutronix.de> wrote:
>
> Reset MAC header in HSR Tx path. This is needed, because direct packet
> transmission, e.g. by specifying PACKET_QDISC_BYPASS does not reset the MAC
> header.
>
> This has been observed using the following setup:
>
> |$ ip link add name hsr0 type hsr slave1 lan0 slave2 lan1 supervision 45 version 1
> |$ ifconfig hsr0 up
> |$ ./test hsr0
>
> The test binary is using mmap'ed sockets and is specifying the
> PACKET_QDISC_BYPASS socket option.
>
> This patch resolves the following warning on a non-patched kernel:
>
> |[  112.725394] ------------[ cut here ]------------
> |[  112.731418] WARNING: CPU: 1 PID: 257 at net/hsr/hsr_forward.c:560 hsr_forward_skb+0x484/0x568
> |[  112.739962] net/hsr/hsr_forward.c:560: Malformed frame (port_src hsr0)
>
> The warning can be safely removed, because the other call sites of
> hsr_forward_skb() make sure that the skb is prepared correctly.
>
> Fixes: d346a3fae3ff ("packet: introduce PACKET_QDISC_BYPASS socket option")
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v3] net: hsr: Reset MAC header for Tx path
  2021-04-06  7:35 [PATCH net v3] net: hsr: Reset MAC header for Tx path Kurt Kanzenbach
  2021-04-06  8:42 ` Eric Dumazet
@ 2021-04-07 22:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-04-07 22:00 UTC (permalink / raw)
  To: Kurt Kanzenbach
  Cc: davem, kuba, m-karicheri2, ap420073, olteanv, george.mccollister,
	luc.vanoostenryck, wanghai38, daniel, brouer, edumazet,
	willemdebruijn.kernel, bigeasy, netdev

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Tue,  6 Apr 2021 09:35:09 +0200 you wrote:
> Reset MAC header in HSR Tx path. This is needed, because direct packet
> transmission, e.g. by specifying PACKET_QDISC_BYPASS does not reset the MAC
> header.
> 
> This has been observed using the following setup:
> 
> |$ ip link add name hsr0 type hsr slave1 lan0 slave2 lan1 supervision 45 version 1
> |$ ifconfig hsr0 up
> |$ ./test hsr0
> 
> [...]

Here is the summary with links:
  - [net,v3] net: hsr: Reset MAC header for Tx path
    https://git.kernel.org/netdev/net/c/9d6803921a16

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06  7:35 [PATCH net v3] net: hsr: Reset MAC header for Tx path Kurt Kanzenbach
2021-04-06  8:42 ` Eric Dumazet
2021-04-07 22:00 ` patchwork-bot+netdevbpf

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git