From d9d8e8088c6ecdc8a2957ffe1002547a9f1c6c0d Mon Sep 17 00:00:00 2001 From: derry Date: Thu, 25 May 2023 16:28:24 +0800 Subject: [PATCH] Fix compilation errors under certain kernel versions #179 --- oaf/Makefile | 4 ++++ oaf/src/app_filter.c | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/oaf/Makefile b/oaf/Makefile index 6a51fc2..aaa95dd 100755 --- a/oaf/Makefile +++ b/oaf/Makefile @@ -23,6 +23,10 @@ define KernelPackage/oaf/description endef +EXTRA_CFLAGS:=-Wno-declaration-after-statement -Wno-strict-prototypes -Wno-unused-variable -Wno-implicit-fallthrough -Wno-missing-braces -Wno-parentheses + + + MAKE_OPTS:= \ $(KERNEL_MAKE_FLAGS) \ M="$(PKG_BUILD_DIR)" \ diff --git a/oaf/src/app_filter.c b/oaf/src/app_filter.c index c27dd23..69b61eb 100755 --- a/oaf/src/app_filter.c +++ b/oaf/src/app_filter.c @@ -913,7 +913,6 @@ int af_check_bcast_ip(flow_info_t *f) return 0; } -#define MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X" u_int32_t app_filter_hook_bypass_handle(struct sk_buff *skb, struct net_device *dev){ flow_info_t flow; u_int8_t smac[ETH_ALEN]; @@ -924,7 +923,7 @@ u_int32_t app_filter_hook_bypass_handle(struct sk_buff *skb, struct net_device * if (0 == af_lan_ip || 0 == af_lan_mask) return NF_ACCEPT; - if (dev->name && strstr(dev->name, "docker")) + if (strstr(dev->name, "docker")) return NF_ACCEPT; memset((char *)&flow, 0x0, sizeof(flow_info_t)); @@ -1151,19 +1150,20 @@ void fini_oaf_timer(void) static struct sock *oaf_sock = NULL; +#define OAF_EXTRA_MSG_BUF_LEN 128 int af_send_msg_to_user(char *pbuf, uint16_t len) { struct sk_buff *nl_skb; struct nlmsghdr *nlh; - //todo: kmalloc - char msg_buf[MAX_OAF_NL_MSG_LEN] = {0}; + int buf_len = OAF_EXTRA_MSG_BUF_LEN + len; + char *msg_buf = kmalloc(buf_len, GFP_KERNEL); struct af_msg_hdr *hdr = NULL; char *p_data = NULL; int ret; if (len >= MAX_OAF_NL_MSG_LEN) return -1; - memset(msg_buf, 0x0, sizeof(msg_buf)); + memset(msg_buf, 0x0, sizeof(buf_len)); nl_skb = nlmsg_new(len + sizeof(struct af_msg_hdr), GFP_ATOMIC); if (!nl_skb) { @@ -1184,6 +1184,7 @@ int af_send_msg_to_user(char *pbuf, uint16_t len) memcpy(p_data, pbuf, len); memcpy(nlmsg_data(nlh), msg_buf, len + sizeof(struct af_msg_hdr)); ret = netlink_unicast(oaf_sock, nl_skb, 999, MSG_DONTWAIT); + kfree(msg_buf); return ret; }