Subject: Re: [PATCH 2/4] macvlan: cleanup rx statistics

From: Patrick McHardy <[email-masked]>
Date: Tue, 24 Nov 2009 11:41:38 +0100

Arnd Bergmann wrote:
> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
> index ae2b5c7..a0dea23 100644
> --- a/drivers/net/macvlan.c
> +++ b/drivers/net/macvlan.c
> @@ -116,42 +116,53 @@ static int macvlan_addr_busy(const struct macvlan_port *port,
>  	return 0;
>  }
>  
> +static inline void macvlan_count_rx(const struct macvlan_dev *vlan, int length,

Please use unsigned int for length values.

Regarding Eric's comments, I also think it would be more readable to use
if (success) {
	...
} else {
	...
}

> +			     int success, int multicast)
> +{
> +	struct macvlan_rx_stats *rx_stats;
> +
> +	rx_stats = per_cpu_ptr(vlan->rx_stats, smp_processor_id());
> +	rx_stats->rx_packets += success != 0;
> +	rx_stats->rx_bytes   += success ? length : 0;
> +	rx_stats->multicast  += success && multicast;
> +	rx_stats->rx_errors  += !success;
> +}
> +
> +static int macvlan_broadcast_one(struct sk_buff *skb, struct net_device *dev,
> +				 const struct ethhdr *eth)
> +{
> +	if (!skb)
> +		return NET_RX_DROP;
> +
> +	skb->dev = dev;
> +	if (!compare_ether_addr_64bits(eth->h_dest,
> +				       dev->broadcast))

This would fit on one line without reducing readability.

> +		skb->pkt_type = PACKET_BROADCAST;
> +	else
> +		skb->pkt_type = PACKET_MULTICAST;
> +
> +	return netif_rx(skb);
> +}