On 11.10.2010 11:35, Kurt Van Dijck wrote:
> Hi,
>
> On Mon, Oct 11, 2010 at 11:01:56AM +0200, [email protected] wrote:
>>
>> Hello all,
>> I would like to bring up the self-reception theme again.
>>
>> In the discussion few weeks ago following ideas has been worked
>> out:
>>
>> 1) Add per-message self reception flag to can_frame
>> 2) Use SO_MARK
>> 3) sk_buff->sk may be used to see the message origin, but it is
>> not available in user space ...
>>
> Didn't Oliver make a patch to export (3) to userspace (via candump)?
Yes, i tried last weekend:
Index: kernel/2.6/net/can/raw.c
===================================================================
--- kernel/2.6/net/can/raw.c (Revision 1198)
+++ kernel/2.6/net/can/raw.c (Arbeitskopie)
@@ -726,6 +726,9 @@
else
size = skb->len;
+ if (!skb->sk)
+ msg->msg_flags |= MSG_DONTROUTE;
+
err = memcpy_toiovec(msg->msg_iov, skb->data, size);
if (err < 0) {
skb_free_datagram(sk, skb);
Index: kernel/2.6/drivers/net/can/vcan.c
===================================================================
--- kernel/2.6/drivers/net/can/vcan.c (Revision 1198)
+++ kernel/2.6/drivers/net/can/vcan.c (Arbeitskopie)
@@ -113,6 +113,9 @@
stats->rx_packets++;
stats->rx_bytes += cf->can_dlc;
+ if (cf->can_id == 0x123)
+ skb->sk = 0;
+
skb->protocol = htons(ETH_P_CAN);
skb->pkt_type = PACKET_BROADCAST;
skb->dev = dev;
Index: can-utils/candump.c
===================================================================
--- can-utils/candump.c (Revision 1198)
+++ can-utils/candump.c (Arbeitskopie)
@@ -725,6 +725,12 @@
fprint_long_canframe(stdout, &frame, NULL,
view);
printf("%s", (color>1)?col_off:"");
+
+ if (msg.msg_flags & MSG_DONTROUTE)
+ printf(" D %08X", msg.msg_flags);
+ else
+ printf(" - %08X", msg.msg_flags);
+
printf("\n");
}
The vcan patch is to introduce CAN frames that tell to be from out of the
local system. But unfortunately i was never able to see MSG_DONTROUTE in
msg_flags ...
Maybe the msg_flags are AND-filtered somewhere in the socketlayer to the
userspace - or i made a mistake somewhere else. I hope to be able to dig a bit
deeper on that the next days.
>>
>> I personally like the first option a bit better, because the
>> self-reception flag is available "automatically" in the can_frame
>> itself without making any additional operations (like in case
>> of SO_MARK). Would the "can_get_echo_skb" be the right place to
>> set that flag?
> I think not.
Me too (thinking not).
>
> The idea behind socketCAN is that the CAN bus is virtually
> extended through the linux system. (1) would deny this nature,
> since _not_ all CAN chips/socketCAN apps are treated equal.
> IMO, to support a 'self-reception' flag, you need a combination
> of (1) & (3):
> * a flag to userspace to indicate a received message was
> 'self-reception'
> * set the above flag (in raw.c or elsewhere) to indicate the sk_buff->sk
> matches the receiving socket.
>
> To userspace, this differs not compared to (1), but I think
> it respects the nature of socketCAN at kernel level.
>
> Not sure if I expressed my idea clear :-)
>
> How this would cooperate with the SO_RECV_OWN_MSGS option is unclear to me.
This is independent as when CAN frames come from outer world, they are not
originated by this socket.
The SO_RECV_OWN_MSGS option only allows you to see your own originated
messages which is usually not wanted.
Regards,
Oliver
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core