diff options
author | David S. Miller <davem@davemloft.net> | 2016-08-22 23:38:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-08-22 23:38:25 -0400 |
commit | 8b7ac60a5d29f4c554340afd0ce2b759de491e1f (patch) | |
tree | 93fb4f36e511096c7db0d35c8b648028a4a95586 /net | |
parent | a616b849bcaee7348aaac5ba17677004c7c77359 (diff) | |
parent | dc1cbd145eecf21209d0322874e1766bcbce3e3f (diff) |
Merge tag 'batadv-next-for-davem-20160822' of git://git.open-mesh.org/linux-merge
Simon Wunderlich says:
====================
This feature patchset includes the following changes:
- place kref_get near usage of referenced objects, separate patches
for various used objects to improve readability and maintainability
by Sven Eckelmann (18 patches)
- Keep batadv net device when all hard interfaces disappear, to
improve situations where tools currently use work arounds, by
Sven Eckelmann
- Add an option to disable debugfs support to minimize footprint when
userspace uses netlink only, by Sven Eckelmann
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/batman-adv/Kconfig | 15 | ||||
-rw-r--r-- | net/batman-adv/Makefile | 4 | ||||
-rw-r--r-- | net/batman-adv/bat_algo.c | 2 | ||||
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 19 | ||||
-rw-r--r-- | net/batman-adv/bat_v.c | 12 | ||||
-rw-r--r-- | net/batman-adv/bat_v_ogm.c | 5 | ||||
-rw-r--r-- | net/batman-adv/bridge_loop_avoidance.c | 13 | ||||
-rw-r--r-- | net/batman-adv/debugfs.h | 2 | ||||
-rw-r--r-- | net/batman-adv/distributed-arp-table.c | 4 | ||||
-rw-r--r-- | net/batman-adv/gateway_client.c | 10 | ||||
-rw-r--r-- | net/batman-adv/hard-interface.c | 8 | ||||
-rw-r--r-- | net/batman-adv/icmp_socket.h | 18 | ||||
-rw-r--r-- | net/batman-adv/main.c | 2 | ||||
-rw-r--r-- | net/batman-adv/multicast.c | 2 | ||||
-rw-r--r-- | net/batman-adv/network-coding.c | 11 | ||||
-rw-r--r-- | net/batman-adv/originator.c | 12 | ||||
-rw-r--r-- | net/batman-adv/soft-interface.c | 4 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 10 | ||||
-rw-r--r-- | net/batman-adv/tvlv.c | 9 | ||||
-rw-r--r-- | net/batman-adv/types.h | 6 |
20 files changed, 131 insertions, 37 deletions
diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig index 833bb145ba3c..f20742cbae6d 100644 --- a/net/batman-adv/Kconfig +++ b/net/batman-adv/Kconfig | |||
@@ -73,10 +73,21 @@ config BATMAN_ADV_MCAST | |||
73 | reduce the air overhead while improving the reliability of | 73 | reduce the air overhead while improving the reliability of |
74 | multicast messages. | 74 | multicast messages. |
75 | 75 | ||
76 | config BATMAN_ADV_DEBUG | 76 | config BATMAN_ADV_DEBUGFS |
77 | bool "B.A.T.M.A.N. debugging" | 77 | bool "batman-adv debugfs entries" |
78 | depends on BATMAN_ADV | 78 | depends on BATMAN_ADV |
79 | depends on DEBUG_FS | 79 | depends on DEBUG_FS |
80 | default y | ||
81 | help | ||
82 | Enable this to export routing related debug tables via debugfs. | ||
83 | The information for each soft-interface and used hard-interface can be | ||
84 | found under batman_adv/ | ||
85 | |||
86 | If unsure, say Y. | ||
87 | |||
88 | config BATMAN_ADV_DEBUG | ||
89 | bool "B.A.T.M.A.N. debugging" | ||
90 | depends on BATMAN_ADV_DEBUGFS | ||
80 | help | 91 | help |
81 | This is an option for use by developers; most people should | 92 | This is an option for use by developers; most people should |
82 | say N here. This enables compilation of support for | 93 | say N here. This enables compilation of support for |
diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile index a83fc6c58d19..f724d3c98a81 100644 --- a/net/batman-adv/Makefile +++ b/net/batman-adv/Makefile | |||
@@ -24,14 +24,14 @@ batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_elp.o | |||
24 | batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_ogm.o | 24 | batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_ogm.o |
25 | batman-adv-y += bitarray.o | 25 | batman-adv-y += bitarray.o |
26 | batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o | 26 | batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o |
27 | batman-adv-$(CONFIG_DEBUG_FS) += debugfs.o | 27 | batman-adv-$(CONFIG_BATMAN_ADV_DEBUGFS) += debugfs.o |
28 | batman-adv-$(CONFIG_BATMAN_ADV_DAT) += distributed-arp-table.o | 28 | batman-adv-$(CONFIG_BATMAN_ADV_DAT) += distributed-arp-table.o |
29 | batman-adv-y += fragmentation.o | 29 | batman-adv-y += fragmentation.o |
30 | batman-adv-y += gateway_client.o | 30 | batman-adv-y += gateway_client.o |
31 | batman-adv-y += gateway_common.o | 31 | batman-adv-y += gateway_common.o |
32 | batman-adv-y += hard-interface.o | 32 | batman-adv-y += hard-interface.o |
33 | batman-adv-y += hash.o | 33 | batman-adv-y += hash.o |
34 | batman-adv-y += icmp_socket.o | 34 | batman-adv-$(CONFIG_BATMAN_ADV_DEBUGFS) += icmp_socket.o |
35 | batman-adv-$(CONFIG_BATMAN_ADV_DEBUG) += log.o | 35 | batman-adv-$(CONFIG_BATMAN_ADV_DEBUG) += log.o |
36 | batman-adv-y += main.o | 36 | batman-adv-y += main.o |
37 | batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += multicast.o | 37 | batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += multicast.o |
diff --git a/net/batman-adv/bat_algo.c b/net/batman-adv/bat_algo.c index f2cc50d354d9..623d04302aa2 100644 --- a/net/batman-adv/bat_algo.c +++ b/net/batman-adv/bat_algo.c | |||
@@ -101,6 +101,7 @@ int batadv_algo_select(struct batadv_priv *bat_priv, char *name) | |||
101 | return 0; | 101 | return 0; |
102 | } | 102 | } |
103 | 103 | ||
104 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
104 | int batadv_algo_seq_print_text(struct seq_file *seq, void *offset) | 105 | int batadv_algo_seq_print_text(struct seq_file *seq, void *offset) |
105 | { | 106 | { |
106 | struct batadv_algo_ops *bat_algo_ops; | 107 | struct batadv_algo_ops *bat_algo_ops; |
@@ -113,6 +114,7 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset) | |||
113 | 114 | ||
114 | return 0; | 115 | return 0; |
115 | } | 116 | } |
117 | #endif | ||
116 | 118 | ||
117 | static int batadv_param_set_ra(const char *val, const struct kernel_param *kp) | 119 | static int batadv_param_set_ra(const char *val, const struct kernel_param *kp) |
118 | { | 120 | { |
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 9ed4f1fc6ac5..e2d18d0b1f06 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -324,17 +324,18 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr) | |||
324 | if (!orig_node->bat_iv.bcast_own_sum) | 324 | if (!orig_node->bat_iv.bcast_own_sum) |
325 | goto free_orig_node; | 325 | goto free_orig_node; |
326 | 326 | ||
327 | kref_get(&orig_node->refcount); | ||
327 | hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig, | 328 | hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig, |
328 | batadv_choose_orig, orig_node, | 329 | batadv_choose_orig, orig_node, |
329 | &orig_node->hash_entry); | 330 | &orig_node->hash_entry); |
330 | if (hash_added != 0) | 331 | if (hash_added != 0) |
331 | goto free_orig_node; | 332 | goto free_orig_node_hash; |
332 | 333 | ||
333 | return orig_node; | 334 | return orig_node; |
334 | 335 | ||
335 | free_orig_node: | 336 | free_orig_node_hash: |
336 | /* free twice, as batadv_orig_node_new sets refcount to 2 */ | ||
337 | batadv_orig_node_put(orig_node); | 337 | batadv_orig_node_put(orig_node); |
338 | free_orig_node: | ||
338 | batadv_orig_node_put(orig_node); | 339 | batadv_orig_node_put(orig_node); |
339 | 340 | ||
340 | return NULL; | 341 | return NULL; |
@@ -1854,6 +1855,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb, | |||
1854 | return NET_RX_SUCCESS; | 1855 | return NET_RX_SUCCESS; |
1855 | } | 1856 | } |
1856 | 1857 | ||
1858 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
1857 | /** | 1859 | /** |
1858 | * batadv_iv_ogm_orig_print_neigh - print neighbors for the originator table | 1860 | * batadv_iv_ogm_orig_print_neigh - print neighbors for the originator table |
1859 | * @orig_node: the orig_node for which the neighbors are printed | 1861 | * @orig_node: the orig_node for which the neighbors are printed |
@@ -1951,6 +1953,7 @@ next: | |||
1951 | if (batman_count == 0) | 1953 | if (batman_count == 0) |
1952 | seq_puts(seq, "No batman nodes in range ...\n"); | 1954 | seq_puts(seq, "No batman nodes in range ...\n"); |
1953 | } | 1955 | } |
1956 | #endif | ||
1954 | 1957 | ||
1955 | /** | 1958 | /** |
1956 | * batadv_iv_ogm_neigh_get_tq_avg - Get the TQ average for a neighbour on a | 1959 | * batadv_iv_ogm_neigh_get_tq_avg - Get the TQ average for a neighbour on a |
@@ -2181,6 +2184,7 @@ batadv_iv_ogm_orig_dump(struct sk_buff *msg, struct netlink_callback *cb, | |||
2181 | cb->args[2] = sub; | 2184 | cb->args[2] = sub; |
2182 | } | 2185 | } |
2183 | 2186 | ||
2187 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
2184 | /** | 2188 | /** |
2185 | * batadv_iv_hardif_neigh_print - print a single hop neighbour node | 2189 | * batadv_iv_hardif_neigh_print - print a single hop neighbour node |
2186 | * @seq: neighbour table seq_file struct | 2190 | * @seq: neighbour table seq_file struct |
@@ -2231,6 +2235,7 @@ static void batadv_iv_neigh_print(struct batadv_priv *bat_priv, | |||
2231 | if (batman_count == 0) | 2235 | if (batman_count == 0) |
2232 | seq_puts(seq, "No batman nodes in range ...\n"); | 2236 | seq_puts(seq, "No batman nodes in range ...\n"); |
2233 | } | 2237 | } |
2238 | #endif | ||
2234 | 2239 | ||
2235 | /** | 2240 | /** |
2236 | * batadv_iv_ogm_neigh_diff - calculate tq difference of two neighbors | 2241 | * batadv_iv_ogm_neigh_diff - calculate tq difference of two neighbors |
@@ -2617,6 +2622,7 @@ out: | |||
2617 | return ret; | 2622 | return ret; |
2618 | } | 2623 | } |
2619 | 2624 | ||
2625 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
2620 | /* fails if orig_node has no router */ | 2626 | /* fails if orig_node has no router */ |
2621 | static int batadv_iv_gw_write_buffer_text(struct batadv_priv *bat_priv, | 2627 | static int batadv_iv_gw_write_buffer_text(struct batadv_priv *bat_priv, |
2622 | struct seq_file *seq, | 2628 | struct seq_file *seq, |
@@ -2680,6 +2686,7 @@ static void batadv_iv_gw_print(struct batadv_priv *bat_priv, | |||
2680 | if (gw_count == 0) | 2686 | if (gw_count == 0) |
2681 | seq_puts(seq, "No gateways in range ...\n"); | 2687 | seq_puts(seq, "No gateways in range ...\n"); |
2682 | } | 2688 | } |
2689 | #endif | ||
2683 | 2690 | ||
2684 | /** | 2691 | /** |
2685 | * batadv_iv_gw_dump_entry - Dump a gateway into a message | 2692 | * batadv_iv_gw_dump_entry - Dump a gateway into a message |
@@ -2797,11 +2804,15 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = { | |||
2797 | .neigh = { | 2804 | .neigh = { |
2798 | .cmp = batadv_iv_ogm_neigh_cmp, | 2805 | .cmp = batadv_iv_ogm_neigh_cmp, |
2799 | .is_similar_or_better = batadv_iv_ogm_neigh_is_sob, | 2806 | .is_similar_or_better = batadv_iv_ogm_neigh_is_sob, |
2807 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
2800 | .print = batadv_iv_neigh_print, | 2808 | .print = batadv_iv_neigh_print, |
2809 | #endif | ||
2801 | .dump = batadv_iv_ogm_neigh_dump, | 2810 | .dump = batadv_iv_ogm_neigh_dump, |
2802 | }, | 2811 | }, |
2803 | .orig = { | 2812 | .orig = { |
2813 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
2804 | .print = batadv_iv_ogm_orig_print, | 2814 | .print = batadv_iv_ogm_orig_print, |
2815 | #endif | ||
2805 | .dump = batadv_iv_ogm_orig_dump, | 2816 | .dump = batadv_iv_ogm_orig_dump, |
2806 | .free = batadv_iv_ogm_orig_free, | 2817 | .free = batadv_iv_ogm_orig_free, |
2807 | .add_if = batadv_iv_ogm_orig_add_if, | 2818 | .add_if = batadv_iv_ogm_orig_add_if, |
@@ -2810,7 +2821,9 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = { | |||
2810 | .gw = { | 2821 | .gw = { |
2811 | .get_best_gw_node = batadv_iv_gw_get_best_gw_node, | 2822 | .get_best_gw_node = batadv_iv_gw_get_best_gw_node, |
2812 | .is_eligible = batadv_iv_gw_is_eligible, | 2823 | .is_eligible = batadv_iv_gw_is_eligible, |
2824 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
2813 | .print = batadv_iv_gw_print, | 2825 | .print = batadv_iv_gw_print, |
2826 | #endif | ||
2814 | .dump = batadv_iv_gw_dump, | 2827 | .dump = batadv_iv_gw_dump, |
2815 | }, | 2828 | }, |
2816 | }; | 2829 | }; |
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c index 9e872dcc1260..e79f6f01182e 100644 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c | |||
@@ -129,6 +129,7 @@ batadv_v_hardif_neigh_init(struct batadv_hardif_neigh_node *hardif_neigh) | |||
129 | batadv_v_elp_throughput_metric_update); | 129 | batadv_v_elp_throughput_metric_update); |
130 | } | 130 | } |
131 | 131 | ||
132 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
132 | /** | 133 | /** |
133 | * batadv_v_orig_print_neigh - print neighbors for the originator table | 134 | * batadv_v_orig_print_neigh - print neighbors for the originator table |
134 | * @orig_node: the orig_node for which the neighbors are printed | 135 | * @orig_node: the orig_node for which the neighbors are printed |
@@ -212,6 +213,7 @@ static void batadv_v_neigh_print(struct batadv_priv *bat_priv, | |||
212 | if (batman_count == 0) | 213 | if (batman_count == 0) |
213 | seq_puts(seq, "No batman nodes in range ...\n"); | 214 | seq_puts(seq, "No batman nodes in range ...\n"); |
214 | } | 215 | } |
216 | #endif | ||
215 | 217 | ||
216 | /** | 218 | /** |
217 | * batadv_v_neigh_dump_neigh - Dump a neighbour into a message | 219 | * batadv_v_neigh_dump_neigh - Dump a neighbour into a message |
@@ -345,6 +347,7 @@ batadv_v_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb, | |||
345 | cb->args[1] = idx; | 347 | cb->args[1] = idx; |
346 | } | 348 | } |
347 | 349 | ||
350 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
348 | /** | 351 | /** |
349 | * batadv_v_orig_print - print the originator table | 352 | * batadv_v_orig_print - print the originator table |
350 | * @bat_priv: the bat priv with all the soft interface information | 353 | * @bat_priv: the bat priv with all the soft interface information |
@@ -411,6 +414,7 @@ next: | |||
411 | if (batman_count == 0) | 414 | if (batman_count == 0) |
412 | seq_puts(seq, "No batman nodes in range ...\n"); | 415 | seq_puts(seq, "No batman nodes in range ...\n"); |
413 | } | 416 | } |
417 | #endif | ||
414 | 418 | ||
415 | /** | 419 | /** |
416 | * batadv_v_orig_dump_subentry - Dump an originator subentry into a | 420 | * batadv_v_orig_dump_subentry - Dump an originator subentry into a |
@@ -827,6 +831,7 @@ out: | |||
827 | return ret; | 831 | return ret; |
828 | } | 832 | } |
829 | 833 | ||
834 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
830 | /* fails if orig_node has no router */ | 835 | /* fails if orig_node has no router */ |
831 | static int batadv_v_gw_write_buffer_text(struct batadv_priv *bat_priv, | 836 | static int batadv_v_gw_write_buffer_text(struct batadv_priv *bat_priv, |
832 | struct seq_file *seq, | 837 | struct seq_file *seq, |
@@ -896,6 +901,7 @@ static void batadv_v_gw_print(struct batadv_priv *bat_priv, | |||
896 | if (gw_count == 0) | 901 | if (gw_count == 0) |
897 | seq_puts(seq, "No gateways in range ...\n"); | 902 | seq_puts(seq, "No gateways in range ...\n"); |
898 | } | 903 | } |
904 | #endif | ||
899 | 905 | ||
900 | /** | 906 | /** |
901 | * batadv_v_gw_dump_entry - Dump a gateway into a message | 907 | * batadv_v_gw_dump_entry - Dump a gateway into a message |
@@ -1034,11 +1040,15 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { | |||
1034 | .hardif_init = batadv_v_hardif_neigh_init, | 1040 | .hardif_init = batadv_v_hardif_neigh_init, |
1035 | .cmp = batadv_v_neigh_cmp, | 1041 | .cmp = batadv_v_neigh_cmp, |
1036 | .is_similar_or_better = batadv_v_neigh_is_sob, | 1042 | .is_similar_or_better = batadv_v_neigh_is_sob, |
1043 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
1037 | .print = batadv_v_neigh_print, | 1044 | .print = batadv_v_neigh_print, |
1045 | #endif | ||
1038 | .dump = batadv_v_neigh_dump, | 1046 | .dump = batadv_v_neigh_dump, |
1039 | }, | 1047 | }, |
1040 | .orig = { | 1048 | .orig = { |
1049 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
1041 | .print = batadv_v_orig_print, | 1050 | .print = batadv_v_orig_print, |
1051 | #endif | ||
1042 | .dump = batadv_v_orig_dump, | 1052 | .dump = batadv_v_orig_dump, |
1043 | }, | 1053 | }, |
1044 | .gw = { | 1054 | .gw = { |
@@ -1046,7 +1056,9 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { | |||
1046 | .show_sel_class = batadv_v_show_sel_class, | 1056 | .show_sel_class = batadv_v_show_sel_class, |
1047 | .get_best_gw_node = batadv_v_gw_get_best_gw_node, | 1057 | .get_best_gw_node = batadv_v_gw_get_best_gw_node, |
1048 | .is_eligible = batadv_v_gw_is_eligible, | 1058 | .is_eligible = batadv_v_gw_is_eligible, |
1059 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
1049 | .print = batadv_v_gw_print, | 1060 | .print = batadv_v_gw_print, |
1061 | #endif | ||
1050 | .dump = batadv_v_gw_dump, | 1062 | .dump = batadv_v_gw_dump, |
1051 | }, | 1063 | }, |
1052 | }; | 1064 | }; |
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index 6fbba4eb0617..1aeeadca620c 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c | |||
@@ -73,13 +73,12 @@ struct batadv_orig_node *batadv_v_ogm_orig_get(struct batadv_priv *bat_priv, | |||
73 | if (!orig_node) | 73 | if (!orig_node) |
74 | return NULL; | 74 | return NULL; |
75 | 75 | ||
76 | kref_get(&orig_node->refcount); | ||
76 | hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig, | 77 | hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig, |
77 | batadv_choose_orig, orig_node, | 78 | batadv_choose_orig, orig_node, |
78 | &orig_node->hash_entry); | 79 | &orig_node->hash_entry); |
79 | if (hash_added != 0) { | 80 | if (hash_added != 0) { |
80 | /* orig_node->refcounter is initialised to 2 by | 81 | /* remove refcnt for newly created orig_node and hash entry */ |
81 | * batadv_orig_node_new() | ||
82 | */ | ||
83 | batadv_orig_node_put(orig_node); | 82 | batadv_orig_node_put(orig_node); |
84 | batadv_orig_node_put(orig_node); | 83 | batadv_orig_node_put(orig_node); |
85 | orig_node = NULL; | 84 | orig_node = NULL; |
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 35ed1d32bab5..e7f690b571ea 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c | |||
@@ -526,11 +526,9 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, u8 *orig, | |||
526 | atomic_set(&entry->wait_periods, 0); | 526 | atomic_set(&entry->wait_periods, 0); |
527 | ether_addr_copy(entry->orig, orig); | 527 | ether_addr_copy(entry->orig, orig); |
528 | INIT_WORK(&entry->report_work, batadv_bla_loopdetect_report); | 528 | INIT_WORK(&entry->report_work, batadv_bla_loopdetect_report); |
529 | |||
530 | /* one for the hash, one for returning */ | ||
531 | kref_init(&entry->refcount); | 529 | kref_init(&entry->refcount); |
532 | kref_get(&entry->refcount); | ||
533 | 530 | ||
531 | kref_get(&entry->refcount); | ||
534 | hash_added = batadv_hash_add(bat_priv->bla.backbone_hash, | 532 | hash_added = batadv_hash_add(bat_priv->bla.backbone_hash, |
535 | batadv_compare_backbone_gw, | 533 | batadv_compare_backbone_gw, |
536 | batadv_choose_backbone_gw, entry, | 534 | batadv_choose_backbone_gw, entry, |
@@ -718,12 +716,13 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv, | |||
718 | claim->lasttime = jiffies; | 716 | claim->lasttime = jiffies; |
719 | kref_get(&backbone_gw->refcount); | 717 | kref_get(&backbone_gw->refcount); |
720 | claim->backbone_gw = backbone_gw; | 718 | claim->backbone_gw = backbone_gw; |
721 | |||
722 | kref_init(&claim->refcount); | 719 | kref_init(&claim->refcount); |
723 | kref_get(&claim->refcount); | 720 | |
724 | batadv_dbg(BATADV_DBG_BLA, bat_priv, | 721 | batadv_dbg(BATADV_DBG_BLA, bat_priv, |
725 | "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n", | 722 | "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n", |
726 | mac, BATADV_PRINT_VID(vid)); | 723 | mac, BATADV_PRINT_VID(vid)); |
724 | |||
725 | kref_get(&claim->refcount); | ||
727 | hash_added = batadv_hash_add(bat_priv->bla.claim_hash, | 726 | hash_added = batadv_hash_add(bat_priv->bla.claim_hash, |
728 | batadv_compare_claim, | 727 | batadv_compare_claim, |
729 | batadv_choose_claim, claim, | 728 | batadv_choose_claim, claim, |
@@ -1997,6 +1996,7 @@ out: | |||
1997 | return ret; | 1996 | return ret; |
1998 | } | 1997 | } |
1999 | 1998 | ||
1999 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
2000 | /** | 2000 | /** |
2001 | * batadv_bla_claim_table_seq_print_text - print the claim table in a seq file | 2001 | * batadv_bla_claim_table_seq_print_text - print the claim table in a seq file |
2002 | * @seq: seq file to print on | 2002 | * @seq: seq file to print on |
@@ -2057,6 +2057,7 @@ out: | |||
2057 | batadv_hardif_put(primary_if); | 2057 | batadv_hardif_put(primary_if); |
2058 | return 0; | 2058 | return 0; |
2059 | } | 2059 | } |
2060 | #endif | ||
2060 | 2061 | ||
2061 | /** | 2062 | /** |
2062 | * batadv_bla_claim_dump_entry - dump one entry of the claim table | 2063 | * batadv_bla_claim_dump_entry - dump one entry of the claim table |
@@ -2220,6 +2221,7 @@ out: | |||
2220 | return ret; | 2221 | return ret; |
2221 | } | 2222 | } |
2222 | 2223 | ||
2224 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
2223 | /** | 2225 | /** |
2224 | * batadv_bla_backbone_table_seq_print_text - print the backbone table in a seq | 2226 | * batadv_bla_backbone_table_seq_print_text - print the backbone table in a seq |
2225 | * file | 2227 | * file |
@@ -2283,6 +2285,7 @@ out: | |||
2283 | batadv_hardif_put(primary_if); | 2285 | batadv_hardif_put(primary_if); |
2284 | return 0; | 2286 | return 0; |
2285 | } | 2287 | } |
2288 | #endif | ||
2286 | 2289 | ||
2287 | /** | 2290 | /** |
2288 | * batadv_bla_backbone_dump_entry - dump one entry of the backbone table | 2291 | * batadv_bla_backbone_dump_entry - dump one entry of the backbone table |
diff --git a/net/batman-adv/debugfs.h b/net/batman-adv/debugfs.h index 1ab4e2e63afc..c68ff3dcb926 100644 --- a/net/batman-adv/debugfs.h +++ b/net/batman-adv/debugfs.h | |||
@@ -26,7 +26,7 @@ struct net_device; | |||
26 | 26 | ||
27 | #define BATADV_DEBUGFS_SUBDIR "batman_adv" | 27 | #define BATADV_DEBUGFS_SUBDIR "batman_adv" |
28 | 28 | ||
29 | #if IS_ENABLED(CONFIG_DEBUG_FS) | 29 | #if IS_ENABLED(CONFIG_BATMAN_ADV_DEBUGFS) |
30 | 30 | ||
31 | void batadv_debugfs_init(void); | 31 | void batadv_debugfs_init(void); |
32 | void batadv_debugfs_destroy(void); | 32 | void batadv_debugfs_destroy(void); |
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index b1cc8bfe11ac..e257efdc5d03 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c | |||
@@ -343,8 +343,8 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip, | |||
343 | ether_addr_copy(dat_entry->mac_addr, mac_addr); | 343 | ether_addr_copy(dat_entry->mac_addr, mac_addr); |
344 | dat_entry->last_update = jiffies; | 344 | dat_entry->last_update = jiffies; |
345 | kref_init(&dat_entry->refcount); | 345 | kref_init(&dat_entry->refcount); |
346 | kref_get(&dat_entry->refcount); | ||
347 | 346 | ||
347 | kref_get(&dat_entry->refcount); | ||
348 | hash_added = batadv_hash_add(bat_priv->dat.hash, batadv_compare_dat, | 348 | hash_added = batadv_hash_add(bat_priv->dat.hash, batadv_compare_dat, |
349 | batadv_hash_dat, dat_entry, | 349 | batadv_hash_dat, dat_entry, |
350 | &dat_entry->hash_entry); | 350 | &dat_entry->hash_entry); |
@@ -795,6 +795,7 @@ void batadv_dat_free(struct batadv_priv *bat_priv) | |||
795 | batadv_dat_hash_free(bat_priv); | 795 | batadv_dat_hash_free(bat_priv); |
796 | } | 796 | } |
797 | 797 | ||
798 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
798 | /** | 799 | /** |
799 | * batadv_dat_cache_seq_print_text - print the local DAT hash table | 800 | * batadv_dat_cache_seq_print_text - print the local DAT hash table |
800 | * @seq: seq file to print on | 801 | * @seq: seq file to print on |
@@ -846,6 +847,7 @@ out: | |||
846 | batadv_hardif_put(primary_if); | 847 | batadv_hardif_put(primary_if); |
847 | return 0; | 848 | return 0; |
848 | } | 849 | } |
850 | #endif | ||
849 | 851 | ||
850 | /** | 852 | /** |
851 | * batadv_arp_get_type - parse an ARP packet and gets the type | 853 | * batadv_arp_get_type - parse an ARP packet and gets the type |
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index c2928c2287b8..de055d64debe 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c | |||
@@ -339,14 +339,15 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv, | |||
339 | if (!gw_node) | 339 | if (!gw_node) |
340 | return; | 340 | return; |
341 | 341 | ||
342 | kref_get(&orig_node->refcount); | 342 | kref_init(&gw_node->refcount); |
343 | INIT_HLIST_NODE(&gw_node->list); | 343 | INIT_HLIST_NODE(&gw_node->list); |
344 | kref_get(&orig_node->refcount); | ||
344 | gw_node->orig_node = orig_node; | 345 | gw_node->orig_node = orig_node; |
345 | gw_node->bandwidth_down = ntohl(gateway->bandwidth_down); | 346 | gw_node->bandwidth_down = ntohl(gateway->bandwidth_down); |
346 | gw_node->bandwidth_up = ntohl(gateway->bandwidth_up); | 347 | gw_node->bandwidth_up = ntohl(gateway->bandwidth_up); |
347 | kref_init(&gw_node->refcount); | ||
348 | 348 | ||
349 | spin_lock_bh(&bat_priv->gw.list_lock); | 349 | spin_lock_bh(&bat_priv->gw.list_lock); |
350 | kref_get(&gw_node->refcount); | ||
350 | hlist_add_head_rcu(&gw_node->list, &bat_priv->gw.list); | 351 | hlist_add_head_rcu(&gw_node->list, &bat_priv->gw.list); |
351 | spin_unlock_bh(&bat_priv->gw.list_lock); | 352 | spin_unlock_bh(&bat_priv->gw.list_lock); |
352 | 353 | ||
@@ -357,6 +358,9 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv, | |||
357 | ntohl(gateway->bandwidth_down) % 10, | 358 | ntohl(gateway->bandwidth_down) % 10, |
358 | ntohl(gateway->bandwidth_up) / 10, | 359 | ntohl(gateway->bandwidth_up) / 10, |
359 | ntohl(gateway->bandwidth_up) % 10); | 360 | ntohl(gateway->bandwidth_up) % 10); |
361 | |||
362 | /* don't return reference to new gw_node */ | ||
363 | batadv_gw_node_put(gw_node); | ||
360 | } | 364 | } |
361 | 365 | ||
362 | /** | 366 | /** |
@@ -478,6 +482,7 @@ void batadv_gw_node_free(struct batadv_priv *bat_priv) | |||
478 | spin_unlock_bh(&bat_priv->gw.list_lock); | 482 | spin_unlock_bh(&bat_priv->gw.list_lock); |
479 | } | 483 | } |
480 | 484 | ||
485 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
481 | int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) | 486 | int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) |
482 | { | 487 | { |
483 | struct net_device *net_dev = (struct net_device *)seq->private; | 488 | struct net_device *net_dev = (struct net_device *)seq->private; |
@@ -505,6 +510,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) | |||
505 | 510 | ||
506 | return 0; | 511 | return 0; |
507 | } | 512 | } |
513 | #endif | ||
508 | 514 | ||
509 | /** | 515 | /** |
510 | * batadv_gw_dump - Dump gateways into a message | 516 | * batadv_gw_dump - Dump gateways into a message |
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 43c9a3e02512..08ce36147c4c 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c | |||
@@ -694,6 +694,7 @@ batadv_hardif_add_interface(struct net_device *net_dev) | |||
694 | INIT_HLIST_HEAD(&hard_iface->neigh_list); | 694 | INIT_HLIST_HEAD(&hard_iface->neigh_list); |
695 | 695 | ||
696 | spin_lock_init(&hard_iface->neigh_list_lock); | 696 | spin_lock_init(&hard_iface->neigh_list_lock); |
697 | kref_init(&hard_iface->refcount); | ||
697 | 698 | ||
698 | hard_iface->num_bcasts = BATADV_NUM_BCASTS_DEFAULT; | 699 | hard_iface->num_bcasts = BATADV_NUM_BCASTS_DEFAULT; |
699 | if (batadv_is_wifi_netdev(net_dev)) | 700 | if (batadv_is_wifi_netdev(net_dev)) |
@@ -701,11 +702,8 @@ batadv_hardif_add_interface(struct net_device *net_dev) | |||
701 | 702 | ||
702 | batadv_v_hardif_init(hard_iface); | 703 | batadv_v_hardif_init(hard_iface); |
703 | 704 | ||
704 | /* extra reference for return */ | ||
705 | kref_init(&hard_iface->refcount); | ||
706 | kref_get(&hard_iface->refcount); | ||
707 | |||
708 | batadv_check_known_mac_addr(hard_iface->net_dev); | 705 | batadv_check_known_mac_addr(hard_iface->net_dev); |
706 | kref_get(&hard_iface->refcount); | ||
709 | list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list); | 707 | list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list); |
710 | 708 | ||
711 | return hard_iface; | 709 | return hard_iface; |
@@ -727,7 +725,7 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) | |||
727 | /* first deactivate interface */ | 725 | /* first deactivate interface */ |
728 | if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) | 726 | if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) |
729 | batadv_hardif_disable_interface(hard_iface, | 727 | batadv_hardif_disable_interface(hard_iface, |
730 | BATADV_IF_CLEANUP_AUTO); | 728 | BATADV_IF_CLEANUP_KEEP); |
731 | 729 | ||
732 | if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) | 730 | if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) |
733 | return; | 731 | return; |
diff --git a/net/batman-adv/icmp_socket.h b/net/batman-adv/icmp_socket.h index 618d5de06f20..e44a7da51431 100644 --- a/net/batman-adv/icmp_socket.h +++ b/net/batman-adv/icmp_socket.h | |||
@@ -26,9 +26,25 @@ struct batadv_icmp_header; | |||
26 | 26 | ||
27 | #define BATADV_ICMP_SOCKET "socket" | 27 | #define BATADV_ICMP_SOCKET "socket" |
28 | 28 | ||
29 | void batadv_socket_init(void); | ||
30 | int batadv_socket_setup(struct batadv_priv *bat_priv); | 29 | int batadv_socket_setup(struct batadv_priv *bat_priv); |
30 | |||
31 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
32 | |||
33 | void batadv_socket_init(void); | ||
31 | void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, | 34 | void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, |
32 | size_t icmp_len); | 35 | size_t icmp_len); |
33 | 36 | ||
37 | #else | ||
38 | |||
39 | static inline void batadv_socket_init(void) | ||
40 | { | ||
41 | } | ||
42 | |||
43 | static inline void | ||
44 | batadv_socket_receive_packet(struct batadv_icmp_header *icmph, size_t icmp_len) | ||
45 | { | ||
46 | } | ||
47 | |||
48 | #endif | ||
49 | |||
34 | #endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ | 50 | #endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ |
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index ef07e5b34415..2c017ab47557 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c | |||
@@ -282,6 +282,7 @@ bool batadv_is_my_mac(struct batadv_priv *bat_priv, const u8 *addr) | |||
282 | return is_my_mac; | 282 | return is_my_mac; |
283 | } | 283 | } |
284 | 284 | ||
285 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
285 | /** | 286 | /** |
286 | * batadv_seq_print_text_primary_if_get - called from debugfs table printing | 287 | * batadv_seq_print_text_primary_if_get - called from debugfs table printing |
287 | * function that requires the primary interface | 288 | * function that requires the primary interface |
@@ -317,6 +318,7 @@ batadv_seq_print_text_primary_if_get(struct seq_file *seq) | |||
317 | out: | 318 | out: |
318 | return primary_if; | 319 | return primary_if; |
319 | } | 320 | } |
321 | #endif | ||
320 | 322 | ||
321 | /** | 323 | /** |
322 | * batadv_max_header_len - calculate maximum encapsulation overhead for a | 324 | * batadv_max_header_len - calculate maximum encapsulation overhead for a |
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index 894df6020f6a..13661f43386f 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c | |||
@@ -1134,6 +1134,7 @@ void batadv_mcast_init(struct batadv_priv *bat_priv) | |||
1134 | BATADV_TVLV_HANDLER_OGM_CIFNOTFND); | 1134 | BATADV_TVLV_HANDLER_OGM_CIFNOTFND); |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
1137 | /** | 1138 | /** |
1138 | * batadv_mcast_flags_print_header - print own mcast flags to debugfs table | 1139 | * batadv_mcast_flags_print_header - print own mcast flags to debugfs table |
1139 | * @bat_priv: the bat priv with all the soft interface information | 1140 | * @bat_priv: the bat priv with all the soft interface information |
@@ -1234,6 +1235,7 @@ int batadv_mcast_flags_seq_print_text(struct seq_file *seq, void *offset) | |||
1234 | 1235 | ||
1235 | return 0; | 1236 | return 0; |
1236 | } | 1237 | } |
1238 | #endif | ||
1237 | 1239 | ||
1238 | /** | 1240 | /** |
1239 | * batadv_mcast_free - free the multicast optimizations structures | 1241 | * batadv_mcast_free - free the multicast optimizations structures |
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index 293ef4ffd4e1..e3baf697a35c 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c | |||
@@ -856,14 +856,12 @@ batadv_nc_get_nc_node(struct batadv_priv *bat_priv, | |||
856 | if (!nc_node) | 856 | if (!nc_node) |
857 | return NULL; | 857 | return NULL; |
858 | 858 | ||
859 | kref_get(&orig_neigh_node->refcount); | ||
860 | |||
861 | /* Initialize nc_node */ | 859 | /* Initialize nc_node */ |
862 | INIT_LIST_HEAD(&nc_node->list); | 860 | INIT_LIST_HEAD(&nc_node->list); |
861 | kref_init(&nc_node->refcount); | ||
863 | ether_addr_copy(nc_node->addr, orig_node->orig); | 862 | ether_addr_copy(nc_node->addr, orig_node->orig); |
863 | kref_get(&orig_neigh_node->refcount); | ||
864 | nc_node->orig_node = orig_neigh_node; | 864 | nc_node->orig_node = orig_neigh_node; |
865 | kref_init(&nc_node->refcount); | ||
866 | kref_get(&nc_node->refcount); | ||
867 | 865 | ||
868 | /* Select ingoing or outgoing coding node */ | 866 | /* Select ingoing or outgoing coding node */ |
869 | if (in_coding) { | 867 | if (in_coding) { |
@@ -879,6 +877,7 @@ batadv_nc_get_nc_node(struct batadv_priv *bat_priv, | |||
879 | 877 | ||
880 | /* Add nc_node to orig_node */ | 878 | /* Add nc_node to orig_node */ |
881 | spin_lock_bh(lock); | 879 | spin_lock_bh(lock); |
880 | kref_get(&nc_node->refcount); | ||
882 | list_add_tail_rcu(&nc_node->list, list); | 881 | list_add_tail_rcu(&nc_node->list, list); |
883 | spin_unlock_bh(lock); | 882 | spin_unlock_bh(lock); |
884 | 883 | ||
@@ -979,7 +978,6 @@ static struct batadv_nc_path *batadv_nc_get_path(struct batadv_priv *bat_priv, | |||
979 | INIT_LIST_HEAD(&nc_path->packet_list); | 978 | INIT_LIST_HEAD(&nc_path->packet_list); |
980 | spin_lock_init(&nc_path->packet_list_lock); | 979 | spin_lock_init(&nc_path->packet_list_lock); |
981 | kref_init(&nc_path->refcount); | 980 | kref_init(&nc_path->refcount); |
982 | kref_get(&nc_path->refcount); | ||
983 | nc_path->last_valid = jiffies; | 981 | nc_path->last_valid = jiffies; |
984 | ether_addr_copy(nc_path->next_hop, dst); | 982 | ether_addr_copy(nc_path->next_hop, dst); |
985 | ether_addr_copy(nc_path->prev_hop, src); | 983 | ether_addr_copy(nc_path->prev_hop, src); |
@@ -989,6 +987,7 @@ static struct batadv_nc_path *batadv_nc_get_path(struct batadv_priv *bat_priv, | |||
989 | nc_path->next_hop); | 987 | nc_path->next_hop); |
990 | 988 | ||
991 | /* Add nc_path to hash table */ | 989 | /* Add nc_path to hash table */ |
990 | kref_get(&nc_path->refcount); | ||
992 | hash_added = batadv_hash_add(hash, batadv_nc_hash_compare, | 991 | hash_added = batadv_hash_add(hash, batadv_nc_hash_compare, |
993 | batadv_nc_hash_choose, &nc_path_key, | 992 | batadv_nc_hash_choose, &nc_path_key, |
994 | &nc_path->hash_entry); | 993 | &nc_path->hash_entry); |
@@ -1882,6 +1881,7 @@ void batadv_nc_mesh_free(struct batadv_priv *bat_priv) | |||
1882 | batadv_hash_destroy(bat_priv->nc.decoding_hash); | 1881 | batadv_hash_destroy(bat_priv->nc.decoding_hash); |
1883 | } | 1882 | } |
1884 | 1883 | ||
1884 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
1885 | /** | 1885 | /** |
1886 | * batadv_nc_nodes_seq_print_text - print the nc node information | 1886 | * batadv_nc_nodes_seq_print_text - print the nc node information |
1887 | * @seq: seq file to print on | 1887 | * @seq: seq file to print on |
@@ -1981,3 +1981,4 @@ int batadv_nc_init_debugfs(struct batadv_priv *bat_priv) | |||
1981 | out: | 1981 | out: |
1982 | return -ENOMEM; | 1982 | return -ENOMEM; |
1983 | } | 1983 | } |
1984 | #endif | ||
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 95c85558c530..5f3bfc41aeb1 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c | |||
@@ -133,9 +133,9 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node, | |||
133 | goto out; | 133 | goto out; |
134 | 134 | ||
135 | kref_init(&vlan->refcount); | 135 | kref_init(&vlan->refcount); |
136 | kref_get(&vlan->refcount); | ||
137 | vlan->vid = vid; | 136 | vlan->vid = vid; |
138 | 137 | ||
138 | kref_get(&vlan->refcount); | ||
139 | hlist_add_head_rcu(&vlan->list, &orig_node->vlan_list); | 139 | hlist_add_head_rcu(&vlan->list, &orig_node->vlan_list); |
140 | 140 | ||
141 | out: | 141 | out: |
@@ -386,6 +386,7 @@ batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node, | |||
386 | orig_ifinfo->if_outgoing = if_outgoing; | 386 | orig_ifinfo->if_outgoing = if_outgoing; |
387 | INIT_HLIST_NODE(&orig_ifinfo->list); | 387 | INIT_HLIST_NODE(&orig_ifinfo->list); |
388 | kref_init(&orig_ifinfo->refcount); | 388 | kref_init(&orig_ifinfo->refcount); |
389 | |||
389 | kref_get(&orig_ifinfo->refcount); | 390 | kref_get(&orig_ifinfo->refcount); |
390 | hlist_add_head_rcu(&orig_ifinfo->list, | 391 | hlist_add_head_rcu(&orig_ifinfo->list, |
391 | &orig_node->ifinfo_list); | 392 | &orig_node->ifinfo_list); |
@@ -459,9 +460,9 @@ batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh, | |||
459 | 460 | ||
460 | INIT_HLIST_NODE(&neigh_ifinfo->list); | 461 | INIT_HLIST_NODE(&neigh_ifinfo->list); |
461 | kref_init(&neigh_ifinfo->refcount); | 462 | kref_init(&neigh_ifinfo->refcount); |
462 | kref_get(&neigh_ifinfo->refcount); | ||
463 | neigh_ifinfo->if_outgoing = if_outgoing; | 463 | neigh_ifinfo->if_outgoing = if_outgoing; |
464 | 464 | ||
465 | kref_get(&neigh_ifinfo->refcount); | ||
465 | hlist_add_head_rcu(&neigh_ifinfo->list, &neigh->ifinfo_list); | 466 | hlist_add_head_rcu(&neigh_ifinfo->list, &neigh->ifinfo_list); |
466 | 467 | ||
467 | out: | 468 | out: |
@@ -653,8 +654,8 @@ batadv_neigh_node_create(struct batadv_orig_node *orig_node, | |||
653 | 654 | ||
654 | /* extra reference for return */ | 655 | /* extra reference for return */ |
655 | kref_init(&neigh_node->refcount); | 656 | kref_init(&neigh_node->refcount); |
656 | kref_get(&neigh_node->refcount); | ||
657 | 657 | ||
658 | kref_get(&neigh_node->refcount); | ||
658 | hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list); | 659 | hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list); |
659 | 660 | ||
660 | batadv_dbg(BATADV_DBG_BATMAN, orig_node->bat_priv, | 661 | batadv_dbg(BATADV_DBG_BATMAN, orig_node->bat_priv, |
@@ -692,6 +693,7 @@ batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node, | |||
692 | return batadv_neigh_node_create(orig_node, hard_iface, neigh_addr); | 693 | return batadv_neigh_node_create(orig_node, hard_iface, neigh_addr); |
693 | } | 694 | } |
694 | 695 | ||
696 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
695 | /** | 697 | /** |
696 | * batadv_hardif_neigh_seq_print_text - print the single hop neighbour list | 698 | * batadv_hardif_neigh_seq_print_text - print the single hop neighbour list |
697 | * @seq: neighbour table seq_file struct | 699 | * @seq: neighbour table seq_file struct |
@@ -725,6 +727,7 @@ int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset) | |||
725 | bat_priv->algo_ops->neigh.print(bat_priv, seq); | 727 | bat_priv->algo_ops->neigh.print(bat_priv, seq); |
726 | return 0; | 728 | return 0; |
727 | } | 729 | } |
730 | #endif | ||
728 | 731 | ||
729 | /** | 732 | /** |
730 | * batadv_hardif_neigh_dump - Dump to netlink the neighbor infos for a specific | 733 | * batadv_hardif_neigh_dump - Dump to netlink the neighbor infos for a specific |
@@ -988,7 +991,6 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, | |||
988 | 991 | ||
989 | /* extra reference for return */ | 992 | /* extra reference for return */ |
990 | kref_init(&orig_node->refcount); | 993 | kref_init(&orig_node->refcount); |
991 | kref_get(&orig_node->refcount); | ||
992 | 994 | ||
993 | orig_node->bat_priv = bat_priv; | 995 | orig_node->bat_priv = bat_priv; |
994 | ether_addr_copy(orig_node->orig, addr); | 996 | ether_addr_copy(orig_node->orig, addr); |
@@ -1339,6 +1341,7 @@ void batadv_purge_orig_ref(struct batadv_priv *bat_priv) | |||
1339 | _batadv_purge_orig(bat_priv); | 1341 | _batadv_purge_orig(bat_priv); |
1340 | } | 1342 | } |
1341 | 1343 | ||
1344 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
1342 | int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) | 1345 | int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) |
1343 | { | 1346 | { |
1344 | struct net_device *net_dev = (struct net_device *)seq->private; | 1347 | struct net_device *net_dev = (struct net_device *)seq->private; |
@@ -1412,6 +1415,7 @@ out: | |||
1412 | batadv_hardif_put(hard_iface); | 1415 | batadv_hardif_put(hard_iface); |
1413 | return 0; | 1416 | return 0; |
1414 | } | 1417 | } |
1418 | #endif | ||
1415 | 1419 | ||
1416 | /** | 1420 | /** |
1417 | * batadv_orig_dump - Dump to netlink the originator infos for a specific | 1421 | * batadv_orig_dump - Dump to netlink the originator infos for a specific |
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index e508bf5957b3..49e16b6e0ba3 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
@@ -594,6 +594,7 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) | |||
594 | } | 594 | } |
595 | 595 | ||
596 | spin_lock_bh(&bat_priv->softif_vlan_list_lock); | 596 | spin_lock_bh(&bat_priv->softif_vlan_list_lock); |
597 | kref_get(&vlan->refcount); | ||
597 | hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list); | 598 | hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list); |
598 | spin_unlock_bh(&bat_priv->softif_vlan_list_lock); | 599 | spin_unlock_bh(&bat_priv->softif_vlan_list_lock); |
599 | 600 | ||
@@ -604,6 +605,9 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) | |||
604 | bat_priv->soft_iface->dev_addr, vid, | 605 | bat_priv->soft_iface->dev_addr, vid, |
605 | BATADV_NULL_IFINDEX, BATADV_NO_MARK); | 606 | BATADV_NULL_IFINDEX, BATADV_NO_MARK); |
606 | 607 | ||
608 | /* don't return reference to new softif_vlan */ | ||
609 | batadv_softif_vlan_put(vlan); | ||
610 | |||
607 | return 0; | 611 | return 0; |
608 | } | 612 | } |
609 | 613 | ||
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 20804078293c..7f663092f6de 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -734,7 +734,6 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr, | |||
734 | if (batadv_is_wifi_netdev(in_dev)) | 734 | if (batadv_is_wifi_netdev(in_dev)) |
735 | tt_local->common.flags |= BATADV_TT_CLIENT_WIFI; | 735 | tt_local->common.flags |= BATADV_TT_CLIENT_WIFI; |
736 | kref_init(&tt_local->common.refcount); | 736 | kref_init(&tt_local->common.refcount); |
737 | kref_get(&tt_local->common.refcount); | ||
738 | tt_local->last_seen = jiffies; | 737 | tt_local->last_seen = jiffies; |
739 | tt_local->common.added_at = tt_local->last_seen; | 738 | tt_local->common.added_at = tt_local->last_seen; |
740 | tt_local->vlan = vlan; | 739 | tt_local->vlan = vlan; |
@@ -746,6 +745,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr, | |||
746 | is_multicast_ether_addr(addr)) | 745 | is_multicast_ether_addr(addr)) |
747 | tt_local->common.flags |= BATADV_TT_CLIENT_NOPURGE; | 746 | tt_local->common.flags |= BATADV_TT_CLIENT_NOPURGE; |
748 | 747 | ||
748 | kref_get(&tt_local->common.refcount); | ||
749 | hash_added = batadv_hash_add(bat_priv->tt.local_hash, batadv_compare_tt, | 749 | hash_added = batadv_hash_add(bat_priv->tt.local_hash, batadv_compare_tt, |
750 | batadv_choose_tt, &tt_local->common, | 750 | batadv_choose_tt, &tt_local->common, |
751 | &tt_local->common.hash_entry); | 751 | &tt_local->common.hash_entry); |
@@ -1047,6 +1047,7 @@ container_register: | |||
1047 | kfree(tt_data); | 1047 | kfree(tt_data); |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
1050 | int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) | 1051 | int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) |
1051 | { | 1052 | { |
1052 | struct net_device *net_dev = (struct net_device *)seq->private; | 1053 | struct net_device *net_dev = (struct net_device *)seq->private; |
@@ -1114,6 +1115,7 @@ out: | |||
1114 | batadv_hardif_put(primary_if); | 1115 | batadv_hardif_put(primary_if); |
1115 | return 0; | 1116 | return 0; |
1116 | } | 1117 | } |
1118 | #endif | ||
1117 | 1119 | ||
1118 | /** | 1120 | /** |
1119 | * batadv_tt_local_dump_entry - Dump one TT local entry into a message | 1121 | * batadv_tt_local_dump_entry - Dump one TT local entry into a message |
@@ -1567,9 +1569,9 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global, | |||
1567 | orig_entry->orig_node = orig_node; | 1569 | orig_entry->orig_node = orig_node; |
1568 | orig_entry->ttvn = ttvn; | 1570 | orig_entry->ttvn = ttvn; |
1569 | kref_init(&orig_entry->refcount); | 1571 | kref_init(&orig_entry->refcount); |
1570 | kref_get(&orig_entry->refcount); | ||
1571 | 1572 | ||
1572 | spin_lock_bh(&tt_global->list_lock); | 1573 | spin_lock_bh(&tt_global->list_lock); |
1574 | kref_get(&orig_entry->refcount); | ||
1573 | hlist_add_head_rcu(&orig_entry->list, | 1575 | hlist_add_head_rcu(&orig_entry->list, |
1574 | &tt_global->orig_list); | 1576 | &tt_global->orig_list); |
1575 | spin_unlock_bh(&tt_global->list_lock); | 1577 | spin_unlock_bh(&tt_global->list_lock); |
@@ -1645,13 +1647,13 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv, | |||
1645 | if (flags & BATADV_TT_CLIENT_ROAM) | 1647 | if (flags & BATADV_TT_CLIENT_ROAM) |
1646 | tt_global_entry->roam_at = jiffies; | 1648 | tt_global_entry->roam_at = jiffies; |
1647 | kref_init(&common->refcount); | 1649 | kref_init(&common->refcount); |
1648 | kref_get(&common->refcount); | ||
1649 | common->added_at = jiffies; | 1650 | common->added_at = jiffies; |
1650 | 1651 | ||
1651 | INIT_HLIST_HEAD(&tt_global_entry->orig_list); | 1652 | INIT_HLIST_HEAD(&tt_global_entry->orig_list); |
1652 | atomic_set(&tt_global_entry->orig_list_count, 0); | 1653 | atomic_set(&tt_global_entry->orig_list_count, 0); |
1653 | spin_lock_init(&tt_global_entry->list_lock); | 1654 | spin_lock_init(&tt_global_entry->list_lock); |
1654 | 1655 | ||
1656 | kref_get(&common->refcount); | ||
1655 | hash_added = batadv_hash_add(bat_priv->tt.global_hash, | 1657 | hash_added = batadv_hash_add(bat_priv->tt.global_hash, |
1656 | batadv_compare_tt, | 1658 | batadv_compare_tt, |
1657 | batadv_choose_tt, common, | 1659 | batadv_choose_tt, common, |
@@ -1796,6 +1798,7 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv, | |||
1796 | return best_entry; | 1798 | return best_entry; |
1797 | } | 1799 | } |
1798 | 1800 | ||
1801 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
1799 | /** | 1802 | /** |
1800 | * batadv_tt_global_print_entry - print all orig nodes who announce the address | 1803 | * batadv_tt_global_print_entry - print all orig nodes who announce the address |
1801 | * for this global entry | 1804 | * for this global entry |
@@ -1919,6 +1922,7 @@ out: | |||
1919 | batadv_hardif_put(primary_if); | 1922 | batadv_hardif_put(primary_if); |
1920 | return 0; | 1923 | return 0; |
1921 | } | 1924 | } |
1925 | #endif | ||
1922 | 1926 | ||
1923 | /** | 1927 | /** |
1924 | * batadv_tt_global_dump_subentry - Dump all TT local entries into a message | 1928 | * batadv_tt_global_dump_subentry - Dump all TT local entries into a message |
diff --git a/net/batman-adv/tvlv.c b/net/batman-adv/tvlv.c index 3d1cf0fb112d..77654f055f24 100644 --- a/net/batman-adv/tvlv.c +++ b/net/batman-adv/tvlv.c | |||
@@ -257,8 +257,13 @@ void batadv_tvlv_container_register(struct batadv_priv *bat_priv, | |||
257 | spin_lock_bh(&bat_priv->tvlv.container_list_lock); | 257 | spin_lock_bh(&bat_priv->tvlv.container_list_lock); |
258 | tvlv_old = batadv_tvlv_container_get(bat_priv, type, version); | 258 | tvlv_old = batadv_tvlv_container_get(bat_priv, type, version); |
259 | batadv_tvlv_container_remove(bat_priv, tvlv_old); | 259 | batadv_tvlv_container_remove(bat_priv, tvlv_old); |
260 | |||
261 | kref_get(&tvlv_new->refcount); | ||
260 | hlist_add_head(&tvlv_new->list, &bat_priv->tvlv.container_list); | 262 | hlist_add_head(&tvlv_new->list, &bat_priv->tvlv.container_list); |
261 | spin_unlock_bh(&bat_priv->tvlv.container_list_lock); | 263 | spin_unlock_bh(&bat_priv->tvlv.container_list_lock); |
264 | |||
265 | /* don't return reference to new tvlv_container */ | ||
266 | batadv_tvlv_container_put(tvlv_new); | ||
262 | } | 267 | } |
263 | 268 | ||
264 | /** | 269 | /** |
@@ -542,8 +547,12 @@ void batadv_tvlv_handler_register(struct batadv_priv *bat_priv, | |||
542 | INIT_HLIST_NODE(&tvlv_handler->list); | 547 | INIT_HLIST_NODE(&tvlv_handler->list); |
543 | 548 | ||
544 | spin_lock_bh(&bat_priv->tvlv.handler_list_lock); | 549 | spin_lock_bh(&bat_priv->tvlv.handler_list_lock); |
550 | kref_get(&tvlv_handler->refcount); | ||
545 | hlist_add_head_rcu(&tvlv_handler->list, &bat_priv->tvlv.handler_list); | 551 | hlist_add_head_rcu(&tvlv_handler->list, &bat_priv->tvlv.handler_list); |
546 | spin_unlock_bh(&bat_priv->tvlv.handler_list_lock); | 552 | spin_unlock_bh(&bat_priv->tvlv.handler_list_lock); |
553 | |||
554 | /* don't return reference to new tvlv_handler */ | ||
555 | batadv_tvlv_handler_put(tvlv_handler); | ||
547 | } | 556 | } |
548 | 557 | ||
549 | /** | 558 | /** |
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index b5f01a36ec34..b3dd1a381aad 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h | |||
@@ -1431,7 +1431,9 @@ struct batadv_algo_neigh_ops { | |||
1431 | struct batadv_hard_iface *if_outgoing1, | 1431 | struct batadv_hard_iface *if_outgoing1, |
1432 | struct batadv_neigh_node *neigh2, | 1432 | struct batadv_neigh_node *neigh2, |
1433 | struct batadv_hard_iface *if_outgoing2); | 1433 | struct batadv_hard_iface *if_outgoing2); |
1434 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
1434 | void (*print)(struct batadv_priv *priv, struct seq_file *seq); | 1435 | void (*print)(struct batadv_priv *priv, struct seq_file *seq); |
1436 | #endif | ||
1435 | void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, | 1437 | void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, |
1436 | struct batadv_priv *priv, | 1438 | struct batadv_priv *priv, |
1437 | struct batadv_hard_iface *hard_iface); | 1439 | struct batadv_hard_iface *hard_iface); |
@@ -1453,8 +1455,10 @@ struct batadv_algo_orig_ops { | |||
1453 | int (*add_if)(struct batadv_orig_node *orig_node, int max_if_num); | 1455 | int (*add_if)(struct batadv_orig_node *orig_node, int max_if_num); |
1454 | int (*del_if)(struct batadv_orig_node *orig_node, int max_if_num, | 1456 | int (*del_if)(struct batadv_orig_node *orig_node, int max_if_num, |
1455 | int del_if_num); | 1457 | int del_if_num); |
1458 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
1456 | void (*print)(struct batadv_priv *priv, struct seq_file *seq, | 1459 | void (*print)(struct batadv_priv *priv, struct seq_file *seq, |
1457 | struct batadv_hard_iface *hard_iface); | 1460 | struct batadv_hard_iface *hard_iface); |
1461 | #endif | ||
1458 | void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, | 1462 | void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, |
1459 | struct batadv_priv *priv, | 1463 | struct batadv_priv *priv, |
1460 | struct batadv_hard_iface *hard_iface); | 1464 | struct batadv_hard_iface *hard_iface); |
@@ -1480,7 +1484,9 @@ struct batadv_algo_gw_ops { | |||
1480 | bool (*is_eligible)(struct batadv_priv *bat_priv, | 1484 | bool (*is_eligible)(struct batadv_priv *bat_priv, |
1481 | struct batadv_orig_node *curr_gw_orig, | 1485 | struct batadv_orig_node *curr_gw_orig, |
1482 | struct batadv_orig_node *orig_node); | 1486 | struct batadv_orig_node *orig_node); |
1487 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS | ||
1483 | void (*print)(struct batadv_priv *bat_priv, struct seq_file *seq); | 1488 | void (*print)(struct batadv_priv *bat_priv, struct seq_file *seq); |
1489 | #endif | ||
1484 | void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, | 1490 | void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, |
1485 | struct batadv_priv *priv); | 1491 | struct batadv_priv *priv); |
1486 | }; | 1492 | }; |