From: Qingfang Deng <dqfext@gmail.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Mitchell Blank Jr <mitch@sfgoth.com>,
Simon Horman <horms@kernel.org>,
linux-ppp@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next] ppp: simplify input error handling
Date: Fri, 6 Mar 2026 17:36:49 +0800 [thread overview]
Message-ID: <20260306093649.1048232-1-dqfext@gmail.com> (raw)
Currently, ppp_input_error() indicates an error by allocating a 0-length
skb and calling ppp_do_recv(). It takes an error code argument, which is
stored in skb->cb, but not used by ppp_receive_frame().
Simplify the error handling by removing the unused parameter and the
unnecessary skb allocation. Instead, call ppp_receive_error() directly
from ppp_input_error() under the recv lock, and the length check in
ppp_receive_frame() can be removed.
Signed-off-by: Qingfang Deng <dqfext@gmail.com>
---
drivers/net/ppp/ppp_async.c | 2 +-
drivers/net/ppp/ppp_generic.c | 31 ++++++++++---------------------
drivers/net/ppp/ppp_synctty.c | 2 +-
include/linux/ppp_channel.h | 2 +-
net/atm/pppoatm.c | 2 +-
5 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c
index b4cf2d09c6bd..93a7b0f6c4e7 100644
--- a/drivers/net/ppp/ppp_async.c
+++ b/drivers/net/ppp/ppp_async.c
@@ -491,7 +491,7 @@ static void ppp_async_process(struct tasklet_struct *t)
/* process received packets */
while ((skb = skb_dequeue(&ap->rqueue)) != NULL) {
if (skb->cb[0])
- ppp_input_error(&ap->chan, 0);
+ ppp_input_error(&ap->chan);
ppp_input(&ap->chan, skb);
}
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 2081da6c2144..6344c5eb0f98 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -2383,12 +2383,10 @@ ppp_input(struct ppp_channel *chan, struct sk_buff *skb)
rcu_read_unlock_bh();
}
-/* Put a 0-length skb in the receive queue as an error indication */
void
-ppp_input_error(struct ppp_channel *chan, int code)
+ppp_input_error(struct ppp_channel *chan)
{
struct channel *pch = chan->ppp;
- struct sk_buff *skb;
struct ppp *ppp;
if (!pch)
@@ -2397,12 +2395,9 @@ ppp_input_error(struct ppp_channel *chan, int code)
rcu_read_lock_bh();
ppp = rcu_dereference_bh(pch->ppp);
if (ppp) {
- skb = alloc_skb(0, GFP_ATOMIC);
- if (skb) {
- skb->len = 0; /* probably unnecessary */
- skb->cb[0] = code;
- ppp_do_recv(ppp, skb, pch);
- }
+ ppp_recv_lock(ppp);
+ ppp_receive_error(ppp);
+ ppp_recv_unlock(ppp);
}
rcu_read_unlock_bh();
}
@@ -2414,20 +2409,14 @@ ppp_input_error(struct ppp_channel *chan, int code)
static void
ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
{
- /* note: a 0-length skb is used as an error indication */
- if (skb->len > 0) {
- skb_checksum_complete_unset(skb);
+ skb_checksum_complete_unset(skb);
#ifdef CONFIG_PPP_MULTILINK
- /* XXX do channel-level decompression here */
- if (PPP_PROTO(skb) == PPP_MP)
- ppp_receive_mp_frame(ppp, skb, pch);
- else
+ /* XXX do channel-level decompression here */
+ if (PPP_PROTO(skb) == PPP_MP)
+ ppp_receive_mp_frame(ppp, skb, pch);
+ else
#endif /* CONFIG_PPP_MULTILINK */
- ppp_receive_nonmp_frame(ppp, skb);
- } else {
- kfree_skb(skb);
- ppp_receive_error(ppp);
- }
+ ppp_receive_nonmp_frame(ppp, skb);
}
static void
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index c2063961f395..b7f243b416f8 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -483,7 +483,7 @@ static void ppp_sync_process(struct tasklet_struct *t)
while ((skb = skb_dequeue(&ap->rqueue)) != NULL) {
if (skb->len == 0) {
/* zero length buffers indicate error */
- ppp_input_error(&ap->chan, 0);
+ ppp_input_error(&ap->chan);
kfree_skb(skb);
}
else
diff --git a/include/linux/ppp_channel.h b/include/linux/ppp_channel.h
index f73fbea0dbc2..ca8ad03eeef0 100644
--- a/include/linux/ppp_channel.h
+++ b/include/linux/ppp_channel.h
@@ -55,7 +55,7 @@ extern void ppp_input(struct ppp_channel *, struct sk_buff *);
/* Called by the channel when an input error occurs, indicating
that we may have missed a packet. */
-extern void ppp_input_error(struct ppp_channel *, int code);
+extern void ppp_input_error(struct ppp_channel *);
/* Attach a channel to a given PPP unit in specified net. */
extern int ppp_register_net_channel(struct net *, struct ppp_channel *);
diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c
index 2574aae3e066..e3c422dc533a 100644
--- a/net/atm/pppoatm.c
+++ b/net/atm/pppoatm.c
@@ -228,7 +228,7 @@ static void pppoatm_push(struct atm_vcc *atmvcc, struct sk_buff *skb)
error:
kfree_skb(skb);
- ppp_input_error(&pvcc->chan, 0);
+ ppp_input_error(&pvcc->chan);
}
static int pppoatm_may_send(struct pppoatm_vcc *pvcc, int size)
--
2.43.0
next reply other threads:[~2026-03-06 9:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 9:36 Qingfang Deng [this message]
2026-03-10 2:20 ` [PATCH net-next] ppp: simplify input error handling patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260306093649.1048232-1-dqfext@gmail.com \
--to=dqfext@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-ppp@vger.kernel.org \
--cc=mitch@sfgoth.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox