Patchwork macvlan: Fix rx counters update in macvlan_handle_frame()

login
register
mail settings
Submitter Sridhar Samudrala
Date July 22, 2010, 11:04 p.m.
Message ID <1279839867.3274.25.camel@w-sridhar.beaverton.ibm.com>
Download mbox | patch
Permalink /patch/59689/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Sridhar Samudrala - July 22, 2010, 11:04 p.m.
Fix macvlan_handle_frame() to update the rx counters based
on the return value of the vlan->receive call.

Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Herbert Xu - July 23, 2010, 7:23 a.m.
On Thu, Jul 22, 2010 at 04:04:27PM -0700, Sridhar Samudrala wrote:
> Fix macvlan_handle_frame() to update the rx counters based
> on the return value of the vlan->receive call.
> 
> Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
> 
> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
> index 87e8d4c..2732df1 100644
> --- a/drivers/net/macvlan.c
> +++ b/drivers/net/macvlan.c
> @@ -152,7 +152,8 @@ static struct sk_buff *macvlan_handle_frame(struct macvlan_port *port,
>  	const struct macvlan_dev *vlan;
>  	const struct macvlan_dev *src;
>  	struct net_device *dev;
> -	unsigned int len;
> +	unsigned int len = 0;
> +	int ret = NET_RX_DROP;
>  
>  	if (is_multicast_ether_addr(eth->h_dest)) {
>  		src = macvlan_hash_lookup(port, eth->h_source);
> @@ -184,18 +185,20 @@ static struct sk_buff *macvlan_handle_frame(struct macvlan_port *port,
>  	dev = vlan->dev;
>  	if (unlikely(!(dev->flags & IFF_UP))) {
>  		kfree_skb(skb);
> -		return NULL;
> +		goto out;

I don't think we should count packet drops when the interface is
down.  This would be inconsistent with other devices such as
IPIP.

Otherthis your patch looks good to me.

Thanks,
David Miller - July 23, 2010, 7:31 a.m.
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Fri, 23 Jul 2010 15:23:39 +0800

> I don't think we should count packet drops when the interface is
> down.  This would be inconsistent with other devices such as
> IPIP.

Agreed.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 87e8d4c..2732df1 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -152,7 +152,8 @@  static struct sk_buff *macvlan_handle_frame(struct macvlan_port *port,
 	const struct macvlan_dev *vlan;
 	const struct macvlan_dev *src;
 	struct net_device *dev;
-	unsigned int len;
+	unsigned int len = 0;
+	int ret = NET_RX_DROP;
 
 	if (is_multicast_ether_addr(eth->h_dest)) {
 		src = macvlan_hash_lookup(port, eth->h_source);
@@ -184,18 +185,20 @@  static struct sk_buff *macvlan_handle_frame(struct macvlan_port *port,
 	dev = vlan->dev;
 	if (unlikely(!(dev->flags & IFF_UP))) {
 		kfree_skb(skb);
-		return NULL;
+		goto out;
 	}
 	len = skb->len + ETH_HLEN;
 	skb = skb_share_check(skb, GFP_ATOMIC);
-	macvlan_count_rx(vlan, len, skb != NULL, 0);
 	if (!skb)
-		return NULL;
+		goto out;
 
 	skb->dev = dev;
 	skb->pkt_type = PACKET_HOST;
 
-	vlan->receive(skb);
+	ret = vlan->receive(skb);
+
+out:
+	macvlan_count_rx(vlan, len, ret == NET_RX_SUCCESS, 0);
 	return NULL;
 }