From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: Wolfgang Grandegger <wg@grandegger.com>,
SocketCAN Core Mailing List <socketcan-core@lists.berlios.de>,
Linux Netdev List <netdev@vger.kernel.org>,
David Miller <davem@davemloft.net>
Subject: Re: [PATCH net-next-2.6] can: Unify droping of invalid tx skbs and netdev stats
Date: Mon, 11 Jan 2010 20:13:50 +0100 [thread overview]
Message-ID: <4B4B786E.80609@pengutronix.de> (raw)
In-Reply-To: <4B4B77D3.6030200@pengutronix.de>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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
I mean...have the struct net device the first argument
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
iEYEARECAAYFAktLeG4ACgkQjTAFq1RaXHPhswCfaeUWz6rQzthR02H+AtqF/kXw
UIcAn0LOdZy8UZP61O9vuQgFU21h6atO
=LQ1H
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2010-01-11 19:13 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 [this message]
[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=4B4B786E.80609@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=socketcan-core@lists.berlios.de \
--cc=socketcan@hartkopp.net \
--cc=wg@grandegger.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).