In listen only mode, tx CAN frames can still reach the driver if injected via the packet socket. This series add a check toward CAN_CTRLMODE_LISTENONLY in can_dropped_invalid_skb() to discard such skb. The first patch does some preparation work and migrates can_dropped_invalid_skb() and can_skb_headroom_valid() from skb.h to skb.c. This preparation is needed because skb.h does not include linux/can/dev.h (for struct can_priv) and uapi/linux/can/netlink.h (for the definition of CAN_CTRLMODE_LISTEONLY) which we need for this change. The function being already big, better to de-inline them and move them to a .c file. The second and last patch is the actual change. * Changelog * v1 -> v2 * move can_dropped_invalid_skb() to skb.c instead of dev.h * also move can_skb_headroom_valid() to skb.c Vincent Mailhol (2): can: skb:: move can_dropped_invalid_skb and can_skb_headroom_valid to skb.c can: dev: drop tx skb if in listen only mode drivers/net/can/dev/skb.c | 65 +++++++++++++++++++++++++++++++++++++++ include/linux/can/skb.h | 59 +---------------------------------- 2 files changed, 66 insertions(+), 58 deletions(-) -- 2.35.1