ppp: add PPPIOCBRIDGECHAN and PPPIOCUNBRIDGECHAN ioctls
authorTom Parkin <tparkin@katalix.com>
Thu, 10 Dec 2020 15:50:57 +0000 (15:50 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 10 Dec 2020 21:57:36 +0000 (13:57 -0800)
commit4cf476ced45d7f12df30a68e833b263e7a2202d1
treef495b11c7d5a11a3c9540deaa06d7626a6d2f590
parent51e13685bd93654e0e9b2559c8e103d6545ddf95
ppp: add PPPIOCBRIDGECHAN and PPPIOCUNBRIDGECHAN ioctls

This new ioctl pair allows two ppp channels to be bridged together:
frames arriving in one channel are transmitted in the other channel
and vice versa.

The practical use for this is primarily to support the L2TP Access
Concentrator use-case.  The end-user session is presented as a ppp
channel (typically PPPoE, although it could be e.g. PPPoA, or even PPP
over a serial link) and is switched into a PPPoL2TP session for
transmission to the LNS.  At the LNS the PPP session is terminated in
the ISP's network.

When a PPP channel is bridged to another it takes a reference on the
other's struct ppp_file.  This reference is dropped when the channels
are unbridged, which can occur either explicitly on userspace calling
the PPPIOCUNBRIDGECHAN ioctl, or implicitly when either channel in the
bridge is unregistered.

In order to implement the channel bridge, struct channel is extended
with a new field, 'bridge', which points to the other struct channel
making up the bridge.

This pointer is RCU protected to avoid adding another lock to the data
path.

To guard against concurrent writes to the pointer, the existing struct
channel lock 'upl' coverage is extended rather than adding a new lock.

The 'upl' lock is used to protect the existing unit pointer.  Since the
bridge effectively replaces the unit (they're mutually exclusive for a
channel) it makes coding easier to use the same lock to cover them
both.

Signed-off-by: Tom Parkin <tparkin@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ppp/ppp_generic.c
include/uapi/linux/ppp-ioctl.h