linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net/packet: Fix a comment about mac_header
@ 2020-09-16 12:23 Xie He
  2020-09-17  8:50 ` Willem de Bruijn
  2020-09-17 23:25 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Xie He @ 2020-09-16 12:23 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, netdev, linux-kernel,
	Willem de Bruijn, John Ogness, Wang Hai, Arnd Bergmann
  Cc: Xie He

1. Change all "dev->hard_header" to "dev->header_ops"

2. On receiving incoming frames when header_ops == NULL:

The comment only says what is wrong, but doesn't say what is right.
This patch changes the comment to make it clear what is right.

3. On transmitting and receiving outgoing frames when header_ops == NULL:

The comment explains that the LL header will be later added by the driver.

However, I think it's better to simply say that the LL header is invisible
to us. This phrasing is better from a software engineering perspective,
because this makes it clear that what happens in the driver should be
hidden from us and we should not care about what happens internally in the
driver.

4. On resuming the LL header (for RAW frames) when header_ops == NULL:

The comment says we are "unlikely" to restore the LL header.

However, we should say that we are "unable" to restore it.
It's not possible (rather than not likely) to restore it, because:

1) There is no way for us to restore because the LL header internally
processed by the driver should be invisible to us.

2) In function packet_rcv and tpacket_rcv, the code only tries to restore
the LL header when header_ops != NULL.

Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Signed-off-by: Xie He <xie.he.0141@gmail.com>
---
 net/packet/af_packet.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 2d5d5fbb435c..f59fa26d4826 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -105,42 +105,43 @@
    - packet socket receives packets with pulled ll header,
      so that SOCK_RAW should push it back.
 
 On receive:
 -----------
 
-Incoming, dev->hard_header!=NULL
+Incoming, dev->header_ops != NULL
    mac_header -> ll header
    data       -> data
 
-Outgoing, dev->hard_header!=NULL
+Outgoing, dev->header_ops != NULL
    mac_header -> ll header
    data       -> ll header
 
-Incoming, dev->hard_header==NULL
-   mac_header -> UNKNOWN position. It is very likely, that it points to ll
-		 header.  PPP makes it, that is wrong, because introduce
-		 assymetry between rx and tx paths.
+Incoming, dev->header_ops == NULL
+   mac_header -> data
+     However drivers often make it point to the ll header.
+     This is incorrect because the ll header should be invisible to us.
    data       -> data
 
-Outgoing, dev->hard_header==NULL
-   mac_header -> data. ll header is still not built!
+Outgoing, dev->header_ops == NULL
+   mac_header -> data. ll header is invisible to us.
    data       -> data
 
 Resume
-  If dev->hard_header==NULL we are unlikely to restore sensible ll header.
+  If dev->header_ops == NULL we are unable to restore the ll header,
+    because it is invisible to us.
 
 
 On transmit:
 ------------
 
-dev->hard_header != NULL
+dev->header_ops != NULL
    mac_header -> ll header
    data       -> ll header
 
-dev->hard_header == NULL (ll header is added by device, we cannot control it)
+dev->header_ops == NULL (ll header is invisible to us)
    mac_header -> data
    data       -> data
 
    We should set nh.raw on output to correct posistion,
    packet classifier depends on it.
  */
-- 
2.25.1


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

* Re: [PATCH net-next] net/packet: Fix a comment about mac_header
  2020-09-16 12:23 [PATCH net-next] net/packet: Fix a comment about mac_header Xie He
@ 2020-09-17  8:50 ` Willem de Bruijn
  2020-09-17 10:17   ` Xie He
  2020-09-17 23:25 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Willem de Bruijn @ 2020-09-17  8:50 UTC (permalink / raw)
  To: Xie He
  Cc: David S. Miller, Jakub Kicinski, Network Development,
	linux-kernel, Willem de Bruijn, John Ogness, Wang Hai,
	Arnd Bergmann

On Wed, Sep 16, 2020 at 8:54 PM Xie He <xie.he.0141@gmail.com> wrote:
>
> 1. Change all "dev->hard_header" to "dev->header_ops"
>
> 2. On receiving incoming frames when header_ops == NULL:
>
> The comment only says what is wrong, but doesn't say what is right.
> This patch changes the comment to make it clear what is right.
>
> 3. On transmitting and receiving outgoing frames when header_ops == NULL:
>
> The comment explains that the LL header will be later added by the driver.
>
> However, I think it's better to simply say that the LL header is invisible
> to us. This phrasing is better from a software engineering perspective,
> because this makes it clear that what happens in the driver should be
> hidden from us and we should not care about what happens internally in the
> driver.
>
> 4. On resuming the LL header (for RAW frames) when header_ops == NULL:
>
> The comment says we are "unlikely" to restore the LL header.
>
> However, we should say that we are "unable" to restore it.
> It's not possible (rather than not likely) to restore it, because:
>
> 1) There is no way for us to restore because the LL header internally
> processed by the driver should be invisible to us.
>
> 2) In function packet_rcv and tpacket_rcv, the code only tries to restore
> the LL header when header_ops != NULL.
>
> Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
> Signed-off-by: Xie He <xie.he.0141@gmail.com>

Acked-by: Willem de Bruijn <willemb@google.com>

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

* Re: [PATCH net-next] net/packet: Fix a comment about mac_header
  2020-09-17  8:50 ` Willem de Bruijn
@ 2020-09-17 10:17   ` Xie He
  0 siblings, 0 replies; 4+ messages in thread
From: Xie He @ 2020-09-17 10:17 UTC (permalink / raw)
  To: Willem de Bruijn
  Cc: David S. Miller, Jakub Kicinski, Network Development,
	linux-kernel, John Ogness, Wang Hai, Arnd Bergmann

On Thu, Sep 17, 2020 at 1:51 AM Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>
> Acked-by: Willem de Bruijn <willemb@google.com>

Thank you, Willem!

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

* Re: [PATCH net-next] net/packet: Fix a comment about mac_header
  2020-09-16 12:23 [PATCH net-next] net/packet: Fix a comment about mac_header Xie He
  2020-09-17  8:50 ` Willem de Bruijn
@ 2020-09-17 23:25 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2020-09-17 23:25 UTC (permalink / raw)
  To: xie.he.0141
  Cc: kuba, netdev, linux-kernel, willemdebruijn.kernel, john.ogness,
	wanghai38, arnd

From: Xie He <xie.he.0141@gmail.com>
Date: Wed, 16 Sep 2020 05:23:08 -0700

> 1. Change all "dev->hard_header" to "dev->header_ops"
> 
> 2. On receiving incoming frames when header_ops == NULL:
> 
> The comment only says what is wrong, but doesn't say what is right.
> This patch changes the comment to make it clear what is right.
> 
> 3. On transmitting and receiving outgoing frames when header_ops == NULL:
> 
> The comment explains that the LL header will be later added by the driver.
> 
> However, I think it's better to simply say that the LL header is invisible
> to us. This phrasing is better from a software engineering perspective,
> because this makes it clear that what happens in the driver should be
> hidden from us and we should not care about what happens internally in the
> driver.
> 
> 4. On resuming the LL header (for RAW frames) when header_ops == NULL:
> 
> The comment says we are "unlikely" to restore the LL header.
> 
> However, we should say that we are "unable" to restore it.
> It's not possible (rather than not likely) to restore it, because:
> 
> 1) There is no way for us to restore because the LL header internally
> processed by the driver should be invisible to us.
> 
> 2) In function packet_rcv and tpacket_rcv, the code only tries to restore
> the LL header when header_ops != NULL.
> 
> Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
> Signed-off-by: Xie He <xie.he.0141@gmail.com>

Applied, thank you.

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

end of thread, other threads:[~2020-09-17 23:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16 12:23 [PATCH net-next] net/packet: Fix a comment about mac_header Xie He
2020-09-17  8:50 ` Willem de Bruijn
2020-09-17 10:17   ` Xie He
2020-09-17 23:25 ` David Miller

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).