Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update connlist_timer.c #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion connlist_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,25 @@
#include <linux/module.h>
#include <linux/timer.h>
#include <linux/jiffies.h>
#include <linux/version.h>
#include "connlist.h"
#include "connlist_timer.h"

struct timer_list aids_connlist_timer;

/// Evsio0n <[email protected]>
/// init_timer() is deprecated for linux version >= 4.15
/// ref:https://lwn.net/Articles/735887/
/// Using timer_setup() returned timerlist.
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0)
static void aids_connlist_timer_func(unsigned long arg)
{
#else
static void aids_connlist_timer_func(struct timer_list *arg)
{
#endif
aids_connlist_entry* entry;
unsigned long flags;

spin_lock_irqsave(&g_connlist_spinlock, flags);
rcu_read_lock();
list_for_each_entry_rcu(entry, &g_aids_connlist_head, link) {
Expand All @@ -27,6 +36,8 @@ static void aids_connlist_timer_func(unsigned long arg)
add_timer(&aids_connlist_timer);
}

/// Using timer_setup() instead
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0)
int aids_connlist_timer_init(void)
{
init_timer(&aids_connlist_timer);
Expand All @@ -36,6 +47,15 @@ int aids_connlist_timer_init(void)
add_timer(&aids_connlist_timer);
return 0;
}
#else
int aids_connlist_timer_init(void)
{
timer_setup(&aids_connlist_timer,aids_connlist_timer_func,0);
aids_connlist_timer.expires = AIDS_CONNLIST_TIMEOUT_CHECK;
add_timer(&aids_connlist_timer);
return 0;
}
#endif

void aids_connlist_timer_deinit(void)
{
Expand Down