From: Alex Layton <alex@layton.in>
To: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>,
linux-can <linux-can@vger.kernel.org>
Subject: Re: can-j1939 API
Date: Mon, 19 Oct 2015 12:53:50 -0400 [thread overview]
Message-ID: <CAFUozzGy0UZhKaeLfJiySkJfrK-XuOD7cwz01=hsO48hAk+mow@mail.gmail.com> (raw)
In-Reply-To: <20151018023225.GA29078@airbook.vandijck-laurijssen.be>
On Sat, Oct 17, 2015 at 10:32 PM, Kurt Van Dijck
<dev.kurt@vandijck-laurijssen.be> wrote:
>
> --- Original message ---
>> Date: Thu, 15 Oct 2015 18:04:58 -0400
>> From: Alex Layton <alex@layton.in>
>> To: linux-can <linux-can@vger.kernel.org>
>> Subject: Re: can-j1939 API
>>
>> On Tue, Sep 29, 2015 at 3:49 PM, Kurt Van Dijck
>> <dev.kurt@vandijck-laurijssen.be> wrote:
>> > I would like to challenge other j1939 (not necessarily socketcan+can-j1939)
>> > users to share their opinions.
>>
>> Hello, I am the author of https://github.com/ISOBlue/isoblue-software,
>> finally getting around to participating in this list.
>>
>> > > > If you look at http://elinux.org/J1939
>> >
>> > > > $ modprobe can-j1939
>> >
>> > This is a systemwide action, as opposed to
>> >
>> > > > $ ip link set can0 j1939 on
>> >
>> > which is an interface-wide action.
>> >
>> > Due to the nature of CAN, the kernel should not/cannot decide if CAN
>> > traffic is J1939 or not.
>> > Unlike other CAN protocols (RAW, BCM, ISOTP), J1939 allocates the whole
>> > CAN id range for its use, and using CAN ids incompatible with j1939
>> > is regarded illegal.
>> >
>> > So this must become a switch.
>>
>> I disagree with this, like Austin Schuh did. In my experience there is
>> almost always other non-J1939 CAN traffic present and it must be
>> possible to use both. The module should just ignore any CAN that does
>> not look right to it, and there needs to still be a way to get at the
>> other CAN on the bus through a CAN_RAW socket or something.
>
> The 'switch' is to turn can-j1939 on/off on a specific interface.
> The condition that I'd like to solve is where you end up having a
> j1939 bus can0, obviously with 29bit CAN id's, and another bus, can1,
> that is NOT j1939 compliant while using 29bit identifiers.
>
> I'd prefer to disable can-j1939 processing on can1 in that case, before
> reporting any obvious protocol violations in the log.
I can understand that. Can you not have you module only listen on
interfaces where J1939 sockets have been opened?
>> > > > and if you think about this kind of assignment, it should be implemented
>> > > > inside the j1939 stuff and not in af_can.c. The can-gw routing netlink
>> >
>> > j1939 touches af_can because address configuration via netlink is
>> > absent in af_can. j1939 adds (with seperate patches) the ability to add
>> > addressess for CAN sockets, but only for those CAN protocols that
>> > support it.
>> > I see no decent way to bypass af_can, except for creating af_j1939.
>>
>> Sorry if this is a stupid question, but what is the point of adding
>> addresses to a CAN interface with ip? Doesn't the code creating the
>> socket set what its address and/or NAME is? My implementation does not
>> modify af_can, though it is admittedly much more simplistic than
>> Kurt's.
>
> I offloaded the (static) addressing onto the kernel, so I needs to know
> its address, much like any other address-capable protocol like e.g. ipv4.
> Its obviously that not every ipv4 capable application needs to know it
> local ip address. I made can-j1939 likewise multi-user ready.
I don't really think of there being a "localhost" type thing in J1939.
The address go with specific function, not devices, Often one physical
device claims multiple addresses on the network, one for each thing
that device does. For my module, when the program opening the socket
does not know or care about which address to use, I simply claim an
address for it that is unused and in the self-configurable range.
>> > > > I remember our discussion about the address claiming but I wonder if we
>> > > > really follow the requirement to only put functionality into the kernel
>> > > > that really has to be implemented there.
>> >
>> > The kernel tracks and validates J1939 traffic. Any userspace application
>> > can track, but none can validate & reject without duplicating effort.
>>
>> I too think at least part of the address handling needs to be in the
>> kernel module.
>>
>> > > > Did you take a look at https://github.com/ISOBlue/isoblue-software -
>> > > > which is far simpler - whether it can fulfill the basic functionalities
>> > > > (segmentation, etc.) to enable j1939 for Linux?
>> >
>> > I took a quick look. It appears that they only put the address claiming
>> > in the kernel. I understand that this is exactly your concern in my
>> > implementation :-).
>>
>> Yes, my implementation does address claiming in the module. From what
>> I understand, mine does even more of the process than Kurt's does (my
>> module actually sends the address claim messages). However, my module
>> does not deal with NAMEs, only the addresses.
>
> I'd like to know your idea:
> Is it possible with isoblue to have multiple sockets using the same
> source address?
> How does an application needs to deal with address changes? Does every
> application just receives the address claims without asking?
No, my module does not allow multiple sockets with the same address.
My module takes the view that address go to functions, not devices,
and assumes one socket per function.
If a socket loses its address, that socket returns -EADDRINUSE the
next time a function is called on it (e.g., recvmesg). When that
happens, the program must use bind again to get a new address. I had
hoped to one day implement transparently claiming another address if
the socket was set as self-configurable.
My module has support for filtering which PGNs a socket actually
receives. If the filters on the socket allow address claim messages
through, the socket will see them.
Alex
next prev parent reply other threads:[~2015-10-19 16:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <linux-can/can-utils/pull/7@github.com>
2015-09-28 6:53 ` [can-utils] J1939 v6 (#7) Marc Kleine-Budde
2015-09-29 12:15 ` Kurt Van Dijck
2015-09-30 15:26 ` Aaron Clarke
2015-09-30 23:38 ` Kurt Van Dijck
[not found] ` <linux-can/can-utils/pull/7/c144149208@github.com>
2015-09-29 18:46 ` Marc Kleine-Budde
2015-09-29 19:49 ` can-j1939 API Kurt Van Dijck
2015-09-29 20:10 ` Austin Schuh
2015-10-15 22:04 ` Alex Layton
2015-10-16 19:36 ` Patrick Menschel
2015-10-18 2:42 ` Kurt Van Dijck
2015-10-19 3:41 ` Patrick Menschel
2015-10-19 6:07 ` Oliver Hartkopp
2015-10-19 9:52 ` Kurt Van Dijck
2015-10-19 16:53 ` Alex Layton
2015-10-19 20:57 ` Kurt Van Dijck
2015-10-19 21:31 ` Kurt Van Dijck
2015-10-22 16:39 ` Alex Layton
2015-10-18 2:32 ` Kurt Van Dijck
2015-10-19 16:53 ` Alex Layton [this message]
2015-10-19 20:44 ` Kurt Van Dijck
2015-10-22 16:39 ` Alex Layton
2015-10-23 11:14 ` Kurt Van Dijck
2015-10-29 19:33 ` Oliver Hartkopp
2015-10-29 23:38 ` Kurt Van Dijck
2015-11-02 12:14 ` Oliver Hartkopp
2015-11-02 12:29 ` Kurt Van Dijck
2015-11-02 13:18 ` Oliver Hartkopp
2015-11-11 19:48 ` Kurt Van Dijck
2015-11-10 21:58 ` Yang
2015-11-11 18:49 ` Kurt Van Dijck
2015-11-17 6:01 ` Yang Wang
2015-11-17 8:43 ` Kurt Van Dijck
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='CAFUozzGy0UZhKaeLfJiySkJfrK-XuOD7cwz01=hsO48hAk+mow@mail.gmail.com' \
--to=alex@layton.in \
--cc=dev.kurt@vandijck-laurijssen.be \
--cc=linux-can@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).