Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

inet: frags: add inet_frag_queue_flush()

Instead of exporting inet_frag_rbtree_purge() which requires that
caller takes care of memory accounting, add a new helper. We will
need to call it from a few places in the next patch.

Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20251207010942.1672972-3-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+15 -11
+2 -3
include/net/inet_frag.h
··· 141 141 void inet_frag_destroy(struct inet_frag_queue *q); 142 142 struct inet_frag_queue *inet_frag_find(struct fqdir *fqdir, void *key); 143 143 144 - /* Free all skbs in the queue; return the sum of their truesizes. */ 145 - unsigned int inet_frag_rbtree_purge(struct rb_root *root, 146 - enum skb_drop_reason reason); 144 + void inet_frag_queue_flush(struct inet_frag_queue *q, 145 + enum skb_drop_reason reason); 147 146 148 147 static inline void inet_frag_putn(struct inet_frag_queue *q, int refs) 149 148 {
+12 -3
net/ipv4/inet_fragment.c
··· 263 263 kmem_cache_free(f->frags_cachep, q); 264 264 } 265 265 266 - unsigned int inet_frag_rbtree_purge(struct rb_root *root, 267 - enum skb_drop_reason reason) 266 + static unsigned int 267 + inet_frag_rbtree_purge(struct rb_root *root, enum skb_drop_reason reason) 268 268 { 269 269 struct rb_node *p = rb_first(root); 270 270 unsigned int sum = 0; ··· 284 284 } 285 285 return sum; 286 286 } 287 - EXPORT_SYMBOL(inet_frag_rbtree_purge); 287 + 288 + void inet_frag_queue_flush(struct inet_frag_queue *q, 289 + enum skb_drop_reason reason) 290 + { 291 + unsigned int sum; 292 + 293 + sum = inet_frag_rbtree_purge(&q->rb_fragments, reason); 294 + sub_frag_mem_limit(q->fqdir, sum); 295 + } 296 + EXPORT_SYMBOL(inet_frag_queue_flush); 288 297 289 298 void inet_frag_destroy(struct inet_frag_queue *q) 290 299 {
+1 -5
net/ipv4/ip_fragment.c
··· 240 240 241 241 static int ip_frag_reinit(struct ipq *qp) 242 242 { 243 - unsigned int sum_truesize = 0; 244 - 245 243 if (!mod_timer_pending(&qp->q.timer, jiffies + qp->q.fqdir->timeout)) 246 244 return -ETIMEDOUT; 247 245 248 - sum_truesize = inet_frag_rbtree_purge(&qp->q.rb_fragments, 249 - SKB_DROP_REASON_FRAG_TOO_FAR); 250 - sub_frag_mem_limit(qp->q.fqdir, sum_truesize); 246 + inet_frag_queue_flush(&qp->q, SKB_DROP_REASON_FRAG_TOO_FAR); 251 247 252 248 qp->q.flags = 0; 253 249 qp->q.len = 0;