Re: can-utils jacd questions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Elenita,

On Thu, Dec 12, 2019 at 03:49:48PM -0600, Elenita Hinds wrote:
> Hi Kurt,
> 
> I tried using getsockname() to retrieve the source address that was
> successfully claimed by jacd but was always getting 0xfe (I was
> expecting it to be 0xf9 as claimed by jacd).
> Is getsockname() expected to be functional for J1939 with kernel v5.4?
> Is there another way to retrieving the dynamically claimed address real-time?

Current stack implementation will return on getsockname(sock, ...) and
getpeername(sock, ...) values provided by user via bind() and/or connect(). If
we configure the socket by name, then address are automatically resolved
over address claim cache.

The question is, should we return some thing different?
If yes, it will be interesting to know, why is it needed? What is the
use case?

> --elenita
> 
> 
> >
> > On Fri, Dec 6, 2019 at 2:59 AM Kurt Van Dijck
> > <dev.kurt@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> > >
> > > Hi,
> > >
> > > On do, 05 dec 2019 14:55:53 -0600, Elenita Hinds wrote:
> > > > Hi all,
> > > >
> > > > I am hoping to re-use the can-utils' jacd as default Address Claiming
> > > > daemon but runs into some issues:
> > > >
> > > > (1) " err(0, <string>, ...) " is called in several places, even though
> > > > looking at the code logic, there is no error and the program should be
> > > > able to continue. The program exits because err()  never returns.
> > > > For example:
> > >
> > > commit 791b6de7 introduced the problem.
> > > it replaced all error(x, y, sss) calls with err(y, sss)
> > > but it should have become warn(y, sss) when x=0.
> > >
> > > Feel free to fix that.
> > >
> > > > (2) The socket is configured to also set the SO_BINDTODEVICE option.
> > > > In our system, this requires the program to have root permissions to
> > > > run but we'd rather not do this for security reasons. Is this option
> > > > required? What are the side-effects if this option is not set? Can it
> > > > be made optional such that the program does not exit if the
> > > > setsockoption(SO_BINDTODEVICE) call fails (seems to work without it)?
> > >
> > > It appears on first sight that SO_BINDTODEVICE isn't strictly necessary
> > > since bind() will have sockaddr_can.can_ifindex set anyway.
> > > In that case, rather then ignore the result,
> > > remove the call to SO_BINDTODEVICE completely.
> > >
> > > >
> > > > (3) The claimed address is only saved to a file when the program
> > > > terminates.  What is the reason for this? Can it not be saved after
> > > > one is claimed already so that another process can  read it real-time
> > > > if needed?
> > >
> > > That should not be necessary.
> > > At time of writing jacd, you could consult 'ip addr show can0' to find
> > > out. I'm not sure what option remained to find it.
> > > I believe you can, from another program, bind() with the same name, and
> > > then getsockname() will return the complete sockaddr_can with SA filled
> > > in.
> > >
> > > > Also, in cases of a program crash or a power outage, the
> > > > claimed address is still saved.
> > >
> > > That is a true remark.
> > > Given a power outage (the program never crashes :-) ),
> > > and looking at the code, +10 years later, I would now write to a temp file,
> > > and rename() the file to make it an atomic operation.
> > > Doing that regularly, or upon change, would be an improvement.
> > >
> > > Kurt
> > > >
> > > >
> > > > Thanks in advance,
> > > > Elenita
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux