2021-02-06 03:29:46

by Xie He

[permalink] [raw]
Subject: [PATCH net-next] net/packet: Improve the comment about LL header visibility criteria

The "dev_has_header" function, recently added in
commit d549699048b4 ("net/packet: fix packet receive on L3 devices
without visible hard header"),
is more accurate as criteria for determining whether a device exposes
the LL header to upper layers, because in addition to dev->header_ops,
it also checks for dev->header_ops->create.

When transmitting an skb on a device, dev_hard_header can be called to
generate an LL header. dev_hard_header will only generate a header if
dev->header_ops->create is present.

Signed-off-by: Xie He <[email protected]>
---
net/packet/af_packet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 6bbc7a448593..e24b2841c643 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -132,17 +132,17 @@ Resume
because it is invisible to us.


On transmit:
------------

-dev->header_ops != NULL
+dev_has_header(dev) == true
mac_header -> ll header
data -> ll header

-dev->header_ops == NULL (ll header is invisible to us)
+dev_has_header(dev) == false (ll header is invisible to us)
mac_header -> data
data -> data

We should set network_header on output to the correct position,
packet classifier depends on it.
*/
--
2.27.0


2021-02-06 04:08:08

by Willem de Bruijn

[permalink] [raw]
Subject: Re: [PATCH net-next] net/packet: Improve the comment about LL header visibility criteria

On Fri, Feb 5, 2021 at 5:42 PM Xie He <[email protected]> wrote:
>
> The "dev_has_header" function, recently added in
> commit d549699048b4 ("net/packet: fix packet receive on L3 devices
> without visible hard header"),
> is more accurate as criteria for determining whether a device exposes
> the LL header to upper layers, because in addition to dev->header_ops,
> it also checks for dev->header_ops->create.
>
> When transmitting an skb on a device, dev_hard_header can be called to
> generate an LL header. dev_hard_header will only generate a header if
> dev->header_ops->create is present.
>
> Signed-off-by: Xie He <[email protected]>

Acked-by: Willem de Bruijn <[email protected]>

Indeed, existence of dev->header_ops->create is the deciding factor. Thanks Xie.

2021-02-06 18:19:42

by Eyal Birger

[permalink] [raw]
Subject: Re: [PATCH net-next] net/packet: Improve the comment about LL header visibility criteria

Hi,

On Sat, Feb 6, 2021 at 4:52 AM Willem de Bruijn
<[email protected]> wrote:
>
> On Fri, Feb 5, 2021 at 5:42 PM Xie He <[email protected]> wrote:
> >
> > The "dev_has_header" function, recently added in
> > commit d549699048b4 ("net/packet: fix packet receive on L3 devices
> > without visible hard header"),
> > is more accurate as criteria for determining whether a device exposes
> > the LL header to upper layers, because in addition to dev->header_ops,
> > it also checks for dev->header_ops->create.
> >
> > When transmitting an skb on a device, dev_hard_header can be called to
> > generate an LL header. dev_hard_header will only generate a header if
> > dev->header_ops->create is present.
> >
> > Signed-off-by: Xie He <[email protected]>
>
> Acked-by: Willem de Bruijn <[email protected]>
>
> Indeed, existence of dev->header_ops->create is the deciding factor. Thanks Xie.

As such, may I suggest making this explicit by making
dev_hard_header() use dev_has_header()?

Eyal.

2021-02-06 19:37:47

by Xie He

[permalink] [raw]
Subject: Re: [PATCH net-next] net/packet: Improve the comment about LL header visibility criteria

On Sat, Feb 6, 2021 at 7:43 AM Eyal Birger <[email protected]> wrote:
>
> As such, may I suggest making this explicit by making
> dev_hard_header() use dev_has_header()?

That is a good idea. We may submit another patch for that.

2021-02-07 00:59:54

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH net-next] net/packet: Improve the comment about LL header visibility criteria

On Fri, 5 Feb 2021 21:51:36 -0500 Willem de Bruijn wrote:
> On Fri, Feb 5, 2021 at 5:42 PM Xie He <[email protected]> wrote:
> >
> > The "dev_has_header" function, recently added in
> > commit d549699048b4 ("net/packet: fix packet receive on L3 devices
> > without visible hard header"),
> > is more accurate as criteria for determining whether a device exposes
> > the LL header to upper layers, because in addition to dev->header_ops,
> > it also checks for dev->header_ops->create.
> >
> > When transmitting an skb on a device, dev_hard_header can be called to
> > generate an LL header. dev_hard_header will only generate a header if
> > dev->header_ops->create is present.
> >
> > Signed-off-by: Xie He <[email protected]>
>
> Acked-by: Willem de Bruijn <[email protected]>
>
> Indeed, existence of dev->header_ops->create is the deciding factor. Thanks Xie.

Applied, thanks!