]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ppp: simplify input error handling
authorQingfang Deng <dqfext@gmail.com>
Fri, 6 Mar 2026 09:36:49 +0000 (17:36 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 10 Mar 2026 02:07:38 +0000 (19:07 -0700)
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>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ppp/ppp_async.c
drivers/net/ppp/ppp_generic.c
drivers/net/ppp/ppp_synctty.c
include/linux/ppp_channel.h
net/atm/pppoatm.c

index b4cf2d09c6bd13cee492555b7887a9ba247cbe80..93a7b0f6c4e7e02b0b8dd960a5dce8840725ff6e 100644 (file)
@@ -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);
        }
 
index 2081da6c21448059045c2d2e78927165f7a3531a..6344c5eb0f9842aa5d2f9c1e98b583ba056a9d8d 100644 (file)
@@ -2383,12 +2383,10 @@ done:
        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
index c2063961f39506688c8f78141ec4c47407b9b93c..b7f243b416f82491c4d0efea5bea8fcc6a5ee202 100644 (file)
@@ -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
index f73fbea0dbc239a22b59bc273afbd405cb4c2037..ca8ad03eeef0f63d378cdd914dfe0dc18c387735 100644 (file)
@@ -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 *);
index 2574aae3e066de54dde6055ed6d630d5275f50c8..e3c422dc533adf85264ca56c608cf33aa01dd446 100644 (file)
@@ -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)