From: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@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>
Subject: Re: [PATCH net-next-2.6] can: Unify droping of invalid tx skbs and netdev stats
Date: Mon, 11 Jan 2010 14:00:19 +0100 [thread overview]
Message-ID: <4B4B20E3.3070603@grandegger.com> (raw)
In-Reply-To: <4B477BB7.2030108-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
Hi Oliver,
Oliver Hartkopp wrote:
> To prevent the CAN drivers to operate on invalid socketbuffers the skbs are
> now checked and silently dropped at the xmit-function consistently.
>
> Also the netdev stats are consistently using the CAN data length code (dlc)
> for [rx|tx]_bytes now.
>
> Signed-off-by: Oliver Hartkopp <oliver-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
>
> ---
>
> diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
> index 166cc7e..95567be 100644
> --- a/drivers/net/can/at91_can.c
> +++ b/drivers/net/can/at91_can.c
> @@ -336,18 +336,24 @@ static void at91_chip_stop(struct net_device *dev, enum can_state state)
> */
> static netdev_tx_t at91_start_xmit(struct sk_buff *skb, struct net_device *dev)
> {
> struct at91_priv *priv = netdev_priv(dev);
> struct net_device_stats *stats = &dev->stats;
> struct can_frame *cf = (struct can_frame *)skb->data;
> unsigned int mb, prio;
> u32 reg_mid, reg_mcr;
>
> + 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;
}
Wolfgang.
next prev parent reply other threads:[~2010-01-11 13:00 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 [this message]
[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
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=4B4B20E3.3070603@grandegger.com \
--to=wg-5yr1bzd7o62+xt7jha+gda@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 \
/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.