From: Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
To: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
Cc: SocketCAN Core Mailing List
<socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org>,
Linux Netdev List
<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Subject: Re: [PATCH net-next-2.6] can: Unify droping of invalid tx skbs and netdev stats
Date: Mon, 11 Jan 2010 16:44:37 +0100 [thread overview]
Message-ID: <4B4B4765.30302@hartkopp.net> (raw)
In-Reply-To: <4B4B20E3.3070603-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
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
next prev parent reply other threads:[~2010-01-11 15:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-08 18:38 [PATCH net-next-2.6] can: Unify droping of invalid tx skbs and netdev stats Oliver Hartkopp
[not found] ` <4B477BB7.2030108-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
2010-01-11 13:00 ` Wolfgang Grandegger
[not found] ` <4B4B20E3.3070603-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-01-11 15:44 ` Oliver Hartkopp [this message]
[not found] ` <4B4B4765.30302-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
2010-01-11 19:11 ` Marc Kleine-Budde
2010-01-11 19:13 ` Marc Kleine-Budde
[not found] ` <4B4B77D3.6030200-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-01-11 19:23 ` Wolfgang Grandegger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B4B4765.30302@hartkopp.net \
--to=socketcan-fj+pqtutwrtk1umjsbkqmq@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org \
--cc=wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.