31 #include <linux/if_arp.h>
49 if (hard_iface->
net_dev == net_dev &&
101 static void batadv_primary_if_update_addr(
struct batadv_priv *bat_priv,
108 primary_if = batadv_primary_if_get_selected(bat_priv);
112 skb = bat_priv->
vis.my_info->skb_packet;
121 batadv_hardif_free_ref(primary_if);
124 static void batadv_primary_if_select(
struct batadv_priv *bat_priv,
132 new_hard_iface =
NULL;
140 bat_priv->
bat_algo_ops->bat_primary_iface_set(new_hard_iface);
141 batadv_primary_if_update_addr(bat_priv, curr_hard_iface);
145 batadv_hardif_free_ref(curr_hard_iface);
157 static void batadv_check_known_mac_addr(
const struct net_device *net_dev)
167 if (hard_iface->
net_dev == net_dev)
170 if (!batadv_compare_eth(hard_iface->
net_dev->dev_addr,
174 pr_warn(
"The newly added mac address (%pM) already exists on: %s\n",
176 pr_warn(
"It is strongly recommended to keep mac addresses unique to avoid problems!\n");
183 const struct batadv_priv *bat_priv = netdev_priv(soft_iface);
217 if (soft_iface->
mtu != min_mtu)
218 soft_iface->
mtu = min_mtu;
230 bat_priv = netdev_priv(hard_iface->
soft_iface);
232 bat_priv->
bat_algo_ops->bat_iface_update_mac(hard_iface);
238 primary_if = batadv_primary_if_get_selected(bat_priv);
240 batadv_primary_if_select(bat_priv, hard_iface);
249 batadv_hardif_free_ref(primary_if);
268 const char *iface_name)
283 pr_err(
"You are about to enable batman-adv on '%s' which already is part of a bridge. Unless you know exactly what you are doing this is probably wrong and won't work the way you think it would.\n",
297 dev_hold(soft_iface);
301 pr_err(
"Can't create batman mesh interface %s: already exists as regular interface\n",
308 bat_priv = netdev_priv(hard_iface->
soft_iface);
310 ret = bat_priv->
bat_algo_ops->bat_iface_enable(hard_iface);
337 "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",
344 "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",
348 if (batadv_hardif_is_iface_up(hard_iface))
349 batadv_hardif_activate_interface(hard_iface);
352 "Not using interface %s (retrying later): interface not active\n",
364 batadv_hardif_free_ref(hard_iface);
374 batadv_hardif_deactivate_interface(hard_iface);
386 primary_if = batadv_primary_if_get_selected(bat_priv);
387 if (hard_iface == primary_if) {
390 new_if = batadv_hardif_get_active(hard_iface->
soft_iface);
391 batadv_primary_if_select(bat_priv, new_if);
394 batadv_hardif_free_ref(new_if);
410 batadv_hardif_free_ref(hard_iface);
414 batadv_hardif_free_ref(primary_if);
418 batadv_hardif_add_interface(
struct net_device *net_dev)
425 ret = batadv_is_valid_iface(net_dev);
443 INIT_LIST_HEAD(&hard_iface->
list);
447 batadv_check_known_mac_addr(hard_iface->
net_dev);
479 batadv_hardif_free_ref(hard_iface);
489 list_del_rcu(&hard_iface->
list);
490 batadv_hardif_remove_interface(hard_iface);
505 hard_iface = batadv_hardif_add_interface(net_dev);
512 batadv_hardif_activate_interface(hard_iface);
516 batadv_hardif_deactivate_interface(hard_iface);
519 list_del_rcu(&hard_iface->
list);
521 batadv_hardif_remove_interface(hard_iface);
531 batadv_check_known_mac_addr(hard_iface->
net_dev);
533 bat_priv = netdev_priv(hard_iface->
soft_iface);
534 bat_priv->
bat_algo_ops->bat_iface_update_mac(hard_iface);
536 primary_if = batadv_primary_if_get_selected(bat_priv);
540 if (hard_iface == primary_if)
541 batadv_primary_if_update_addr(bat_priv,
NULL);
548 batadv_hardif_free_ref(hard_iface);
551 batadv_hardif_free_ref(primary_if);
570 #ifdef CONFIG_WIRELESS_EXT
574 if (net_device->wireless_handlers)
588 .notifier_call = batadv_hard_if_event,