Commit 511a3eda authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

net: dropreason: propagate drop_reason to skb_release_data()

When an skb with a frag list is consumed, we currently
pretend all skbs in the frag list were dropped.

In order to fix this, add a @reason argument to skb_release_data()
and skb_release_all().
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0e84afe8
...@@ -769,7 +769,7 @@ static void skb_free_head(struct sk_buff *skb) ...@@ -769,7 +769,7 @@ static void skb_free_head(struct sk_buff *skb)
} }
} }
static void skb_release_data(struct sk_buff *skb) static void skb_release_data(struct sk_buff *skb, enum skb_drop_reason reason)
{ {
struct skb_shared_info *shinfo = skb_shinfo(skb); struct skb_shared_info *shinfo = skb_shinfo(skb);
int i; int i;
...@@ -792,7 +792,7 @@ static void skb_release_data(struct sk_buff *skb) ...@@ -792,7 +792,7 @@ static void skb_release_data(struct sk_buff *skb)
free_head: free_head:
if (shinfo->frag_list) if (shinfo->frag_list)
kfree_skb_list(shinfo->frag_list); kfree_skb_list_reason(shinfo->frag_list, reason);
skb_free_head(skb); skb_free_head(skb);
exit: exit:
...@@ -855,11 +855,11 @@ void skb_release_head_state(struct sk_buff *skb) ...@@ -855,11 +855,11 @@ void skb_release_head_state(struct sk_buff *skb)
} }
/* Free everything but the sk_buff shell. */ /* Free everything but the sk_buff shell. */
static void skb_release_all(struct sk_buff *skb) static void skb_release_all(struct sk_buff *skb, enum skb_drop_reason reason)
{ {
skb_release_head_state(skb); skb_release_head_state(skb);
if (likely(skb->head)) if (likely(skb->head))
skb_release_data(skb); skb_release_data(skb, reason);
} }
/** /**
...@@ -873,7 +873,7 @@ static void skb_release_all(struct sk_buff *skb) ...@@ -873,7 +873,7 @@ static void skb_release_all(struct sk_buff *skb)
void __kfree_skb(struct sk_buff *skb) void __kfree_skb(struct sk_buff *skb)
{ {
skb_release_all(skb); skb_release_all(skb, SKB_DROP_REASON_NOT_SPECIFIED);
kfree_skbmem(skb); kfree_skbmem(skb);
} }
EXPORT_SYMBOL(__kfree_skb); EXPORT_SYMBOL(__kfree_skb);
...@@ -1056,7 +1056,7 @@ EXPORT_SYMBOL(consume_skb); ...@@ -1056,7 +1056,7 @@ EXPORT_SYMBOL(consume_skb);
void __consume_stateless_skb(struct sk_buff *skb) void __consume_stateless_skb(struct sk_buff *skb)
{ {
trace_consume_skb(skb); trace_consume_skb(skb);
skb_release_data(skb); skb_release_data(skb, SKB_CONSUMED);
kfree_skbmem(skb); kfree_skbmem(skb);
} }
...@@ -1081,7 +1081,7 @@ static void napi_skb_cache_put(struct sk_buff *skb) ...@@ -1081,7 +1081,7 @@ static void napi_skb_cache_put(struct sk_buff *skb)
void __kfree_skb_defer(struct sk_buff *skb) void __kfree_skb_defer(struct sk_buff *skb)
{ {
skb_release_all(skb); skb_release_all(skb, SKB_DROP_REASON_NOT_SPECIFIED);
napi_skb_cache_put(skb); napi_skb_cache_put(skb);
} }
...@@ -1119,7 +1119,7 @@ void napi_consume_skb(struct sk_buff *skb, int budget) ...@@ -1119,7 +1119,7 @@ void napi_consume_skb(struct sk_buff *skb, int budget)
return; return;
} }
skb_release_all(skb); skb_release_all(skb, SKB_CONSUMED);
napi_skb_cache_put(skb); napi_skb_cache_put(skb);
} }
EXPORT_SYMBOL(napi_consume_skb); EXPORT_SYMBOL(napi_consume_skb);
...@@ -1250,7 +1250,7 @@ EXPORT_SYMBOL_GPL(alloc_skb_for_msg); ...@@ -1250,7 +1250,7 @@ EXPORT_SYMBOL_GPL(alloc_skb_for_msg);
*/ */
struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src) struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src)
{ {
skb_release_all(dst); skb_release_all(dst, SKB_CONSUMED);
return __skb_clone(dst, src); return __skb_clone(dst, src);
} }
EXPORT_SYMBOL_GPL(skb_morph); EXPORT_SYMBOL_GPL(skb_morph);
...@@ -1873,7 +1873,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, ...@@ -1873,7 +1873,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
if (skb_has_frag_list(skb)) if (skb_has_frag_list(skb))
skb_clone_fraglist(skb); skb_clone_fraglist(skb);
skb_release_data(skb); skb_release_data(skb, SKB_CONSUMED);
} else { } else {
skb_free_head(skb); skb_free_head(skb);
} }
...@@ -6213,7 +6213,7 @@ static int pskb_carve_inside_header(struct sk_buff *skb, const u32 off, ...@@ -6213,7 +6213,7 @@ static int pskb_carve_inside_header(struct sk_buff *skb, const u32 off,
skb_frag_ref(skb, i); skb_frag_ref(skb, i);
if (skb_has_frag_list(skb)) if (skb_has_frag_list(skb))
skb_clone_fraglist(skb); skb_clone_fraglist(skb);
skb_release_data(skb); skb_release_data(skb, SKB_CONSUMED);
} else { } else {
/* we can reuse existing recount- all we did was /* we can reuse existing recount- all we did was
* relocate values * relocate values
...@@ -6356,7 +6356,7 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off, ...@@ -6356,7 +6356,7 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,
kfree(data); kfree(data);
return -ENOMEM; return -ENOMEM;
} }
skb_release_data(skb); skb_release_data(skb, SKB_CONSUMED);
skb->head = data; skb->head = data;
skb->head_frag = 0; skb->head_frag = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment