[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4B4B20E3.3070603@grandegger.com>
Date: Mon, 11 Jan 2010 14:00:19 +0100
From: Wolfgang Grandegger <wg@...ndegger.com>
To: Oliver Hartkopp <socketcan@...tkopp.net>
CC: David Miller <davem@...emloft.net>,
SocketCAN Core Mailing List <socketcan-core@...ts.berlios.de>,
Linux Netdev List <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next-2.6] can: Unify droping of invalid tx skbs and
netdev stats
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@...tkopp.net>
>
> ---
>
> 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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists