* exclusive access to can interface @ 2013-01-07 16:52 Alexander Stein 2013-01-07 18:16 ` Marc Kleine-Budde 2013-01-07 18:37 ` Oliver Hartkopp 0 siblings, 2 replies; 13+ messages in thread From: Alexander Stein @ 2013-01-07 16:52 UTC (permalink / raw) To: linux-can Hello, is there a way to get exclusive (write) access to a CAN interface, so that only one bound socket can write CAN frames on the bus? Best regards, Alexander ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: exclusive access to can interface 2013-01-07 16:52 exclusive access to can interface Alexander Stein @ 2013-01-07 18:16 ` Marc Kleine-Budde 2013-01-08 9:23 ` Alexander Stein 2013-01-22 9:41 ` Alexander Stein 2013-01-07 18:37 ` Oliver Hartkopp 1 sibling, 2 replies; 13+ messages in thread From: Marc Kleine-Budde @ 2013-01-07 18:16 UTC (permalink / raw) To: Alexander Stein; +Cc: linux-can [-- Attachment #1: Type: text/plain, Size: 497 bytes --] On 01/07/2013 05:52 PM, Alexander Stein wrote: > is there a way to get exclusive (write) access to a CAN interface, so > that only one bound socket can write CAN frames on the bus? No, what's the use case? Marc -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de | [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 261 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: exclusive access to can interface 2013-01-07 18:16 ` Marc Kleine-Budde @ 2013-01-08 9:23 ` Alexander Stein 2013-01-08 9:32 ` Marc Kleine-Budde 2013-01-08 10:08 ` Wolfgang Grandegger 2013-01-22 9:41 ` Alexander Stein 1 sibling, 2 replies; 13+ messages in thread From: Alexander Stein @ 2013-01-08 9:23 UTC (permalink / raw) To: Marc Kleine-Budde; +Cc: linux-can Hello Marc, On Monday 07 January 2013 19:16:20, Marc Kleine-Budde wrote: > On 01/07/2013 05:52 PM, Alexander Stein wrote: > > is there a way to get exclusive (write) access to a CAN interface, so > > that only one bound socket can write CAN frames on the bus? > > No, what's the use case? This was a customers request in order to prevent multiple applications (or instances) to send CAN frames on a specific CAN interface at the same time with the very same CAN-IDs. Concurrent reads shall still be allowed! Best regards, Alexander ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: exclusive access to can interface 2013-01-08 9:23 ` Alexander Stein @ 2013-01-08 9:32 ` Marc Kleine-Budde 2013-01-08 9:48 ` Alexander Stein 2013-01-08 10:08 ` Wolfgang Grandegger 1 sibling, 1 reply; 13+ messages in thread From: Marc Kleine-Budde @ 2013-01-08 9:32 UTC (permalink / raw) To: Alexander Stein; +Cc: linux-can [-- Attachment #1: Type: text/plain, Size: 1038 bytes --] On 01/08/2013 10:23 AM, Alexander Stein wrote: > Hello Marc, > > On Monday 07 January 2013 19:16:20, Marc Kleine-Budde wrote: >> On 01/07/2013 05:52 PM, Alexander Stein wrote: >>> is there a way to get exclusive (write) access to a CAN interface, so >>> that only one bound socket can write CAN frames on the bus? >> >> No, what's the use case? > > This was a customers request in order to prevent multiple applications (or > instances) to send CAN frames on a specific CAN interface at the same time > with the very same CAN-IDs. Concurrent reads shall still be allowed! Sending CAN frames is proper serialized by the networking subsystem :) If back to back CAN frames are a problem it seems the design of the application is fishy. Marc -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de | [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 261 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: exclusive access to can interface 2013-01-08 9:32 ` Marc Kleine-Budde @ 2013-01-08 9:48 ` Alexander Stein 2013-01-08 10:09 ` Oliver Hartkopp 0 siblings, 1 reply; 13+ messages in thread From: Alexander Stein @ 2013-01-08 9:48 UTC (permalink / raw) To: Marc Kleine-Budde; +Cc: linux-can Hello, On Tuesday 08 January 2013 10:32:25, Marc Kleine-Budde wrote: > On 01/08/2013 10:23 AM, Alexander Stein wrote: > > Hello Marc, > > > > On Monday 07 January 2013 19:16:20, Marc Kleine-Budde wrote: > >> On 01/07/2013 05:52 PM, Alexander Stein wrote: > >>> is there a way to get exclusive (write) access to a CAN interface, so > >>> that only one bound socket can write CAN frames on the bus? > >> > >> No, what's the use case? > > > > This was a customers request in order to prevent multiple applications (or > > instances) to send CAN frames on a specific CAN interface at the same time > > with the very same CAN-IDs. Concurrent reads shall still be allowed! > > Sending CAN frames is proper serialized by the networking subsystem :) > If back to back CAN frames are a problem it seems the design of the > application is fishy. I don't think serializaton or back to back frames are the problem. Think of CANopen there would be the same Node-ID twice on the bus. Alexander ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: exclusive access to can interface 2013-01-08 9:48 ` Alexander Stein @ 2013-01-08 10:09 ` Oliver Hartkopp 2013-01-08 10:18 ` Heinz-Jürgen Oertel 0 siblings, 1 reply; 13+ messages in thread From: Oliver Hartkopp @ 2013-01-08 10:09 UTC (permalink / raw) To: Alexander Stein; +Cc: Marc Kleine-Budde, linux-can Am 08.01.2013 10:48, schrieb Alexander Stein: > Hello, > > On Tuesday 08 January 2013 10:32:25, Marc Kleine-Budde wrote: >> On 01/08/2013 10:23 AM, Alexander Stein wrote: >>> Hello Marc, >>> >>> On Monday 07 January 2013 19:16:20, Marc Kleine-Budde wrote: >>>> On 01/07/2013 05:52 PM, Alexander Stein wrote: >>>>> is there a way to get exclusive (write) access to a CAN interface, so >>>>> that only one bound socket can write CAN frames on the bus? >>>> >>>> No, what's the use case? >>> >>> This was a customers request in order to prevent multiple applications (or >>> instances) to send CAN frames on a specific CAN interface at the same time >>> with the very same CAN-IDs. Concurrent reads shall still be allowed! >> >> Sending CAN frames is proper serialized by the networking subsystem :) >> If back to back CAN frames are a problem it seems the design of the >> application is fishy. > > I don't think serializaton or back to back frames are the problem. Think of CANopen there would be the same Node-ID twice on the bus. > This should be solved by the system setup. E.g. if you start two applications using/providing identical resources at the same time, you'll always get into trouble. If you start two inetd daemons, the second one would fail as he would like to bind the same IP ports. But this kind of mechanic is not available with CAN sockets. I would tend to make sure that the Node-ID is always unique in your system. What would happen, if you start a Node-ID on your host that already exists on the CAN networks attached to the system? You have to deal with that too: E.g. terminate myself with some error logging if i see my own Node-ID Even if i don't think you should go that way, you can use the can-gw routings and let the applications work on different (virtual) CAN interfaces. One CAN interface, that can write to the real CAN and one that only reads from the real CAN: ip link add dev can0_rw type vcan ip link add dev can0_ro type vcan cangw -A -s can0 -d can0_rw -e cangw -A -s can0_rw -d can0 -e cangw -A -s can0 -d can0_ro -e Then let the sending app run on can0_rw and the others on can0_ro. You might also add CAN filters to these routing rules. Regards, Oliver ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: exclusive access to can interface 2013-01-08 10:09 ` Oliver Hartkopp @ 2013-01-08 10:18 ` Heinz-Jürgen Oertel 0 siblings, 0 replies; 13+ messages in thread From: Heinz-Jürgen Oertel @ 2013-01-08 10:18 UTC (permalink / raw) To: Oliver Hartkopp Cc: Alexander Stein, Marc Kleine-Budde, linux-can@vger.kernel.org Am Dienstag, 8. Januar 2013, 11:09:28 schrieb Oliver Hartkopp: > ..... > This should be solved by the system setup. +1 > E.g. if you start two applications using/providing identical resources at > the same time, you'll always get into trouble. > > If you start two inetd daemons, the second one would fail as he would like > to bind the same IP ports. But this kind of mechanic is not available with > CAN sockets. > > I would tend to make sure that the Node-ID is always unique in your system. > What would happen, if you start a Node-ID on your host that already exists > on the CAN networks attached to the system? You have to deal with that too: > E.g. terminate myself with some error logging if i see my own Node-ID that is the point, correct. > ..... regards Heinz ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: exclusive access to can interface 2013-01-08 9:23 ` Alexander Stein 2013-01-08 9:32 ` Marc Kleine-Budde @ 2013-01-08 10:08 ` Wolfgang Grandegger 2013-01-08 10:15 ` Heinz-Jürgen Oertel 1 sibling, 1 reply; 13+ messages in thread From: Wolfgang Grandegger @ 2013-01-08 10:08 UTC (permalink / raw) To: Alexander Stein; +Cc: Marc Kleine-Budde, linux-can On 01/08/2013 10:23 AM, Alexander Stein wrote: > Hello Marc, > > On Monday 07 January 2013 19:16:20, Marc Kleine-Budde wrote: >> On 01/07/2013 05:52 PM, Alexander Stein wrote: >>> is there a way to get exclusive (write) access to a CAN interface, so >>> that only one bound socket can write CAN frames on the bus? >> >> No, what's the use case? > > This was a customers request in order to prevent multiple applications (or > instances) to send CAN frames on a specific CAN interface at the same time > with the very same CAN-IDs. Concurrent reads shall still be allowed! Application == CANopen?! It's like giving exclusive access to a network device. Isn't that possible? Well, at a first glance I have not found anything like that. Wolfgang. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: exclusive access to can interface 2013-01-08 10:08 ` Wolfgang Grandegger @ 2013-01-08 10:15 ` Heinz-Jürgen Oertel 0 siblings, 0 replies; 13+ messages in thread From: Heinz-Jürgen Oertel @ 2013-01-08 10:15 UTC (permalink / raw) To: Alexander Stein Cc: Wolfgang Grandegger, Marc Kleine-Budde, linux-can@vger.kernel.org Am Dienstag, 8. Januar 2013, 11:08:36 schrieb Wolfgang Grandegger: > On 01/08/2013 10:23 AM, Alexander Stein wrote: > > Hello Marc, > > > > On Monday 07 January 2013 19:16:20, Marc Kleine-Budde wrote: > >> On 01/07/2013 05:52 PM, Alexander Stein wrote: > >>> is there a way to get exclusive (write) access to a CAN interface, > >>> so > >>> that only one bound socket can write CAN frames on the bus? > >> > >> No, what's the use case? > > > > This was a customers request in order to prevent multiple applications > > (or instances) to send CAN frames on a specific CAN interface at the > > same time with the very same CAN-IDs. Concurrent reads shall still be > > allowed! > Application == CANopen?! It's like giving exclusive access to a network > device. Isn't that possible? Well, at a first glance I have not found > anything like that. > > Wolfgang. It of course should be possible to start two or more instances of a CAN or CANopen application. Sending out the same CAN Id by the applications should inhibited by the application or the system designer starting the CAN(open) applications. Like in real life. In real CAN network each of the CANopen nodes has to have different Node-Ids and properly configured PDOs in order to prevent sending the same CAN Id by different devices. Starting two CANopen applications on a Linux box using the same physical CAN will not disturb the CAN frames, but is wrong by design. I see no need for the OPs request. Regards Heinz ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: exclusive access to can interface 2013-01-07 18:16 ` Marc Kleine-Budde 2013-01-08 9:23 ` Alexander Stein @ 2013-01-22 9:41 ` Alexander Stein 2013-01-22 12:53 ` Kurt Van Dijck 1 sibling, 1 reply; 13+ messages in thread From: Alexander Stein @ 2013-01-22 9:41 UTC (permalink / raw) To: Marc Kleine-Budde; +Cc: linux-can Hello again, On Monday 07 January 2013 19:16:20, Marc Kleine-Budde wrote: > On 01/07/2013 05:52 PM, Alexander Stein wrote: > > is there a way to get exclusive (write) access to a CAN interface, so > > that only one bound socket can write CAN frames on the bus? > > No, what's the use case? I have now a more detailed view about the customers request and background: The problem runs some (time consuming) tests using CAN and they want to prohibit CAN write access meanwhile in order to prevent e.g. some (mis-)configuration of CAN devices or firmware updates. In such a case the test might shutdown and needs to be restarted. During the test nobody alse should be allowed to write to the CAN bus. I think this is justified. It seems this is unrelated to CANopen or user application started twice, like I've expected and written before. Best regards, Alexander ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: exclusive access to can interface 2013-01-22 9:41 ` Alexander Stein @ 2013-01-22 12:53 ` Kurt Van Dijck 2013-01-22 13:36 ` Alexander Stein 0 siblings, 1 reply; 13+ messages in thread From: Kurt Van Dijck @ 2013-01-22 12:53 UTC (permalink / raw) To: Alexander Stein; +Cc: Marc Kleine-Budde, linux-can On 22 Jan 2013, at 10:41, Alexander Stein <alexander.stein@systec-electronic.com> wrote: > Hello again, > > On Monday 07 January 2013 19:16:20, Marc Kleine-Budde wrote: >> On 01/07/2013 05:52 PM, Alexander Stein wrote: >>> is there a way to get exclusive (write) access to a CAN interface, so >>> that only one bound socket can write CAN frames on the bus? >> >> No, what's the use case? > > I have now a more detailed view about the customers request and background: The problem runs some (time consuming) tests using CAN and they want to prohibit CAN write access meanwhile in order to prevent e.g. some (mis-)configuration of CAN devices or firmware updates. In such a case the test might shutdown and needs to be exclusive access could be used to prevent possible race conditions, not to solve configuration of the local software. > restarted. During the test nobody alse should be allowed to write to the CAN bus. I think this is justified. "Nobody should write to the CAN bus" != "Nobody should be allowed to write to the CAN bus" The exclusive access is only enforce on the local system. Other participants on the CAN bus still are able to write to the CAN bus. Your problem won't be solved. > It seems this is unrelated to CANopen or user application started twice, like I've expected and written before. > > Best regards, > Alexander > > -- > To unsubscribe from this list: send the line "unsubscribe linux-can" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: exclusive access to can interface 2013-01-22 12:53 ` Kurt Van Dijck @ 2013-01-22 13:36 ` Alexander Stein 0 siblings, 0 replies; 13+ messages in thread From: Alexander Stein @ 2013-01-22 13:36 UTC (permalink / raw) To: Kurt Van Dijck; +Cc: Marc Kleine-Budde, linux-can On Tuesday 22 January 2013 13:53:22, Kurt Van Dijck wrote: > On 22 Jan 2013, at 10:41, Alexander Stein <alexander.stein@systec-electronic.com> wrote: > > > Hello again, > > > > On Monday 07 January 2013 19:16:20, Marc Kleine-Budde wrote: > >> On 01/07/2013 05:52 PM, Alexander Stein wrote: > >>> is there a way to get exclusive (write) access to a CAN interface, so > >>> that only one bound socket can write CAN frames on the bus? > >> > >> No, what's the use case? > > > > I have now a more detailed view about the customers request and background: The problem runs some (time consuming) tests using CAN and they want to prohibit CAN write access meanwhile in order to prevent e.g. some (mis-)configuration of CAN devices or firmware updates. In such a case the test might shutdown and needs to be > exclusive access could be used to prevent possible race conditions, not to solve configuration of the local software. > > > restarted. During the test nobody alse should be allowed to write to the CAN bus. I think this is justified. > "Nobody should write to the CAN bus" != "Nobody should be allowed to write to the CAN bus" > > The exclusive access is only enforce on the local system. Other participants on the CAN bus > still are able to write to the CAN bus. > Your problem won't be solved. As this specific CAN interface is the only access to this CAN network it is enough. It is obvious that you can't lock this bus completly, the same is for file locking on networking file systems, they either don't work at all or just locally. Best regards, Alexander ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: exclusive access to can interface 2013-01-07 16:52 exclusive access to can interface Alexander Stein 2013-01-07 18:16 ` Marc Kleine-Budde @ 2013-01-07 18:37 ` Oliver Hartkopp 1 sibling, 0 replies; 13+ messages in thread From: Oliver Hartkopp @ 2013-01-07 18:37 UTC (permalink / raw) To: Alexander Stein; +Cc: linux-can On 07.01.2013 17:52, Alexander Stein wrote: > is there a way to get exclusive (write) access to a CAN interface, so that only one bound socket can write CAN frames on the bus? > Not really. In a very early SocketCAN implementation we had the possibility to define the capabilities to access CAN sockets. See http://svn.berlios.de/wsvn/socketcan/trunk/kernel/2.6/net/can/raw.c?op=log&op=log&peg=1258&page=2 We removed it in: http://svn.berlios.de/wsvn/socketcan/trunk/kernel/2.6/net/can/raw.c?op=revision&rev=489&peg=1258 http://svn.berlios.de/wsvn/socketcan/trunk/kernel/2.6/net/can/raw.c?op=revision&rev=490&peg=1258 You might think about re-introducing some capability checking, e.g. that only root or some other special user may write on CAN RAW sockets. E.g. see "if (!capable(CAP_NET_RAW))" http://lxr.linux.no/#linux+v3.7.1/net/packet/af_packet.c#L2480 in packet_create() ... Regards, Oliver ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2013-01-22 13:36 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-01-07 16:52 exclusive access to can interface Alexander Stein 2013-01-07 18:16 ` Marc Kleine-Budde 2013-01-08 9:23 ` Alexander Stein 2013-01-08 9:32 ` Marc Kleine-Budde 2013-01-08 9:48 ` Alexander Stein 2013-01-08 10:09 ` Oliver Hartkopp 2013-01-08 10:18 ` Heinz-Jürgen Oertel 2013-01-08 10:08 ` Wolfgang Grandegger 2013-01-08 10:15 ` Heinz-Jürgen Oertel 2013-01-22 9:41 ` Alexander Stein 2013-01-22 12:53 ` Kurt Van Dijck 2013-01-22 13:36 ` Alexander Stein 2013-01-07 18:37 ` Oliver Hartkopp
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).