public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: David Ahern <dsa@cumulusnetworks•com>
To: Nikolay Aleksandrov <razor@blackwall•org>, netdev@vger•kernel.org
Cc: shm@cumulusnetworks•com, davem@davemloft•net,
	Nikolay Aleksandrov <nikolay@cumulusnetworks•com>
Subject: Re: [PATCH net-next] vrf: plug skb leaks
Date: Wed, 19 Aug 2015 10:13:25 -0700	[thread overview]
Message-ID: <55D4B935.5090400@cumulusnetworks.com> (raw)
In-Reply-To: <1439953949-23736-1-git-send-email-razor@blackwall.org>

Hi Nikolay:

On 8/18/15 8:12 PM, Nikolay Aleksandrov wrote:
> diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
> index ed208317cbb5..4aa06450fafa 100644
> --- a/drivers/net/vrf.c
> +++ b/drivers/net/vrf.c
> @@ -97,6 +97,12 @@ static bool is_ip_rx_frame(struct sk_buff *skb)
>   	return false;
>   }
>
> +static void vrf_tx_error(struct net_device *vrf_dev, struct sk_buff *skb)
> +{
> +	vrf_dev->stats.tx_errors++;
> +	kfree_skb(skb);
> +}
> +
>   /* note: already called with rcu_read_lock */
>   static rx_handler_result_t vrf_handle_frame(struct sk_buff **pskb)
>   {
> @@ -149,7 +155,8 @@ static struct rtnl_link_stats64 *vrf_get_stats64(struct net_device *dev,
>   static netdev_tx_t vrf_process_v6_outbound(struct sk_buff *skb,
>   					   struct net_device *dev)
>   {
> -	return 0;
> +	vrf_tx_error(dev, skb);
> +	return NET_XMIT_DROP;
>   }
>
>   static int vrf_send_v4_prep(struct sk_buff *skb, struct flowi4 *fl4,
> @@ -206,8 +213,7 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
>   out:
>   	return ret;
>   err:
> -	vrf_dev->stats.tx_errors++;
> -	kfree_skb(skb);
> +	vrf_tx_error(vrf_dev, skb);
>   	goto out;
>   }
>
> @@ -219,6 +225,7 @@ static netdev_tx_t is_ip_tx_frame(struct sk_buff *skb, struct net_device *dev)
>   	case htons(ETH_P_IPV6):
>   		return vrf_process_v6_outbound(skb, dev);
>   	default:
> +		vrf_tx_error(dev, skb);
>   		return NET_XMIT_DROP;
>   	}
>   }
>

Would be simpler to do the vrf_tx_error at the end of is_ip_tx_frame() 
if ret == NET_XMIT_DROP.

David

  reply	other threads:[~2015-08-19 17:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19  3:12 [PATCH net-next] vrf: plug skb leaks Nikolay Aleksandrov
2015-08-19 17:13 ` David Ahern [this message]
     [not found]   ` <CABQ03vHefGG1yM6CPM2Xosa_MgxfgO0YK9EeqmHAQLZUWsh8Uw@mail.gmail.com>
2015-08-19 20:17     ` Nikolay Aleksandrov
2015-08-19 21:00       ` David Ahern
2015-08-20 19:59 ` David Miller

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=55D4B935.5090400@cumulusnetworks.com \
    --to=dsa@cumulusnetworks$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=nikolay@cumulusnetworks$(echo .)com \
    --cc=razor@blackwall$(echo .)org \
    --cc=shm@cumulusnetworks$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox