1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/uaccess.h>
3 #include <linux/bpfilter.h>
4 #include <uapi/linux/bpf.h>
5 #include <linux/wait.h>
6 #include <linux/kmod.h>
8 int (*bpfilter_process_sockopt)(struct sock *sk, int optname,
10 unsigned int optlen, bool is_set);
11 EXPORT_SYMBOL_GPL(bpfilter_process_sockopt);
13 int bpfilter_mbox_request(struct sock *sk, int optname, char __user *optval,
14 unsigned int optlen, bool is_set)
16 if (!bpfilter_process_sockopt) {
17 int err = request_module("bpfilter");
21 if (!bpfilter_process_sockopt)
24 return bpfilter_process_sockopt(sk, optname, optval, optlen, is_set);
27 int bpfilter_ip_set_sockopt(struct sock *sk, int optname, char __user *optval,
30 return bpfilter_mbox_request(sk, optname, optval, optlen, true);
33 int bpfilter_ip_get_sockopt(struct sock *sk, int optname, char __user *optval,
38 if (get_user(len, optlen))
41 return bpfilter_mbox_request(sk, optname, optval, len, false);