1 // SPDX-License-Identifier: GPL-2.0
6 #include <sys/socket.h>
9 #include "../../include/uapi/linux/bpf.h"
10 #include <asm/unistd.h>
15 static int handle_get_cmd(struct mbox_request *cmd)
26 static int handle_set_cmd(struct mbox_request *cmd)
31 static void loop(void)
34 struct mbox_request req;
35 struct mbox_reply reply;
38 n = read(0, &req, sizeof(req));
39 if (n != sizeof(req)) {
40 fprintf(debug_f, "invalid request %d\n", n);
44 reply.status = req.is_set ?
45 handle_set_cmd(&req) :
48 n = write(1, &reply, sizeof(reply));
49 if (n != sizeof(reply)) {
50 fprintf(debug_f, "reply failed %d\n", n);
58 debug_f = fopen("/dev/kmsg", "w");
59 setvbuf(debug_f, 0, _IOLBF, 0);
60 fprintf(debug_f, "Started bpfilter\n");