From: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@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>,
Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@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:11:15 +0100 [thread overview]
Message-ID: <4B4B77D3.6030200@pengutronix.de> (raw)
In-Reply-To: <4B4B4765.30302-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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
cheers, Marc
- --
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAktLd9MACgkQjTAFq1RaXHPaXACfRm0YdKxSPWX8lYudtvnq7WIo
8EMAn1nwRpxJ4mMgD/D4RNwZDT1oO9DY
=t+n5
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2010-01-11 19:11 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 [this message]
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=4B4B77D3.6030200@pengutronix.de \
--to=mkl-bicnvbalz9megne8c9+irq@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=socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@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.