can: add drop reasons in the receive path of AF_CAN
authorDavide Caratti <dcaratti@redhat.com>
Wed, 4 Jun 2025 16:06:04 +0000 (18:06 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Tue, 10 Jun 2025 08:23:30 +0000 (10:23 +0200)
commit127c49624a0980ee7b8a5ba9094d6942332a48da
tree71e9014b1f7f595c54558aa02fe7220877f70fcf
parent9e97db3c075a77d15a6be26541e7dad22dbfc793
can: add drop reasons in the receive path of AF_CAN

Besides the existing pr_warn_once(), use skb drop reasons in case AF_CAN
layer drops non-conformant CAN{,FD,XL} frames, or conformant frames
received by "wrong" devices, so that it's possible to debug (and count)
such events using existing tracepoints:

| # perf record -e skb:kfree_skb -aR -- ./drv/canfdtest -v -g -l 1 vcan0
| # perf script
| [...]
| canfdtest  1123 [000]  3893.271264: skb:kfree_skb: skbaddr=0xffff975703c9f700 rx_sk=(nil) protocol=12 location=can_rcv+0x4b  reason: CAN_RX_INVALID_FRAME

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Link: https://patch.msgid.link/20250604160605.1005704-2-dcaratti@redhat.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
include/net/dropreason-core.h
net/can/af_can.c