diff options
Diffstat (limited to 'net/batman-adv/hard-interface.c')
-rw-r--r-- | net/batman-adv/hard-interface.c | 245 |
1 files changed, 121 insertions, 124 deletions
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index dc334fa89847..e7eba9c32e70 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* | 1 | /* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: |
2 | * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: | ||
3 | * | 2 | * |
4 | * Marek Lindner, Simon Wunderlich | 3 | * Marek Lindner, Simon Wunderlich |
5 | * | 4 | * |
@@ -16,7 +15,6 @@ | |||
16 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
18 | * 02110-1301, USA | 17 | * 02110-1301, USA |
19 | * | ||
20 | */ | 18 | */ |
21 | 19 | ||
22 | #include "main.h" | 20 | #include "main.h" |
@@ -32,7 +30,7 @@ | |||
32 | 30 | ||
33 | #include <linux/if_arp.h> | 31 | #include <linux/if_arp.h> |
34 | 32 | ||
35 | void hardif_free_rcu(struct rcu_head *rcu) | 33 | void batadv_hardif_free_rcu(struct rcu_head *rcu) |
36 | { | 34 | { |
37 | struct hard_iface *hard_iface; | 35 | struct hard_iface *hard_iface; |
38 | 36 | ||
@@ -41,12 +39,12 @@ void hardif_free_rcu(struct rcu_head *rcu) | |||
41 | kfree(hard_iface); | 39 | kfree(hard_iface); |
42 | } | 40 | } |
43 | 41 | ||
44 | struct hard_iface *hardif_get_by_netdev(const struct net_device *net_dev) | 42 | struct hard_iface *batadv_hardif_get_by_netdev(const struct net_device *net_dev) |
45 | { | 43 | { |
46 | struct hard_iface *hard_iface; | 44 | struct hard_iface *hard_iface; |
47 | 45 | ||
48 | rcu_read_lock(); | 46 | rcu_read_lock(); |
49 | list_for_each_entry_rcu(hard_iface, &hardif_list, list) { | 47 | list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { |
50 | if (hard_iface->net_dev == net_dev && | 48 | if (hard_iface->net_dev == net_dev && |
51 | atomic_inc_not_zero(&hard_iface->refcount)) | 49 | atomic_inc_not_zero(&hard_iface->refcount)) |
52 | goto out; | 50 | goto out; |
@@ -59,7 +57,7 @@ out: | |||
59 | return hard_iface; | 57 | return hard_iface; |
60 | } | 58 | } |
61 | 59 | ||
62 | static int is_valid_iface(const struct net_device *net_dev) | 60 | static int batadv_is_valid_iface(const struct net_device *net_dev) |
63 | { | 61 | { |
64 | if (net_dev->flags & IFF_LOOPBACK) | 62 | if (net_dev->flags & IFF_LOOPBACK) |
65 | return 0; | 63 | return 0; |
@@ -71,22 +69,19 @@ static int is_valid_iface(const struct net_device *net_dev) | |||
71 | return 0; | 69 | return 0; |
72 | 70 | ||
73 | /* no batman over batman */ | 71 | /* no batman over batman */ |
74 | if (softif_is_valid(net_dev)) | 72 | if (batadv_softif_is_valid(net_dev)) |
75 | return 0; | 73 | return 0; |
76 | 74 | ||
77 | /* Device is being bridged */ | ||
78 | /* if (net_dev->priv_flags & IFF_BRIDGE_PORT) | ||
79 | return 0; */ | ||
80 | |||
81 | return 1; | 75 | return 1; |
82 | } | 76 | } |
83 | 77 | ||
84 | static struct hard_iface *hardif_get_active(const struct net_device *soft_iface) | 78 | static struct hard_iface * |
79 | batadv_hardif_get_active(const struct net_device *soft_iface) | ||
85 | { | 80 | { |
86 | struct hard_iface *hard_iface; | 81 | struct hard_iface *hard_iface; |
87 | 82 | ||
88 | rcu_read_lock(); | 83 | rcu_read_lock(); |
89 | list_for_each_entry_rcu(hard_iface, &hardif_list, list) { | 84 | list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { |
90 | if (hard_iface->soft_iface != soft_iface) | 85 | if (hard_iface->soft_iface != soft_iface) |
91 | continue; | 86 | continue; |
92 | 87 | ||
@@ -102,13 +97,13 @@ out: | |||
102 | return hard_iface; | 97 | return hard_iface; |
103 | } | 98 | } |
104 | 99 | ||
105 | static void primary_if_update_addr(struct bat_priv *bat_priv, | 100 | static void batadv_primary_if_update_addr(struct bat_priv *bat_priv, |
106 | struct hard_iface *oldif) | 101 | struct hard_iface *oldif) |
107 | { | 102 | { |
108 | struct vis_packet *vis_packet; | 103 | struct vis_packet *vis_packet; |
109 | struct hard_iface *primary_if; | 104 | struct hard_iface *primary_if; |
110 | 105 | ||
111 | primary_if = primary_if_get_selected(bat_priv); | 106 | primary_if = batadv_primary_if_get_selected(bat_priv); |
112 | if (!primary_if) | 107 | if (!primary_if) |
113 | goto out; | 108 | goto out; |
114 | 109 | ||
@@ -118,14 +113,14 @@ static void primary_if_update_addr(struct bat_priv *bat_priv, | |||
118 | memcpy(vis_packet->sender_orig, | 113 | memcpy(vis_packet->sender_orig, |
119 | primary_if->net_dev->dev_addr, ETH_ALEN); | 114 | primary_if->net_dev->dev_addr, ETH_ALEN); |
120 | 115 | ||
121 | bla_update_orig_address(bat_priv, primary_if, oldif); | 116 | batadv_bla_update_orig_address(bat_priv, primary_if, oldif); |
122 | out: | 117 | out: |
123 | if (primary_if) | 118 | if (primary_if) |
124 | hardif_free_ref(primary_if); | 119 | batadv_hardif_free_ref(primary_if); |
125 | } | 120 | } |
126 | 121 | ||
127 | static void primary_if_select(struct bat_priv *bat_priv, | 122 | static void batadv_primary_if_select(struct bat_priv *bat_priv, |
128 | struct hard_iface *new_hard_iface) | 123 | struct hard_iface *new_hard_iface) |
129 | { | 124 | { |
130 | struct hard_iface *curr_hard_iface; | 125 | struct hard_iface *curr_hard_iface; |
131 | 126 | ||
@@ -141,14 +136,14 @@ static void primary_if_select(struct bat_priv *bat_priv, | |||
141 | goto out; | 136 | goto out; |
142 | 137 | ||
143 | bat_priv->bat_algo_ops->bat_primary_iface_set(new_hard_iface); | 138 | bat_priv->bat_algo_ops->bat_primary_iface_set(new_hard_iface); |
144 | primary_if_update_addr(bat_priv, curr_hard_iface); | 139 | batadv_primary_if_update_addr(bat_priv, curr_hard_iface); |
145 | 140 | ||
146 | out: | 141 | out: |
147 | if (curr_hard_iface) | 142 | if (curr_hard_iface) |
148 | hardif_free_ref(curr_hard_iface); | 143 | batadv_hardif_free_ref(curr_hard_iface); |
149 | } | 144 | } |
150 | 145 | ||
151 | static bool hardif_is_iface_up(const struct hard_iface *hard_iface) | 146 | static bool batadv_hardif_is_iface_up(const struct hard_iface *hard_iface) |
152 | { | 147 | { |
153 | if (hard_iface->net_dev->flags & IFF_UP) | 148 | if (hard_iface->net_dev->flags & IFF_UP) |
154 | return true; | 149 | return true; |
@@ -156,12 +151,12 @@ static bool hardif_is_iface_up(const struct hard_iface *hard_iface) | |||
156 | return false; | 151 | return false; |
157 | } | 152 | } |
158 | 153 | ||
159 | static void check_known_mac_addr(const struct net_device *net_dev) | 154 | static void batadv_check_known_mac_addr(const struct net_device *net_dev) |
160 | { | 155 | { |
161 | const struct hard_iface *hard_iface; | 156 | const struct hard_iface *hard_iface; |
162 | 157 | ||
163 | rcu_read_lock(); | 158 | rcu_read_lock(); |
164 | list_for_each_entry_rcu(hard_iface, &hardif_list, list) { | 159 | list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { |
165 | if ((hard_iface->if_status != IF_ACTIVE) && | 160 | if ((hard_iface->if_status != IF_ACTIVE) && |
166 | (hard_iface->if_status != IF_TO_BE_ACTIVATED)) | 161 | (hard_iface->if_status != IF_TO_BE_ACTIVATED)) |
167 | continue; | 162 | continue; |
@@ -169,8 +164,8 @@ static void check_known_mac_addr(const struct net_device *net_dev) | |||
169 | if (hard_iface->net_dev == net_dev) | 164 | if (hard_iface->net_dev == net_dev) |
170 | continue; | 165 | continue; |
171 | 166 | ||
172 | if (!compare_eth(hard_iface->net_dev->dev_addr, | 167 | if (!batadv_compare_eth(hard_iface->net_dev->dev_addr, |
173 | net_dev->dev_addr)) | 168 | net_dev->dev_addr)) |
174 | continue; | 169 | continue; |
175 | 170 | ||
176 | pr_warn("The newly added mac address (%pM) already exists on: %s\n", | 171 | pr_warn("The newly added mac address (%pM) already exists on: %s\n", |
@@ -180,19 +175,20 @@ static void check_known_mac_addr(const struct net_device *net_dev) | |||
180 | rcu_read_unlock(); | 175 | rcu_read_unlock(); |
181 | } | 176 | } |
182 | 177 | ||
183 | int hardif_min_mtu(struct net_device *soft_iface) | 178 | int batadv_hardif_min_mtu(struct net_device *soft_iface) |
184 | { | 179 | { |
185 | const struct bat_priv *bat_priv = netdev_priv(soft_iface); | 180 | const struct bat_priv *bat_priv = netdev_priv(soft_iface); |
186 | const struct hard_iface *hard_iface; | 181 | const struct hard_iface *hard_iface; |
187 | /* allow big frames if all devices are capable to do so | 182 | /* allow big frames if all devices are capable to do so |
188 | * (have MTU > 1500 + BAT_HEADER_LEN) */ | 183 | * (have MTU > 1500 + BAT_HEADER_LEN) |
184 | */ | ||
189 | int min_mtu = ETH_DATA_LEN; | 185 | int min_mtu = ETH_DATA_LEN; |
190 | 186 | ||
191 | if (atomic_read(&bat_priv->fragmentation)) | 187 | if (atomic_read(&bat_priv->fragmentation)) |
192 | goto out; | 188 | goto out; |
193 | 189 | ||
194 | rcu_read_lock(); | 190 | rcu_read_lock(); |
195 | list_for_each_entry_rcu(hard_iface, &hardif_list, list) { | 191 | list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { |
196 | if ((hard_iface->if_status != IF_ACTIVE) && | 192 | if ((hard_iface->if_status != IF_ACTIVE) && |
197 | (hard_iface->if_status != IF_TO_BE_ACTIVATED)) | 193 | (hard_iface->if_status != IF_TO_BE_ACTIVATED)) |
198 | continue; | 194 | continue; |
@@ -200,7 +196,8 @@ int hardif_min_mtu(struct net_device *soft_iface) | |||
200 | if (hard_iface->soft_iface != soft_iface) | 196 | if (hard_iface->soft_iface != soft_iface) |
201 | continue; | 197 | continue; |
202 | 198 | ||
203 | min_mtu = min_t(int, hard_iface->net_dev->mtu - BAT_HEADER_LEN, | 199 | min_mtu = min_t(int, |
200 | hard_iface->net_dev->mtu - BATADV_HEADER_LEN, | ||
204 | min_mtu); | 201 | min_mtu); |
205 | } | 202 | } |
206 | rcu_read_unlock(); | 203 | rcu_read_unlock(); |
@@ -209,16 +206,16 @@ out: | |||
209 | } | 206 | } |
210 | 207 | ||
211 | /* adjusts the MTU if a new interface with a smaller MTU appeared. */ | 208 | /* adjusts the MTU if a new interface with a smaller MTU appeared. */ |
212 | void update_min_mtu(struct net_device *soft_iface) | 209 | void batadv_update_min_mtu(struct net_device *soft_iface) |
213 | { | 210 | { |
214 | int min_mtu; | 211 | int min_mtu; |
215 | 212 | ||
216 | min_mtu = hardif_min_mtu(soft_iface); | 213 | min_mtu = batadv_hardif_min_mtu(soft_iface); |
217 | if (soft_iface->mtu != min_mtu) | 214 | if (soft_iface->mtu != min_mtu) |
218 | soft_iface->mtu = min_mtu; | 215 | soft_iface->mtu = min_mtu; |
219 | } | 216 | } |
220 | 217 | ||
221 | static void hardif_activate_interface(struct hard_iface *hard_iface) | 218 | static void batadv_hardif_activate_interface(struct hard_iface *hard_iface) |
222 | { | 219 | { |
223 | struct bat_priv *bat_priv; | 220 | struct bat_priv *bat_priv; |
224 | struct hard_iface *primary_if = NULL; | 221 | struct hard_iface *primary_if = NULL; |
@@ -231,25 +228,24 @@ static void hardif_activate_interface(struct hard_iface *hard_iface) | |||
231 | bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface); | 228 | bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface); |
232 | hard_iface->if_status = IF_TO_BE_ACTIVATED; | 229 | hard_iface->if_status = IF_TO_BE_ACTIVATED; |
233 | 230 | ||
234 | /** | 231 | /* the first active interface becomes our primary interface or |
235 | * the first active interface becomes our primary interface or | ||
236 | * the next active interface after the old primary interface was removed | 232 | * the next active interface after the old primary interface was removed |
237 | */ | 233 | */ |
238 | primary_if = primary_if_get_selected(bat_priv); | 234 | primary_if = batadv_primary_if_get_selected(bat_priv); |
239 | if (!primary_if) | 235 | if (!primary_if) |
240 | primary_if_select(bat_priv, hard_iface); | 236 | batadv_primary_if_select(bat_priv, hard_iface); |
241 | 237 | ||
242 | bat_info(hard_iface->soft_iface, "Interface activated: %s\n", | 238 | batadv_info(hard_iface->soft_iface, "Interface activated: %s\n", |
243 | hard_iface->net_dev->name); | 239 | hard_iface->net_dev->name); |
244 | 240 | ||
245 | update_min_mtu(hard_iface->soft_iface); | 241 | batadv_update_min_mtu(hard_iface->soft_iface); |
246 | 242 | ||
247 | out: | 243 | out: |
248 | if (primary_if) | 244 | if (primary_if) |
249 | hardif_free_ref(primary_if); | 245 | batadv_hardif_free_ref(primary_if); |
250 | } | 246 | } |
251 | 247 | ||
252 | static void hardif_deactivate_interface(struct hard_iface *hard_iface) | 248 | static void batadv_hardif_deactivate_interface(struct hard_iface *hard_iface) |
253 | { | 249 | { |
254 | if ((hard_iface->if_status != IF_ACTIVE) && | 250 | if ((hard_iface->if_status != IF_ACTIVE) && |
255 | (hard_iface->if_status != IF_TO_BE_ACTIVATED)) | 251 | (hard_iface->if_status != IF_TO_BE_ACTIVATED)) |
@@ -257,17 +253,18 @@ static void hardif_deactivate_interface(struct hard_iface *hard_iface) | |||
257 | 253 | ||
258 | hard_iface->if_status = IF_INACTIVE; | 254 | hard_iface->if_status = IF_INACTIVE; |
259 | 255 | ||
260 | bat_info(hard_iface->soft_iface, "Interface deactivated: %s\n", | 256 | batadv_info(hard_iface->soft_iface, "Interface deactivated: %s\n", |
261 | hard_iface->net_dev->name); | 257 | hard_iface->net_dev->name); |
262 | 258 | ||
263 | update_min_mtu(hard_iface->soft_iface); | 259 | batadv_update_min_mtu(hard_iface->soft_iface); |
264 | } | 260 | } |
265 | 261 | ||
266 | int hardif_enable_interface(struct hard_iface *hard_iface, | 262 | int batadv_hardif_enable_interface(struct hard_iface *hard_iface, |
267 | const char *iface_name) | 263 | const char *iface_name) |
268 | { | 264 | { |
269 | struct bat_priv *bat_priv; | 265 | struct bat_priv *bat_priv; |
270 | struct net_device *soft_iface; | 266 | struct net_device *soft_iface; |
267 | __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN); | ||
271 | int ret; | 268 | int ret; |
272 | 269 | ||
273 | if (hard_iface->if_status != IF_NOT_IN_USE) | 270 | if (hard_iface->if_status != IF_NOT_IN_USE) |
@@ -284,7 +281,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface, | |||
284 | soft_iface = dev_get_by_name(&init_net, iface_name); | 281 | soft_iface = dev_get_by_name(&init_net, iface_name); |
285 | 282 | ||
286 | if (!soft_iface) { | 283 | if (!soft_iface) { |
287 | soft_iface = softif_create(iface_name); | 284 | soft_iface = batadv_softif_create(iface_name); |
288 | 285 | ||
289 | if (!soft_iface) { | 286 | if (!soft_iface) { |
290 | ret = -ENOMEM; | 287 | ret = -ENOMEM; |
@@ -295,7 +292,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface, | |||
295 | dev_hold(soft_iface); | 292 | dev_hold(soft_iface); |
296 | } | 293 | } |
297 | 294 | ||
298 | if (!softif_is_valid(soft_iface)) { | 295 | if (!batadv_softif_is_valid(soft_iface)) { |
299 | pr_err("Can't create batman mesh interface %s: already exists as regular interface\n", | 296 | pr_err("Can't create batman mesh interface %s: already exists as regular interface\n", |
300 | soft_iface->name); | 297 | soft_iface->name); |
301 | ret = -EINVAL; | 298 | ret = -EINVAL; |
@@ -306,48 +303,46 @@ int hardif_enable_interface(struct hard_iface *hard_iface, | |||
306 | bat_priv = netdev_priv(hard_iface->soft_iface); | 303 | bat_priv = netdev_priv(hard_iface->soft_iface); |
307 | 304 | ||
308 | ret = bat_priv->bat_algo_ops->bat_iface_enable(hard_iface); | 305 | ret = bat_priv->bat_algo_ops->bat_iface_enable(hard_iface); |
309 | if (ret < 0) { | 306 | if (ret < 0) |
310 | ret = -ENOMEM; | ||
311 | goto err_dev; | 307 | goto err_dev; |
312 | } | ||
313 | 308 | ||
314 | hard_iface->if_num = bat_priv->num_ifaces; | 309 | hard_iface->if_num = bat_priv->num_ifaces; |
315 | bat_priv->num_ifaces++; | 310 | bat_priv->num_ifaces++; |
316 | hard_iface->if_status = IF_INACTIVE; | 311 | hard_iface->if_status = IF_INACTIVE; |
317 | orig_hash_add_if(hard_iface, bat_priv->num_ifaces); | 312 | batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces); |
318 | 313 | ||
319 | hard_iface->batman_adv_ptype.type = __constant_htons(ETH_P_BATMAN); | 314 | hard_iface->batman_adv_ptype.type = ethertype; |
320 | hard_iface->batman_adv_ptype.func = batman_skb_recv; | 315 | hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv; |
321 | hard_iface->batman_adv_ptype.dev = hard_iface->net_dev; | 316 | hard_iface->batman_adv_ptype.dev = hard_iface->net_dev; |
322 | dev_add_pack(&hard_iface->batman_adv_ptype); | 317 | dev_add_pack(&hard_iface->batman_adv_ptype); |
323 | 318 | ||
324 | atomic_set(&hard_iface->frag_seqno, 1); | 319 | atomic_set(&hard_iface->frag_seqno, 1); |
325 | bat_info(hard_iface->soft_iface, "Adding interface: %s\n", | 320 | batadv_info(hard_iface->soft_iface, "Adding interface: %s\n", |
326 | hard_iface->net_dev->name); | 321 | hard_iface->net_dev->name); |
327 | 322 | ||
328 | if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < | 323 | if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < |
329 | ETH_DATA_LEN + BAT_HEADER_LEN) | 324 | ETH_DATA_LEN + BATADV_HEADER_LEN) |
330 | bat_info(hard_iface->soft_iface, | 325 | batadv_info(hard_iface->soft_iface, |
331 | "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %zi would solve the problem.\n", | 326 | "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %zi would solve the problem.\n", |
332 | hard_iface->net_dev->name, hard_iface->net_dev->mtu, | 327 | hard_iface->net_dev->name, hard_iface->net_dev->mtu, |
333 | ETH_DATA_LEN + BAT_HEADER_LEN); | 328 | ETH_DATA_LEN + BATADV_HEADER_LEN); |
334 | 329 | ||
335 | if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < | 330 | if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < |
336 | ETH_DATA_LEN + BAT_HEADER_LEN) | 331 | ETH_DATA_LEN + BATADV_HEADER_LEN) |
337 | bat_info(hard_iface->soft_iface, | 332 | batadv_info(hard_iface->soft_iface, |
338 | "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %zi.\n", | 333 | "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %zi.\n", |
339 | hard_iface->net_dev->name, hard_iface->net_dev->mtu, | 334 | hard_iface->net_dev->name, hard_iface->net_dev->mtu, |
340 | ETH_DATA_LEN + BAT_HEADER_LEN); | 335 | ETH_DATA_LEN + BATADV_HEADER_LEN); |
341 | 336 | ||
342 | if (hardif_is_iface_up(hard_iface)) | 337 | if (batadv_hardif_is_iface_up(hard_iface)) |
343 | hardif_activate_interface(hard_iface); | 338 | batadv_hardif_activate_interface(hard_iface); |
344 | else | 339 | else |
345 | bat_err(hard_iface->soft_iface, | 340 | batadv_err(hard_iface->soft_iface, |
346 | "Not using interface %s (retrying later): interface not active\n", | 341 | "Not using interface %s (retrying later): interface not active\n", |
347 | hard_iface->net_dev->name); | 342 | hard_iface->net_dev->name); |
348 | 343 | ||
349 | /* begin scheduling originator messages on that interface */ | 344 | /* begin scheduling originator messages on that interface */ |
350 | schedule_bat_ogm(hard_iface); | 345 | batadv_schedule_bat_ogm(hard_iface); |
351 | 346 | ||
352 | out: | 347 | out: |
353 | return 0; | 348 | return 0; |
@@ -355,67 +350,68 @@ out: | |||
355 | err_dev: | 350 | err_dev: |
356 | dev_put(soft_iface); | 351 | dev_put(soft_iface); |
357 | err: | 352 | err: |
358 | hardif_free_ref(hard_iface); | 353 | batadv_hardif_free_ref(hard_iface); |
359 | return ret; | 354 | return ret; |
360 | } | 355 | } |
361 | 356 | ||
362 | void hardif_disable_interface(struct hard_iface *hard_iface) | 357 | void batadv_hardif_disable_interface(struct hard_iface *hard_iface) |
363 | { | 358 | { |
364 | struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); | 359 | struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); |
365 | struct hard_iface *primary_if = NULL; | 360 | struct hard_iface *primary_if = NULL; |
366 | 361 | ||
367 | if (hard_iface->if_status == IF_ACTIVE) | 362 | if (hard_iface->if_status == IF_ACTIVE) |
368 | hardif_deactivate_interface(hard_iface); | 363 | batadv_hardif_deactivate_interface(hard_iface); |
369 | 364 | ||
370 | if (hard_iface->if_status != IF_INACTIVE) | 365 | if (hard_iface->if_status != IF_INACTIVE) |
371 | goto out; | 366 | goto out; |
372 | 367 | ||
373 | bat_info(hard_iface->soft_iface, "Removing interface: %s\n", | 368 | batadv_info(hard_iface->soft_iface, "Removing interface: %s\n", |
374 | hard_iface->net_dev->name); | 369 | hard_iface->net_dev->name); |
375 | dev_remove_pack(&hard_iface->batman_adv_ptype); | 370 | dev_remove_pack(&hard_iface->batman_adv_ptype); |
376 | 371 | ||
377 | bat_priv->num_ifaces--; | 372 | bat_priv->num_ifaces--; |
378 | orig_hash_del_if(hard_iface, bat_priv->num_ifaces); | 373 | batadv_orig_hash_del_if(hard_iface, bat_priv->num_ifaces); |
379 | 374 | ||
380 | primary_if = primary_if_get_selected(bat_priv); | 375 | primary_if = batadv_primary_if_get_selected(bat_priv); |
381 | if (hard_iface == primary_if) { | 376 | if (hard_iface == primary_if) { |
382 | struct hard_iface *new_if; | 377 | struct hard_iface *new_if; |
383 | 378 | ||
384 | new_if = hardif_get_active(hard_iface->soft_iface); | 379 | new_if = batadv_hardif_get_active(hard_iface->soft_iface); |
385 | primary_if_select(bat_priv, new_if); | 380 | batadv_primary_if_select(bat_priv, new_if); |
386 | 381 | ||
387 | if (new_if) | 382 | if (new_if) |
388 | hardif_free_ref(new_if); | 383 | batadv_hardif_free_ref(new_if); |
389 | } | 384 | } |
390 | 385 | ||
391 | bat_priv->bat_algo_ops->bat_iface_disable(hard_iface); | 386 | bat_priv->bat_algo_ops->bat_iface_disable(hard_iface); |
392 | hard_iface->if_status = IF_NOT_IN_USE; | 387 | hard_iface->if_status = IF_NOT_IN_USE; |
393 | 388 | ||
394 | /* delete all references to this hard_iface */ | 389 | /* delete all references to this hard_iface */ |
395 | purge_orig_ref(bat_priv); | 390 | batadv_purge_orig_ref(bat_priv); |
396 | purge_outstanding_packets(bat_priv, hard_iface); | 391 | batadv_purge_outstanding_packets(bat_priv, hard_iface); |
397 | dev_put(hard_iface->soft_iface); | 392 | dev_put(hard_iface->soft_iface); |
398 | 393 | ||
399 | /* nobody uses this interface anymore */ | 394 | /* nobody uses this interface anymore */ |
400 | if (!bat_priv->num_ifaces) | 395 | if (!bat_priv->num_ifaces) |
401 | softif_destroy(hard_iface->soft_iface); | 396 | batadv_softif_destroy(hard_iface->soft_iface); |
402 | 397 | ||
403 | hard_iface->soft_iface = NULL; | 398 | hard_iface->soft_iface = NULL; |
404 | hardif_free_ref(hard_iface); | 399 | batadv_hardif_free_ref(hard_iface); |
405 | 400 | ||
406 | out: | 401 | out: |
407 | if (primary_if) | 402 | if (primary_if) |
408 | hardif_free_ref(primary_if); | 403 | batadv_hardif_free_ref(primary_if); |
409 | } | 404 | } |
410 | 405 | ||
411 | static struct hard_iface *hardif_add_interface(struct net_device *net_dev) | 406 | static struct hard_iface * |
407 | batadv_hardif_add_interface(struct net_device *net_dev) | ||
412 | { | 408 | { |
413 | struct hard_iface *hard_iface; | 409 | struct hard_iface *hard_iface; |
414 | int ret; | 410 | int ret; |
415 | 411 | ||
416 | ASSERT_RTNL(); | 412 | ASSERT_RTNL(); |
417 | 413 | ||
418 | ret = is_valid_iface(net_dev); | 414 | ret = batadv_is_valid_iface(net_dev); |
419 | if (ret != 1) | 415 | if (ret != 1) |
420 | goto out; | 416 | goto out; |
421 | 417 | ||
@@ -425,7 +421,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev) | |||
425 | if (!hard_iface) | 421 | if (!hard_iface) |
426 | goto release_dev; | 422 | goto release_dev; |
427 | 423 | ||
428 | ret = sysfs_add_hardif(&hard_iface->hardif_obj, net_dev); | 424 | ret = batadv_sysfs_add_hardif(&hard_iface->hardif_obj, net_dev); |
429 | if (ret) | 425 | if (ret) |
430 | goto free_if; | 426 | goto free_if; |
431 | 427 | ||
@@ -437,11 +433,10 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev) | |||
437 | /* extra reference for return */ | 433 | /* extra reference for return */ |
438 | atomic_set(&hard_iface->refcount, 2); | 434 | atomic_set(&hard_iface->refcount, 2); |
439 | 435 | ||
440 | check_known_mac_addr(hard_iface->net_dev); | 436 | batadv_check_known_mac_addr(hard_iface->net_dev); |
441 | list_add_tail_rcu(&hard_iface->list, &hardif_list); | 437 | list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list); |
442 | 438 | ||
443 | /** | 439 | /* This can't be called via a bat_priv callback because |
444 | * This can't be called via a bat_priv callback because | ||
445 | * we have no bat_priv yet. | 440 | * we have no bat_priv yet. |
446 | */ | 441 | */ |
447 | atomic_set(&hard_iface->seqno, 1); | 442 | atomic_set(&hard_iface->seqno, 1); |
@@ -457,102 +452,103 @@ out: | |||
457 | return NULL; | 452 | return NULL; |
458 | } | 453 | } |
459 | 454 | ||
460 | static void hardif_remove_interface(struct hard_iface *hard_iface) | 455 | static void batadv_hardif_remove_interface(struct hard_iface *hard_iface) |
461 | { | 456 | { |
462 | ASSERT_RTNL(); | 457 | ASSERT_RTNL(); |
463 | 458 | ||
464 | /* first deactivate interface */ | 459 | /* first deactivate interface */ |
465 | if (hard_iface->if_status != IF_NOT_IN_USE) | 460 | if (hard_iface->if_status != IF_NOT_IN_USE) |
466 | hardif_disable_interface(hard_iface); | 461 | batadv_hardif_disable_interface(hard_iface); |
467 | 462 | ||
468 | if (hard_iface->if_status != IF_NOT_IN_USE) | 463 | if (hard_iface->if_status != IF_NOT_IN_USE) |
469 | return; | 464 | return; |
470 | 465 | ||
471 | hard_iface->if_status = IF_TO_BE_REMOVED; | 466 | hard_iface->if_status = IF_TO_BE_REMOVED; |
472 | sysfs_del_hardif(&hard_iface->hardif_obj); | 467 | batadv_sysfs_del_hardif(&hard_iface->hardif_obj); |
473 | hardif_free_ref(hard_iface); | 468 | batadv_hardif_free_ref(hard_iface); |
474 | } | 469 | } |
475 | 470 | ||
476 | void hardif_remove_interfaces(void) | 471 | void batadv_hardif_remove_interfaces(void) |
477 | { | 472 | { |
478 | struct hard_iface *hard_iface, *hard_iface_tmp; | 473 | struct hard_iface *hard_iface, *hard_iface_tmp; |
479 | 474 | ||
480 | rtnl_lock(); | 475 | rtnl_lock(); |
481 | list_for_each_entry_safe(hard_iface, hard_iface_tmp, | 476 | list_for_each_entry_safe(hard_iface, hard_iface_tmp, |
482 | &hardif_list, list) { | 477 | &batadv_hardif_list, list) { |
483 | list_del_rcu(&hard_iface->list); | 478 | list_del_rcu(&hard_iface->list); |
484 | hardif_remove_interface(hard_iface); | 479 | batadv_hardif_remove_interface(hard_iface); |
485 | } | 480 | } |
486 | rtnl_unlock(); | 481 | rtnl_unlock(); |
487 | } | 482 | } |
488 | 483 | ||
489 | static int hard_if_event(struct notifier_block *this, | 484 | static int batadv_hard_if_event(struct notifier_block *this, |
490 | unsigned long event, void *ptr) | 485 | unsigned long event, void *ptr) |
491 | { | 486 | { |
492 | struct net_device *net_dev = ptr; | 487 | struct net_device *net_dev = ptr; |
493 | struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); | 488 | struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); |
494 | struct hard_iface *primary_if = NULL; | 489 | struct hard_iface *primary_if = NULL; |
495 | struct bat_priv *bat_priv; | 490 | struct bat_priv *bat_priv; |
496 | 491 | ||
497 | if (!hard_iface && event == NETDEV_REGISTER) | 492 | if (!hard_iface && event == NETDEV_REGISTER) |
498 | hard_iface = hardif_add_interface(net_dev); | 493 | hard_iface = batadv_hardif_add_interface(net_dev); |
499 | 494 | ||
500 | if (!hard_iface) | 495 | if (!hard_iface) |
501 | goto out; | 496 | goto out; |
502 | 497 | ||
503 | switch (event) { | 498 | switch (event) { |
504 | case NETDEV_UP: | 499 | case NETDEV_UP: |
505 | hardif_activate_interface(hard_iface); | 500 | batadv_hardif_activate_interface(hard_iface); |
506 | break; | 501 | break; |
507 | case NETDEV_GOING_DOWN: | 502 | case NETDEV_GOING_DOWN: |
508 | case NETDEV_DOWN: | 503 | case NETDEV_DOWN: |
509 | hardif_deactivate_interface(hard_iface); | 504 | batadv_hardif_deactivate_interface(hard_iface); |
510 | break; | 505 | break; |
511 | case NETDEV_UNREGISTER: | 506 | case NETDEV_UNREGISTER: |
512 | list_del_rcu(&hard_iface->list); | 507 | list_del_rcu(&hard_iface->list); |
513 | 508 | ||
514 | hardif_remove_interface(hard_iface); | 509 | batadv_hardif_remove_interface(hard_iface); |
515 | break; | 510 | break; |
516 | case NETDEV_CHANGEMTU: | 511 | case NETDEV_CHANGEMTU: |
517 | if (hard_iface->soft_iface) | 512 | if (hard_iface->soft_iface) |
518 | update_min_mtu(hard_iface->soft_iface); | 513 | batadv_update_min_mtu(hard_iface->soft_iface); |
519 | break; | 514 | break; |
520 | case NETDEV_CHANGEADDR: | 515 | case NETDEV_CHANGEADDR: |
521 | if (hard_iface->if_status == IF_NOT_IN_USE) | 516 | if (hard_iface->if_status == IF_NOT_IN_USE) |
522 | goto hardif_put; | 517 | goto hardif_put; |
523 | 518 | ||
524 | check_known_mac_addr(hard_iface->net_dev); | 519 | batadv_check_known_mac_addr(hard_iface->net_dev); |
525 | 520 | ||
526 | bat_priv = netdev_priv(hard_iface->soft_iface); | 521 | bat_priv = netdev_priv(hard_iface->soft_iface); |
527 | bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface); | 522 | bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface); |
528 | 523 | ||
529 | primary_if = primary_if_get_selected(bat_priv); | 524 | primary_if = batadv_primary_if_get_selected(bat_priv); |
530 | if (!primary_if) | 525 | if (!primary_if) |
531 | goto hardif_put; | 526 | goto hardif_put; |
532 | 527 | ||
533 | if (hard_iface == primary_if) | 528 | if (hard_iface == primary_if) |
534 | primary_if_update_addr(bat_priv, NULL); | 529 | batadv_primary_if_update_addr(bat_priv, NULL); |
535 | break; | 530 | break; |
536 | default: | 531 | default: |
537 | break; | 532 | break; |
538 | } | 533 | } |
539 | 534 | ||
540 | hardif_put: | 535 | hardif_put: |
541 | hardif_free_ref(hard_iface); | 536 | batadv_hardif_free_ref(hard_iface); |
542 | out: | 537 | out: |
543 | if (primary_if) | 538 | if (primary_if) |
544 | hardif_free_ref(primary_if); | 539 | batadv_hardif_free_ref(primary_if); |
545 | return NOTIFY_DONE; | 540 | return NOTIFY_DONE; |
546 | } | 541 | } |
547 | 542 | ||
548 | /* This function returns true if the interface represented by ifindex is a | 543 | /* This function returns true if the interface represented by ifindex is a |
549 | * 802.11 wireless device */ | 544 | * 802.11 wireless device |
550 | bool is_wifi_iface(int ifindex) | 545 | */ |
546 | bool batadv_is_wifi_iface(int ifindex) | ||
551 | { | 547 | { |
552 | struct net_device *net_device = NULL; | 548 | struct net_device *net_device = NULL; |
553 | bool ret = false; | 549 | bool ret = false; |
554 | 550 | ||
555 | if (ifindex == NULL_IFINDEX) | 551 | if (ifindex == BATADV_NULL_IFINDEX) |
556 | goto out; | 552 | goto out; |
557 | 553 | ||
558 | net_device = dev_get_by_index(&init_net, ifindex); | 554 | net_device = dev_get_by_index(&init_net, ifindex); |
@@ -561,7 +557,8 @@ bool is_wifi_iface(int ifindex) | |||
561 | 557 | ||
562 | #ifdef CONFIG_WIRELESS_EXT | 558 | #ifdef CONFIG_WIRELESS_EXT |
563 | /* pre-cfg80211 drivers have to implement WEXT, so it is possible to | 559 | /* pre-cfg80211 drivers have to implement WEXT, so it is possible to |
564 | * check for wireless_handlers != NULL */ | 560 | * check for wireless_handlers != NULL |
561 | */ | ||
565 | if (net_device->wireless_handlers) | 562 | if (net_device->wireless_handlers) |
566 | ret = true; | 563 | ret = true; |
567 | else | 564 | else |
@@ -575,6 +572,6 @@ out: | |||
575 | return ret; | 572 | return ret; |
576 | } | 573 | } |
577 | 574 | ||
578 | struct notifier_block hard_if_notifier = { | 575 | struct notifier_block batadv_hard_if_notifier = { |
579 | .notifier_call = hard_if_event, | 576 | .notifier_call = batadv_hard_if_event, |
580 | }; | 577 | }; |