Skip to content

Commit

Permalink
net/hsr: Move to per-hsr device prune timer.
Browse files Browse the repository at this point in the history
Signed-off-by: Arvid Brodin <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Arvid Brodin authored and davem330 committed Jul 8, 2014
1 parent 81ba6af commit abff716
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 27 deletions.
10 changes: 9 additions & 1 deletion net/hsr/hsr_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ static void hsr_dev_destroy(struct net_device *hsr_dev)

hsr = netdev_priv(hsr_dev);

del_timer(&hsr->announce_timer);
del_timer_sync(&hsr->prune_timer);
del_timer_sync(&hsr->announce_timer);
unregister_hsr_master(hsr); /* calls list_del_rcu on hsr */
restore_slaves(hsr_dev);
call_rcu(&hsr->rcu_head, reclaim_hsr_dev); /* reclaim hsr */
Expand Down Expand Up @@ -523,6 +524,10 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
hsr->announce_timer.function = hsr_announce;
hsr->announce_timer.data = (unsigned long) hsr;

init_timer(&hsr->prune_timer);
hsr->prune_timer.function = hsr_prune_nodes;
hsr->prune_timer.data = (unsigned long) hsr;

ether_addr_copy(hsr->sup_multicast_addr, def_multicast_addr);
hsr->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec;

Expand Down Expand Up @@ -596,6 +601,9 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
if (res)
goto fail;

hsr->prune_timer.expires = jiffies + msecs_to_jiffies(PRUNE_PERIOD);
add_timer(&hsr->prune_timer);

register_hsr_master(hsr);

return 0;
Expand Down
5 changes: 4 additions & 1 deletion net/hsr/hsr_framereg.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,15 @@ static bool is_late(struct hsr_node *node, enum hsr_dev_idx dev_idx)
/* Remove stale sequence_nr records. Called by timer every
* HSR_LIFE_CHECK_INTERVAL (two seconds or so).
*/
void hsr_prune_nodes(struct hsr_priv *hsr)
void hsr_prune_nodes(unsigned long data)
{
struct hsr_priv *hsr;
struct hsr_node *node;
unsigned long timestamp;
unsigned long time_a, time_b;

hsr = (struct hsr_priv *) data;

rcu_read_lock();
list_for_each_entry_rcu(node, &hsr->node_db, mac_list) {
/* Shorthand */
Expand Down
2 changes: 1 addition & 1 deletion net/hsr/hsr_framereg.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void hsr_register_frame_in(struct hsr_node *node, enum hsr_dev_idx dev_idx);
int hsr_register_frame_out(struct hsr_node *node, enum hsr_dev_idx dev_idx,
struct sk_buff *skb);

void hsr_prune_nodes(struct hsr_priv *hsr);
void hsr_prune_nodes(unsigned long data);

int hsr_create_self_node(struct list_head *self_node_db,
unsigned char addr_a[ETH_ALEN],
Expand Down
24 changes: 0 additions & 24 deletions net/hsr/hsr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,6 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
}


static struct timer_list prune_timer;

static void prune_nodes_all(unsigned long data)
{
struct hsr_priv *hsr;

rcu_read_lock();
list_for_each_entry_rcu(hsr, &hsr_list, hsr_list)
hsr_prune_nodes(hsr);
rcu_read_unlock();

prune_timer.expires = jiffies + msecs_to_jiffies(PRUNE_PERIOD);
add_timer(&prune_timer);
}


static struct notifier_block hsr_nb = {
.notifier_call = hsr_netdev_notify, /* Slave event notifications */
};
Expand All @@ -202,14 +186,7 @@ static int __init hsr_init(void)

BUILD_BUG_ON(sizeof(struct hsr_tag) != HSR_HLEN);

init_timer(&prune_timer);
prune_timer.function = prune_nodes_all;
prune_timer.data = 0;
prune_timer.expires = jiffies + msecs_to_jiffies(PRUNE_PERIOD);
add_timer(&prune_timer);

register_netdevice_notifier(&hsr_nb);

res = hsr_netlink_init();

return res;
Expand All @@ -218,7 +195,6 @@ static int __init hsr_init(void)
static void __exit hsr_exit(void)
{
unregister_netdevice_notifier(&hsr_nb);
del_timer_sync(&prune_timer);
hsr_netlink_exit();
}

Expand Down
1 change: 1 addition & 0 deletions net/hsr/hsr_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ struct hsr_priv {
struct list_head node_db; /* Other HSR nodes */
struct list_head self_node_db; /* MACs of slaves */
struct timer_list announce_timer; /* Supervision frame dispatch */
struct timer_list prune_timer;
int announce_count;
u16 sequence_nr;
spinlock_t seqnr_lock; /* locking for sequence_nr */
Expand Down

0 comments on commit abff716

Please sign in to comment.