Skip to content

Commit 385114d

Browse files
Peter Oskolkovdavem330
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 <[email protected]> Signed-off-by: Peter Oskolkov <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Cc: Florian Westphal <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7969e5c commit 385114d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

include/linux/skbuff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2585,7 +2585,7 @@ static inline void __skb_queue_purge(struct sk_buff_head *list)
25852585
kfree_skb(skb);
25862586
}
25872587

2588-
void skb_rbtree_purge(struct rb_root *root);
2588+
unsigned int skb_rbtree_purge(struct rb_root *root);
25892589

25902590
void *netdev_alloc_frag(unsigned int fragsz);
25912591

net/core/skbuff.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2858,23 +2858,27 @@ EXPORT_SYMBOL(skb_queue_purge);
28582858
/**
28592859
* skb_rbtree_purge - empty a skb rbtree
28602860
* @root: root of the rbtree to empty
2861+
* Return value: the sum of truesizes of all purged skbs.
28612862
*
28622863
* Delete all buffers on an &sk_buff rbtree. Each buffer is removed from
28632864
* the list and one reference dropped. This function does not take
28642865
* any lock. Synchronization should be handled by the caller (e.g., TCP
28652866
* out-of-order queue is protected by the socket lock).
28662867
*/
2867-
void skb_rbtree_purge(struct rb_root *root)
2868+
unsigned int skb_rbtree_purge(struct rb_root *root)
28682869
{
28692870
struct rb_node *p = rb_first(root);
2871+
unsigned int sum = 0;
28702872

28712873
while (p) {
28722874
struct sk_buff *skb = rb_entry(p, struct sk_buff, rbnode);
28732875

28742876
p = rb_next(p);
28752877
rb_erase(&skb->rbnode, root);
2878+
sum += skb->truesize;
28762879
kfree_skb(skb);
28772880
}
2881+
return sum;
28782882
}
28792883

28802884
/**

0 commit comments

Comments
 (0)