From nobody Tue Apr 7 01:01:29 2026 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 995831E5702 for ; Tue, 17 Mar 2026 05:41:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773726111; cv=none; b=Nyvbg69sTxJ5Ggega7svzmYtDLoCoq8IA4Oim9q4mpGg4nXDiEzbeN27WHVdi36gyxytmNBB1M7e5mhEKhAUIVJhbbfqC9bR+1rRSAuqha5xHcQcAS62lM9kbTH+tueu6Iy8ivFFjYIrCQy4g15YKIxmZYP0wAnLxuhr6hll/Mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773726111; c=relaxed/simple; bh=bltp3WJAylvLdfOQ5q+iE7Igpst4STCCh4hr4m1hx5E=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=M6TofIDsEOUJcXbY9SsvEoVBoBthjS9KoIufHslW0Y2XcHGqo6h6mDIz4GHjv3G/EvEfkEsrdqnbAagaD3kBeKcoQEnOQZxaHXKPNrROZ1W07I5YbmXd4iDlnSIrQDWO9hJXU5bCuNbVGrg8xzWfB5JCwRva31nAPiRh3nZe/kY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XdM7Lny4; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XdM7Lny4" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-b97ba4c2be2so228803966b.1 for ; Mon, 16 Mar 2026 22:41:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773726109; x=1774330909; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=/aseV1JohbHZtQxOSTDVIyaCJRT3wIWyomxb4YwbsJs=; b=XdM7Lny4kDM5mG8unAVNW/01cajvbi3iCjTsI9k25xzGVVUoaFwbKfY8MhSEh7yPu6 OnLqcNNBGnVF1g8soXk1NXdO3W+VVQ+QsY+zeykMfD4dyKZvshTv/kv/dykVoKv1Qv25 PuOscBnQffthI7f5Fd6816DUmIAhy0W279Q/WkYloqmfhgkJAAU3wNJXbYejZV+xWTqO JV1U+cKePKPXs03/xAlkAMwfmSAg/1W5ri+H/2rlZmuSAtnQXXRTocch5H9wKrnGOOTF lhihCQ6N30Qt5CmCpdPbvCsZjwayOq7gq7uuvVoLcaZdqaY24DaoOhDjWBjQOqcJh5DK nrkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773726109; x=1774330909; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/aseV1JohbHZtQxOSTDVIyaCJRT3wIWyomxb4YwbsJs=; b=O71PEjCXZIuOFbgWwlzr3IjHye5/IQhIcbsZsY9Ud7NQfQfvJMMCLOAVgB0jCpYzkY Y6us+MXiH9ux4CoelNFCE6yPfUrIketfe1jF2cFYL+LOwfaOpMNDF/Buga17FPFiOCEW /TqHSM6QXQc7q088P4l+rwm/KbUdH1/FyAmtJunI9pk0gLDtKpB+5k1jQXz0MQlni8fI YvGP7YSmEvuCycYZ5qm76clnx85jBWPBwhY45WHTfhacLbsxOb4QmTteG8tRBBdTD56Z 0MTtMLymJcgwElv3+dj4xQAFqLYtph85H7E/kSm/4tbRQh17RMKW2uGQIe6+9beW21F6 qD2g== X-Forwarded-Encrypted: i=1; AJvYcCU7Cy/dYPxqcQ6QXHK2A2D6kT2wwYotKkKDOIZ59WXUUe7MvSkRS86d4xYaUzoDX7KE/svLR7HN74roHUM=@vger.kernel.org X-Gm-Message-State: AOJu0Yxz4UDJmtwqr2D+leGmFT/sNRn407zcYz5jAafSvXffGnwc/fwf CRzlbeSx4KZoImUO5yXSSp72hX5cBGsdSvvCpPtzDPQkO/p9iZYVHFFB X-Gm-Gg: ATEYQzyH9dVRL69d0t7zrMQKCioWDrYuL471vt30IWnbnWMpLDw7WQ5+We36cKJuX7l 6qbTC1CIXdDdu87tG+TwjWlGsVjE2WMDEZCCtU04fi/yRzxWNq67YBSd1KQu3SPZCLaPV98SHIf E5PWhH5son6o6SlH6im+1hWRQ/PHo346DrFJ1BcFtS4L+H1TxhI7YPrkrf+cYUkyRSf/L3oj6zz sqMPvXSLMkD4pKLDkS2Ms692eYlGd7kOhSe05woSSHF9bR3ZQE3kpv32KAalhl0HvbKz5xHkrcV Hw/MeCSzfdV5dAWvCEihXIewbus88Sm8UGGerQ2MbVFrXwVvM31kJvkXlfq5vPmOFrn3mJLJTmH JL9uncS/mpk6stJmZww7fLbMmI9YObaIo3myqTuryEOJogN/zjAbvf4fNPV3nv7HZ9B/6D8JWkB aGl8CaaKU= X-Received: by 2002:a17:907:72c2:b0:b97:b20f:c5b2 with SMTP id a640c23a62f3a-b97b2100569mr440106766b.9.1773726108699; Mon, 16 Mar 2026 22:41:48 -0700 (PDT) Received: from gmail.com ([2a09:bac1:5520::49b:49]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b976cefca43sm687527566b.46.2026.03.16.22.41.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 22:41:47 -0700 (PDT) From: Qingfang Deng To: linux-ppp@vger.kernel.org, James Chapman , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2] l2tp: ppp: use max L2TP header size for PPP channel hdrlen Date: Tue, 17 Mar 2026 13:41:40 +0800 Message-ID: <20260317054141.524879-1-dqfext@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. To avoid the unnecessary reallocations, set chan.hdrlen to PPPOL2TP_L2TP_HDR_SIZE_SEQ (10) unconditionally at registration and remove the ineffective update in the setsockopt callback. Signed-off-by: Qingfang Deng --- v2: rebase to net-next and drop fixes tag - https://lore.kernel.org/netdev/20260313034732.209792-1-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, stru= ct sockaddr_unsized *userva goto out_no_ppp; } =20 - /* 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 =3D PPPOL2TP_L2TP_HDR_SIZE_NOSEQ; + po->chan.hdrlen =3D PPPOL2TP_L2TP_HDR_SIZE_SEQ; =20 po->chan.private =3D sk; po->chan.ops =3D &pppol2tp_chan_ops; @@ -1176,12 +1177,6 @@ static int pppol2tp_session_setsockopt(struct sock *= sk, break; } session->send_seq =3D !!val; - { - struct pppox_sock *po =3D pppox_sk(sk); - - po->chan.hdrlen =3D val ? PPPOL2TP_L2TP_HDR_SIZE_SEQ : - PPPOL2TP_L2TP_HDR_SIZE_NOSEQ; - } l2tp_session_set_header_len(session, session->tunnel->version, session->tunnel->encap); break; --=20 2.43.0