]> Pileus Git - ~andy/linux/commitdiff
skb: api to report errors for zero copy skbs
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 1 Nov 2012 09:16:28 +0000 (09:16 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 3 Nov 2012 01:29:57 +0000 (21:29 -0400)
Orphaning frags for zero copy skbs needs to allocate data in atomic
context so is has a chance to fail. If it does we currently discard
the skb which is safe, but we don't report anything to the caller,
so it can not recover by e.g. disabling zero copy.

Add an API to free skb reporting such errors: this is used
by tun in case orphaning frags fails.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
net/core/skbuff.c

index e5eae5bc1d4da4881276ec59084bd53568f9c451..f2af494330ab6bde481d49927895cfd42fa54c78 100644 (file)
@@ -568,6 +568,7 @@ static inline struct rtable *skb_rtable(const struct sk_buff *skb)
 }
 
 extern void kfree_skb(struct sk_buff *skb);
+extern void skb_tx_error(struct sk_buff *skb);
 extern void consume_skb(struct sk_buff *skb);
 extern void           __kfree_skb(struct sk_buff *skb);
 extern struct kmem_cache *skbuff_head_cache;
index 4abdf71a23f8ea99c34623bcbc68a18acd0c3e5f..d9addea10309098648a17048e4a9b4989ebc8440 100644 (file)
@@ -634,6 +634,26 @@ void kfree_skb(struct sk_buff *skb)
 }
 EXPORT_SYMBOL(kfree_skb);
 
+/**
+ *     skb_tx_error - report an sk_buff xmit error
+ *     @skb: buffer that triggered an error
+ *
+ *     Report xmit error if a device callback is tracking this skb.
+ *     skb must be freed afterwards.
+ */
+void skb_tx_error(struct sk_buff *skb)
+{
+       if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
+               struct ubuf_info *uarg;
+
+               uarg = skb_shinfo(skb)->destructor_arg;
+               if (uarg->callback)
+                       uarg->callback(uarg, false);
+               skb_shinfo(skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY;
+       }
+}
+EXPORT_SYMBOL(skb_tx_error);
+
 /**
  *     consume_skb - free an skbuff
  *     @skb: buffer to free