BSD: Disable interface on down

Instead of removing the interface when downed, disable it. Enable it
when it comes back up again.

Signed-off-by: Roy Marples <roy@marples.name>
This commit is contained in:
Roy Marples 2016-01-19 17:48:01 +00:00 committed by Jouni Malinen
parent dc0ad60314
commit af060932de

View file

@ -62,6 +62,7 @@ struct bsd_driver_data {
struct l2_packet_data *sock_xmit;/* raw packet xmit socket */ struct l2_packet_data *sock_xmit;/* raw packet xmit socket */
char ifname[IFNAMSIZ+1]; /* interface name */ char ifname[IFNAMSIZ+1]; /* interface name */
int flags;
unsigned int ifindex; /* interface index */ unsigned int ifindex; /* interface index */
void *ctx; void *ctx;
struct wpa_driver_capa capa; /* driver capability */ struct wpa_driver_capa capa; /* driver capability */
@ -287,6 +288,7 @@ bsd_ctrl_iface(void *priv, int enable)
strerror(errno)); strerror(errno));
return -1; return -1;
} }
drv->flags = ifr.ifr_flags;
if (enable) { if (enable) {
if (ifr.ifr_flags & IFF_UP) if (ifr.ifr_flags & IFF_UP)
@ -304,6 +306,7 @@ bsd_ctrl_iface(void *priv, int enable)
return -1; return -1;
} }
drv->flags = ifr.ifr_flags;
return 0; return 0;
} }
@ -1289,15 +1292,20 @@ wpa_driver_bsd_event_receive(int sock, void *ctx, void *sock_ctx)
drv = bsd_get_drvindex(global, ifm->ifm_index); drv = bsd_get_drvindex(global, ifm->ifm_index);
if (drv == NULL) if (drv == NULL)
return; return;
if ((rtm->rtm_flags & RTF_UP) == 0) { if ((ifm->ifm_flags & IFF_UP) == 0 &&
os_strlcpy(event.interface_status.ifname, drv->ifname, (drv->flags & IFF_UP) != 0) {
sizeof(event.interface_status.ifname));
event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' DOWN", wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' DOWN",
event.interface_status.ifname); drv->ifname);
wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS, wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_DISABLED,
&event); NULL);
} else if ((ifm->ifm_flags & IFF_UP) != 0 &&
(drv->flags & IFF_UP) == 0) {
wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' UP",
drv->ifname);
wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED,
NULL);
} }
drv->flags = ifm->ifm_flags;
break; break;
} }
} }