Skip to content

Commit ed3320c

Browse files
hartkoppmarckleinebudde
authored andcommitted
can: dev: __can_get_echo_skb(): fix real payload length return value for RTR frames
The can_get_echo_skb() function returns the number of received bytes to be used for netdev statistics. In the case of RTR frames we get a valid (potential non-zero) data length value which has to be passed for further operations. But on the wire RTR frames have no payload length. Therefore the value to be used in the statistics has to be zero for RTR frames. Reported-by: Vincent Mailhol <[email protected]> Signed-off-by: Oliver Hartkopp <[email protected]> Link: https://lore.kernel.org/r/[email protected] Fixes: cf5046b ("can: dev: let can_get_echo_skb() return dlc of CAN frame") Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 2283f79 commit ed3320c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/net/can/dev.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,13 @@ __can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr)
512512
*/
513513
struct sk_buff *skb = priv->echo_skb[idx];
514514
struct canfd_frame *cf = (struct canfd_frame *)skb->data;
515-
u8 len = cf->len;
516515

517-
*len_ptr = len;
516+
/* get the real payload length for netdev statistics */
517+
if (cf->can_id & CAN_RTR_FLAG)
518+
*len_ptr = 0;
519+
else
520+
*len_ptr = cf->len;
521+
518522
priv->echo_skb[idx] = NULL;
519523

520524
return skb;

0 commit comments

Comments
 (0)