net_eq(sock_net(sk), seq_file_net(seq)));
}
+#ifdef CONFIG_BPF_SYSCALL
+static const struct seq_operations bpf_iter_udp_seq_ops;
+#endif
static struct udp_table *udp_get_table_seq(struct seq_file *seq,
struct net *net)
{
- const struct udp_iter_state *state = seq->private;
const struct udp_seq_afinfo *afinfo;
- if (state->bpf_seq_afinfo)
+#ifdef CONFIG_BPF_SYSCALL
+ if (seq->op == &bpf_iter_udp_seq_ops)
return net->ipv4.udp_table;
+#endif
afinfo = pde_data(file_inode(seq->file));
return afinfo->udp_table ? : net->ipv4.udp_table;
static int bpf_iter_init_udp(void *priv_data, struct bpf_iter_aux_info *aux)
{
- struct udp_iter_state *st = priv_data;
- struct udp_seq_afinfo *afinfo;
- int ret;
-
- afinfo = kmalloc(sizeof(*afinfo), GFP_USER | __GFP_NOWARN);
- if (!afinfo)
- return -ENOMEM;
-
- afinfo->family = AF_UNSPEC;
- afinfo->udp_table = NULL;
- st->bpf_seq_afinfo = afinfo;
- ret = bpf_iter_init_seq_net(priv_data, aux);
- if (ret)
- kfree(afinfo);
- return ret;
+ return bpf_iter_init_seq_net(priv_data, aux);
}
static void bpf_iter_fini_udp(void *priv_data)
{
- struct udp_iter_state *st = priv_data;
-
- kfree(st->bpf_seq_afinfo);
bpf_iter_fini_seq_net(priv_data);
}