[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4B4B4765.30302@hartkopp.net>
Date: Mon, 11 Jan 2010 16:44:37 +0100
From: Oliver Hartkopp <socketcan@...tkopp.net>
To: Wolfgang Grandegger <wg@...ndegger.com>
CC: David Miller <davem@...emloft.net>,
SocketCAN Core Mailing List <socketcan-core@...ts.berlios.de>,
Linux Netdev List <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next-2.6] can: Unify droping of invalid tx skbs and
netdev stats
Wolfgang Grandegger wrote:
>>
>> + if (skb->len != sizeof(*cf) || cf->can_dlc > 8) {
>> + kfree_skb(skb);
>> + dev->stats.tx_dropped++;
>> + return NETDEV_TX_OK;
>> + }
>
> A static inline function "invalid_can_skb(skb)" (or "no_can_skb") would
> be handy here:
>
> if (invalid_can_skb(skb)) {
> kfree_skb(skb);
> dev->stats.tx_dropped++;
> return NETDEV_TX_OK;
> }
Another idea could be:
if (can_dropped_invalid_skb(skb, dev))
return NETDEV_TX_OK;
with
static inline int can_dropped_invalid_skb(struct sk_buff *skb, struct net_device *dev)
{
const struct can_frame *cf = (struct can_frame *)skb->data;
if (unlikely(skb->len != sizeof(*cf) || cf->can_dlc > 8)) {
kfree_skb(skb);
dev->stats.tx_dropped++;
return 1;
}
return 0;
}
Any preferences?
Regards,
Oliver
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists