Skip to content

Commit e4fe1bf

Browse files
aditighagMartin KaFai Lau
authored andcommitted
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>
1 parent 7625d2e commit e4fe1bf

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
@@ -437,7 +437,6 @@ struct udp_seq_afinfo {
437437
struct udp_iter_state {
438438
struct seq_net_private p;
439439
int bucket;
440-
struct udp_seq_afinfo *bpf_seq_afinfo;
441440
};
442441

443442
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
@@ -2998,14 +2998,18 @@ static bool seq_sk_match(struct seq_file *seq, const struct sock *sk)
29982998
net_eq(sock_net(sk), seq_file_net(seq)));
29992999
}
30003000

3001+
#ifdef CONFIG_BPF_SYSCALL
3002+
static const struct seq_operations bpf_iter_udp_seq_ops;
3003+
#endif
30013004
static struct udp_table *udp_get_table_seq(struct seq_file *seq,
30023005
struct net *net)
30033006
{
3004-
const struct udp_iter_state *state = seq->private;
30053007
const struct udp_seq_afinfo *afinfo;
30063008

3007-
if (state->bpf_seq_afinfo)
3009+
#ifdef CONFIG_BPF_SYSCALL
3010+
if (seq->op == &bpf_iter_udp_seq_ops)
30083011
return net->ipv4.udp_table;
3012+
#endif
30093013

30103014
afinfo = pde_data(file_inode(seq->file));
30113015
return afinfo->udp_table ? : net->ipv4.udp_table;
@@ -3429,28 +3433,11 @@ DEFINE_BPF_ITER_FUNC(udp, struct bpf_iter_meta *meta,
34293433

34303434
static int bpf_iter_init_udp(void *priv_data, struct bpf_iter_aux_info *aux)
34313435
{
3432-
struct udp_iter_state *st = priv_data;
3433-
struct udp_seq_afinfo *afinfo;
3434-
int ret;
3435-
3436-
afinfo = kmalloc(sizeof(*afinfo), GFP_USER | __GFP_NOWARN);
3437-
if (!afinfo)
3438-
return -ENOMEM;
3439-
3440-
afinfo->family = AF_UNSPEC;
3441-
afinfo->udp_table = NULL;
3442-
st->bpf_seq_afinfo = afinfo;
3443-
ret = bpf_iter_init_seq_net(priv_data, aux);
3444-
if (ret)
3445-
kfree(afinfo);
3446-
return ret;
3436+
return bpf_iter_init_seq_net(priv_data, aux);
34473437
}
34483438

34493439
static void bpf_iter_fini_udp(void *priv_data)
34503440
{
3451-
struct udp_iter_state *st = priv_data;
3452-
3453-
kfree(st->bpf_seq_afinfo);
34543441
bpf_iter_fini_seq_net(priv_data);
34553442
}
34563443

0 commit comments

Comments
 (0)