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 <[email protected]>
>
> ---
>
> 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.
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core