netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kurt Kanzenbach <kurt@linutronix.de>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andriin@fb.com>,
	Antoine Tenart <atenart@kernel.org>, Wei Wang <weiwan@google.com>,
	Cong Wang <cong.wang@bytedance.com>,
	Taehee Yoo <ap420073@gmail.com>,
	Jesper Dangaard Brouer <brouer@redhat.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net v2] net: Reset MAC header for direct packet transmission
Date: Mon, 29 Mar 2021 12:30:37 +0200	[thread overview]
Message-ID: <878s661cc2.fsf@kurt> (raw)
In-Reply-To: <CANn89iJfLQwADLMw6A9J103qM=1y3O6ki1hQMb3cDuJVrwAkrg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3027 bytes --]

On Mon Mar 29 2021, Eric Dumazet wrote:
> Note that last year, I addressed the issue differently in commit
> 96cc4b69581db68efc9749ef32e9cf8e0160c509
> ("macvlan: do not assume mac_header is set in macvlan_broadcast()")
> (amended with commit 1712b2fff8c682d145c7889d2290696647d82dab
> "macvlan: use skb_reset_mac_header() in macvlan_queue_xmit()")
>
> My reasoning was that in TX path, when ndo_start_xmit() is called, MAC
> header is essentially skb->data,
> so I was hoping to _remove_ skb_reset_mac_header(skb) eventually from
> the fast path (aka __dev_queue_xmit),
> because most drivers do not care about MAC header, they just use skb->data.
>
> I understand it is more difficult to review drivers instead of just
> adding more code in  __dev_direct_xmit()
>
> In hsr case, I do not really see why the existing check can not be
> simply reworked ?

It can be reworked, no problem. I just thought it might be better to add
it to the generic code just in case there are more drivers suffering
from the issue.

>
> mac_header really makes sense in input path, when some layer wants to
> get it after it has been pulled.
>
> diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
> index ed82a470b6e154be28d7e53be57019bccd4a964d..cda495cb1471e23e6666c1f2e9d27a01694f997f
> 100644
> --- a/net/hsr/hsr_forward.c
> +++ b/net/hsr/hsr_forward.c
> @@ -555,11 +555,7 @@ 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;
> -       }
> +       skb_reset_mac_header(skb);

hsr_forward_skb() has four call sites. Three of them make sure that the
header is properly set. The Tx path does not. So, maybe something like
below?

Thanks,
Kurt

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;
-       }
-

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2021-03-29 10:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29  7:17 [PATCH net v2] net: Reset MAC header for direct packet transmission Kurt Kanzenbach
2021-03-29  8:51 ` Eric Dumazet
2021-03-29 10:30   ` Kurt Kanzenbach [this message]
2021-03-29 12:13     ` Eric Dumazet
2021-03-29 12:41       ` Julian Wiedmann
2021-03-29 13:17         ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878s661cc2.fsf@kurt \
    --to=kurt@linutronix.de \
    --cc=andriin@fb.com \
    --cc=ap420073@gmail.com \
    --cc=ast@kernel.org \
    --cc=atenart@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=brouer@redhat.com \
    --cc=cong.wang@bytedance.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=weiwan@google.com \
    --cc=willemdebruijn.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).