can: fix loss of CAN frames in raw_rcv
authorOliver Hartkopp <socketcan@hartkopp.net>
Sun, 21 Jun 2015 16:50:44 +0000 (18:50 +0200)
committerSasha Levin <sasha.levin@oracle.com>
Sun, 12 Jul 2015 16:50:46 +0000 (12:50 -0400)
[ Upstream commit 36c01245eb8046c16eee6431e7dbfbb302635fa8 ]

As reported by Manfred Schlaegl here

   http://marc.info/?l=linux-netdev&m=143482089824232&w=2

commit 514ac99c64b "can: fix multiple delivery of a single CAN frame for
overlapping CAN filters" requires the skb->tstamp to be set to check for
identical CAN skbs.

As net timestamping is influenced by several players (netstamp_needed and
netdev_tstamp_prequeue) Manfred missed a proper timestamp which leads to
CAN frame loss.

As skb timestamping became now mandatory for CAN related skbs this patch
makes sure that received CAN skbs always have a proper timestamp set.
Maybe there's a better solution in the future but this patch fixes the
CAN frame loss so far.

Reported-by: Manfred Schlaegl <manfred.schlaegl@gmx.at>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/net/can/dev.c
drivers/net/can/slcan.c
drivers/net/can/vcan.c
net/can/af_can.c

index 573b53b38af4b561910e875c1e76a854dc2920d1..bb686e15102cdfc0b785583d253a0d9d6f2d3c1c 100644 (file)
@@ -360,6 +360,9 @@ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
                struct can_frame *cf = (struct can_frame *)skb->data;
                u8 dlc = cf->can_dlc;
 
+               if (!(skb->tstamp.tv64))
+                       __net_timestamp(skb);
+
                netif_rx(priv->echo_skb[idx]);
                priv->echo_skb[idx] = NULL;
 
@@ -496,6 +499,7 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
        if (unlikely(!skb))
                return NULL;
 
+       __net_timestamp(skb);
        skb->protocol = htons(ETH_P_CAN);
        skb->pkt_type = PACKET_BROADCAST;
        skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -524,6 +528,7 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev,
        if (unlikely(!skb))
                return NULL;
 
+       __net_timestamp(skb);
        skb->protocol = htons(ETH_P_CANFD);
        skb->pkt_type = PACKET_BROADCAST;
        skb->ip_summed = CHECKSUM_UNNECESSARY;
index acb5b92ace92da17f55a5d892e90e7d7530a1952..cb6b4723af4a6afef9727cbf58f60966b0ed2803 100644 (file)
@@ -210,6 +210,7 @@ static void slc_bump(struct slcan *sl)
        if (!skb)
                return;
 
+       __net_timestamp(skb);
        skb->dev = sl->dev;
        skb->protocol = htons(ETH_P_CAN);
        skb->pkt_type = PACKET_BROADCAST;
index 4e94057ef5cf55df4600496d38b5fce433f851b4..30e4627a0c01bed311af06b77d227c897ff40c12 100644 (file)
@@ -81,6 +81,9 @@ static void vcan_rx(struct sk_buff *skb, struct net_device *dev)
        skb->dev       = dev;
        skb->ip_summed = CHECKSUM_UNNECESSARY;
 
+       if (!(skb->tstamp.tv64))
+               __net_timestamp(skb);
+
        netif_rx_ni(skb);
 }
 
index d6030d6949dfcf748c1edef1057bb38f198088ab..9a3244941a5cbaae90864d327e47bbd54c3e9be2 100644 (file)
@@ -313,8 +313,12 @@ int can_send(struct sk_buff *skb, int loop)
                return err;
        }
 
-       if (newskb)
+       if (newskb) {
+               if (!(newskb->tstamp.tv64))
+                       __net_timestamp(newskb);
+
                netif_rx_ni(newskb);
+       }
 
        /* update statistics */
        can_stats.tx_frames++;