[RFC net-next v2 2/2] pppoe: queue unbound packets directly
From: Qingfang Deng
Date: Tue Oct 27 2026 - 23:06:32 EST
Queue unbound packets directly with sock_queue_rcv_skb() and remove
the unused backlog callback.
Previously, __sk_receive_skb() serialized receive processing with
PPPIOCGCHAN through the socket lock. Receivers either finished before
the ioctl acquired ownership or ran from the backlog after PPPOX_BOUND
was set.
The new lockless path relies on synchronize_net() from commit
92c1bf630abf ("pppox: drain queued packets on channel handoff").
After setting PPPOX_BOUND, PPPIOCGCHAN waits for receivers that saw
the old state to finish queueing before draining sk_receive_queue
into PPP. This prevents packets from being stranded after handoff.
SOCK_RCU_FREE protects the socket lifetime during teardown.
Signed-off-by: Qingfang Deng <qingfang.deng@xxxxxxxxx>
---
v2: new patch
---
drivers/net/ppp/pppoe.c | 40 ++++++----------------------------------
1 file changed, 6 insertions(+), 34 deletions(-)
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index fbd04e7252b2..ae4184dae8dd 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -340,35 +340,7 @@ static struct notifier_block pppoe_notifier = {
/************************************************************************
*
- * Do the real work of receiving a PPPoE Session frame.
- *
- ***********************************************************************/
-static int pppoe_rcv_core(struct sock *sk, struct sk_buff *skb)
-{
- struct pppox_sock *po = pppox_sk(sk);
-
- /* Backlog receive. Semantics of backlog rcv preclude any code from
- * executing in lock_sock()/release_sock() bounds; meaning sk->sk_state
- * can't change.
- */
-
- if (sk->sk_state & PPPOX_BOUND) {
- ppp_input(&po->chan, skb);
- } else {
- if (sock_queue_rcv_skb(sk, skb))
- goto abort_kfree;
- }
-
- return NET_RX_SUCCESS;
-
-abort_kfree:
- kfree_skb(skb);
- return NET_RX_DROP;
-}
-
-/************************************************************************
- *
- * Receive wrapper called in BH context.
+ * Receive a PPPoE Session frame.
*
***********************************************************************/
static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
@@ -415,11 +387,12 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
if (!po)
goto drop;
- if (likely(po->sk.sk_state & PPPOX_BOUND)) {
+ if (likely(po->sk.sk_state & PPPOX_BOUND))
ppp_input(&po->chan, skb);
- return NET_RX_SUCCESS;
- }
- return __sk_receive_skb(&po->sk, skb, 0, 1, false);
+ else if (sock_queue_rcv_skb(&po->sk, skb))
+ goto drop;
+
+ return NET_RX_SUCCESS;
drop:
kfree_skb(skb);
@@ -526,7 +499,6 @@ static int pppoe_create(struct net *net, struct socket *sock, int kern)
sock->state = SS_UNCONNECTED;
sock->ops = &pppoe_ops;
- sk->sk_backlog_rcv = pppoe_rcv_core;
sk->sk_destruct = pppoe_destruct;
sk->sk_state = PPPOX_NONE;
sk->sk_type = SOCK_STREAM;
--
2.43.0