aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/hard-interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/batman-adv/hard-interface.c')
-rw-r--r--net/batman-adv/hard-interface.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 8c4b790b98be..47c79d724ba3 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -146,7 +146,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
146 if (!new_hard_iface) 146 if (!new_hard_iface)
147 goto out; 147 goto out;
148 148
149 bat_priv->bat_algo_ops->bat_ogm_init_primary(new_hard_iface); 149 bat_priv->bat_algo_ops->bat_primary_iface_set(new_hard_iface);
150 primary_if_update_addr(bat_priv, curr_hard_iface); 150 primary_if_update_addr(bat_priv, curr_hard_iface);
151 151
152out: 152out:
@@ -304,22 +304,17 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
304 if (!softif_is_valid(soft_iface)) { 304 if (!softif_is_valid(soft_iface)) {
305 pr_err("Can't create batman mesh interface %s: already exists as regular interface\n", 305 pr_err("Can't create batman mesh interface %s: already exists as regular interface\n",
306 soft_iface->name); 306 soft_iface->name);
307 dev_put(soft_iface);
308 ret = -EINVAL; 307 ret = -EINVAL;
309 goto err; 308 goto err_dev;
310 } 309 }
311 310
312 hard_iface->soft_iface = soft_iface; 311 hard_iface->soft_iface = soft_iface;
313 bat_priv = netdev_priv(hard_iface->soft_iface); 312 bat_priv = netdev_priv(hard_iface->soft_iface);
314 313
315 bat_priv->bat_algo_ops->bat_ogm_init(hard_iface); 314 ret = bat_priv->bat_algo_ops->bat_iface_enable(hard_iface);
316 315 if (ret < 0) {
317 if (!hard_iface->packet_buff) {
318 bat_err(hard_iface->soft_iface,
319 "Can't add interface packet (%s): out of memory\n",
320 hard_iface->net_dev->name);
321 ret = -ENOMEM; 316 ret = -ENOMEM;
322 goto err; 317 goto err_dev;
323 } 318 }
324 319
325 hard_iface->if_num = bat_priv->num_ifaces; 320 hard_iface->if_num = bat_priv->num_ifaces;
@@ -332,7 +327,6 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
332 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev; 327 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
333 dev_add_pack(&hard_iface->batman_adv_ptype); 328 dev_add_pack(&hard_iface->batman_adv_ptype);
334 329
335 atomic_set(&hard_iface->seqno, 1);
336 atomic_set(&hard_iface->frag_seqno, 1); 330 atomic_set(&hard_iface->frag_seqno, 1);
337 bat_info(hard_iface->soft_iface, "Adding interface: %s\n", 331 bat_info(hard_iface->soft_iface, "Adding interface: %s\n",
338 hard_iface->net_dev->name); 332 hard_iface->net_dev->name);
@@ -364,6 +358,8 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
364out: 358out:
365 return 0; 359 return 0;
366 360
361err_dev:
362 dev_put(soft_iface);
367err: 363err:
368 hardif_free_ref(hard_iface); 364 hardif_free_ref(hard_iface);
369 return ret; 365 return ret;
@@ -398,8 +394,7 @@ void hardif_disable_interface(struct hard_iface *hard_iface)
398 hardif_free_ref(new_if); 394 hardif_free_ref(new_if);
399 } 395 }
400 396
401 kfree(hard_iface->packet_buff); 397 bat_priv->bat_algo_ops->bat_iface_disable(hard_iface);
402 hard_iface->packet_buff = NULL;
403 hard_iface->if_status = IF_NOT_IN_USE; 398 hard_iface->if_status = IF_NOT_IN_USE;
404 399
405 /* delete all references to this hard_iface */ 400 /* delete all references to this hard_iface */
@@ -451,6 +446,13 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
451 check_known_mac_addr(hard_iface->net_dev); 446 check_known_mac_addr(hard_iface->net_dev);
452 list_add_tail_rcu(&hard_iface->list, &hardif_list); 447 list_add_tail_rcu(&hard_iface->list, &hardif_list);
453 448
449 /**
450 * This can't be called via a bat_priv callback because
451 * we have no bat_priv yet.
452 */
453 atomic_set(&hard_iface->seqno, 1);
454 hard_iface->packet_buff = NULL;
455
454 return hard_iface; 456 return hard_iface;
455 457
456free_if: 458free_if:
@@ -572,8 +574,7 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
572 goto err_free; 574 goto err_free;
573 575
574 /* expect a valid ethernet header here. */ 576 /* expect a valid ethernet header here. */
575 if (unlikely(skb->mac_len != sizeof(struct ethhdr) || 577 if (unlikely(skb->mac_len != ETH_HLEN || !skb_mac_header(skb)))
576 !skb_mac_header(skb)))
577 goto err_free; 578 goto err_free;
578 579
579 if (!hard_iface->soft_iface) 580 if (!hard_iface->soft_iface)
@@ -602,7 +603,7 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
602 603
603 switch (batman_ogm_packet->header.packet_type) { 604 switch (batman_ogm_packet->header.packet_type) {
604 /* batman originator packet */ 605 /* batman originator packet */
605 case BAT_OGM: 606 case BAT_IV_OGM:
606 ret = recv_bat_ogm_packet(skb, hard_iface); 607 ret = recv_bat_ogm_packet(skb, hard_iface);
607 break; 608 break;
608 609