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>
This commit is contained in:
Arvid Brodin 2014-07-04 23:35:47 +02:00 коммит произвёл David S. Miller
Родитель 81ba6afd6e
Коммит abff716276
5 изменённых файлов: 15 добавлений и 27 удалений

Просмотреть файл

@ -429,7 +429,8 @@ static void hsr_dev_destroy(struct net_device *hsr_dev)
hsr = netdev_priv(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 */ unregister_hsr_master(hsr); /* calls list_del_rcu on hsr */
restore_slaves(hsr_dev); restore_slaves(hsr_dev);
call_rcu(&hsr->rcu_head, reclaim_hsr_dev); /* reclaim hsr */ 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.function = hsr_announce;
hsr->announce_timer.data = (unsigned long) hsr; 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); ether_addr_copy(hsr->sup_multicast_addr, def_multicast_addr);
hsr->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec; 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) if (res)
goto fail; goto fail;
hsr->prune_timer.expires = jiffies + msecs_to_jiffies(PRUNE_PERIOD);
add_timer(&hsr->prune_timer);
register_hsr_master(hsr); register_hsr_master(hsr);
return 0; return 0;

Просмотреть файл

@ -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 /* Remove stale sequence_nr records. Called by timer every
* HSR_LIFE_CHECK_INTERVAL (two seconds or so). * 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; struct hsr_node *node;
unsigned long timestamp; unsigned long timestamp;
unsigned long time_a, time_b; unsigned long time_a, time_b;
hsr = (struct hsr_priv *) data;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(node, &hsr->node_db, mac_list) { list_for_each_entry_rcu(node, &hsr->node_db, mac_list) {
/* Shorthand */ /* Shorthand */

Просмотреть файл

@ -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, int hsr_register_frame_out(struct hsr_node *node, enum hsr_dev_idx dev_idx,
struct sk_buff *skb); 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, int hsr_create_self_node(struct list_head *self_node_db,
unsigned char addr_a[ETH_ALEN], unsigned char addr_a[ETH_ALEN],

Просмотреть файл

@ -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 = { static struct notifier_block hsr_nb = {
.notifier_call = hsr_netdev_notify, /* Slave event notifications */ .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); 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); register_netdevice_notifier(&hsr_nb);
res = hsr_netlink_init(); res = hsr_netlink_init();
return res; return res;
@ -218,7 +195,6 @@ static int __init hsr_init(void)
static void __exit hsr_exit(void) static void __exit hsr_exit(void)
{ {
unregister_netdevice_notifier(&hsr_nb); unregister_netdevice_notifier(&hsr_nb);
del_timer_sync(&prune_timer);
hsr_netlink_exit(); hsr_netlink_exit();
} }

Просмотреть файл

@ -153,6 +153,7 @@ struct hsr_priv {
struct list_head node_db; /* Other HSR nodes */ struct list_head node_db; /* Other HSR nodes */
struct list_head self_node_db; /* MACs of slaves */ struct list_head self_node_db; /* MACs of slaves */
struct timer_list announce_timer; /* Supervision frame dispatch */ struct timer_list announce_timer; /* Supervision frame dispatch */
struct timer_list prune_timer;
int announce_count; int announce_count;
u16 sequence_nr; u16 sequence_nr;
spinlock_t seqnr_lock; /* locking for sequence_nr */ spinlock_t seqnr_lock; /* locking for sequence_nr */