1 /* Copyright (C) 2007-2016 B.A.T.M.A.N. contributors:
3 * Marek Lindner, Simon Wunderlich
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #include "hard-interface.h"
21 #include <linux/atomic.h>
22 #include <linux/bug.h>
23 #include <linux/byteorder/generic.h>
24 #include <linux/errno.h>
26 #include <linux/if_arp.h>
27 #include <linux/if_ether.h>
29 #include <linux/kernel.h>
30 #include <linux/kref.h>
31 #include <linux/list.h>
32 #include <linux/netdevice.h>
33 #include <linux/printk.h>
34 #include <linux/rculist.h>
35 #include <linux/rtnetlink.h>
36 #include <linux/slab.h>
37 #include <linux/spinlock.h>
38 #include <linux/workqueue.h>
40 #include "bridge_loop_avoidance.h"
42 #include "distributed-arp-table.h"
43 #include "gateway_client.h"
44 #include "originator.h"
47 #include "soft-interface.h"
49 #include "translation-table.h"
52 * batadv_hardif_release - release hard interface from lists and queue for
53 * free after rcu grace period
54 * @ref: kref pointer of the hard interface
56 void batadv_hardif_release(struct kref
*ref
)
58 struct batadv_hard_iface
*hard_iface
;
60 hard_iface
= container_of(ref
, struct batadv_hard_iface
, refcount
);
61 dev_put(hard_iface
->net_dev
);
63 kfree_rcu(hard_iface
, rcu
);
66 struct batadv_hard_iface
*
67 batadv_hardif_get_by_netdev(const struct net_device
*net_dev
)
69 struct batadv_hard_iface
*hard_iface
;
72 list_for_each_entry_rcu(hard_iface
, &batadv_hardif_list
, list
) {
73 if (hard_iface
->net_dev
== net_dev
&&
74 kref_get_unless_zero(&hard_iface
->refcount
))
86 * batadv_mutual_parents - check if two devices are each others parent
87 * @dev1: 1st net_device
88 * @dev2: 2nd net_device
90 * veth devices come in pairs and each is the parent of the other!
92 * Return: true if the devices are each others parent, otherwise false
94 static bool batadv_mutual_parents(const struct net_device
*dev1
,
95 const struct net_device
*dev2
)
97 int dev1_parent_iflink
= dev_get_iflink(dev1
);
98 int dev2_parent_iflink
= dev_get_iflink(dev2
);
100 if (!dev1_parent_iflink
|| !dev2_parent_iflink
)
103 return (dev1_parent_iflink
== dev2
->ifindex
) &&
104 (dev2_parent_iflink
== dev1
->ifindex
);
108 * batadv_is_on_batman_iface - check if a device is a batman iface descendant
109 * @net_dev: the device to check
111 * If the user creates any virtual device on top of a batman-adv interface, it
112 * is important to prevent this new interface to be used to create a new mesh
113 * network (this behaviour would lead to a batman-over-batman configuration).
114 * This function recursively checks all the fathers of the device passed as
115 * argument looking for a batman-adv soft interface.
117 * Return: true if the device is descendant of a batman-adv mesh interface (or
118 * if it is a batman-adv interface itself), false otherwise
120 static bool batadv_is_on_batman_iface(const struct net_device
*net_dev
)
122 struct net_device
*parent_dev
;
123 struct net
*net
= dev_net(net_dev
);
126 /* check if this is a batman-adv mesh interface */
127 if (batadv_softif_is_valid(net_dev
))
130 /* no more parents..stop recursion */
131 if (dev_get_iflink(net_dev
) == 0 ||
132 dev_get_iflink(net_dev
) == net_dev
->ifindex
)
135 /* recurse over the parent device */
136 parent_dev
= __dev_get_by_index(net
, dev_get_iflink(net_dev
));
137 /* if we got a NULL parent_dev there is something broken.. */
138 if (WARN(!parent_dev
, "Cannot find parent device"))
141 if (batadv_mutual_parents(net_dev
, parent_dev
))
144 ret
= batadv_is_on_batman_iface(parent_dev
);
149 static bool batadv_is_valid_iface(const struct net_device
*net_dev
)
151 if (net_dev
->flags
& IFF_LOOPBACK
)
154 if (net_dev
->type
!= ARPHRD_ETHER
)
157 if (net_dev
->addr_len
!= ETH_ALEN
)
160 /* no batman over batman */
161 if (batadv_is_on_batman_iface(net_dev
))
168 * batadv_is_wifi_netdev - check if the given net_device struct is a wifi
170 * @net_device: the device to check
172 * Return: true if the net device is a 802.11 wireless device, false otherwise.
174 bool batadv_is_wifi_netdev(struct net_device
*net_device
)
179 #ifdef CONFIG_WIRELESS_EXT
180 /* pre-cfg80211 drivers have to implement WEXT, so it is possible to
181 * check for wireless_handlers != NULL
183 if (net_device
->wireless_handlers
)
187 /* cfg80211 drivers have to set ieee80211_ptr */
188 if (net_device
->ieee80211_ptr
)
194 static struct batadv_hard_iface
*
195 batadv_hardif_get_active(const struct net_device
*soft_iface
)
197 struct batadv_hard_iface
*hard_iface
;
200 list_for_each_entry_rcu(hard_iface
, &batadv_hardif_list
, list
) {
201 if (hard_iface
->soft_iface
!= soft_iface
)
204 if (hard_iface
->if_status
== BATADV_IF_ACTIVE
&&
205 kref_get_unless_zero(&hard_iface
->refcount
))
216 static void batadv_primary_if_update_addr(struct batadv_priv
*bat_priv
,
217 struct batadv_hard_iface
*oldif
)
219 struct batadv_hard_iface
*primary_if
;
221 primary_if
= batadv_primary_if_get_selected(bat_priv
);
225 batadv_dat_init_own_addr(bat_priv
, primary_if
);
226 batadv_bla_update_orig_address(bat_priv
, primary_if
, oldif
);
229 batadv_hardif_put(primary_if
);
232 static void batadv_primary_if_select(struct batadv_priv
*bat_priv
,
233 struct batadv_hard_iface
*new_hard_iface
)
235 struct batadv_hard_iface
*curr_hard_iface
;
240 kref_get(&new_hard_iface
->refcount
);
242 curr_hard_iface
= rcu_dereference_protected(bat_priv
->primary_if
, 1);
243 rcu_assign_pointer(bat_priv
->primary_if
, new_hard_iface
);
248 bat_priv
->bat_algo_ops
->bat_primary_iface_set(new_hard_iface
);
249 batadv_primary_if_update_addr(bat_priv
, curr_hard_iface
);
253 batadv_hardif_put(curr_hard_iface
);
257 batadv_hardif_is_iface_up(const struct batadv_hard_iface
*hard_iface
)
259 if (hard_iface
->net_dev
->flags
& IFF_UP
)
265 static void batadv_check_known_mac_addr(const struct net_device
*net_dev
)
267 const struct batadv_hard_iface
*hard_iface
;
270 list_for_each_entry_rcu(hard_iface
, &batadv_hardif_list
, list
) {
271 if ((hard_iface
->if_status
!= BATADV_IF_ACTIVE
) &&
272 (hard_iface
->if_status
!= BATADV_IF_TO_BE_ACTIVATED
))
275 if (hard_iface
->net_dev
== net_dev
)
278 if (!batadv_compare_eth(hard_iface
->net_dev
->dev_addr
,
282 pr_warn("The newly added mac address (%pM) already exists on: %s\n",
283 net_dev
->dev_addr
, hard_iface
->net_dev
->name
);
284 pr_warn("It is strongly recommended to keep mac addresses unique to avoid problems!\n");
290 * batadv_hardif_recalc_extra_skbroom() - Recalculate skbuff extra head/tailroom
291 * @soft_iface: netdev struct of the mesh interface
293 static void batadv_hardif_recalc_extra_skbroom(struct net_device
*soft_iface
)
295 const struct batadv_hard_iface
*hard_iface
;
296 unsigned short lower_header_len
= ETH_HLEN
;
297 unsigned short lower_headroom
= 0;
298 unsigned short lower_tailroom
= 0;
299 unsigned short needed_headroom
;
302 list_for_each_entry_rcu(hard_iface
, &batadv_hardif_list
, list
) {
303 if (hard_iface
->if_status
== BATADV_IF_NOT_IN_USE
)
306 if (hard_iface
->soft_iface
!= soft_iface
)
309 lower_header_len
= max_t(unsigned short, lower_header_len
,
310 hard_iface
->net_dev
->hard_header_len
);
312 lower_headroom
= max_t(unsigned short, lower_headroom
,
313 hard_iface
->net_dev
->needed_headroom
);
315 lower_tailroom
= max_t(unsigned short, lower_tailroom
,
316 hard_iface
->net_dev
->needed_tailroom
);
320 needed_headroom
= lower_headroom
+ (lower_header_len
- ETH_HLEN
);
321 needed_headroom
+= batadv_max_header_len();
323 soft_iface
->needed_headroom
= needed_headroom
;
324 soft_iface
->needed_tailroom
= lower_tailroom
;
327 int batadv_hardif_min_mtu(struct net_device
*soft_iface
)
329 struct batadv_priv
*bat_priv
= netdev_priv(soft_iface
);
330 const struct batadv_hard_iface
*hard_iface
;
331 int min_mtu
= INT_MAX
;
334 list_for_each_entry_rcu(hard_iface
, &batadv_hardif_list
, list
) {
335 if ((hard_iface
->if_status
!= BATADV_IF_ACTIVE
) &&
336 (hard_iface
->if_status
!= BATADV_IF_TO_BE_ACTIVATED
))
339 if (hard_iface
->soft_iface
!= soft_iface
)
342 min_mtu
= min_t(int, hard_iface
->net_dev
->mtu
, min_mtu
);
346 if (atomic_read(&bat_priv
->fragmentation
) == 0)
349 /* with fragmentation enabled the maximum size of internally generated
350 * packets such as translation table exchanges or tvlv containers, etc
351 * has to be calculated
353 min_mtu
= min_t(int, min_mtu
, BATADV_FRAG_MAX_FRAG_SIZE
);
354 min_mtu
-= sizeof(struct batadv_frag_packet
);
355 min_mtu
*= BATADV_FRAG_MAX_FRAGMENTS
;
358 /* report to the other components the maximum amount of bytes that
359 * batman-adv can send over the wire (without considering the payload
360 * overhead). For example, this value is used by TT to compute the
361 * maximum local table table size
363 atomic_set(&bat_priv
->packet_size_max
, min_mtu
);
365 /* the real soft-interface MTU is computed by removing the payload
366 * overhead from the maximum amount of bytes that was just computed.
368 * However batman-adv does not support MTUs bigger than ETH_DATA_LEN
370 return min_t(int, min_mtu
- batadv_max_header_len(), ETH_DATA_LEN
);
373 /* adjusts the MTU if a new interface with a smaller MTU appeared. */
374 void batadv_update_min_mtu(struct net_device
*soft_iface
)
376 soft_iface
->mtu
= batadv_hardif_min_mtu(soft_iface
);
378 /* Check if the local translate table should be cleaned up to match a
379 * new (and smaller) MTU.
381 batadv_tt_local_resize_to_mtu(soft_iface
);
385 batadv_hardif_activate_interface(struct batadv_hard_iface
*hard_iface
)
387 struct batadv_priv
*bat_priv
;
388 struct batadv_hard_iface
*primary_if
= NULL
;
390 if (hard_iface
->if_status
!= BATADV_IF_INACTIVE
)
393 bat_priv
= netdev_priv(hard_iface
->soft_iface
);
395 bat_priv
->bat_algo_ops
->bat_iface_update_mac(hard_iface
);
396 hard_iface
->if_status
= BATADV_IF_TO_BE_ACTIVATED
;
398 /* the first active interface becomes our primary interface or
399 * the next active interface after the old primary interface was removed
401 primary_if
= batadv_primary_if_get_selected(bat_priv
);
403 batadv_primary_if_select(bat_priv
, hard_iface
);
405 batadv_info(hard_iface
->soft_iface
, "Interface activated: %s\n",
406 hard_iface
->net_dev
->name
);
408 batadv_update_min_mtu(hard_iface
->soft_iface
);
410 if (bat_priv
->bat_algo_ops
->bat_iface_activate
)
411 bat_priv
->bat_algo_ops
->bat_iface_activate(hard_iface
);
415 batadv_hardif_put(primary_if
);
419 batadv_hardif_deactivate_interface(struct batadv_hard_iface
*hard_iface
)
421 if ((hard_iface
->if_status
!= BATADV_IF_ACTIVE
) &&
422 (hard_iface
->if_status
!= BATADV_IF_TO_BE_ACTIVATED
))
425 hard_iface
->if_status
= BATADV_IF_INACTIVE
;
427 batadv_info(hard_iface
->soft_iface
, "Interface deactivated: %s\n",
428 hard_iface
->net_dev
->name
);
430 batadv_update_min_mtu(hard_iface
->soft_iface
);
434 * batadv_master_del_slave - remove hard_iface from the current master interface
435 * @slave: the interface enslaved in another master
436 * @master: the master from which slave has to be removed
438 * Invoke ndo_del_slave on master passing slave as argument. In this way slave
439 * is free'd and master can correctly change its internal state.
441 * Return: 0 on success, a negative value representing the error otherwise
443 static int batadv_master_del_slave(struct batadv_hard_iface
*slave
,
444 struct net_device
*master
)
452 if (master
->netdev_ops
->ndo_del_slave
)
453 ret
= master
->netdev_ops
->ndo_del_slave(master
, slave
->net_dev
);
458 int batadv_hardif_enable_interface(struct batadv_hard_iface
*hard_iface
,
459 struct net
*net
, const char *iface_name
)
461 struct batadv_priv
*bat_priv
;
462 struct net_device
*soft_iface
, *master
;
463 __be16 ethertype
= htons(ETH_P_BATMAN
);
464 int max_header_len
= batadv_max_header_len();
467 if (hard_iface
->if_status
!= BATADV_IF_NOT_IN_USE
)
470 kref_get(&hard_iface
->refcount
);
472 soft_iface
= dev_get_by_name(net
, iface_name
);
475 soft_iface
= batadv_softif_create(net
, iface_name
);
482 /* dev_get_by_name() increases the reference counter for us */
483 dev_hold(soft_iface
);
486 if (!batadv_softif_is_valid(soft_iface
)) {
487 pr_err("Can't create batman mesh interface %s: already exists as regular interface\n",
493 /* check if the interface is enslaved in another virtual one and
494 * in that case unlink it first
496 master
= netdev_master_upper_dev_get(hard_iface
->net_dev
);
497 ret
= batadv_master_del_slave(hard_iface
, master
);
501 hard_iface
->soft_iface
= soft_iface
;
502 bat_priv
= netdev_priv(hard_iface
->soft_iface
);
504 ret
= netdev_master_upper_dev_link(hard_iface
->net_dev
,
505 soft_iface
, NULL
, NULL
);
509 ret
= bat_priv
->bat_algo_ops
->bat_iface_enable(hard_iface
);
513 hard_iface
->if_num
= bat_priv
->num_ifaces
;
514 bat_priv
->num_ifaces
++;
515 hard_iface
->if_status
= BATADV_IF_INACTIVE
;
516 ret
= batadv_orig_hash_add_if(hard_iface
, bat_priv
->num_ifaces
);
518 bat_priv
->bat_algo_ops
->bat_iface_disable(hard_iface
);
519 bat_priv
->num_ifaces
--;
520 hard_iface
->if_status
= BATADV_IF_NOT_IN_USE
;
524 kref_get(&hard_iface
->refcount
);
525 hard_iface
->batman_adv_ptype
.type
= ethertype
;
526 hard_iface
->batman_adv_ptype
.func
= batadv_batman_skb_recv
;
527 hard_iface
->batman_adv_ptype
.dev
= hard_iface
->net_dev
;
528 dev_add_pack(&hard_iface
->batman_adv_ptype
);
530 batadv_info(hard_iface
->soft_iface
, "Adding interface: %s\n",
531 hard_iface
->net_dev
->name
);
533 if (atomic_read(&bat_priv
->fragmentation
) &&
534 hard_iface
->net_dev
->mtu
< ETH_DATA_LEN
+ max_header_len
)
535 batadv_info(hard_iface
->soft_iface
,
536 "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 %i would solve the problem.\n",
537 hard_iface
->net_dev
->name
, hard_iface
->net_dev
->mtu
,
538 ETH_DATA_LEN
+ max_header_len
);
540 if (!atomic_read(&bat_priv
->fragmentation
) &&
541 hard_iface
->net_dev
->mtu
< ETH_DATA_LEN
+ max_header_len
)
542 batadv_info(hard_iface
->soft_iface
,
543 "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 %i.\n",
544 hard_iface
->net_dev
->name
, hard_iface
->net_dev
->mtu
,
545 ETH_DATA_LEN
+ max_header_len
);
547 if (batadv_hardif_is_iface_up(hard_iface
))
548 batadv_hardif_activate_interface(hard_iface
);
550 batadv_err(hard_iface
->soft_iface
,
551 "Not using interface %s (retrying later): interface not active\n",
552 hard_iface
->net_dev
->name
);
554 batadv_hardif_recalc_extra_skbroom(soft_iface
);
556 /* begin scheduling originator messages on that interface */
557 batadv_schedule_bat_ogm(hard_iface
);
563 netdev_upper_dev_unlink(hard_iface
->net_dev
, soft_iface
);
565 hard_iface
->soft_iface
= NULL
;
568 batadv_hardif_put(hard_iface
);
572 void batadv_hardif_disable_interface(struct batadv_hard_iface
*hard_iface
,
573 enum batadv_hard_if_cleanup autodel
)
575 struct batadv_priv
*bat_priv
= netdev_priv(hard_iface
->soft_iface
);
576 struct batadv_hard_iface
*primary_if
= NULL
;
578 batadv_hardif_deactivate_interface(hard_iface
);
580 if (hard_iface
->if_status
!= BATADV_IF_INACTIVE
)
583 batadv_info(hard_iface
->soft_iface
, "Removing interface: %s\n",
584 hard_iface
->net_dev
->name
);
585 dev_remove_pack(&hard_iface
->batman_adv_ptype
);
586 batadv_hardif_put(hard_iface
);
588 bat_priv
->num_ifaces
--;
589 batadv_orig_hash_del_if(hard_iface
, bat_priv
->num_ifaces
);
591 primary_if
= batadv_primary_if_get_selected(bat_priv
);
592 if (hard_iface
== primary_if
) {
593 struct batadv_hard_iface
*new_if
;
595 new_if
= batadv_hardif_get_active(hard_iface
->soft_iface
);
596 batadv_primary_if_select(bat_priv
, new_if
);
599 batadv_hardif_put(new_if
);
602 bat_priv
->bat_algo_ops
->bat_iface_disable(hard_iface
);
603 hard_iface
->if_status
= BATADV_IF_NOT_IN_USE
;
605 /* delete all references to this hard_iface */
606 batadv_purge_orig_ref(bat_priv
);
607 batadv_purge_outstanding_packets(bat_priv
, hard_iface
);
608 dev_put(hard_iface
->soft_iface
);
610 netdev_upper_dev_unlink(hard_iface
->net_dev
, hard_iface
->soft_iface
);
611 batadv_hardif_recalc_extra_skbroom(hard_iface
->soft_iface
);
613 /* nobody uses this interface anymore */
614 if (!bat_priv
->num_ifaces
) {
615 batadv_gw_check_client_stop(bat_priv
);
617 if (autodel
== BATADV_IF_CLEANUP_AUTO
)
618 batadv_softif_destroy_sysfs(hard_iface
->soft_iface
);
621 hard_iface
->soft_iface
= NULL
;
622 batadv_hardif_put(hard_iface
);
626 batadv_hardif_put(primary_if
);
630 * batadv_hardif_remove_interface_finish - cleans up the remains of a hardif
631 * @work: work queue item
633 * Free the parts of the hard interface which can not be removed under
634 * rtnl lock (to prevent deadlock situations).
636 static void batadv_hardif_remove_interface_finish(struct work_struct
*work
)
638 struct batadv_hard_iface
*hard_iface
;
640 hard_iface
= container_of(work
, struct batadv_hard_iface
,
643 batadv_debugfs_del_hardif(hard_iface
);
644 batadv_sysfs_del_hardif(&hard_iface
->hardif_obj
);
645 batadv_hardif_put(hard_iface
);
648 static struct batadv_hard_iface
*
649 batadv_hardif_add_interface(struct net_device
*net_dev
)
651 struct batadv_hard_iface
*hard_iface
;
656 if (!batadv_is_valid_iface(net_dev
))
661 hard_iface
= kzalloc(sizeof(*hard_iface
), GFP_ATOMIC
);
665 ret
= batadv_sysfs_add_hardif(&hard_iface
->hardif_obj
, net_dev
);
669 hard_iface
->if_num
= -1;
670 hard_iface
->net_dev
= net_dev
;
671 hard_iface
->soft_iface
= NULL
;
672 hard_iface
->if_status
= BATADV_IF_NOT_IN_USE
;
674 ret
= batadv_debugfs_add_hardif(hard_iface
);
678 INIT_LIST_HEAD(&hard_iface
->list
);
679 INIT_HLIST_HEAD(&hard_iface
->neigh_list
);
680 INIT_WORK(&hard_iface
->cleanup_work
,
681 batadv_hardif_remove_interface_finish
);
683 spin_lock_init(&hard_iface
->neigh_list_lock
);
685 hard_iface
->num_bcasts
= BATADV_NUM_BCASTS_DEFAULT
;
686 if (batadv_is_wifi_netdev(net_dev
))
687 hard_iface
->num_bcasts
= BATADV_NUM_BCASTS_WIRELESS
;
689 /* extra reference for return */
690 kref_init(&hard_iface
->refcount
);
691 kref_get(&hard_iface
->refcount
);
693 batadv_check_known_mac_addr(hard_iface
->net_dev
);
694 list_add_tail_rcu(&hard_iface
->list
, &batadv_hardif_list
);
699 batadv_sysfs_del_hardif(&hard_iface
->hardif_obj
);
708 static void batadv_hardif_remove_interface(struct batadv_hard_iface
*hard_iface
)
712 /* first deactivate interface */
713 if (hard_iface
->if_status
!= BATADV_IF_NOT_IN_USE
)
714 batadv_hardif_disable_interface(hard_iface
,
715 BATADV_IF_CLEANUP_AUTO
);
717 if (hard_iface
->if_status
!= BATADV_IF_NOT_IN_USE
)
720 hard_iface
->if_status
= BATADV_IF_TO_BE_REMOVED
;
721 queue_work(batadv_event_workqueue
, &hard_iface
->cleanup_work
);
724 void batadv_hardif_remove_interfaces(void)
726 struct batadv_hard_iface
*hard_iface
, *hard_iface_tmp
;
729 list_for_each_entry_safe(hard_iface
, hard_iface_tmp
,
730 &batadv_hardif_list
, list
) {
731 list_del_rcu(&hard_iface
->list
);
732 batadv_hardif_remove_interface(hard_iface
);
737 static int batadv_hard_if_event(struct notifier_block
*this,
738 unsigned long event
, void *ptr
)
740 struct net_device
*net_dev
= netdev_notifier_info_to_dev(ptr
);
741 struct batadv_hard_iface
*hard_iface
;
742 struct batadv_hard_iface
*primary_if
= NULL
;
743 struct batadv_priv
*bat_priv
;
745 if (batadv_softif_is_valid(net_dev
) && event
== NETDEV_REGISTER
) {
746 batadv_sysfs_add_meshif(net_dev
);
747 bat_priv
= netdev_priv(net_dev
);
748 batadv_softif_create_vlan(bat_priv
, BATADV_NO_FLAGS
);
752 hard_iface
= batadv_hardif_get_by_netdev(net_dev
);
753 if (!hard_iface
&& (event
== NETDEV_REGISTER
||
754 event
== NETDEV_POST_TYPE_CHANGE
))
755 hard_iface
= batadv_hardif_add_interface(net_dev
);
762 batadv_hardif_activate_interface(hard_iface
);
764 case NETDEV_GOING_DOWN
:
766 batadv_hardif_deactivate_interface(hard_iface
);
768 case NETDEV_UNREGISTER
:
769 case NETDEV_PRE_TYPE_CHANGE
:
770 list_del_rcu(&hard_iface
->list
);
772 batadv_hardif_remove_interface(hard_iface
);
774 case NETDEV_CHANGEMTU
:
775 if (hard_iface
->soft_iface
)
776 batadv_update_min_mtu(hard_iface
->soft_iface
);
778 case NETDEV_CHANGEADDR
:
779 if (hard_iface
->if_status
== BATADV_IF_NOT_IN_USE
)
782 batadv_check_known_mac_addr(hard_iface
->net_dev
);
784 bat_priv
= netdev_priv(hard_iface
->soft_iface
);
785 bat_priv
->bat_algo_ops
->bat_iface_update_mac(hard_iface
);
787 primary_if
= batadv_primary_if_get_selected(bat_priv
);
791 if (hard_iface
== primary_if
)
792 batadv_primary_if_update_addr(bat_priv
, NULL
);
799 batadv_hardif_put(hard_iface
);
802 batadv_hardif_put(primary_if
);
806 struct notifier_block batadv_hard_if_notifier
= {
807 .notifier_call
= batadv_hard_if_event
,