Skip to content

Commit 1231eec

Browse files
committed
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>
1 parent 8ef522c commit 1231eec

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

include/net/inet_frag.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,8 @@ void inet_frag_kill(struct inet_frag_queue *q, int *refs);
141141
void inet_frag_destroy(struct inet_frag_queue *q);
142142
struct inet_frag_queue *inet_frag_find(struct fqdir *fqdir, void *key);
143143

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);
147146

148147
static inline void inet_frag_putn(struct inet_frag_queue *q, int refs)
149148
{

net/ipv4/inet_fragment.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ static void inet_frag_destroy_rcu(struct rcu_head *head)
263263
kmem_cache_free(f->frags_cachep, q);
264264
}
265265

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)
268268
{
269269
struct rb_node *p = rb_first(root);
270270
unsigned int sum = 0;
@@ -284,7 +284,16 @@ unsigned int inet_frag_rbtree_purge(struct rb_root *root,
284284
}
285285
return sum;
286286
}
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);
288297

289298
void inet_frag_destroy(struct inet_frag_queue *q)
290299
{

net/ipv4/ip_fragment.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,10 @@ static int ip_frag_too_far(struct ipq *qp)
240240

241241
static int ip_frag_reinit(struct ipq *qp)
242242
{
243-
unsigned int sum_truesize = 0;
244-
245243
if (!mod_timer_pending(&qp->q.timer, jiffies + qp->q.fqdir->timeout))
246244
return -ETIMEDOUT;
247245

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);
251247

252248
qp->q.flags = 0;
253249
qp->q.len = 0;

0 commit comments

Comments
 (0)