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 static int bpfilter_mbox_request(struct sock
*sk
, int optname
,
15 unsigned int optlen
, bool is_set
)
17 if (!bpfilter_process_sockopt
) {
18 int err
= request_module("bpfilter");
22 if (!bpfilter_process_sockopt
)
25 return bpfilter_process_sockopt(sk
, optname
, optval
, optlen
, is_set
);
28 int bpfilter_ip_set_sockopt(struct sock
*sk
, int optname
, char __user
*optval
,
31 return bpfilter_mbox_request(sk
, optname
, optval
, optlen
, true);
34 int bpfilter_ip_get_sockopt(struct sock
*sk
, int optname
, char __user
*optval
,
39 if (get_user(len
, optlen
))
42 return bpfilter_mbox_request(sk
, optname
, optval
, len
, false);