On Wed. 24 Nov. 2021 à 06:01, Oliver Hartkopp <socketcan@xxxxxxxxxxxx> wrote: > On 23.11.21 12:53, Vincent Mailhol wrote: > > CAN error skb is an interface specific to socket CAN. The CAN error > > skb does not correspond to any actual CAN frame sent on the wire. Only > > an error flag and a delimiter are transmitted when an error occurs > > (c.f. ISO 11898-1 section 10.4.4.2 "Error flag"). > > > > For this reason, it makes no sense to increment the rx_packets and > > rx_bytes fields of struct net_device_stats because no actual payload > > were transmitted on the wire. > > > > (..) > > > diff --git a/drivers/net/can/dev/rx-offload.c b/drivers/net/can/dev/rx-offload.c > > index 37b0cc65237b..bb47e9a49240 100644 > > --- a/drivers/net/can/dev/rx-offload.c > > +++ b/drivers/net/can/dev/rx-offload.c > > @@ -54,8 +54,10 @@ static int can_rx_offload_napi_poll(struct napi_struct *napi, int quota) > > struct can_frame *cf = (struct can_frame *)skb->data; > > > > work_done++; > > - stats->rx_packets++; > > - stats->rx_bytes += cf->len; > > + if (!(cf->can_id & CAN_ERR_MASK)) { > > This looks wrong. And it is. > Did you think of CAN_ERR_FLAG ?? Yes, I will fix this in v2. > > + stats->rx_packets++; > > + stats->rx_bytes += cf->len; > > + } > > netif_receive_skb(skb); > > (..) > > > diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c > > index 1679cbe45ded..d582c39fc8d0 100644 > > --- a/drivers/net/can/usb/ucan.c > > +++ b/drivers/net/can/usb/ucan.c > > @@ -621,8 +621,10 @@ static void ucan_rx_can_msg(struct ucan_priv *up, struct ucan_message_in *m) > > memcpy(cf->data, m->msg.can_msg.data, cf->len); > > > > /* don't count error frames as real packets */ > > - stats->rx_packets++; > > - stats->rx_bytes += cf->len; > > + if (!(cf->can_id & CAN_ERR_FLAG)) { > > Ah, here we are :-) Thank you!