Linux 4.18.10
[linux/fpc-iii.git] / net / ipv4 / bpfilter / sockopt.c
blob5e04ed25bc0e92a5f4e62c78b45b50d9e6b7d1fc
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,
9 char __user *optval,
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,
14 char __user *optval,
15 unsigned int optlen, bool is_set)
17 if (!bpfilter_process_sockopt) {
18 int err = request_module("bpfilter");
20 if (err)
21 return err;
22 if (!bpfilter_process_sockopt)
23 return -ECHILD;
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,
29 unsigned int optlen)
31 return bpfilter_mbox_request(sk, optname, optval, optlen, true);
34 int bpfilter_ip_get_sockopt(struct sock *sk, int optname, char __user *optval,
35 int __user *optlen)
37 int len;
39 if (get_user(len, optlen))
40 return -EFAULT;
42 return bpfilter_mbox_request(sk, optname, optval, len, false);