Skip to content

Commit

Permalink
can: fix loss of CAN frames in raw_rcv
Browse files Browse the repository at this point in the history
As reported by Manfred Schlaegl here

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

commit 514ac99 "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 <[email protected]>
Signed-off-by: Oliver Hartkopp <[email protected]>
Cc: linux-stable <[email protected]>
Signed-off-by: Marc Kleine-Budde <[email protected]>
  • Loading branch information
hartkopp authored and marckleinebudde committed Jun 21, 2015
1 parent 7b48f45 commit 36c0124
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions drivers/net/can/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,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;

Expand Down Expand Up @@ -575,6 +578,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;
Expand Down Expand Up @@ -603,6 +607,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;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/can/slcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,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;
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/can/vcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,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);
}

Expand Down
6 changes: 5 additions & 1 deletion net/can/af_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,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++;
Expand Down

0 comments on commit 36c0124

Please sign in to comment.