aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorOliver Hartkopp <oliver@hartkopp.net>2010-01-12 05:00:46 -0500
committerDavid S. Miller <davem@davemloft.net>2010-01-12 05:00:46 -0500
commit3ccd4c6167d3b39d52631767ebbf8b5677c5855d (patch)
treebfcb801edebd00e8b30e897038bad7fee39625cc /include/linux
parentd218d11133d888f9745802146a50255a4781d37a (diff)
can: Unify droping of invalid tx skbs and netdev stats
To prevent the CAN drivers to operate on invalid socketbuffers the skbs are now checked and silently dropped at the xmit-function consistently. Also the netdev stats are consistently using the CAN data length code (dlc) for [rx|tx]_bytes now. Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/can/dev.h15
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. */
64static 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
63struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); 78struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max);
64void free_candev(struct net_device *dev); 79void free_candev(struct net_device *dev);
65 80