From patchwork Thu May 3 23:32:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 908617 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qYBaqrgd"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40cmGp4KPdz9s3G for ; Fri, 4 May 2018 19:01:54 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:From:Subject:Message-Id:Date: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zyifZO30TRkqYsPfvaQ1llwlnTtylIHL6f/laVk3CIY=; b=qYBaqrgdZG0mwv 7OJdAxyFrusGRmEdq/kKaXXOxFM82gIqlpNddcRfS2OXvVG4mC8QbFhhcMeNZOCfBAqEsNEPDOoPD /4FyhS6vY066eqOpVDVLyl+7fPUpMahj/cqZFgboeEEmZ0JwpMPUIW/sB/Rcmb42G7AoOQp3sqQ3q zljxbRz7b4zeaGtm9GXbIjNF3QiKJDt4SRbDzJbo3PHvvapnklDSvL1IRuW/7WFuchEi2nDt0CDBi /20yshv+jsIkczIJDs5IIeVrq3/tNXgddBt0B74/8PVlkXXwyJPZUSITMvmklClMNxmnXz8hqsZVI 1qADqtispODYfedlqSLQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fEWb6-0001oE-1r; Fri, 04 May 2018 09:01:48 +0000 Received: from mail-qk0-f202.google.com ([209.85.220.202]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fENiN-0004XN-K2 for hostap@lists.infradead.org; Thu, 03 May 2018 23:32:45 +0000 Received: by mail-qk0-f202.google.com with SMTP id q185so14434320qke.7 for ; Thu, 03 May 2018 16:32:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=8xnhh5zO6WkA8IG16KcQ/mJFvI1JQjdVhJ2FPh4dTJg=; b=CWu3MDh6odNxezxezdXJHoOvtyPp488aZ5f6M0cR+sLslJKgWA+zYq5WcUH0WsScG3 W1LInEu6CRr7GGuWuhtlDd5eP/xDXMY7d9aGk5qTUSaQvfqVQE+8uohfBPvC6yxjUYfq D8ZWbxTHtNeWChURkWRb98yiVL6INbVqGqbP86tWv6BZuWGfAb6SUXwxx241XQRRCxJA kHbvW+9+UqKWgHa8BsjrMCyyRa5P9936+/vUmNXaAhayNMeddh2vuGz6XU4+r+bEcZFI JikPtPJJznQHEfgtPf9BvXTAHcwC1gMhlsk43bYJovdSqRH2dpnh07v5l4KulNaC+Q4v CRmw== X-Gm-Message-State: ALQs6tDgoQycDjlQvn6vhV2DF8HMqxQ6CsshCteK/A6JXmQDk+q7ZuXB VHNaGn9vriqbAJ2QK817W0PJyzcIX40JyCvtNwc= X-Google-Smtp-Source: AB8JxZrWVtZtavvJ162/DeEHZokyl5zADVHB9HvIdo5tOSwINFJPwx9psQnfXnZ0ehT4wVLxm//20kO3yk8MdTOUQgg= MIME-Version: 1.0 X-Received: by 2002:a0c:952f:: with SMTP id l44-v6mr15247037qvl.56.1525390352244; Thu, 03 May 2018 16:32:32 -0700 (PDT) Date: Thu, 3 May 2018 16:32:28 -0700 Message-Id: <20180503233228.46852-1-matthewmwang@chromium.org> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog Subject: [PATCH] dbus: export roam time, roam complete, and session length to dbus From: Matthew Wang To: j@w1.fi, hostap@lists.infradead.org, matthewmwang@chromium.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180503_163243_658344_63F0F360 X-CRM114-Status: GOOD ( 14.78 ) X-Spam-Score: 0.2 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.220.202 listed in list.dnswl.org] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.220.202 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Mailman-Approved-At: Fri, 04 May 2018 02:01:45 -0700 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hostap@lists.infradead.org, matthewmwang@chromium.org Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Added new Interface properties "RoamTime", "RoamComplete", and "SessionLength". "RoamTime" carries the roam time of the most recent roam in milliseconds. "RoamComplete" carries True or False corresponding to the success status of the most recent roam. "SessionLength" carries the number of milliseconds corresponding to how long the connection to the last AP was before a roam or disconnect happened. These properties will all be logged in UMA to compare FT vs non-FT network behaviors. Signed-off-by: Matthew Wang --- doc/dbus.doxygen | 15 ++++++ wpa_supplicant/dbus/dbus_new.c | 27 ++++++++++ wpa_supplicant/dbus/dbus_new.h | 3 ++ wpa_supplicant/dbus/dbus_new_handlers.c | 65 +++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new_handlers.h | 3 ++ wpa_supplicant/notify.c | 27 ++++++++++ wpa_supplicant/notify.h | 3 ++ wpa_supplicant/wpa_supplicant.c | 34 +++++++++++++ wpa_supplicant/wpa_supplicant_i.h | 4 ++ 9 files changed, 181 insertions(+) diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index 2ca40ae9b..d3003b31d 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -769,6 +769,21 @@ fi.w1.wpa_supplicant1.CreateInterface.

The most recent IEEE 802.11 status code for association rejection.

+
  • +

    RoamTime - i - (read)

    +

    The most recent roam time in milliseconds.

    +
  • + +
  • +

    RoamComplete - b - (read)

    +

    The most recent roam success or failure.

    +
  • + +
  • +

    SessionLength - i - (read)

    +

    The most recent BSS session length in milliseconds.

    +
  • +
  • EapolVersion - s - (read/write)

    IEEE 802.1X/EAPOL version number

    diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index e0f16bbda..168e9baf6 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -2162,6 +2162,15 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s, prop = "AssocStatusCode"; flush = TRUE; break; + case WPAS_DBUS_PROP_ROAM_TIME: + prop = "RoamTime"; + break; + case WPAS_DBUS_PROP_ROAM_COMPLETE: + prop = "RoamComplete"; + break; + case WPAS_DBUS_PROP_SESSION_LENGTH: + prop = "SessionLength"; + break; default: wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d", __func__, property); @@ -2731,6 +2740,24 @@ static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = { NULL, NULL }, + { + "RoamTime", WPAS_DBUS_NEW_IFACE_INTERFACE, "i", + wpas_dbus_getter_roam_time, + NULL, + NULL + }, + { + "RoamComplete", WPAS_DBUS_NEW_IFACE_INTERFACE, "b", + wpas_dbus_getter_roam_complete, + NULL, + NULL + }, + { + "SessionLength", WPAS_DBUS_NEW_IFACE_INTERFACE, "i", + wpas_dbus_getter_session_length, + NULL, + NULL + }, { NULL, NULL, NULL, NULL, NULL, NULL } }; diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index e68acb7a1..08f4858b1 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -31,6 +31,9 @@ enum wpas_dbus_prop { WPAS_DBUS_PROP_BSSS, WPAS_DBUS_PROP_DISCONNECT_REASON, WPAS_DBUS_PROP_ASSOC_STATUS_CODE, + WPAS_DBUS_PROP_ROAM_TIME, + WPAS_DBUS_PROP_ROAM_COMPLETE, + WPAS_DBUS_PROP_SESSION_LENGTH, }; enum wpas_dbus_bss_prop { diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index a3c98fadd..4e3412cdc 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -3158,6 +3158,71 @@ dbus_bool_t wpas_dbus_getter_assoc_status_code( } +/** + * wpas_dbus_getter_roam_time - Get most recent roam time + * @iter: Pointer to incoming dbus message iter + * @error: Location to store error on failure + * @user_data: Function specific data + * Returns: TRUE on success, FALSE on failure + * + * Getter for "RoamTime" property. + */ +dbus_bool_t wpas_dbus_getter_roam_time( + const struct wpa_dbus_property_desc *property_desc, + DBusMessageIter *iter, DBusError *error, void *user_data) +{ + struct wpa_supplicant *wpa_s = user_data; + dbus_int32_t roam_time = wpa_s->roam_time.sec * 1000 + + wpa_s->roam_time.usec / 1000; + + return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32, + &roam_time, error); +} + +/** + * wpas_dbus_getter_roam_complete - Get most recent roam success or failure + * @iter: Pointer to incoming dbus message iter + * @error: Location to store error on failure + * @user_data: Function specific data + * Returns: TRUE on success, FALSE on failure + * + * Getter for "RoamComplete" property. + */ +dbus_bool_t wpas_dbus_getter_roam_complete( + const struct wpa_dbus_property_desc *property_desc, + DBusMessageIter *iter, DBusError *error, void *user_data) +{ + struct wpa_supplicant *wpa_s = user_data; + dbus_bool_t roam_complete = os_reltime_initialized(&wpa_s->roam_time) ? + TRUE : FALSE; + + return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN, + &roam_complete, error); +} + + +/** + * wpas_dbus_getter_session_length - Get most recent BSS session length + * @iter: Pointer to incoming dbus message iter + * @error: Location to store error on failure + * @user_data: Function specific data + * Returns: TRUE on success, FALSE on failure + * + * Getter for "SessionLength" property. + */ +dbus_bool_t wpas_dbus_getter_session_length( + const struct wpa_dbus_property_desc *property_desc, + DBusMessageIter *iter, DBusError *error, void *user_data) +{ + struct wpa_supplicant *wpa_s = user_data; + dbus_int32_t session_length = wpa_s->session_length.sec * 1000 + + wpa_s->session_length.usec / 1000; + + return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32, + &session_length, error); +} + + /** * wpas_dbus_getter_bss_expire_age - Get BSS entry expiration age * @iter: Pointer to incoming dbus message iter diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h index 26652ad3d..7a03b7f9f 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.h +++ b/wpa_supplicant/dbus/dbus_new_handlers.h @@ -148,6 +148,9 @@ DECLARE_ACCESSOR(wpas_dbus_setter_fast_reauth); DECLARE_ACCESSOR(wpas_dbus_getter_disconnect_reason); DECLARE_ACCESSOR(wpas_dbus_getter_disassociate_reason); DECLARE_ACCESSOR(wpas_dbus_getter_assoc_status_code); +DECLARE_ACCESSOR(wpas_dbus_getter_roam_time); +DECLARE_ACCESSOR(wpas_dbus_getter_roam_complete); +DECLARE_ACCESSOR(wpas_dbus_getter_session_length); DECLARE_ACCESSOR(wpas_dbus_getter_bss_expire_age); DECLARE_ACCESSOR(wpas_dbus_setter_bss_expire_age); DECLARE_ACCESSOR(wpas_dbus_getter_bss_expire_count); diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index 83df04f39..a2b04716d 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -149,6 +149,33 @@ void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s) } +void wpas_notify_roam_time(struct wpa_supplicant *wpa_s) +{ + if (wpa_s->p2p_mgmt) + return; + + wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME); +} + + +void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s) +{ + if (wpa_s->p2p_mgmt) + return; + + wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE); +} + + +void wpas_notify_session_length(struct wpa_supplicant *wpa_s) +{ + if (wpa_s->p2p_mgmt) + return; + + wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH); +} + + void wpas_notify_network_changed(struct wpa_supplicant *wpa_s) { if (wpa_s->p2p_mgmt) diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index 3ca933c76..bde20e83d 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -24,6 +24,9 @@ void wpas_notify_state_changed(struct wpa_supplicant *wpa_s, enum wpa_states old_state); void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s); void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s); +void wpas_notify_roam_time(struct wpa_supplicant *wpa_s); +void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s); +void wpas_notify_session_length(struct wpa_supplicant *wpa_s); void wpas_notify_network_changed(struct wpa_supplicant *wpa_s); void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s); void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s); diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index dcd787bec..df27c55ad 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -839,6 +839,40 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_supplicant_state_txt(wpa_s->wpa_state), wpa_supplicant_state_txt(state)); + if (state == WPA_AUTHENTICATING && wpa_s->wpa_state == WPA_COMPLETED) { + if (wpa_s->sme.prev_bssid_set && + os_memcmp(wpa_s->sme.prev_bssid, wpa_s->pending_bssid, ETH_ALEN) != 0) { + os_get_reltime(&wpa_s->roam_start); + } + } else if (state == WPA_COMPLETED && + os_reltime_initialized(&wpa_s->roam_start)) { + os_reltime_age(&wpa_s->roam_start, &wpa_s->roam_time); + wpa_s->roam_start.sec = 0; + wpa_s->roam_start.usec = 0; + wpas_notify_auth_changed(wpa_s); + wpas_notify_roam_time(wpa_s); + wpas_notify_roam_complete(wpa_s); + } else if (state == WPA_DISCONNECTED && + os_reltime_initialized(&wpa_s->roam_start)) { + wpa_s->roam_start.sec = 0; + wpa_s->roam_start.usec = 0; + wpa_s->roam_time.sec = 0; + wpa_s->roam_time.usec = 0; + wpas_notify_roam_complete(wpa_s); + } + + if (state == WPA_COMPLETED && wpa_s->wpa_state != WPA_COMPLETED) { + wpas_notify_auth_changed(wpa_s); + os_get_reltime(&wpa_s->session_start); + } else if (state != WPA_COMPLETED && + wpa_s->wpa_state == WPA_COMPLETED && + os_reltime_initialized(&wpa_s->session_start)) { + os_reltime_age(&wpa_s->session_start, &wpa_s->session_length); + wpa_s->session_start.sec = 0; + wpa_s->session_start.usec = 0; + wpas_notify_session_length(wpa_s); + } + if (state == WPA_INTERFACE_DISABLED) { /* Assure normal scan when interface is restored */ wpa_s->normal_scans = 0; diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 4d18177fb..a4d56b810 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -492,6 +492,10 @@ struct wpa_supplicant { struct wpa_supplicant *next; struct l2_packet_data *l2; struct l2_packet_data *l2_br; + struct os_reltime roam_start; + struct os_reltime roam_time; + struct os_reltime session_start; + struct os_reltime session_length; unsigned char own_addr[ETH_ALEN]; unsigned char perm_addr[ETH_ALEN]; char ifname[100];