Skip to contentSkip to conversation

pppoe: pass bound packets directly to generic PPP

RFC Superseded Qingfang Deng 1 participant 2 messages Oct 28

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

RFC v2 1/2 pppoe: pass bound packets directly to generic PPP

Bound PPPoE sockets pass received frames to the generic PPP layer. They currently do so through __sk_receive_skb(), which takes the socket BH lock and serializes calls to ppp_input().

The lock originally prevented ppp_input() from racing with ppp_unregister_channel(). Commit ec4215683e47 ("ppp: defer channel free to an RCU grace period to fix pppol2tp RX UAF") now keeps the generic PPP channel alive until in-flight RCU readers have completed, so bound packets can be passed directly to ppp_input() from pppoe_rcv().

The direct bound receive path also skips the socket filter check in __sk_receive_skb(). This does not affect normal pppd PPPoE operation:
pppd uses the kernel PPP channel and does not attach a receive filter to a socket. Instead, it uses the generic PPP pass and active filters, installed through PPPIOCSPASS and PPPIOCSACTIVE, unaffected by this change.

A local receive-path benchmark sends 1492-byte IPv4 packets through multiqueue TAP -> PPPoE -> PPP in an x86-64 eight-vCPU QEMU KVM guest. The generic PPP receive lock (ppp->rlock) is retained in both variants. Median throughput over 12 samples per cell across four boots, expressed as IP-layer Gbps:

Senders Before Gbps After Gbps Change

        1        25.85       26.71     +3.33%
        2        45.19       46.93     +3.86%
        4        84.14       88.36     +5.01%
        8        60.39       68.50    +13.43%

Repeating the test with a separate benchmark-only change that removes the generic PPP receive lock:

Senders Before Gbps After Gbps Change

        1        26.35       26.58     +0.87%
        2        46.57       47.54     +2.07%
        4        87.04       91.47     +5.09%
        8        64.01      161.85   +152.86%

In these tests, eight senders perform worse than four in every configuration with at least one receive lock remaining. Removing both locks restores scaling: throughput increases from 91.47 Gbps with four senders to 161.85 Gbps with eight senders.

---
v2:
- Split out the synchronize_net() change (already in net tree e7b01bc0202a)
- Do not change the banner comment
- Include the benchmark results

v1: https://lore.kernel.org/netdev/[email protected]/

Sent as RFC, as net-next is not yet open and commit e7b01bc0202a is not present in this tree.

---
 drivers/net/ppp/pppoe.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ppp/pppoe.c +4 -0
index 9edf8151bd7d..fbd04e7252b2 100644
@@ -415,6 +415,10 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
 	if (!po)
 		goto drop;
 
+	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);
 
 drop:
Signature · 1 line
2.43.0
#1 lore raw

RFC v2 2/2 pppoe: queue unbound packets directly

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.

---
v2: new patch

---
 drivers/net/ppp/pppoe.c | 40 ++++++----------------------------------
 1 file changed, 6 insertions(+), 34 deletions(-)
drivers/net/ppp/pppoe.c +6 -34
index fbd04e7252b2..ae4184dae8dd 100644
@@ -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;
Signature · 1 line
2.43.0