Commit 72414442 authored by Antonio Quartulli's avatar Antonio Quartulli

batman-adv: a delayed_work has to be initialised once

A delayed_work struct does not need to be initialized each
every time before being enqueued. Therefore the
INIT_DELAYED_WORK() macro should be used during the
initialization process only.
Signed-off-by: default avatarAntonio Quartulli <ordex@autistici.org>
Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
parent 1ad759d8
...@@ -1100,16 +1100,6 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv, ...@@ -1100,16 +1100,6 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
} }
} }
/* (re)start the timer */
static void batadv_bla_start_timer(struct batadv_priv *bat_priv)
{
INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work);
queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
}
/* periodic work to do: /* periodic work to do:
* * purge structures when they are too old * * purge structures when they are too old
* * send announcements * * send announcements
...@@ -1180,7 +1170,8 @@ static void batadv_bla_periodic_work(struct work_struct *work) ...@@ -1180,7 +1170,8 @@ static void batadv_bla_periodic_work(struct work_struct *work)
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
batadv_bla_start_timer(bat_priv); queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
} }
/* The hash for claim and backbone hash receive the same key because they /* The hash for claim and backbone hash receive the same key because they
...@@ -1238,7 +1229,10 @@ int batadv_bla_init(struct batadv_priv *bat_priv) ...@@ -1238,7 +1229,10 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n"); batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n");
batadv_bla_start_timer(bat_priv); INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work);
queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
return 0; return 0;
} }
......
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
#define BATADV_TT_LOCAL_TIMEOUT 600000 /* in milliseconds */ #define BATADV_TT_LOCAL_TIMEOUT 600000 /* in milliseconds */
#define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in milliseconds */ #define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in milliseconds */
#define BATADV_TT_CLIENT_TEMP_TIMEOUT 600000 /* in milliseconds */ #define BATADV_TT_CLIENT_TEMP_TIMEOUT 600000 /* in milliseconds */
#define BATADV_TT_WORK_PERIOD 5000 /* 5 seconds */
#define BATADV_ORIG_WORK_PERIOD 1000 /* 1 second */
#define BATADV_DAT_ENTRY_TIMEOUT (5*60000) /* 5 mins in milliseconds */ #define BATADV_DAT_ENTRY_TIMEOUT (5*60000) /* 5 mins in milliseconds */
/* sliding packet range of received originator messages in sequence numbers /* sliding packet range of received originator messages in sequence numbers
* (should be a multiple of our word size) * (should be a multiple of our word size)
......
...@@ -34,13 +34,6 @@ static struct lock_class_key batadv_orig_hash_lock_class_key; ...@@ -34,13 +34,6 @@ static struct lock_class_key batadv_orig_hash_lock_class_key;
static void batadv_purge_orig(struct work_struct *work); static void batadv_purge_orig(struct work_struct *work);
static void batadv_start_purge_timer(struct batadv_priv *bat_priv)
{
INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig);
queue_delayed_work(batadv_event_workqueue,
&bat_priv->orig_work, msecs_to_jiffies(1000));
}
/* returns 1 if they are the same originator */ /* returns 1 if they are the same originator */
static int batadv_compare_orig(const struct hlist_node *node, const void *data2) static int batadv_compare_orig(const struct hlist_node *node, const void *data2)
{ {
...@@ -63,7 +56,11 @@ int batadv_originator_init(struct batadv_priv *bat_priv) ...@@ -63,7 +56,11 @@ int batadv_originator_init(struct batadv_priv *bat_priv)
batadv_hash_set_lock_class(bat_priv->orig_hash, batadv_hash_set_lock_class(bat_priv->orig_hash,
&batadv_orig_hash_lock_class_key); &batadv_orig_hash_lock_class_key);
batadv_start_purge_timer(bat_priv); INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig);
queue_delayed_work(batadv_event_workqueue,
&bat_priv->orig_work,
msecs_to_jiffies(BATADV_ORIG_WORK_PERIOD));
return 0; return 0;
err: err:
...@@ -396,7 +393,9 @@ static void batadv_purge_orig(struct work_struct *work) ...@@ -396,7 +393,9 @@ static void batadv_purge_orig(struct work_struct *work)
delayed_work = container_of(work, struct delayed_work, work); delayed_work = container_of(work, struct delayed_work, work);
bat_priv = container_of(delayed_work, struct batadv_priv, orig_work); bat_priv = container_of(delayed_work, struct batadv_priv, orig_work);
_batadv_purge_orig(bat_priv); _batadv_purge_orig(bat_priv);
batadv_start_purge_timer(bat_priv); queue_delayed_work(batadv_event_workqueue,
&bat_priv->orig_work,
msecs_to_jiffies(BATADV_ORIG_WORK_PERIOD));
} }
void batadv_purge_orig_ref(struct batadv_priv *bat_priv) void batadv_purge_orig_ref(struct batadv_priv *bat_priv)
......
...@@ -155,8 +155,6 @@ _batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, ...@@ -155,8 +155,6 @@ _batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
spin_unlock_bh(&bat_priv->forw_bcast_list_lock); spin_unlock_bh(&bat_priv->forw_bcast_list_lock);
/* start timer for this packet */ /* start timer for this packet */
INIT_DELAYED_WORK(&forw_packet->delayed_work,
batadv_send_outstanding_bcast_packet);
queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work, queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work,
send_time); send_time);
} }
...@@ -210,6 +208,9 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, ...@@ -210,6 +208,9 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
/* how often did we send the bcast packet ? */ /* how often did we send the bcast packet ? */
forw_packet->num_packets = 0; forw_packet->num_packets = 0;
INIT_DELAYED_WORK(&forw_packet->delayed_work,
batadv_send_outstanding_bcast_packet);
_batadv_add_bcast_packet_to_list(bat_priv, forw_packet, delay); _batadv_add_bcast_packet_to_list(bat_priv, forw_packet, delay);
return NETDEV_TX_OK; return NETDEV_TX_OK;
......
...@@ -52,13 +52,6 @@ static int batadv_compare_tt(const struct hlist_node *node, const void *data2) ...@@ -52,13 +52,6 @@ static int batadv_compare_tt(const struct hlist_node *node, const void *data2)
return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
} }
static void batadv_tt_start_timer(struct batadv_priv *bat_priv)
{
INIT_DELAYED_WORK(&bat_priv->tt.work, batadv_tt_purge);
queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work,
msecs_to_jiffies(5000));
}
static struct batadv_tt_common_entry * static struct batadv_tt_common_entry *
batadv_tt_hash_find(struct batadv_hashtable *hash, const void *data) batadv_tt_hash_find(struct batadv_hashtable *hash, const void *data)
{ {
...@@ -2136,7 +2129,9 @@ int batadv_tt_init(struct batadv_priv *bat_priv) ...@@ -2136,7 +2129,9 @@ int batadv_tt_init(struct batadv_priv *bat_priv)
if (ret < 0) if (ret < 0)
return ret; return ret;
batadv_tt_start_timer(bat_priv); INIT_DELAYED_WORK(&bat_priv->tt.work, batadv_tt_purge);
queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work,
msecs_to_jiffies(BATADV_TT_WORK_PERIOD));
return 1; return 1;
} }
...@@ -2286,7 +2281,8 @@ static void batadv_tt_purge(struct work_struct *work) ...@@ -2286,7 +2281,8 @@ static void batadv_tt_purge(struct work_struct *work)
batadv_tt_req_purge(bat_priv); batadv_tt_req_purge(bat_priv);
batadv_tt_roam_purge(bat_priv); batadv_tt_roam_purge(bat_priv);
batadv_tt_start_timer(bat_priv); queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work,
msecs_to_jiffies(BATADV_TT_WORK_PERIOD));
} }
void batadv_tt_free(struct batadv_priv *bat_priv) void batadv_tt_free(struct batadv_priv *bat_priv)
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
/* hash class keys */ /* hash class keys */
static struct lock_class_key batadv_vis_hash_lock_class_key; static struct lock_class_key batadv_vis_hash_lock_class_key;
static void batadv_start_vis_timer(struct batadv_priv *bat_priv);
/* free the info */ /* free the info */
static void batadv_free_info(struct kref *ref) static void batadv_free_info(struct kref *ref)
{ {
...@@ -830,7 +828,9 @@ static void batadv_send_vis_packets(struct work_struct *work) ...@@ -830,7 +828,9 @@ static void batadv_send_vis_packets(struct work_struct *work)
kref_put(&info->refcount, batadv_free_info); kref_put(&info->refcount, batadv_free_info);
} }
spin_unlock_bh(&bat_priv->vis.hash_lock); spin_unlock_bh(&bat_priv->vis.hash_lock);
batadv_start_vis_timer(bat_priv);
queue_delayed_work(batadv_event_workqueue, &bat_priv->vis.work,
msecs_to_jiffies(BATADV_VIS_INTERVAL));
} }
/* init the vis server. this may only be called when if_list is already /* init the vis server. this may only be called when if_list is already
...@@ -900,7 +900,11 @@ int batadv_vis_init(struct batadv_priv *bat_priv) ...@@ -900,7 +900,11 @@ int batadv_vis_init(struct batadv_priv *bat_priv)
} }
spin_unlock_bh(&bat_priv->vis.hash_lock); spin_unlock_bh(&bat_priv->vis.hash_lock);
batadv_start_vis_timer(bat_priv);
INIT_DELAYED_WORK(&bat_priv->vis.work, batadv_send_vis_packets);
queue_delayed_work(batadv_event_workqueue, &bat_priv->vis.work,
msecs_to_jiffies(BATADV_VIS_INTERVAL));
return 0; return 0;
free_info: free_info:
...@@ -937,11 +941,3 @@ void batadv_vis_quit(struct batadv_priv *bat_priv) ...@@ -937,11 +941,3 @@ void batadv_vis_quit(struct batadv_priv *bat_priv)
bat_priv->vis.my_info = NULL; bat_priv->vis.my_info = NULL;
spin_unlock_bh(&bat_priv->vis.hash_lock); spin_unlock_bh(&bat_priv->vis.hash_lock);
} }
/* schedule packets for (re)transmission */
static void batadv_start_vis_timer(struct batadv_priv *bat_priv)
{
INIT_DELAYED_WORK(&bat_priv->vis.work, batadv_send_vis_packets);
queue_delayed_work(batadv_event_workqueue, &bat_priv->vis.work,
msecs_to_jiffies(BATADV_VIS_INTERVAL));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment