From 27bdddf01025c2122c76dc99fd8131ba01694f82 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Mon, 12 Dec 2016 18:34:28 +0100 Subject: [PATCH] netdev: Emit DISCONNECT_BY_SME event on eapol failures There are situations when a CMD_DISCONNECT or deauthenticate will be issued locally because of an error detected locally where netdev would not be able to emit a event to the device object. The CMD_DISCONNECT handler can only send an event if the disconnect is triggered by the AP because we don't have an enum value defined for other diconnects. We have these values defined for the connect callback but those errors may happen when the connect callback is already NULL because a connection has been estabilshed. So add an event type for local errors. These situations may occur in a transition negotiation or in an eapol handshake failure during rekeying resulting in a call to netdev_handshake_failed. --- src/device.c | 4 ++++ src/netdev.c | 4 ++++ src/netdev.h | 1 + 3 files changed, 9 insertions(+) diff --git a/src/device.c b/src/device.c index cffe5409..54a1a42d 100644 --- a/src/device.c +++ b/src/device.c @@ -615,6 +615,10 @@ static void device_netdev_event(struct netdev *netdev, enum netdev_event event, break; case NETDEV_EVENT_DISCONNECT_BY_AP: device_disconnect_by_ap(device); + break; + case NETDEV_EVENT_DISCONNECT_BY_SME: + device_disassociated(device); + break; }; } diff --git a/src/netdev.c b/src/netdev.c index 20feda6b..4245c98a 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -323,6 +323,7 @@ static void netdev_connect_failed(struct l_genl_msg *msg, void *user_data) { struct netdev *netdev = user_data; netdev_connect_cb_t connect_cb = netdev->connect_cb; + netdev_event_func_t event_filter = netdev->event_filter; void *connect_data = netdev->user_data; enum netdev_result result = netdev->result; @@ -333,6 +334,9 @@ static void netdev_connect_failed(struct l_genl_msg *msg, void *user_data) if (connect_cb) connect_cb(netdev, result, connect_data); + else if (event_filter) + event_filter(netdev, NETDEV_EVENT_DISCONNECT_BY_SME, + connect_data); } static void netdev_free(void *data) diff --git a/src/netdev.h b/src/netdev.h index 3a4bb629..c0b632f3 100644 --- a/src/netdev.h +++ b/src/netdev.h @@ -43,6 +43,7 @@ enum netdev_event { NETDEV_EVENT_SETTING_KEYS, NETDEV_EVENT_LOST_BEACON, NETDEV_EVENT_DISCONNECT_BY_AP, + NETDEV_EVENT_DISCONNECT_BY_SME, }; enum netdev_watch_event {