Skip to content

Commit bdd091b

Browse files
committed
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 0ad646c ("tun: call dev_get_valid_name() before register_netdevice()") I made three small changes related to flow_gc_timer. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 02db34d + ee74d99 commit bdd091b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/net/tun.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -454,25 +454,28 @@ static void tun_flow_cleanup(unsigned long data)
454454

455455
tun_debug(KERN_INFO, tun, "tun_flow_cleanup\n");
456456

457-
spin_lock_bh(&tun->lock);
457+
spin_lock(&tun->lock);
458458
for (i = 0; i < TUN_NUM_FLOW_ENTRIES; i++) {
459459
struct tun_flow_entry *e;
460460
struct hlist_node *n;
461461

462462
hlist_for_each_entry_safe(e, n, &tun->flows[i], hash_link) {
463463
unsigned long this_timer;
464-
count++;
464+
465465
this_timer = e->updated + delay;
466-
if (time_before_eq(this_timer, jiffies))
466+
if (time_before_eq(this_timer, jiffies)) {
467467
tun_flow_delete(tun, e);
468-
else if (time_before(this_timer, next_timer))
468+
continue;
469+
}
470+
count++;
471+
if (time_before(this_timer, next_timer))
469472
next_timer = this_timer;
470473
}
471474
}
472475

473476
if (count)
474477
mod_timer(&tun->flow_gc_timer, round_jiffies_up(next_timer));
475-
spin_unlock_bh(&tun->lock);
478+
spin_unlock(&tun->lock);
476479
}
477480

478481
static void tun_flow_update(struct tun_struct *tun, u32 rxhash,
@@ -1194,8 +1197,6 @@ static void tun_flow_init(struct tun_struct *tun)
11941197

11951198
tun->ageing_time = TUN_FLOW_EXPIRE;
11961199
setup_timer(&tun->flow_gc_timer, tun_flow_cleanup, (unsigned long)tun);
1197-
mod_timer(&tun->flow_gc_timer,
1198-
round_jiffies_up(jiffies + tun->ageing_time));
11991200
}
12001201

12011202
static void tun_flow_uninit(struct tun_struct *tun)

0 commit comments

Comments
 (0)