Commit bdd091ba authored by David S. Miller's avatar David S. Miller

Merge branch 'tun-timer-cleanups'

Eric Dumazet says:

====================
tun: timer cleanups

While working on a syzkaller issue that might have been
fixed already by Cong Wang in commit 0ad646c8
("tun: call dev_get_valid_name() before register_netdevice()")
I made three small changes related to flow_gc_timer.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 02db34d0 ee74d996
...@@ -454,25 +454,28 @@ static void tun_flow_cleanup(unsigned long data) ...@@ -454,25 +454,28 @@ static void tun_flow_cleanup(unsigned long data)
tun_debug(KERN_INFO, tun, "tun_flow_cleanup\n"); tun_debug(KERN_INFO, tun, "tun_flow_cleanup\n");
spin_lock_bh(&tun->lock); spin_lock(&tun->lock);
for (i = 0; i < TUN_NUM_FLOW_ENTRIES; i++) { for (i = 0; i < TUN_NUM_FLOW_ENTRIES; i++) {
struct tun_flow_entry *e; struct tun_flow_entry *e;
struct hlist_node *n; struct hlist_node *n;
hlist_for_each_entry_safe(e, n, &tun->flows[i], hash_link) { hlist_for_each_entry_safe(e, n, &tun->flows[i], hash_link) {
unsigned long this_timer; unsigned long this_timer;
count++;
this_timer = e->updated + delay; this_timer = e->updated + delay;
if (time_before_eq(this_timer, jiffies)) if (time_before_eq(this_timer, jiffies)) {
tun_flow_delete(tun, e); tun_flow_delete(tun, e);
else if (time_before(this_timer, next_timer)) continue;
}
count++;
if (time_before(this_timer, next_timer))
next_timer = this_timer; next_timer = this_timer;
} }
} }
if (count) if (count)
mod_timer(&tun->flow_gc_timer, round_jiffies_up(next_timer)); mod_timer(&tun->flow_gc_timer, round_jiffies_up(next_timer));
spin_unlock_bh(&tun->lock); spin_unlock(&tun->lock);
} }
static void tun_flow_update(struct tun_struct *tun, u32 rxhash, static void tun_flow_update(struct tun_struct *tun, u32 rxhash,
...@@ -1194,8 +1197,6 @@ static void tun_flow_init(struct tun_struct *tun) ...@@ -1194,8 +1197,6 @@ static void tun_flow_init(struct tun_struct *tun)
tun->ageing_time = TUN_FLOW_EXPIRE; tun->ageing_time = TUN_FLOW_EXPIRE;
setup_timer(&tun->flow_gc_timer, tun_flow_cleanup, (unsigned long)tun); setup_timer(&tun->flow_gc_timer, tun_flow_cleanup, (unsigned long)tun);
mod_timer(&tun->flow_gc_timer,
round_jiffies_up(jiffies + tun->ageing_time));
} }
static void tun_flow_uninit(struct tun_struct *tun) static void tun_flow_uninit(struct tun_struct *tun)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment