netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] drivers/net/wan/hdlc: Change the default of hard_header_len to 0
@ 2020-09-02 12:07 Xie He
  2020-09-02 22:43 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Xie He @ 2020-09-02 12:07 UTC (permalink / raw)
  To: Krzysztof Halasa, David S. Miller, Jakub Kicinski, netdev, linux-kernel
  Cc: Xie He, Martin Schiller

Change the default value of hard_header_len in hdlc.c from 16 to 0.

Currently there are 6 HDLC protocol drivers, among them:

hdlc_raw_eth, hdlc_cisco, hdlc_ppp, hdlc_x25 set hard_header_len when
attaching the protocol, overriding the default. So this patch does not
affect them.

hdlc_raw and hdlc_fr don't set hard_header_len when attaching the
protocol. So this patch will change the hard_header_len of the HDLC
device for them from 16 to 0.

This is the correct change because both hdlc_raw and hdlc_fr don't have
header_ops, and the code in net/packet/af_packet.c expects the value of
hard_header_len to be consistent with header_ops.

In net/packet/af_packet.c, in the packet_snd function,
for AF_PACKET/DGRAM sockets it would reserve a headroom of
hard_header_len and call dev_hard_header to fill in that headroom,
and for AF_PACKET/RAW sockets, it does not reserve the headroom and
does not call dev_hard_header, but checks if the user has provided a
header of length hard_header_len (in function dev_validate_header).

Cc: Krzysztof Halasa <khc@pm.waw.pl>
Cc: Martin Schiller <ms@dev.tdt.de>
Signed-off-by: Xie He <xie.he.0141@gmail.com>
---
 drivers/net/wan/hdlc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c
index 386ed2aa31fd..9b00708676cf 100644
--- a/drivers/net/wan/hdlc.c
+++ b/drivers/net/wan/hdlc.c
@@ -229,7 +229,7 @@ static void hdlc_setup_dev(struct net_device *dev)
 	dev->min_mtu		 = 68;
 	dev->max_mtu		 = HDLC_MAX_MTU;
 	dev->type		 = ARPHRD_RAWHDLC;
-	dev->hard_header_len	 = 16;
+	dev->hard_header_len	 = 0;
 	dev->needed_headroom	 = 0;
 	dev->addr_len		 = 0;
 	dev->header_ops		 = &hdlc_null_ops;
-- 
2.25.1


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

* Re: [PATCH net] drivers/net/wan/hdlc: Change the default of hard_header_len to 0
  2020-09-02 12:07 [PATCH net] drivers/net/wan/hdlc: Change the default of hard_header_len to 0 Xie He
@ 2020-09-02 22:43 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-09-02 22:43 UTC (permalink / raw)
  To: xie.he.0141; +Cc: khc, kuba, netdev, linux-kernel, ms

From: Xie He <xie.he.0141@gmail.com>
Date: Wed,  2 Sep 2020 05:07:06 -0700

> Change the default value of hard_header_len in hdlc.c from 16 to 0.
> 
> Currently there are 6 HDLC protocol drivers, among them:
> 
> hdlc_raw_eth, hdlc_cisco, hdlc_ppp, hdlc_x25 set hard_header_len when
> attaching the protocol, overriding the default. So this patch does not
> affect them.
> 
> hdlc_raw and hdlc_fr don't set hard_header_len when attaching the
> protocol. So this patch will change the hard_header_len of the HDLC
> device for them from 16 to 0.
> 
> This is the correct change because both hdlc_raw and hdlc_fr don't have
> header_ops, and the code in net/packet/af_packet.c expects the value of
> hard_header_len to be consistent with header_ops.
> 
> In net/packet/af_packet.c, in the packet_snd function,
> for AF_PACKET/DGRAM sockets it would reserve a headroom of
> hard_header_len and call dev_hard_header to fill in that headroom,
> and for AF_PACKET/RAW sockets, it does not reserve the headroom and
> does not call dev_hard_header, but checks if the user has provided a
> header of length hard_header_len (in function dev_validate_header).
> 
> Cc: Krzysztof Halasa <khc@pm.waw.pl>
> Cc: Martin Schiller <ms@dev.tdt.de>
> Signed-off-by: Xie He <xie.he.0141@gmail.com>

Applied, thanks.

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

end of thread, other threads:[~2020-09-02 22:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-02 12:07 [PATCH net] drivers/net/wan/hdlc: Change the default of hard_header_len to 0 Xie He
2020-09-02 22:43 ` 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).