net: modify skb_rbtree_purge to return the truesize of all purged skbs.
authorPeter Oskolkov <posk@google.com>
Thu, 2 Aug 2018 23:34:38 +0000 (23:34 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Aug 2018 00:16:46 +0000 (17:16 -0700)
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>
include/linux/skbuff.h
net/core/skbuff.c

index fd3cb1b247df8d7df21008ed000dfb966391b340..47848367c816eefdb0aaffe84ea2953050003494 100644 (file)
@@ -2585,7 +2585,7 @@ static inline void __skb_queue_purge(struct sk_buff_head *list)
                kfree_skb(skb);
 }
 
-void skb_rbtree_purge(struct rb_root *root);
+unsigned int skb_rbtree_purge(struct rb_root *root);
 
 void *netdev_alloc_frag(unsigned int fragsz);
 
index 51b0a9126e121c3cf092a6baaa6fe58d749213a2..8d574a88125d2772ee37fe717b6503e1f0e8884e 100644 (file)
@@ -2858,23 +2858,27 @@ EXPORT_SYMBOL(skb_queue_purge);
 /**
  *     skb_rbtree_purge - empty a skb rbtree
  *     @root: root of the rbtree to empty
+ *     Return value: the sum of truesizes of all purged skbs.
  *
  *     Delete all buffers on an &sk_buff rbtree. Each buffer is removed from
  *     the list and one reference dropped. This function does not take
  *     any lock. Synchronization should be handled by the caller (e.g., TCP
  *     out-of-order queue is protected by the socket lock).
  */
-void skb_rbtree_purge(struct rb_root *root)
+unsigned int skb_rbtree_purge(struct rb_root *root)
 {
        struct rb_node *p = rb_first(root);
+       unsigned int sum = 0;
 
        while (p) {
                struct sk_buff *skb = rb_entry(p, struct sk_buff, rbnode);
 
                p = rb_next(p);
                rb_erase(&skb->rbnode, root);
+               sum += skb->truesize;
                kfree_skb(skb);
        }
+       return sum;
 }
 
 /**