The following commit has been merged in the merge/master branch: commit 66c1598113ecd3197671fcd70c69aa986e77767e Merge: 4ffe28ffec5b1393e819256e30925144c1105c5e ea24494956f4b7018be99810b167f52ba349369c Author: Antonio Quartulli ordex@autistici.org Date: Mon Aug 26 23:37:11 2013 +0200
Merge remote-tracking branch 'pkg/next' into merge/master
Conflicts: net/batman-adv/compat.h
diff --combined net/batman-adv/gateway_client.c index 7614af3,1ce4b87..1ce4b87 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@@ -190,6 -190,33 +190,33 @@@ next return curr_gw; }
+ /** + * batadv_gw_check_client_stop - check if client mode has been switched off + * @bat_priv: the bat priv with all the soft interface information + * + * This function assumes the caller has checked that the gw state *is actually + * changing*. This function is not supposed to be called when there is no state + * change. + */ + void batadv_gw_check_client_stop(struct batadv_priv *bat_priv) + { + struct batadv_gw_node *curr_gw; + + if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_CLIENT) + return; + + curr_gw = batadv_gw_get_selected_gw_node(bat_priv); + if (!curr_gw) + return; + + /* if batman-adv is switching the gw client mode off and a gateway was + * already selected, send a DEL uevent + */ + batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, NULL); + + batadv_gw_node_free_ref(curr_gw); + } + void batadv_gw_election(struct batadv_priv *bat_priv) { struct batadv_gw_node *curr_gw = NULL, *next_gw = NULL; diff --combined net/batman-adv/gateway_client.h index 1037d75,ceef4eb..ceef4eb --- a/net/batman-adv/gateway_client.h +++ b/net/batman-adv/gateway_client.h @@@ -20,6 -20,7 +20,7 @@@ #ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ #define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
+ void batadv_gw_check_client_stop(struct batadv_priv *bat_priv); void batadv_gw_deselect(struct batadv_priv *bat_priv); void batadv_gw_election(struct batadv_priv *bat_priv); struct batadv_orig_node * diff --combined net/batman-adv/hard-interface.c index c478e6b,e884dc7..e884dc7 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@@ -28,6 -28,7 +28,7 @@@ #include "originator.h" #include "hash.h" #include "bridge_loop_avoidance.h" + #include "gateway_client.h"
#include <linux/if_arp.h> #include <linux/if_ether.h> @@@ -533,8 -534,12 +534,12 @@@ void batadv_hardif_disable_interface(st dev_put(hard_iface->soft_iface);
/* nobody uses this interface anymore */ - if (!bat_priv->num_ifaces && autodel == BATADV_IF_CLEANUP_AUTO) - batadv_softif_destroy_sysfs(hard_iface->soft_iface); + if (!bat_priv->num_ifaces) { + batadv_gw_check_client_stop(bat_priv); + + if (autodel == BATADV_IF_CLEANUP_AUTO) + batadv_softif_destroy_sysfs(hard_iface->soft_iface); + }
netdev_upper_dev_unlink(hard_iface->net_dev, hard_iface->soft_iface); hard_iface->soft_iface = NULL; diff --combined net/batman-adv/sysfs.c index 929e304,4114b96..4114b96 --- a/net/batman-adv/sysfs.c +++ b/net/batman-adv/sysfs.c @@@ -385,6 -385,10 +385,10 @@@ static ssize_t batadv_store_gw_mode(str curr_gw_mode_str, buff);
batadv_gw_deselect(bat_priv); + /* always call batadv_gw_check_client_stop() before changing the gateway + * state + */ + batadv_gw_check_client_stop(bat_priv); atomic_set(&bat_priv->gw_mode, (unsigned int)gw_mode_tmp); return count; }