diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2012-11-01 09:16:28 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-02 21:29:57 -0400 |
commit | 25121173f7b1e4ac3fc692df6e7b8c52ec36abba (patch) | |
tree | 5d52c2fe88397dae0ee799c194d46bf641b0a902 /net/core/skbuff.c | |
parent | e19d6763cc300fcb706bd291b24ac06be71e1ce6 (diff) |
skb: api to report errors for zero copy skbs
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>
Diffstat (limited to 'net/core/skbuff.c')
-rw-r--r-- | net/core/skbuff.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 4abdf71a23f8..d9addea10309 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -635,6 +635,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 * |