diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-09-27 12:03:39 -0400 |
---|---|---|
committer | Antonio Quartulli <antonio@meshcoding.com> | 2013-10-02 07:46:19 -0400 |
commit | 6c519bad7b19a2c14a075b400edabaa630330123 (patch) | |
tree | c937e1f722ff9c3468bca8077bb42f045d3a3207 /net/batman-adv/network-coding.c | |
parent | c31eeaced22ce8bd61268a3c595d542bb38c0a4f (diff) |
batman-adv: set up network coding packet handlers during module init
batman-adv saves its table of packet handlers as a global state, so handlers
must be set up only once (and setting them up a second time will fail).
The recently-added network coding support tries to set up its handler each time
a new softif is registered, which obviously fails when more that one softif is
used (and in consequence, the softif creation fails).
Fix this by splitting up batadv_nc_init into batadv_nc_init (which is called
only once) and batadv_nc_mesh_init (which is called for each softif); in
addition batadv_nc_free is renamed to batadv_nc_mesh_free to keep naming
consistent.
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Diffstat (limited to 'net/batman-adv/network-coding.c')
-rw-r--r-- | net/batman-adv/network-coding.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index a487d46e0aec..4ecc0b6bf8ab 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c | |||
@@ -35,6 +35,20 @@ static int batadv_nc_recv_coded_packet(struct sk_buff *skb, | |||
35 | struct batadv_hard_iface *recv_if); | 35 | struct batadv_hard_iface *recv_if); |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * batadv_nc_init - one-time initialization for network coding | ||
39 | */ | ||
40 | int __init batadv_nc_init(void) | ||
41 | { | ||
42 | int ret; | ||
43 | |||
44 | /* Register our packet type */ | ||
45 | ret = batadv_recv_handler_register(BATADV_CODED, | ||
46 | batadv_nc_recv_coded_packet); | ||
47 | |||
48 | return ret; | ||
49 | } | ||
50 | |||
51 | /** | ||
38 | * batadv_nc_start_timer - initialise the nc periodic worker | 52 | * batadv_nc_start_timer - initialise the nc periodic worker |
39 | * @bat_priv: the bat priv with all the soft interface information | 53 | * @bat_priv: the bat priv with all the soft interface information |
40 | */ | 54 | */ |
@@ -45,10 +59,10 @@ static void batadv_nc_start_timer(struct batadv_priv *bat_priv) | |||
45 | } | 59 | } |
46 | 60 | ||
47 | /** | 61 | /** |
48 | * batadv_nc_init - initialise coding hash table and start house keeping | 62 | * batadv_nc_mesh_init - initialise coding hash table and start house keeping |
49 | * @bat_priv: the bat priv with all the soft interface information | 63 | * @bat_priv: the bat priv with all the soft interface information |
50 | */ | 64 | */ |
51 | int batadv_nc_init(struct batadv_priv *bat_priv) | 65 | int batadv_nc_mesh_init(struct batadv_priv *bat_priv) |
52 | { | 66 | { |
53 | bat_priv->nc.timestamp_fwd_flush = jiffies; | 67 | bat_priv->nc.timestamp_fwd_flush = jiffies; |
54 | bat_priv->nc.timestamp_sniffed_purge = jiffies; | 68 | bat_priv->nc.timestamp_sniffed_purge = jiffies; |
@@ -70,11 +84,6 @@ int batadv_nc_init(struct batadv_priv *bat_priv) | |||
70 | batadv_hash_set_lock_class(bat_priv->nc.coding_hash, | 84 | batadv_hash_set_lock_class(bat_priv->nc.coding_hash, |
71 | &batadv_nc_decoding_hash_lock_class_key); | 85 | &batadv_nc_decoding_hash_lock_class_key); |
72 | 86 | ||
73 | /* Register our packet type */ | ||
74 | if (batadv_recv_handler_register(BATADV_CODED, | ||
75 | batadv_nc_recv_coded_packet) < 0) | ||
76 | goto err; | ||
77 | |||
78 | INIT_DELAYED_WORK(&bat_priv->nc.work, batadv_nc_worker); | 87 | INIT_DELAYED_WORK(&bat_priv->nc.work, batadv_nc_worker); |
79 | batadv_nc_start_timer(bat_priv); | 88 | batadv_nc_start_timer(bat_priv); |
80 | 89 | ||
@@ -1721,12 +1730,11 @@ free_nc_packet: | |||
1721 | } | 1730 | } |
1722 | 1731 | ||
1723 | /** | 1732 | /** |
1724 | * batadv_nc_free - clean up network coding memory | 1733 | * batadv_nc_mesh_free - clean up network coding memory |
1725 | * @bat_priv: the bat priv with all the soft interface information | 1734 | * @bat_priv: the bat priv with all the soft interface information |
1726 | */ | 1735 | */ |
1727 | void batadv_nc_free(struct batadv_priv *bat_priv) | 1736 | void batadv_nc_mesh_free(struct batadv_priv *bat_priv) |
1728 | { | 1737 | { |
1729 | batadv_recv_handler_unregister(BATADV_CODED); | ||
1730 | cancel_delayed_work_sync(&bat_priv->nc.work); | 1738 | cancel_delayed_work_sync(&bat_priv->nc.work); |
1731 | 1739 | ||
1732 | batadv_nc_purge_paths(bat_priv, bat_priv->nc.coding_hash, NULL); | 1740 | batadv_nc_purge_paths(bat_priv, bat_priv->nc.coding_hash, NULL); |