From 0f3cf094349f594345cdc1eb21d9b2e40a36d7e8 Mon Sep 17 00:00:00 2001 From: derry Date: Mon, 6 Apr 2020 00:12:56 -0700 Subject: [PATCH] fix build problem upon kernel 4.17 --- oaf/src/af_client.c | 7 ++++--- oaf/src/app_filter.c | 13 ++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/oaf/src/af_client.c b/oaf/src/af_client.c index 3bede34..02232e8 100755 --- a/oaf/src/af_client.c +++ b/oaf/src/af_client.c @@ -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); } diff --git a/oaf/src/app_filter.c b/oaf/src/app_filter.c index 67e8607..76b8162 100755 --- a/oaf/src/app_filter.c +++ b/oaf/src/app_filter.c @@ -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 + }