Skip to content

Commit 3bde783

Browse files
posk-iogregkh
authored andcommitted
net: modify skb_rbtree_purge to return the truesize of all purged skbs.
Tested: see the next patch is the series. Suggested-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Peter Oskolkov <posk@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit 385114d) Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7750c41 commit 3bde783

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

include/linux/skbuff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2581,7 +2581,7 @@ static inline void __skb_queue_purge(struct sk_buff_head *list)
25812581
kfree_skb(skb);
25822582
}
25832583

2584-
void skb_rbtree_purge(struct rb_root *root);
2584+
unsigned int skb_rbtree_purge(struct rb_root *root);
25852585

25862586
void *netdev_alloc_frag(unsigned int fragsz);
25872587

net/core/skbuff.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2842,23 +2842,27 @@ EXPORT_SYMBOL(skb_queue_purge);
28422842
/**
28432843
* skb_rbtree_purge - empty a skb rbtree
28442844
* @root: root of the rbtree to empty
2845+
* Return value: the sum of truesizes of all purged skbs.
28452846
*
28462847
* Delete all buffers on an &sk_buff rbtree. Each buffer is removed from
28472848
* the list and one reference dropped. This function does not take
28482849
* any lock. Synchronization should be handled by the caller (e.g., TCP
28492850
* out-of-order queue is protected by the socket lock).
28502851
*/
2851-
void skb_rbtree_purge(struct rb_root *root)
2852+
unsigned int skb_rbtree_purge(struct rb_root *root)
28522853
{
28532854
struct rb_node *p = rb_first(root);
2855+
unsigned int sum = 0;
28542856

28552857
while (p) {
28562858
struct sk_buff *skb = rb_entry(p, struct sk_buff, rbnode);
28572859

28582860
p = rb_next(p);
28592861
rb_erase(&skb->rbnode, root);
2862+
sum += skb->truesize;
28602863
kfree_skb(skb);
28612864
}
2865+
return sum;
28622866
}
28632867

28642868
/**

0 commit comments

Comments
 (0)