diff mbox

[net-next,02/10] vxlan: handle skb_clone failure

Message ID 1370406254-6341-2-git-send-email-stephen@networkplumber.org
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Stephen Hemminger June 5, 2013, 4:24 a.m. UTC
skb_clone can fail if out of memory. Just skip the fanout.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

---
Does not impact stable, this was introduced by the multiple
destination code.
---
 drivers/net/vxlan.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Cong Wang June 5, 2013, 6:59 a.m. UTC | #1
On Wed, 05 Jun 2013 at 04:24 GMT, Stephen Hemminger <stephen@networkplumber.org> wrote:
>  		skb1 = skb_clone(skb, GFP_ATOMIC);
> -		rc1 = vxlan_xmit_one(skb1, dev, rdst, did_rsc);
> -		if (rc == NETDEV_TX_OK)
> -			rc = rc1;
> +		if (skb1) {
> +			rc1 = vxlan_xmit_one(skb1, dev, rdst, did_rsc);
> +			if (rc == NETDEV_TX_OK)
> +				rc = rc1;
> +		}

If OOM, shouldn't we exit immediately instead of continue handle the
next one?

--
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
David Stevens June 5, 2013, 12:50 p.m. UTC | #2
Acked-by: David L Stevens <dlstevens@us.ibm.com>

> From: Stephen Hemminger <stephen@networkplumber.org>
 
> skb_clone can fail if out of memory. Just skip the fanout.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> 
> ---
> Does not impact stable, this was introduced by the multiple
> destination code.
> ---
>  drivers/net/vxlan.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
> index 536082a..9085c81 100644
> --- a/drivers/net/vxlan.c
> +++ b/drivers/net/vxlan.c
> @@ -1197,9 +1197,11 @@ static netdev_tx_t vxlan_xmit(struct sk_buff 
> *skb, struct net_device *dev)
>        struct sk_buff *skb1;
> 
>        skb1 = skb_clone(skb, GFP_ATOMIC);
> -      rc1 = vxlan_xmit_one(skb1, dev, rdst, did_rsc);
> -      if (rc == NETDEV_TX_OK)
> -         rc = rc1;
> +      if (skb1) {
> +         rc1 = vxlan_xmit_one(skb1, dev, rdst, did_rsc);
> +         if (rc == NETDEV_TX_OK)
> +            rc = rc1;
> +      }
>     }
> 
>     rc1 = vxlan_xmit_one(skb, dev, rdst0, did_rsc);
> -- 
> 1.7.10.4
> 
> --
> 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
> 

--
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
David Stevens June 5, 2013, 2:05 p.m. UTC | #3
netdev-owner@vger.kernel.org wrote on 06/05/2013 02:59:56 AM:

> From: Cong Wang <xiyou.wangcong@gmail.com>
> To: netdev@vger.kernel.org
> Date: 06/05/2013 03:00 AM
> Subject: Re: [PATCH net-next 02/10] vxlan: handle skb_clone failure
> Sent by: netdev-owner@vger.kernel.org
> 
> On Wed, 05 Jun 2013 at 04:24 GMT, Stephen Hemminger 
> <stephen@networkplumber.org> wrote:
> >        skb1 = skb_clone(skb, GFP_ATOMIC);
> > -      rc1 = vxlan_xmit_one(skb1, dev, rdst, did_rsc);
> > -      if (rc == NETDEV_TX_OK)
> > -         rc = rc1;
> > +      if (skb1) {
> > +         rc1 = vxlan_xmit_one(skb1, dev, rdst, did_rsc);
> > +         if (rc == NETDEV_TX_OK)
> > +            rc = rc1;
> > +      }
> 
> If OOM, shouldn't we exit immediately instead of continue handle the
> next one?

It could be a temporary condition; trying again doesn't really hurt,
in case some do go through. So, I prefer this, but could live with
bailing for all destinations, too.

                                                        +-DLS

--
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
Cong Wang June 6, 2013, 12:47 a.m. UTC | #4
On Wed, Jun 5, 2013 at 10:05 PM, David Stevens <dlstevens@us.ibm.com> wrote:
> netdev-owner@vger.kernel.org wrote on 06/05/2013 02:59:56 AM:
>
>> From: Cong Wang <xiyou.wangcong@gmail.com>
>> If OOM, shouldn't we exit immediately instead of continue handle the
>> next one?
>
> It could be a temporary condition; trying again doesn't really hurt,
> in case some do go through. So, I prefer this, but could live with
> bailing for all destinations, too.
>

The problem we don't know if it is temporary or not, unless mm provides
EAGAIN?
--
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
Stephen Hemminger June 6, 2013, 1:31 a.m. UTC | #5
On Thu, 6 Jun 2013 08:47:49 +0800
Cong Wang <xiyou.wangcong@gmail.com> wrote:

> On Wed, Jun 5, 2013 at 10:05 PM, David Stevens <dlstevens@us.ibm.com> wrote:
> > netdev-owner@vger.kernel.org wrote on 06/05/2013 02:59:56 AM:
> >
> >> From: Cong Wang <xiyou.wangcong@gmail.com>
> >> If OOM, shouldn't we exit immediately instead of continue handle the
> >> next one?
> >
> > It could be a temporary condition; trying again doesn't really hurt,
> > in case some do go through. So, I prefer this, but could live with
> > bailing for all destinations, too.
> >
> 
> The problem we don't know if it is temporary or not, unless mm provides
> EAGAIN?
> --
> 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

There is no EAGAIN in the network transmit path, it is not called from
user context.
--
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
diff mbox

Patch

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 536082a..9085c81 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1197,9 +1197,11 @@  static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
 		struct sk_buff *skb1;
 
 		skb1 = skb_clone(skb, GFP_ATOMIC);
-		rc1 = vxlan_xmit_one(skb1, dev, rdst, did_rsc);
-		if (rc == NETDEV_TX_OK)
-			rc = rc1;
+		if (skb1) {
+			rc1 = vxlan_xmit_one(skb1, dev, rdst, did_rsc);
+			if (rc == NETDEV_TX_OK)
+				rc = rc1;
+		}
 	}
 
 	rc1 = vxlan_xmit_one(skb, dev, rdst0, did_rsc);