When a new hard_iface has a master already, ndo_del_slave has to be used in order to let the old master perform its cleaning up routing correctly. Unregistering the master iface only could lead to a inconsistent state in the old master knowledge.
Introduced by 5e57e3bff429cd403f0e30af69cf87a2cd55598f ("batman-adv: free an hard-interface before adding it").
Reported-by: Marek Lindner lindner_marek@yahoo.de Signed-off-by: Antonio Quartulli ordex@autistici.org --- hard-interface.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/hard-interface.c b/hard-interface.c index fd99e42..f446e69 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -346,8 +346,15 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, * in that case unlink it first */ master = netdev_master_upper_dev_get(hard_iface->net_dev); - if (master) - netdev_upper_dev_unlink(hard_iface->net_dev, master); + if (master && master->netdev_ops->ndo_del_slave) { + ret = master->netdev_ops->ndo_del_slave(master, + hard_iface->net_dev); + if (ret < 0) + goto err_dev; + } else if (master) { + ret = -EINVAL; + goto err_dev; + }
hard_iface->soft_iface = soft_iface; bat_priv = netdev_priv(hard_iface->soft_iface);