aboutsummaryrefslogtreecommitdiffstats
path: root/src/drivers/driver_bsd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2016-01-20 17:13:12 (GMT)
committerJouni Malinen <j@w1.fi>2016-02-05 15:40:45 (GMT)
commitcb22e3b25041d1ac605dceda53e3932565e87f47 (patch)
treeffdf0be543af09383d66aa94611b8452e3a701b9 /src/drivers/driver_bsd.c
parenta8ef133f1d739fdb74d8cb23b44bd3977ffbf67b (diff)
downloadhostap-cb22e3b25041d1ac605dceda53e3932565e87f47.zip
hostap-cb22e3b25041d1ac605dceda53e3932565e87f47.tar.gz
hostap-cb22e3b25041d1ac605dceda53e3932565e87f47.tar.bz2
BSD: Zero ifindex on interface removal
If an interface is removed, zero the remembered ifindex. Don't try to set properties on the interface when it is removed. Signed-off-by: Roy Marples <roy@marples.name>
Diffstat (limited to 'src/drivers/driver_bsd.c')
-rw-r--r--src/drivers/driver_bsd.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/drivers/driver_bsd.c b/src/drivers/driver_bsd.c
index da9fc66..99f3504 100644
--- a/src/drivers/driver_bsd.c
+++ b/src/drivers/driver_bsd.c
@@ -94,6 +94,9 @@ bsd_set80211(void *priv, int op, int val, const void *arg, int arg_len)
struct bsd_driver_data *drv = priv;
struct ieee80211req ireq;
+ if (drv->ifindex == 0)
+ return -1;
+
os_memset(&ireq, 0, sizeof(ireq));
os_strlcpy(ireq.i_name, drv->ifname, sizeof(ireq.i_name));
ireq.i_type = op;
@@ -881,7 +884,8 @@ bsd_deinit(void *priv)
{
struct bsd_driver_data *drv = priv;
- bsd_ctrl_iface(drv, 0);
+ if (drv->ifindex != 0)
+ bsd_ctrl_iface(drv, 0);
if (drv->sock_xmit != NULL)
l2_packet_deinit(drv->sock_xmit);
os_free(drv);
@@ -1226,6 +1230,8 @@ wpa_driver_bsd_event_receive(int sock, void *ctx, void *sock_ctx)
switch (ifan->ifan_what) {
case IFAN_DEPARTURE:
event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
+ drv->ifindex = 0;
+ break;
default:
return;
}
@@ -1576,16 +1582,21 @@ wpa_driver_bsd_deinit(void *priv)
{
struct bsd_driver_data *drv = priv;
- wpa_driver_bsd_set_wpa(drv, 0);
+ if (drv->ifindex != 0) {
+ wpa_driver_bsd_set_wpa(drv, 0);
- /* NB: mark interface down */
- bsd_ctrl_iface(drv, 0);
+ /* NB: mark interface down */
+ bsd_ctrl_iface(drv, 0);
- wpa_driver_bsd_set_wpa_internal(drv, drv->prev_wpa, drv->prev_privacy);
+ wpa_driver_bsd_set_wpa_internal(drv, drv->prev_wpa,
+ drv->prev_privacy);
- if (set80211param(drv, IEEE80211_IOC_ROAMING, drv->prev_roaming) < 0)
- wpa_printf(MSG_DEBUG, "%s: failed to restore roaming state",
- __func__);
+ if (set80211param(drv, IEEE80211_IOC_ROAMING, drv->prev_roaming)
+ < 0)
+ wpa_printf(MSG_DEBUG,
+ "%s: failed to restore roaming state",
+ __func__);
+ }
if (drv->sock_xmit != NULL)
l2_packet_deinit(drv->sock_xmit);