OpenAppFilter: sync with upstream source

This commit is contained in:
CN_SZTL 2020-04-06 19:48:06 +08:00
parent 5f8e3d7696
commit b8c2073d4c
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
3 changed files with 18 additions and 15 deletions

View File

@ -4,7 +4,7 @@ include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=oaf
PKG_VERSION:=3.0
PKG_RELEASE:=1
PKG_RELEASE:=2
include $(INCLUDE_DIR)/package.mk
@ -17,6 +17,7 @@ define KernelPackage/oaf
SUBMENU:=Netfilter Extensions
TITLE:=open app filter kernel module
FILES:=$(PKG_BUILD_DIR)/oaf.ko
DEPENDS:=+kmod-ipt-conntrack
KCONFIG:=
AUTOLOAD:=$(call AutoLoad,0,$(PKG_AUTOLOAD))
endef
@ -27,17 +28,11 @@ endef
MAKE_OPTS:= \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)" \
$(KERNEL_MAKE_FLAGS) \
M="$(PKG_BUILD_DIR)" \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
$(EXTRA_KCONFIG)
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
$(MAKE_OPTS) \

View File

@ -132,8 +132,8 @@ void check_client_expire(void)
AF_CLIENT_LOCK_W();
for (i = 0; i < MAX_AF_CLIENT_HASH_SIZE; i++){
list_for_each_entry(node, &af_client_list_table[i], hlist) {
AF_DEBUG("mac:"MAC_FMT" update:%d cur:%d, interval:%d\n", MAC_ARRAY(node->mac),
node->update_jiffies, HZ, (jiffies - node->update_jiffies) / HZ);
AF_DEBUG("mac:"MAC_FMT" update:%lu interval:%lu\n", MAC_ARRAY(node->mac),
node->update_jiffies, (jiffies - node->update_jiffies) / HZ);
if (jiffies > (node->update_jiffies + MAX_CLIENT_ACTIVE_TIME * HZ)) {
AF_INFO("del client:"MAC_FMT"\n", MAC_ARRAY(node->mac));
list_del(&(node->hlist));
@ -213,7 +213,8 @@ static u_int32_t nfclient_hook(unsigned int hook,
AF_CLIENT_LOCK_W();
nfc = find_af_client(smac);
if (!nfc){
AF_DEBUG("from dev:%s [%s] %pI4--->%pI4", skb->dev, (iph->protocol == IPPROTO_TCP ? "TCP" : "UDP"),
if (skb->dev)
AF_DEBUG("from dev:%s [%s] %pI4--->%pI4", skb->dev->name, (iph->protocol == IPPROTO_TCP ? "TCP" : "UDP"),
&iph->saddr, &iph->daddr);
nfc = nf_client_add(smac);
}

View File

@ -276,14 +276,14 @@ void load_feature_buf_from_file(char **config_buf)
if(IS_ERR(fp)) {
printk("open feature file failed\n");
return -1;
return;
}
inode = fp->f_inode;
size = inode->i_size;
AF_INFO("feature file size: %d\n", size);
AF_INFO("feature file size: %u\n", size);
if (size == 0) {
AF_WARN("warning, file size = %d\n", size);
AF_WARN("warning, file size = %u\n", size);
return;
}
*config_buf = (char *) kzalloc( sizeof(char) * size, GFP_KERNEL);
@ -709,9 +709,16 @@ int app_filter_match(flow_info_t *flow)
#define APP_FILTER_DROP_BITS 0xf0000000
u_int32_t af_get_timestamp_sec(void)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0)
struct timespec64 ts;
ktime_get_ts64(&ts);
return (u_int32_t)ts.tv_sec;
#else
struct timespec ts;
ts = current_kernel_time();
return ts.tv_sec;
#endif
}