netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
To: socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org,
	wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org
Subject: Re: [PATCH net-next-2.6 v3] can: Unify droping of invalid tx skbs and netdev stats
Date: Mon, 11 Jan 2010 15:55:37 -0800 (PST)	[thread overview]
Message-ID: <20100111.155537.166350032.davem@davemloft.net> (raw)
In-Reply-To: <4B4BB1F9.3010808-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>

From: Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
Date: Tue, 12 Jan 2010 00:19:21 +0100

>  static netdev_tx_t vcan_tx(struct sk_buff *skb, struct net_device *dev)
>  {
> +	struct can_frame *cf = (struct can_frame *)skb->data;
>  	struct net_device_stats *stats = &dev->stats;
>  	int loop;
>  
> +	if (unlikely(skb->len != sizeof(*cf) || cf->can_dlc > 8)) {
> +		kfree_skb(skb);
> +		stats->tx_dropped++;
> +		return NETDEV_TX_OK;
> +	}
> +
 ...
> +/* Drop a given socketbuffer if it does not contain a valid CAN frame. */
> +static inline int can_dropped_invalid_skb(struct net_device *dev,
> +					  struct sk_buff *skb)
> +{
> +	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;
> +}
> +
>  struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max);

Why are you not using the new helper function in vcan_tx()?

  parent reply	other threads:[~2010-01-11 23:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-11 23:19 [PATCH net-next-2.6 v3] can: Unify droping of invalid tx skbs and netdev stats Oliver Hartkopp
     [not found] ` <4B4BB1F9.3010808-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
2010-01-11 23:55   ` David Miller [this message]
     [not found]     ` <20100111.155537.166350032.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2010-01-12  8:32       ` Oliver Hartkopp
     [not found]         ` <4B4C338B.7000808-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
2010-01-12  8:39           ` David Miller
2010-01-12  8:44           ` 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=20100111.155537.166350032.davem@davemloft.net \
    --to=davem-ft/pcqaiutieiz0/mpfg9q@public.gmane.org \
    --cc=mkl-bIcnvbaLZ9MEGnE8C9+IrQ@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 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).