Skip to content

Commit

Permalink
fix build problem upon kernel 4.17
Browse files Browse the repository at this point in the history
  • Loading branch information
destan19 committed Apr 6, 2020
1 parent b3e2557 commit 0f3cf09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 4 additions & 3 deletions oaf/src/af_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
}
Expand Down
13 changes: 10 additions & 3 deletions oaf/src/app_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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

}


Expand Down

0 comments on commit 0f3cf09

Please sign in to comment.