* [PATCH net] l2tp: ppp: use max L2TP header size for PPP channel hdrlen
@ 2026-03-13 3:47 Qingfang Deng
2026-03-17 2:54 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Qingfang Deng @ 2026-03-13 3:47 UTC (permalink / raw)
To: linux-ppp, James Chapman, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, netdev, linux-kernel
chan.hdrlen is read once at channel registration by
ppp_register_net_channel(), and used to set the PPP net device's
hard_header_len. It was set to PPPOL2TP_L2TP_HDR_SIZE_NOSEQ (6), which
is 4 bytes too small if sequence numbers are later enabled via
setsockopt(PPPOL2TP_SO_SENDSEQ), causing unnecessary skb reallocations
on the TX path.
The setsockopt handler attempted to change netdev's hard_header_len by
updating chan.hdrlen, but the PPP layer never re-reads it after the
registration, so the update had no effect.
Set chan.hdrlen to PPPOL2TP_L2TP_HDR_SIZE_SEQ (10) unconditionally at
registration and remove the ineffective update in setsockopt.
Fixes: 3557baabf280 ("[L2TP]: PPP over L2TP driver core")
Signed-off-by: Qingfang Deng <dqfext@gmail.com>
---
net/l2tp/l2tp_ppp.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index ae4543d5597b..99d6582f41de 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -787,11 +787,12 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr_unsized *userva
goto out_no_ppp;
}
- /* The only header we need to worry about is the L2TP
- * header. This size is different depending on whether
- * sequence numbers are enabled for the data channel.
+ /* Reserve enough headroom for the L2TP header with sequence numbers,
+ * which is the largest possible. This is used by the PPP layer to set
+ * the net device's hard_header_len at registration, which must be
+ * sufficient regardless of whether sequence numbers are enabled later.
*/
- po->chan.hdrlen = PPPOL2TP_L2TP_HDR_SIZE_NOSEQ;
+ po->chan.hdrlen = PPPOL2TP_L2TP_HDR_SIZE_SEQ;
po->chan.private = sk;
po->chan.ops = &pppol2tp_chan_ops;
@@ -1176,12 +1177,6 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
break;
}
session->send_seq = !!val;
- {
- struct pppox_sock *po = pppox_sk(sk);
-
- po->chan.hdrlen = val ? PPPOL2TP_L2TP_HDR_SIZE_SEQ :
- PPPOL2TP_L2TP_HDR_SIZE_NOSEQ;
- }
l2tp_session_set_header_len(session, session->tunnel->version,
session->tunnel->encap);
break;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] l2tp: ppp: use max L2TP header size for PPP channel hdrlen
2026-03-13 3:47 [PATCH net] l2tp: ppp: use max L2TP header size for PPP channel hdrlen Qingfang Deng
@ 2026-03-17 2:54 ` Jakub Kicinski
2026-03-17 3:06 ` Qingfang Deng
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2026-03-17 2:54 UTC (permalink / raw)
To: Qingfang Deng
Cc: linux-ppp, James Chapman, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, netdev, linux-kernel
On Fri, 13 Mar 2026 11:47:31 +0800 Qingfang Deng wrote:
> chan.hdrlen is read once at channel registration by
> ppp_register_net_channel(), and used to set the PPP net device's
> hard_header_len. It was set to PPPOL2TP_L2TP_HDR_SIZE_NOSEQ (6), which
> is 4 bytes too small if sequence numbers are later enabled via
> setsockopt(PPPOL2TP_SO_SENDSEQ), causing unnecessary skb reallocations
> on the TX path.
If the main effect of this patch is that we avoid reallocations I think
this is an optimization and should go to net-next? If there's more to
it please explain in the commit msg a bit more.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] l2tp: ppp: use max L2TP header size for PPP channel hdrlen
2026-03-17 2:54 ` Jakub Kicinski
@ 2026-03-17 3:06 ` Qingfang Deng
0 siblings, 0 replies; 3+ messages in thread
From: Qingfang Deng @ 2026-03-17 3:06 UTC (permalink / raw)
To: Jakub Kicinski
Cc: linux-ppp, James Chapman, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, netdev, linux-kernel
On Tue, Mar 17, 2026 at 10:55 AM Jakub Kicinski <kuba@kernel.org> wrote:
> If the main effect of this patch is that we avoid reallocations I think
> this is an optimization and should go to net-next?
Yes, it is to avoid skb reallocations. I can repost it to net-next.
Regards,
Qingfang
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-17 3:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13 3:47 [PATCH net] l2tp: ppp: use max L2TP header size for PPP channel hdrlen Qingfang Deng
2026-03-17 2:54 ` Jakub Kicinski
2026-03-17 3:06 ` Qingfang Deng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox