Skip to content

Commit cde5da2

Browse files
committed
udp: seq_file: Remove bpf_seq_afinfo from udp_iter_state
JIRA: https://issues.redhat.com/browse/RHEL-65787 commit e4fe1bf Author: Aditi Ghag <aditi.ghag@isovalent.com> Date: Fri May 19 22:51:52 2023 +0000 udp: seq_file: Remove bpf_seq_afinfo from udp_iter_state This is a preparatory commit to remove the field. The field was previously shared between proc fs and BPF UDP socket iterators. As the follow-up commits will decouple the implementation for the iterators, remove the field. As for BPF socket iterator, filtering of sockets is exepected to be done in BPF programs. Suggested-by: Martin KaFai Lau <martin.lau@kernel.org> Signed-off-by: Aditi Ghag <aditi.ghag@isovalent.com> Link: https://lore.kernel.org/r/20230519225157.760788-5-aditi.ghag@isovalent.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
1 parent dcbb4b8 commit cde5da2

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

include/net/udp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ struct udp_seq_afinfo {
431431
struct udp_iter_state {
432432
struct seq_net_private p;
433433
int bucket;
434-
struct udp_seq_afinfo *bpf_seq_afinfo;
435434
};
436435

437436
void *udp_seq_start(struct seq_file *seq, loff_t *pos);

net/ipv4/udp.c

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,14 +3006,18 @@ static bool seq_sk_match(struct seq_file *seq, const struct sock *sk)
30063006
net_eq(sock_net(sk), seq_file_net(seq)));
30073007
}
30083008

3009+
#ifdef CONFIG_BPF_SYSCALL
3010+
static const struct seq_operations bpf_iter_udp_seq_ops;
3011+
#endif
30093012
static struct udp_table *udp_get_table_seq(struct seq_file *seq,
30103013
struct net *net)
30113014
{
3012-
const struct udp_iter_state *state = seq->private;
30133015
const struct udp_seq_afinfo *afinfo;
30143016

3015-
if (state->bpf_seq_afinfo)
3017+
#ifdef CONFIG_BPF_SYSCALL
3018+
if (seq->op == &bpf_iter_udp_seq_ops)
30163019
return net->ipv4.udp_table;
3020+
#endif
30173021

30183022
afinfo = pde_data(file_inode(seq->file));
30193023
return afinfo->udp_table ? : net->ipv4.udp_table;
@@ -3348,28 +3352,11 @@ DEFINE_BPF_ITER_FUNC(udp, struct bpf_iter_meta *meta,
33483352

33493353
static int bpf_iter_init_udp(void *priv_data, struct bpf_iter_aux_info *aux)
33503354
{
3351-
struct udp_iter_state *st = priv_data;
3352-
struct udp_seq_afinfo *afinfo;
3353-
int ret;
3354-
3355-
afinfo = kmalloc(sizeof(*afinfo), GFP_USER | __GFP_NOWARN);
3356-
if (!afinfo)
3357-
return -ENOMEM;
3358-
3359-
afinfo->family = AF_UNSPEC;
3360-
afinfo->udp_table = NULL;
3361-
st->bpf_seq_afinfo = afinfo;
3362-
ret = bpf_iter_init_seq_net(priv_data, aux);
3363-
if (ret)
3364-
kfree(afinfo);
3365-
return ret;
3355+
return bpf_iter_init_seq_net(priv_data, aux);
33663356
}
33673357

33683358
static void bpf_iter_fini_udp(void *priv_data)
33693359
{
3370-
struct udp_iter_state *st = priv_data;
3371-
3372-
kfree(st->bpf_seq_afinfo);
33733360
bpf_iter_fini_seq_net(priv_data);
33743361
}
33753362

0 commit comments

Comments
 (0)