net/hsr: Move to per-hsr device prune timer.
Subsystems (3)
PATCH 3/10 net/hsr: Move to per-hsr device prune timer.
Signed-off-by Arvid Brodin <[email protected]>
--- net/hsr/hsr_device.c | 10 +++++++++- net/hsr/hsr_framereg.c | 5 ++++- net/hsr/hsr_framereg.h | 2 +- net/hsr/hsr_main.c | 24 ------------------------ net/hsr/hsr_main.h | 1 + 5 files changed, 15 insertions(+), 27 deletions(-)
net/hsr/hsr_device.c +9 -1
@@ -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 */
@@ -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;
@@ -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 ;
net/hsr/hsr_framereg.c +4 -1
@@ -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 */
net/hsr/hsr_framereg.h +1 -1
@@ -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],
net/hsr/hsr_main.c +0 -24
@@ -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 */ };
@@ -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;
@@ -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 (); }
net/hsr/hsr_main.h +1 -0
@@ -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 */
Signature · 6 lines
1.8.3.2 -- Arvid Brodin | Consultant (Linux) ALTEN | Knarrarnäsgatan 7 | SE-164 40 Kista | Sweden [email protected] | www.alten.se/en/