aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJordan Rife <[email protected]>2025-05-02 16:15:20 +0000
committerMartin KaFai Lau <[email protected]>2025-05-02 17:54:35 +0000
commit3e485e15a169fb69c07c75d9f82843dd481215fc (patch)
tree8c7dadffa7c3a139dea396cd8e91eef8c7889368
parentbpf: net_sched: Fix using bpf qdisc as default qdisc (diff)
downloadkernel-3e485e15a169fb69c07c75d9f82843dd481215fc.tar.gz
kernel-3e485e15a169fb69c07c75d9f82843dd481215fc.zip
bpf: udp: Make mem flags configurable through bpf_iter_udp_realloc_batch
Prepare for the next patch which needs to be able to choose either GFP_USER or GFP_NOWAIT for calls to bpf_iter_udp_realloc_batch. Signed-off-by: Jordan Rife <[email protected]> Signed-off-by: Martin KaFai Lau <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]>
-rw-r--r--net/ipv4/udp.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index f9f5b92cf4b6..68a77323bc51 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -3424,7 +3424,7 @@ struct bpf_udp_iter_state {
};
static int bpf_iter_udp_realloc_batch(struct bpf_udp_iter_state *iter,
- unsigned int new_batch_sz);
+ unsigned int new_batch_sz, gfp_t flags);
static struct sock *bpf_iter_udp_batch(struct seq_file *seq)
{
struct bpf_udp_iter_state *iter = seq->private;
@@ -3500,7 +3500,8 @@ again:
iter->st_bucket_done = true;
goto done;
}
- if (!resized && !bpf_iter_udp_realloc_batch(iter, batch_sks * 3 / 2)) {
+ if (!resized && !bpf_iter_udp_realloc_batch(iter, batch_sks * 3 / 2,
+ GFP_USER)) {
resized = true;
/* After allocating a larger batch, retry one more time to grab
* the whole bucket.
@@ -3863,12 +3864,12 @@ DEFINE_BPF_ITER_FUNC(udp, struct bpf_iter_meta *meta,
struct udp_sock *udp_sk, uid_t uid, int bucket)
static int bpf_iter_udp_realloc_batch(struct bpf_udp_iter_state *iter,
- unsigned int new_batch_sz)
+ unsigned int new_batch_sz, gfp_t flags)
{
struct sock **new_batch;
new_batch = kvmalloc_array(new_batch_sz, sizeof(*new_batch),
- GFP_USER | __GFP_NOWARN);
+ flags | __GFP_NOWARN);
if (!new_batch)
return -ENOMEM;
@@ -3891,7 +3892,7 @@ static int bpf_iter_init_udp(void *priv_data, struct bpf_iter_aux_info *aux)
if (ret)
return ret;
- ret = bpf_iter_udp_realloc_batch(iter, INIT_BATCH_SZ);
+ ret = bpf_iter_udp_realloc_batch(iter, INIT_BATCH_SZ, GFP_USER);
if (ret)
bpf_iter_fini_seq_net(priv_data);