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