1 /* Copyright (C) 2007-2015 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/bug.h>
22 #include <linux/byteorder/generic.h>
23 #include <linux/errno.h>
25 #include <linux/if_arp.h>
26 #include <linux/if_ether.h>
28 #include <linux/kernel.h>
29 #include <linux/list.h>
30 #include <linux/netdevice.h>
31 #include <linux/printk.h>
32 #include <linux/rculist.h>
33 #include <linux/rtnetlink.h>
34 #include <linux/slab.h>
35 #include <linux/spinlock.h>
36 #include <linux/workqueue.h>
37 #include <net/net_namespace.h>
39 #include "bridge_loop_avoidance.h"
41 #include "distributed-arp-table.h"
42 #include "gateway_client.h"
43 #include "originator.h"
46 #include "soft-interface.h"
48 #include "translation-table.h"
50 void batadv_hardif_free_rcu(struct rcu_head
*rcu
)
52 struct batadv_hard_iface
*hard_iface
;
54 hard_iface
= container_of(rcu
, struct batadv_hard_iface
, rcu
);
55 dev_put(hard_iface
->net_dev
);
59 struct batadv_hard_iface
*
60 batadv_hardif_get_by_netdev(const struct net_device
*net_dev
)
62 struct batadv_hard_iface
*hard_iface
;
65 list_for_each_entry_rcu(hard_iface
, &batadv_hardif_list
, list
) {
66 if (hard_iface
->net_dev
== net_dev
&&
67 atomic_inc_not_zero(&hard_iface
->refcount
))
79 * batadv_mutual_parents - check if two devices are each others parent
80 * @dev1: 1st net_device
81 * @dev2: 2nd net_device
83 * veth devices come in pairs and each is the parent of the other!
85 * Return: true if the devices are each others parent, otherwise false
87 static bool batadv_mutual_parents(const struct net_device
*dev1
,
88 const struct net_device
*dev2
)
90 int dev1_parent_iflink
= dev_get_iflink(dev1
);
91 int dev2_parent_iflink
= dev_get_iflink(dev2
);
93 if (!dev1_parent_iflink
|| !dev2_parent_iflink
)
96 return (dev1_parent_iflink
== dev2
->ifindex
) &&
97 (dev2_parent_iflink
== dev1
->ifindex
);
101 * batadv_is_on_batman_iface - check if a device is a batman iface descendant
102 * @net_dev: the device to check
104 * If the user creates any virtual device on top of a batman-adv interface, it
105 * is important to prevent this new interface to be used to create a new mesh
106 * network (this behaviour would lead to a batman-over-batman configuration).
107 * This function recursively checks all the fathers of the device passed as
108 * argument looking for a batman-adv soft interface.
110 * Returns true if the device is descendant of a batman-adv mesh interface (or
111 * if it is a batman-adv interface itself), false otherwise
113 static bool batadv_is_on_batman_iface(const struct net_device
*net_dev
)
115 struct net_device
*parent_dev
;
118 /* check if this is a batman-adv mesh interface */
119 if (batadv_softif_is_valid(net_dev
))
122 /* no more parents..stop recursion */
123 if (dev_get_iflink(net_dev
) == 0 ||
124 dev_get_iflink(net_dev
) == net_dev
->ifindex
)
127 /* recurse over the parent device */
128 parent_dev
= __dev_get_by_index(&init_net
, dev_get_iflink(net_dev
));
129 /* if we got a NULL parent_dev there is something broken.. */
130 if (WARN(!parent_dev
, "Cannot find parent device"))
133 if (batadv_mutual_parents(net_dev
, parent_dev
))
136 ret
= batadv_is_on_batman_iface(parent_dev
);
141 static int batadv_is_valid_iface(const struct net_device
*net_dev
)
143 if (net_dev
->flags
& IFF_LOOPBACK
)
146 if (net_dev
->type
!= ARPHRD_ETHER
)
149 if (net_dev
->addr_len
!= ETH_ALEN
)
152 /* no batman over batman */
153 if (batadv_is_on_batman_iface(net_dev
))
160 * batadv_is_wifi_netdev - check if the given net_device struct is a wifi
162 * @net_device: the device to check
164 * Returns true if the net device is a 802.11 wireless device, false otherwise.
166 bool batadv_is_wifi_netdev(struct net_device
*net_device
)
171 #ifdef CONFIG_WIRELESS_EXT
172 /* pre-cfg80211 drivers have to implement WEXT, so it is possible to
173 * check for wireless_handlers != NULL
175 if (net_device
->wireless_handlers
)
179 /* cfg80211 drivers have to set ieee80211_ptr */
180 if (net_device
->ieee80211_ptr
)
186 static struct batadv_hard_iface
*
187 batadv_hardif_get_active(const struct net_device
*soft_iface
)
189 struct batadv_hard_iface
*hard_iface
;
192 list_for_each_entry_rcu(hard_iface
, &batadv_hardif_list
, list
) {
193 if (hard_iface
->soft_iface
!= soft_iface
)
196 if (hard_iface
->if_status
== BATADV_IF_ACTIVE
&&
197 atomic_inc_not_zero(&hard_iface
->refcount
))
208 static void batadv_primary_if_update_addr(struct batadv_priv
*bat_priv
,
209 struct batadv_hard_iface
*oldif
)
211 struct batadv_hard_iface
*primary_if
;
213 primary_if
= batadv_primary_if_get_selected(bat_priv
);
217 batadv_dat_init_own_addr(bat_priv
, primary_if
);
218 batadv_bla_update_orig_address(bat_priv
, primary_if
, oldif
);
221 batadv_hardif_free_ref(primary_if
);
224 static void batadv_primary_if_select(struct batadv_priv
*bat_priv
,
225 struct batadv_hard_iface
*new_hard_iface
)
227 struct batadv_hard_iface
*curr_hard_iface
;
231 if (new_hard_iface
&& !atomic_inc_not_zero(&new_hard_iface
->refcount
))
232 new_hard_iface
= NULL
;
234 curr_hard_iface
= rcu_dereference_protected(bat_priv
->primary_if
, 1);
235 rcu_assign_pointer(bat_priv
->primary_if
, new_hard_iface
);
240 bat_priv
->bat_algo_ops
->bat_primary_iface_set(new_hard_iface
);
241 batadv_primary_if_update_addr(bat_priv
, curr_hard_iface
);
245 batadv_hardif_free_ref(curr_hard_iface
);
249 batadv_hardif_is_iface_up(const struct batadv_hard_iface
*hard_iface
)
251 if (hard_iface
->net_dev
->flags
& IFF_UP
)
257 static void batadv_check_known_mac_addr(const struct net_device
*net_dev
)
259 const struct batadv_hard_iface
*hard_iface
;
262 list_for_each_entry_rcu(hard_iface
, &batadv_hardif_list
, list
) {
263 if ((hard_iface
->if_status
!= BATADV_IF_ACTIVE
) &&
264 (hard_iface
->if_status
!= BATADV_IF_TO_BE_ACTIVATED
))
267 if (hard_iface
->net_dev
== net_dev
)
270 if (!batadv_compare_eth(hard_iface
->net_dev
->dev_addr
,
274 pr_warn("The newly added mac address (%pM) already exists on: %s\n",
275 net_dev
->dev_addr
, hard_iface
->net_dev
->name
);
276 pr_warn("It is strongly recommended to keep mac addresses unique to avoid problems!\n");
282 * batadv_hardif_recalc_extra_skbroom() - Recalculate skbuff extra head/tailroom
283 * @soft_iface: netdev struct of the mesh interface
285 static void batadv_hardif_recalc_extra_skbroom(struct net_device
*soft_iface
)
287 const struct batadv_hard_iface
*hard_iface
;
288 unsigned short lower_header_len
= ETH_HLEN
;
289 unsigned short lower_headroom
= 0;
290 unsigned short lower_tailroom
= 0;
291 unsigned short needed_headroom
;
294 list_for_each_entry_rcu(hard_iface
, &batadv_hardif_list
, list
) {
295 if (hard_iface
->if_status
== BATADV_IF_NOT_IN_USE
)
298 if (hard_iface
->soft_iface
!= soft_iface
)
301 lower_header_len
= max_t(unsigned short, lower_header_len
,
302 hard_iface
->net_dev
->hard_header_len
);
304 lower_headroom
= max_t(unsigned short, lower_headroom
,
305 hard_iface
->net_dev
->needed_headroom
);
307 lower_tailroom
= max_t(unsigned short, lower_tailroom
,
308 hard_iface
->net_dev
->needed_tailroom
);
312 needed_headroom
= lower_headroom
+ (lower_header_len
- ETH_HLEN
);
313 needed_headroom
+= batadv_max_header_len();
315 soft_iface
->needed_headroom
= needed_headroom
;
316 soft_iface
->needed_tailroom
= lower_tailroom
;
319 int batadv_hardif_min_mtu(struct net_device
*soft_iface
)
321 struct batadv_priv
*bat_priv
= netdev_priv(soft_iface
);
322 const struct batadv_hard_iface
*hard_iface
;
323 int min_mtu
= INT_MAX
;
326 list_for_each_entry_rcu(hard_iface
, &batadv_hardif_list
, list
) {
327 if ((hard_iface
->if_status
!= BATADV_IF_ACTIVE
) &&
328 (hard_iface
->if_status
!= BATADV_IF_TO_BE_ACTIVATED
))
331 if (hard_iface
->soft_iface
!= soft_iface
)
334 min_mtu
= min_t(int, hard_iface
->net_dev
->mtu
, min_mtu
);
338 if (atomic_read(&bat_priv
->fragmentation
) == 0)
341 /* with fragmentation enabled the maximum size of internally generated
342 * packets such as translation table exchanges or tvlv containers, etc
343 * has to be calculated
345 min_mtu
= min_t(int, min_mtu
, BATADV_FRAG_MAX_FRAG_SIZE
);
346 min_mtu
-= sizeof(struct batadv_frag_packet
);
347 min_mtu
*= BATADV_FRAG_MAX_FRAGMENTS
;
350 /* report to the other components the maximum amount of bytes that
351 * batman-adv can send over the wire (without considering the payload
352 * overhead). For example, this value is used by TT to compute the
353 * maximum local table table size
355 atomic_set(&bat_priv
->packet_size_max
, min_mtu
);
357 /* the real soft-interface MTU is computed by removing the payload
358 * overhead from the maximum amount of bytes that was just computed.
360 * However batman-adv does not support MTUs bigger than ETH_DATA_LEN
362 return min_t(int, min_mtu
- batadv_max_header_len(), ETH_DATA_LEN
);
365 /* adjusts the MTU if a new interface with a smaller MTU appeared. */
366 void batadv_update_min_mtu(struct net_device
*soft_iface
)
368 soft_iface
->mtu
= batadv_hardif_min_mtu(soft_iface
);
370 /* Check if the local translate table should be cleaned up to match a
371 * new (and smaller) MTU.
373 batadv_tt_local_resize_to_mtu(soft_iface
);
377 batadv_hardif_activate_interface(struct batadv_hard_iface
*hard_iface
)
379 struct batadv_priv
*bat_priv
;
380 struct batadv_hard_iface
*primary_if
= NULL
;
382 if (hard_iface
->if_status
!= BATADV_IF_INACTIVE
)
385 bat_priv
= netdev_priv(hard_iface
->soft_iface
);
387 bat_priv
->bat_algo_ops
->bat_iface_update_mac(hard_iface
);
388 hard_iface
->if_status
= BATADV_IF_TO_BE_ACTIVATED
;
390 /* the first active interface becomes our primary interface or
391 * the next active interface after the old primary interface was removed
393 primary_if
= batadv_primary_if_get_selected(bat_priv
);
395 batadv_primary_if_select(bat_priv
, hard_iface
);
397 batadv_info(hard_iface
->soft_iface
, "Interface activated: %s\n",
398 hard_iface
->net_dev
->name
);
400 batadv_update_min_mtu(hard_iface
->soft_iface
);
404 batadv_hardif_free_ref(primary_if
);
408 batadv_hardif_deactivate_interface(struct batadv_hard_iface
*hard_iface
)
410 if ((hard_iface
->if_status
!= BATADV_IF_ACTIVE
) &&
411 (hard_iface
->if_status
!= BATADV_IF_TO_BE_ACTIVATED
))
414 hard_iface
->if_status
= BATADV_IF_INACTIVE
;
416 batadv_info(hard_iface
->soft_iface
, "Interface deactivated: %s\n",
417 hard_iface
->net_dev
->name
);
419 batadv_update_min_mtu(hard_iface
->soft_iface
);
423 * batadv_master_del_slave - remove hard_iface from the current master interface
424 * @slave: the interface enslaved in another master
425 * @master: the master from which slave has to be removed
427 * Invoke ndo_del_slave on master passing slave as argument. In this way slave
428 * is free'd and master can correctly change its internal state.
429 * Return 0 on success, a negative value representing the error otherwise
431 static int batadv_master_del_slave(struct batadv_hard_iface
*slave
,
432 struct net_device
*master
)
440 if (master
->netdev_ops
->ndo_del_slave
)
441 ret
= master
->netdev_ops
->ndo_del_slave(master
, slave
->net_dev
);
446 int batadv_hardif_enable_interface(struct batadv_hard_iface
*hard_iface
,
447 const char *iface_name
)
449 struct batadv_priv
*bat_priv
;
450 struct net_device
*soft_iface
, *master
;
451 __be16 ethertype
= htons(ETH_P_BATMAN
);
452 int max_header_len
= batadv_max_header_len();
455 if (hard_iface
->if_status
!= BATADV_IF_NOT_IN_USE
)
458 if (!atomic_inc_not_zero(&hard_iface
->refcount
))
461 soft_iface
= dev_get_by_name(&init_net
, iface_name
);
464 soft_iface
= batadv_softif_create(iface_name
);
471 /* dev_get_by_name() increases the reference counter for us */
472 dev_hold(soft_iface
);
475 if (!batadv_softif_is_valid(soft_iface
)) {
476 pr_err("Can't create batman mesh interface %s: already exists as regular interface\n",
482 /* check if the interface is enslaved in another virtual one and
483 * in that case unlink it first
485 master
= netdev_master_upper_dev_get(hard_iface
->net_dev
);
486 ret
= batadv_master_del_slave(hard_iface
, master
);
490 hard_iface
->soft_iface
= soft_iface
;
491 bat_priv
= netdev_priv(hard_iface
->soft_iface
);
493 ret
= netdev_master_upper_dev_link(hard_iface
->net_dev
,
494 soft_iface
, NULL
, NULL
);
498 ret
= bat_priv
->bat_algo_ops
->bat_iface_enable(hard_iface
);
502 hard_iface
->if_num
= bat_priv
->num_ifaces
;
503 bat_priv
->num_ifaces
++;
504 hard_iface
->if_status
= BATADV_IF_INACTIVE
;
505 ret
= batadv_orig_hash_add_if(hard_iface
, bat_priv
->num_ifaces
);
507 bat_priv
->bat_algo_ops
->bat_iface_disable(hard_iface
);
508 bat_priv
->num_ifaces
--;
509 hard_iface
->if_status
= BATADV_IF_NOT_IN_USE
;
513 hard_iface
->batman_adv_ptype
.type
= ethertype
;
514 hard_iface
->batman_adv_ptype
.func
= batadv_batman_skb_recv
;
515 hard_iface
->batman_adv_ptype
.dev
= hard_iface
->net_dev
;
516 dev_add_pack(&hard_iface
->batman_adv_ptype
);
518 batadv_info(hard_iface
->soft_iface
, "Adding interface: %s\n",
519 hard_iface
->net_dev
->name
);
521 if (atomic_read(&bat_priv
->fragmentation
) &&
522 hard_iface
->net_dev
->mtu
< ETH_DATA_LEN
+ max_header_len
)
523 batadv_info(hard_iface
->soft_iface
,
524 "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",
525 hard_iface
->net_dev
->name
, hard_iface
->net_dev
->mtu
,
526 ETH_DATA_LEN
+ max_header_len
);
528 if (!atomic_read(&bat_priv
->fragmentation
) &&
529 hard_iface
->net_dev
->mtu
< ETH_DATA_LEN
+ max_header_len
)
530 batadv_info(hard_iface
->soft_iface
,
531 "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",
532 hard_iface
->net_dev
->name
, hard_iface
->net_dev
->mtu
,
533 ETH_DATA_LEN
+ max_header_len
);
535 if (batadv_hardif_is_iface_up(hard_iface
))
536 batadv_hardif_activate_interface(hard_iface
);
538 batadv_err(hard_iface
->soft_iface
,
539 "Not using interface %s (retrying later): interface not active\n",
540 hard_iface
->net_dev
->name
);
542 batadv_hardif_recalc_extra_skbroom(soft_iface
);
544 /* begin scheduling originator messages on that interface */
545 batadv_schedule_bat_ogm(hard_iface
);
551 netdev_upper_dev_unlink(hard_iface
->net_dev
, soft_iface
);
553 hard_iface
->soft_iface
= NULL
;
556 batadv_hardif_free_ref(hard_iface
);
560 void batadv_hardif_disable_interface(struct batadv_hard_iface
*hard_iface
,
561 enum batadv_hard_if_cleanup autodel
)
563 struct batadv_priv
*bat_priv
= netdev_priv(hard_iface
->soft_iface
);
564 struct batadv_hard_iface
*primary_if
= NULL
;
566 if (hard_iface
->if_status
== BATADV_IF_ACTIVE
)
567 batadv_hardif_deactivate_interface(hard_iface
);
569 if (hard_iface
->if_status
!= BATADV_IF_INACTIVE
)
572 batadv_info(hard_iface
->soft_iface
, "Removing interface: %s\n",
573 hard_iface
->net_dev
->name
);
574 dev_remove_pack(&hard_iface
->batman_adv_ptype
);
576 bat_priv
->num_ifaces
--;
577 batadv_orig_hash_del_if(hard_iface
, bat_priv
->num_ifaces
);
579 primary_if
= batadv_primary_if_get_selected(bat_priv
);
580 if (hard_iface
== primary_if
) {
581 struct batadv_hard_iface
*new_if
;
583 new_if
= batadv_hardif_get_active(hard_iface
->soft_iface
);
584 batadv_primary_if_select(bat_priv
, new_if
);
587 batadv_hardif_free_ref(new_if
);
590 bat_priv
->bat_algo_ops
->bat_iface_disable(hard_iface
);
591 hard_iface
->if_status
= BATADV_IF_NOT_IN_USE
;
593 /* delete all references to this hard_iface */
594 batadv_purge_orig_ref(bat_priv
);
595 batadv_purge_outstanding_packets(bat_priv
, hard_iface
);
596 dev_put(hard_iface
->soft_iface
);
598 netdev_upper_dev_unlink(hard_iface
->net_dev
, hard_iface
->soft_iface
);
599 batadv_hardif_recalc_extra_skbroom(hard_iface
->soft_iface
);
601 /* nobody uses this interface anymore */
602 if (!bat_priv
->num_ifaces
) {
603 batadv_gw_check_client_stop(bat_priv
);
605 if (autodel
== BATADV_IF_CLEANUP_AUTO
)
606 batadv_softif_destroy_sysfs(hard_iface
->soft_iface
);
609 hard_iface
->soft_iface
= NULL
;
610 batadv_hardif_free_ref(hard_iface
);
614 batadv_hardif_free_ref(primary_if
);
618 * batadv_hardif_remove_interface_finish - cleans up the remains of a hardif
619 * @work: work queue item
621 * Free the parts of the hard interface which can not be removed under
622 * rtnl lock (to prevent deadlock situations).
624 static void batadv_hardif_remove_interface_finish(struct work_struct
*work
)
626 struct batadv_hard_iface
*hard_iface
;
628 hard_iface
= container_of(work
, struct batadv_hard_iface
,
631 batadv_debugfs_del_hardif(hard_iface
);
632 batadv_sysfs_del_hardif(&hard_iface
->hardif_obj
);
633 batadv_hardif_free_ref(hard_iface
);
636 static struct batadv_hard_iface
*
637 batadv_hardif_add_interface(struct net_device
*net_dev
)
639 struct batadv_hard_iface
*hard_iface
;
644 ret
= batadv_is_valid_iface(net_dev
);
650 hard_iface
= kzalloc(sizeof(*hard_iface
), GFP_ATOMIC
);
654 ret
= batadv_sysfs_add_hardif(&hard_iface
->hardif_obj
, net_dev
);
658 hard_iface
->if_num
= -1;
659 hard_iface
->net_dev
= net_dev
;
660 hard_iface
->soft_iface
= NULL
;
661 hard_iface
->if_status
= BATADV_IF_NOT_IN_USE
;
663 ret
= batadv_debugfs_add_hardif(hard_iface
);
667 INIT_LIST_HEAD(&hard_iface
->list
);
668 INIT_HLIST_HEAD(&hard_iface
->neigh_list
);
669 INIT_WORK(&hard_iface
->cleanup_work
,
670 batadv_hardif_remove_interface_finish
);
672 spin_lock_init(&hard_iface
->neigh_list_lock
);
674 hard_iface
->num_bcasts
= BATADV_NUM_BCASTS_DEFAULT
;
675 if (batadv_is_wifi_netdev(net_dev
))
676 hard_iface
->num_bcasts
= BATADV_NUM_BCASTS_WIRELESS
;
678 /* extra reference for return */
679 atomic_set(&hard_iface
->refcount
, 2);
681 batadv_check_known_mac_addr(hard_iface
->net_dev
);
682 list_add_tail_rcu(&hard_iface
->list
, &batadv_hardif_list
);
687 batadv_sysfs_del_hardif(&hard_iface
->hardif_obj
);
696 static void batadv_hardif_remove_interface(struct batadv_hard_iface
*hard_iface
)
700 /* first deactivate interface */
701 if (hard_iface
->if_status
!= BATADV_IF_NOT_IN_USE
)
702 batadv_hardif_disable_interface(hard_iface
,
703 BATADV_IF_CLEANUP_AUTO
);
705 if (hard_iface
->if_status
!= BATADV_IF_NOT_IN_USE
)
708 hard_iface
->if_status
= BATADV_IF_TO_BE_REMOVED
;
709 queue_work(batadv_event_workqueue
, &hard_iface
->cleanup_work
);
712 void batadv_hardif_remove_interfaces(void)
714 struct batadv_hard_iface
*hard_iface
, *hard_iface_tmp
;
717 list_for_each_entry_safe(hard_iface
, hard_iface_tmp
,
718 &batadv_hardif_list
, list
) {
719 list_del_rcu(&hard_iface
->list
);
720 batadv_hardif_remove_interface(hard_iface
);
725 static int batadv_hard_if_event(struct notifier_block
*this,
726 unsigned long event
, void *ptr
)
728 struct net_device
*net_dev
= netdev_notifier_info_to_dev(ptr
);
729 struct batadv_hard_iface
*hard_iface
;
730 struct batadv_hard_iface
*primary_if
= NULL
;
731 struct batadv_priv
*bat_priv
;
733 if (batadv_softif_is_valid(net_dev
) && event
== NETDEV_REGISTER
) {
734 batadv_sysfs_add_meshif(net_dev
);
735 bat_priv
= netdev_priv(net_dev
);
736 batadv_softif_create_vlan(bat_priv
, BATADV_NO_FLAGS
);
740 hard_iface
= batadv_hardif_get_by_netdev(net_dev
);
741 if (!hard_iface
&& (event
== NETDEV_REGISTER
||
742 event
== NETDEV_POST_TYPE_CHANGE
))
743 hard_iface
= batadv_hardif_add_interface(net_dev
);
750 batadv_hardif_activate_interface(hard_iface
);
752 case NETDEV_GOING_DOWN
:
754 batadv_hardif_deactivate_interface(hard_iface
);
756 case NETDEV_UNREGISTER
:
757 case NETDEV_PRE_TYPE_CHANGE
:
758 list_del_rcu(&hard_iface
->list
);
760 batadv_hardif_remove_interface(hard_iface
);
762 case NETDEV_CHANGEMTU
:
763 if (hard_iface
->soft_iface
)
764 batadv_update_min_mtu(hard_iface
->soft_iface
);
766 case NETDEV_CHANGEADDR
:
767 if (hard_iface
->if_status
== BATADV_IF_NOT_IN_USE
)
770 batadv_check_known_mac_addr(hard_iface
->net_dev
);
772 bat_priv
= netdev_priv(hard_iface
->soft_iface
);
773 bat_priv
->bat_algo_ops
->bat_iface_update_mac(hard_iface
);
775 primary_if
= batadv_primary_if_get_selected(bat_priv
);
779 if (hard_iface
== primary_if
)
780 batadv_primary_if_update_addr(bat_priv
, NULL
);
787 batadv_hardif_free_ref(hard_iface
);
790 batadv_hardif_free_ref(primary_if
);
794 struct notifier_block batadv_hard_if_notifier
= {
795 .notifier_call
= batadv_hard_if_event
,