Hi,
On Mon, Oct 11, 2010 at 05:14:20PM +0200, [email protected] wrote:
> Hello Kurt,
>
> > IMO, a CAN frame from another socket should be treated as coming from
> > another bus node.
> > I know (J1939 is still in the queue) that some protocols may benefit from
> > several sockets cooperating, but should that be exported to userspace?
>
>
> I fully agree on that. Two different sockets shall behave as two
> different CAN nodes on the same CAN bus even if they are opened
> on the same hardware. Taking that in to account vcan shall be actually
> called "virtual CAN bus" and not "virtual CAN interface"...
>
> My understanding of "self-reception" per-socket option is that the
> messages send over the specific socket are not only received by
> other sockets on the same HW, but also by the original socket (so
> "echo" may be even better name for that). And the reason why I
> want to receive (some of) my own Tx messages is because I want
> to know *exactly* when whose messages where physically send over
> CAN bus. And that I am getting by reading the timestamp of my
> self-received message. And the per-message self-receive flag helps
> me to distinguish between Rx messages (coming from other CAN nodes
> or other sockets on the same CAN node) and my own Tx messages.
Thanks for the update. Seems like my understanding was right.
>
> Regards,
> Vladislav
Oliver, I assembled a patch showing my idea of what need to be done.
never tested, never even compiled, it just shows my thinking.
---
net/can/raw.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
Index: linux/net/can/raw.c
===================================================================
--- linux.orig/net/can/raw.c 2010-10-12 08:46:33.711192001 +0200
+++ linux/net/can/raw.c 2010-10-12 08:49:17.191192001 +0200
@@ -94,20 +94,23 @@
return (struct raw_sock *)sk;
}
-static void raw_rcv(struct sk_buff *skb, void *data)
+static void raw_rcv(struct sk_buff *oskb, void *data)
{
struct sock *sk = (struct sock *)data;
struct raw_sock *ro = raw_sk(sk);
struct sockaddr_can *addr;
+ struct sk_buff *skb; /* new */
/* check the received tx sock reference */
- if (!ro->recv_own_msgs && skb->sk == sk)
+ if (!ro->recv_own_msgs && oskb->sk == sk)
return;
/* clone the given skb to be able to enqueue it into the rcv queue */
- skb = skb_clone(skb, GFP_ATOMIC);
+ skb = skb_clone(oskb, GFP_ATOMIC);
if (!skb)
return;
+ if (oskb->sk == sk)
+ skb->msg_flags |= MSG_DONTROUTE;
/*
* Put the datagram to the queue so that raw_recvmsg() can
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core