From: David Jander <david@protonic.nl>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>,
linux-can <linux-can@vger.kernel.org>
Subject: Re: j1939: bind() and connect()
Date: Tue, 15 Aug 2017 12:24:53 +0200 [thread overview]
Message-ID: <20170815122453.3945bead@erd980> (raw)
In-Reply-To: <7164d44c-76f9-45f6-b5fa-c931f058163f@pengutronix.de>
On Tue, 15 Aug 2017 11:16:44 +0200
Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> On 08/15/2017 11:01 AM, David Jander wrote:
> > On Tue, 15 Aug 2017 10:14:18 +0200
> > Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> >
> >> On 08/14/2017 07:37 PM, Marc Kleine-Budde wrote:
> >>> - Should a second bind() be allowed on a previously bind() socket?
> >>>
> >>> As far as I understand the code, there's some support, but when the
> >>> interface is switched, j1939_ifindex_stop() is not called.
> >>
> >> Ah, there's a check, that you cannot re-bind() to another interface:
> >>
> >>> if (bound_dev_if != addr->can_ifindex)
> >
> > This makes sense. re-bind() to another interface only would make sense if
> > bind() to any interface is also permitted, but that would imply separate
> > address-claims on all different interfaces with potentially different
> > source-address being claimed on each one.... don't think the stack should take
> > care of such complex scenarios, at least not at first IMHO.
>
> Bind to any interface doesn't work, you cannot send anything:
>
> > static int j1939sk_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
> > {
> [...]
> > ifindex = jsk->ifindex_started;
> > if (!ifindex)
> > return -EBADFD;
>
> And you will probably not receive anything, as the rx-register, which
> takes place in j1939_ifindex_start() is not done if you try to bind to
> any device (bound_dev_if == 0).
>
> > if (bound_dev_if && bound_dev_if != jsk->ifindex_started) {
> [...]
> >
> > ret = j1939_ifindex_start(bound_dev_if);
>
> Then I'll add proper test, that you have to bind to a specific
> interface. That will make the code much simpler.
I agree. Don't know if the case for bind-any will ever be necessary in the
context of J1939, but we certainly should keep things simple for now.
I've had cases myself where an ECU would talk J1939 on two interfaces at the
same time, but not yet something like a Group-Function server exporting the
same functions on more than one interface. I could think of that use-case
happening though, but it can also be solved easily in user-space opening more
than one socket...
Best regards,
--
David Jander
Protonic Holland.
next prev parent reply other threads:[~2017-08-15 10:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-14 17:37 j1939: bind() and connect() Marc Kleine-Budde
2017-08-15 8:14 ` Marc Kleine-Budde
2017-08-15 9:01 ` David Jander
2017-08-15 9:16 ` Marc Kleine-Budde
2017-08-15 10:24 ` David Jander [this message]
2017-08-16 21:08 ` Kurt Van Dijck
2017-08-17 7:35 ` Marc Kleine-Budde
2017-08-17 8:28 ` Kurt Van Dijck
2017-08-17 8:32 ` Marc Kleine-Budde
2017-08-16 9:34 ` Kurt Van Dijck
2017-08-16 10:06 ` Marc Kleine-Budde
2017-08-16 10:29 ` David Jander
2017-08-16 21:18 ` Kurt Van Dijck
2017-08-16 10:47 ` Marc Kleine-Budde
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=20170815122453.3945bead@erd980 \
--to=david@protonic.nl \
--cc=dev.kurt@vandijck-laurijssen.be \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
/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.