From: Tom Parkin <tparkin@katalix.com>
To: Guillaume Nault <gnault@redhat.com>
Cc: netdev@vger.kernel.org, jchapman@katalix.com
Subject: Re: [RFC PATCH 0/2] add ppp_generic ioctl to bridge channels
Date: Tue, 10 Nov 2020 11:54:07 +0000 [thread overview]
Message-ID: <20201110115407.GA5635@katalix.com> (raw)
In-Reply-To: <20201109225153.GL2366@linux.home>
[-- Attachment #1: Type: text/plain, Size: 2967 bytes --]
On Mon, Nov 09, 2020 at 23:51:53 +0100, Guillaume Nault wrote:
> > * I believe that the fact we're not explicitly locking anything in the
> > ppp_input path for access to the channel bridge field is OK since:
> >
> > - ppp_input is called from the socket backlog recv
> >
> > - pppox_unbind (which calls ppp_channel_unregister, which unsets the
> > channel bridge field) is called from the socket release
> >
> > As such I think the bridge pointer cannot change in the recv
> > path since as the pppoe.c code says: "Semantics of backlog rcv
> > preclude any code from executing in lock_sock()/release_sock()
> > bounds".
>
> But ppp_input() is used beyond pppoe. For example, I'm pretty sure these
> pre-conditions aren't met for L2TP (pppol2tp_recv() processes packets
> directly, packets aren't queued by sk_receive_skb()).
Yes, that's true. I was basing my assumption on the fact that the
l2tp/pppox recv path made similar checks to those in in pppoe.c, e.g.
sk_state.
I take your point more widely though: ppp_input is used by multiple
pppox drivers, so it probably makes more sense to protect the bridge
with a lock than rely on the driver implementation(s) all behaving in
the same way.
> To avoid locking the channel bridge in the data path, you can protect
> the pointer with RCU.
Ack, I'll look at doing so.
> > * When userspace makes a PPPIOCBRIDGECHAN ioctl call, the channel the
> > ioctl is called on is updated to point to the channel identified
> > using the index passed in the ioctl call.
> >
> > As such, allow PPP frames to pass in both directions from channel A
> > to channel B, userspace must call ioctl twice: once to bridge A to B,
> > and once to bridge B to A.
> >
> > This approach makes the kernel coding easier, because the ioctl
> > handler doesn't need to do anything to lock the channel which is
> > identified by index: it's sufficient to find it in the per-net list
> > (under protection of the list lock) and take a reference on it.
> >
> > The downside is that userspace must make two ioctl calls to fully set
> > up the bridge.
>
> That's probably okay, but that'd allow for very strange setups, like
> channel A pointing to channel B and channel B being used by a PPP unit.
> I'd prefer to avoid having to think about such scenarios when reasoning
> about the code.
Good point about the cognitive load. I agree with you there.
> I think that the channel needs to be locked anyway to safely modify the
> bridge pointer. So the "no lock needed" benefit of the 2 ioctl calls
> approach doesn't seem to stand.
Agreed.
> BTW, shouldn't we have an "UNBRIDGE" command to remove the bridge
> between two channels?
I'm not sure of the usecase for it to be honest. Do you have
something specific in mind?
Thanks very much for your review and comments, it's much appreciated
:-)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-11-10 11:54 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-06 18:16 [RFC PATCH 0/2] add ppp_generic ioctl to bridge channels Tom Parkin
2020-11-06 18:16 ` [RFC PATCH 1/2] ppp: add PPPIOCBRIDGECHAN ioctl Tom Parkin
2020-11-09 23:24 ` Guillaume Nault
2020-11-10 12:04 ` Tom Parkin
2020-11-15 16:28 ` Guillaume Nault
2020-11-17 12:26 ` Tom Parkin
2020-11-17 14:06 ` Guillaume Nault
2020-11-06 18:16 ` [RFC PATCH 2/2] docs: update ppp_generic.rst to describe ioctl PPPIOCBRIDGECHAN Tom Parkin
2020-11-09 22:51 ` [RFC PATCH 0/2] add ppp_generic ioctl to bridge channels Guillaume Nault
2020-11-10 11:54 ` Tom Parkin [this message]
2020-11-15 11:59 ` Guillaume Nault
2020-11-17 12:12 ` Tom Parkin
2020-11-09 23:52 ` Jakub Kicinski
2020-11-10 9:28 ` Guillaume Nault
2020-11-10 12:42 ` Tom Parkin
2020-11-10 15:02 ` Guillaume Nault
2020-11-10 16:47 ` Jakub Kicinski
2020-11-17 12:54 ` Tom Parkin
2020-11-17 14:17 ` Guillaume Nault
2020-11-17 16:52 ` Jakub Kicinski
2020-11-18 20:24 ` Guillaume Nault
2020-11-20 1:17 ` Jakub Kicinski
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=20201110115407.GA5635@katalix.com \
--to=tparkin@katalix.com \
--cc=gnault@redhat.com \
--cc=jchapman@katalix.com \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.