From: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public•gmane.org>
To: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public•gmane.org>
Cc: SocketCAN Core Mailing List
<socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public•gmane.org>,
Oliver Hartkopp
<socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public•gmane.org>,
David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public•gmane.org>,
Linux Netdev List
<netdev-u79uwXL29TY76Z2rM5mHXA@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 20:23:27 +0100 [thread overview]
Message-ID: <4B4B7AAF.5050607@grandegger.com> (raw)
In-Reply-To: <4B4B77D3.6030200-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Marc Kleine-Budde wrote:
> Oliver Hartkopp wrote:
>> 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;
>> }
>
> this functions looks nice, but I'd swap its arguments, in order to have
> the same signature as the alloc_can_skb() functions
Yep.
Wolfgang.
prev parent reply other threads:[~2010-01-11 19:23 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
[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 [this message]
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=4B4B7AAF.5050607@grandegger.com \
--to=wg-5yr1bzd7o62+xt7jha+gda@public$(echo .)gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public$(echo .)gmane.org \
--cc=mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public$(echo .)gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
--cc=socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public$(echo .)gmane.org \
--cc=socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public$(echo .)gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox