]> rtime.felk.cvut.cz Git - socketcan-devel.git/commitdiff
Added flag to preserve the timestamp from the source device when routing
authorhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Fri, 19 Feb 2010 07:06:17 +0000 (07:06 +0000)
committerhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Fri, 19 Feb 2010 07:06:17 +0000 (07:06 +0000)
the CAN frame (which saves some time, if the timestamp is not needed).
Usually the skb->tstamp is cleared which makes the destination interface
create a new timestamp (e.g. when the frame hit's the bus) on loopback.

git-svn-id: svn://svn.berlios.de//socketcan/trunk@1130 030b6a49-0b11-0410-94ab-b0dab22257f2

kernel/2.6/include/socketcan/can/gw.h
kernel/2.6/net/can/gw.c

index b0dba41b008268e40c43857d9a4e2e99d5d4e5f5..e5609684ec85d86f0db7c3f3b5a575bb6dbcb89f 100644 (file)
@@ -27,6 +27,7 @@ struct rtcanmsg {
 };
 
 #define CAN_GW_TXFLAGS_LOOPBACK 0x01
+#define CAN_GW_TXFLAGS_SRC_TSTAMP 0x02
 
 /* CAN rtnetlink attribute definitions */
 enum {
index 262934bfcb23934ee4969d0e713e3f78cec1036e..d38ccb625fd8c91cad7f44b9c9055a6f4c41cf0d 100644 (file)
@@ -112,6 +112,7 @@ struct gw_job {
 
 /* content of u32 gwjob.flags */
 #define CAN_TX_LOOPBACK 0x00000001
+#define CAN_TX_SRC_TSTAMP 0x00000002
 
 /* modification functions that are invoked in the hot path in gw_rcv */
 void mod_and_id (struct can_frame *cf, struct can_can_gw *mod) {
@@ -196,6 +197,10 @@ static void gw_rcv(struct sk_buff *skb, void *data)
        while (modidx < MAX_MODFUNCTIONS && gwj->ccgw.modfunc[modidx])
                (*gwj->ccgw.modfunc[modidx++])(cf, &gwj->ccgw);
 
+       /* clear the skb timestamp if not configured the other way */
+       if (!(gwj->flags & CAN_TX_SRC_TSTAMP))
+               skb->tstamp.tv64 = 0;
+
        /* send to netdevice */
        if (can_send(nskb, gwj->flags & CAN_TX_LOOPBACK))
                gwj->dropped_frames++;
@@ -315,6 +320,9 @@ static int gw_create_job(struct sk_buff *skb,  struct nlmsghdr *nlh, void *arg)
        if (r->can_txflags & CAN_GW_TXFLAGS_LOOPBACK)
                gwj->flags |= CAN_TX_LOOPBACK;
 
+       if (r->can_txflags & CAN_GW_TXFLAGS_SRC_TSTAMP)
+               gwj->flags |= CAN_TX_SRC_TSTAMP;
+
        memset(&gwj->ccgw, 0, sizeof(gwj->ccgw)); 
 
        /* check for additional attributes / filters here */