diff options
Diffstat (limited to 'include/linux/can/dev.h')
-rw-r--r-- | include/linux/can/dev.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 3db7767d2a17..7e7c98a3e908 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h | |||
@@ -60,6 +60,21 @@ struct can_priv { | |||
60 | */ | 60 | */ |
61 | #define get_can_dlc(i) (min_t(__u8, (i), 8)) | 61 | #define get_can_dlc(i) (min_t(__u8, (i), 8)) |
62 | 62 | ||
63 | /* Drop a given socketbuffer if it does not contain a valid CAN frame. */ | ||
64 | static inline int can_dropped_invalid_skb(struct net_device *dev, | ||
65 | struct sk_buff *skb) | ||
66 | { | ||
67 | const struct can_frame *cf = (struct can_frame *)skb->data; | ||
68 | |||
69 | if (unlikely(skb->len != sizeof(*cf) || cf->can_dlc > 8)) { | ||
70 | kfree_skb(skb); | ||
71 | dev->stats.tx_dropped++; | ||
72 | return 1; | ||
73 | } | ||
74 | |||
75 | return 0; | ||
76 | } | ||
77 | |||
63 | struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); | 78 | struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); |
64 | void free_candev(struct net_device *dev); | 79 | void free_candev(struct net_device *dev); |
65 | 80 | ||