diff options
author | Arvid Brodin <arvid.brodin@alten.se> | 2014-07-04 17:35:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-08 14:35:30 -0400 |
commit | abff7162765cd66ab109c97fd433ef1f39299120 (patch) | |
tree | 4d7f1547bf99ac7a0e9a68556b8d74550ba26d0d /net | |
parent | 81ba6afd6e6443d2bf4bf40f16df1f1f91c603f8 (diff) |
net/hsr: Move to per-hsr device prune timer.
Signed-off-by: Arvid Brodin <arvid.brodin@alten.se>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/hsr/hsr_device.c | 10 | ||||
-rw-r--r-- | net/hsr/hsr_framereg.c | 5 | ||||
-rw-r--r-- | net/hsr/hsr_framereg.h | 2 | ||||
-rw-r--r-- | net/hsr/hsr_main.c | 24 | ||||
-rw-r--r-- | net/hsr/hsr_main.h | 1 |
5 files changed, 15 insertions, 27 deletions
diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 4e5d92a8f079..f224067153e4 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c | |||
@@ -429,7 +429,8 @@ static void hsr_dev_destroy(struct net_device *hsr_dev) | |||
429 | 429 | ||
430 | hsr = netdev_priv(hsr_dev); | 430 | hsr = netdev_priv(hsr_dev); |
431 | 431 | ||
432 | del_timer(&hsr->announce_timer); | 432 | del_timer_sync(&hsr->prune_timer); |
433 | del_timer_sync(&hsr->announce_timer); | ||
433 | unregister_hsr_master(hsr); /* calls list_del_rcu on hsr */ | 434 | unregister_hsr_master(hsr); /* calls list_del_rcu on hsr */ |
434 | restore_slaves(hsr_dev); | 435 | restore_slaves(hsr_dev); |
435 | call_rcu(&hsr->rcu_head, reclaim_hsr_dev); /* reclaim hsr */ | 436 | call_rcu(&hsr->rcu_head, reclaim_hsr_dev); /* reclaim hsr */ |
@@ -523,6 +524,10 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], | |||
523 | hsr->announce_timer.function = hsr_announce; | 524 | hsr->announce_timer.function = hsr_announce; |
524 | hsr->announce_timer.data = (unsigned long) hsr; | 525 | hsr->announce_timer.data = (unsigned long) hsr; |
525 | 526 | ||
527 | init_timer(&hsr->prune_timer); | ||
528 | hsr->prune_timer.function = hsr_prune_nodes; | ||
529 | hsr->prune_timer.data = (unsigned long) hsr; | ||
530 | |||
526 | ether_addr_copy(hsr->sup_multicast_addr, def_multicast_addr); | 531 | ether_addr_copy(hsr->sup_multicast_addr, def_multicast_addr); |
527 | hsr->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec; | 532 | hsr->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec; |
528 | 533 | ||
@@ -596,6 +601,9 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], | |||
596 | if (res) | 601 | if (res) |
597 | goto fail; | 602 | goto fail; |
598 | 603 | ||
604 | hsr->prune_timer.expires = jiffies + msecs_to_jiffies(PRUNE_PERIOD); | ||
605 | add_timer(&hsr->prune_timer); | ||
606 | |||
599 | register_hsr_master(hsr); | 607 | register_hsr_master(hsr); |
600 | 608 | ||
601 | return 0; | 609 | return 0; |
diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index b419edbd7012..79e3f7ff6654 100644 --- a/net/hsr/hsr_framereg.c +++ b/net/hsr/hsr_framereg.c | |||
@@ -366,12 +366,15 @@ static bool is_late(struct hsr_node *node, enum hsr_dev_idx dev_idx) | |||
366 | /* Remove stale sequence_nr records. Called by timer every | 366 | /* Remove stale sequence_nr records. Called by timer every |
367 | * HSR_LIFE_CHECK_INTERVAL (two seconds or so). | 367 | * HSR_LIFE_CHECK_INTERVAL (two seconds or so). |
368 | */ | 368 | */ |
369 | void hsr_prune_nodes(struct hsr_priv *hsr) | 369 | void hsr_prune_nodes(unsigned long data) |
370 | { | 370 | { |
371 | struct hsr_priv *hsr; | ||
371 | struct hsr_node *node; | 372 | struct hsr_node *node; |
372 | unsigned long timestamp; | 373 | unsigned long timestamp; |
373 | unsigned long time_a, time_b; | 374 | unsigned long time_a, time_b; |
374 | 375 | ||
376 | hsr = (struct hsr_priv *) data; | ||
377 | |||
375 | rcu_read_lock(); | 378 | rcu_read_lock(); |
376 | list_for_each_entry_rcu(node, &hsr->node_db, mac_list) { | 379 | list_for_each_entry_rcu(node, &hsr->node_db, mac_list) { |
377 | /* Shorthand */ | 380 | /* Shorthand */ |
diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h index 3675139df379..ccb09cf4ec5b 100644 --- a/net/hsr/hsr_framereg.h +++ b/net/hsr/hsr_framereg.h | |||
@@ -32,7 +32,7 @@ void hsr_register_frame_in(struct hsr_node *node, enum hsr_dev_idx dev_idx); | |||
32 | int hsr_register_frame_out(struct hsr_node *node, enum hsr_dev_idx dev_idx, | 32 | int hsr_register_frame_out(struct hsr_node *node, enum hsr_dev_idx dev_idx, |
33 | struct sk_buff *skb); | 33 | struct sk_buff *skb); |
34 | 34 | ||
35 | void hsr_prune_nodes(struct hsr_priv *hsr); | 35 | void hsr_prune_nodes(unsigned long data); |
36 | 36 | ||
37 | int hsr_create_self_node(struct list_head *self_node_db, | 37 | int hsr_create_self_node(struct list_head *self_node_db, |
38 | unsigned char addr_a[ETH_ALEN], | 38 | unsigned char addr_a[ETH_ALEN], |
diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c index bcda901437bc..5f9cd7fdbd93 100644 --- a/net/hsr/hsr_main.c +++ b/net/hsr/hsr_main.c | |||
@@ -175,22 +175,6 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event, | |||
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | static struct timer_list prune_timer; | ||
179 | |||
180 | static void prune_nodes_all(unsigned long data) | ||
181 | { | ||
182 | struct hsr_priv *hsr; | ||
183 | |||
184 | rcu_read_lock(); | ||
185 | list_for_each_entry_rcu(hsr, &hsr_list, hsr_list) | ||
186 | hsr_prune_nodes(hsr); | ||
187 | rcu_read_unlock(); | ||
188 | |||
189 | prune_timer.expires = jiffies + msecs_to_jiffies(PRUNE_PERIOD); | ||
190 | add_timer(&prune_timer); | ||
191 | } | ||
192 | |||
193 | |||
194 | static struct notifier_block hsr_nb = { | 178 | static struct notifier_block hsr_nb = { |
195 | .notifier_call = hsr_netdev_notify, /* Slave event notifications */ | 179 | .notifier_call = hsr_netdev_notify, /* Slave event notifications */ |
196 | }; | 180 | }; |
@@ -202,14 +186,7 @@ static int __init hsr_init(void) | |||
202 | 186 | ||
203 | BUILD_BUG_ON(sizeof(struct hsr_tag) != HSR_HLEN); | 187 | BUILD_BUG_ON(sizeof(struct hsr_tag) != HSR_HLEN); |
204 | 188 | ||
205 | init_timer(&prune_timer); | ||
206 | prune_timer.function = prune_nodes_all; | ||
207 | prune_timer.data = 0; | ||
208 | prune_timer.expires = jiffies + msecs_to_jiffies(PRUNE_PERIOD); | ||
209 | add_timer(&prune_timer); | ||
210 | |||
211 | register_netdevice_notifier(&hsr_nb); | 189 | register_netdevice_notifier(&hsr_nb); |
212 | |||
213 | res = hsr_netlink_init(); | 190 | res = hsr_netlink_init(); |
214 | 191 | ||
215 | return res; | 192 | return res; |
@@ -218,7 +195,6 @@ static int __init hsr_init(void) | |||
218 | static void __exit hsr_exit(void) | 195 | static void __exit hsr_exit(void) |
219 | { | 196 | { |
220 | unregister_netdevice_notifier(&hsr_nb); | 197 | unregister_netdevice_notifier(&hsr_nb); |
221 | del_timer_sync(&prune_timer); | ||
222 | hsr_netlink_exit(); | 198 | hsr_netlink_exit(); |
223 | } | 199 | } |
224 | 200 | ||
diff --git a/net/hsr/hsr_main.h b/net/hsr/hsr_main.h index d919321b0bdb..43689a6d731f 100644 --- a/net/hsr/hsr_main.h +++ b/net/hsr/hsr_main.h | |||
@@ -153,6 +153,7 @@ struct hsr_priv { | |||
153 | struct list_head node_db; /* Other HSR nodes */ | 153 | struct list_head node_db; /* Other HSR nodes */ |
154 | struct list_head self_node_db; /* MACs of slaves */ | 154 | struct list_head self_node_db; /* MACs of slaves */ |
155 | struct timer_list announce_timer; /* Supervision frame dispatch */ | 155 | struct timer_list announce_timer; /* Supervision frame dispatch */ |
156 | struct timer_list prune_timer; | ||
156 | int announce_count; | 157 | int announce_count; |
157 | u16 sequence_nr; | 158 | u16 sequence_nr; |
158 | spinlock_t seqnr_lock; /* locking for sequence_nr */ | 159 | spinlock_t seqnr_lock; /* locking for sequence_nr */ |