From patchwork Fri May 4 18:16:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 909383 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="MrjfAcgG"; 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 40fJ9C46hRz9s35 for ; Mon, 7 May 2018 07:02:23 +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=LYaubZvLrGnLyephOWkd6gAb+9roKkKrh1Qd7c1Q+kU=; b=MrjfAcgGXOpi1A /LHmkwgG0M5+NCmAIfjjAcMuS8dE3EhoAmj6+Db/jtuk656tSJDI0+m1fXsFd4P/FTQqArDsfkz2R eCaUpDCMFzrHFbNTFGS6Mzp2jY4FG0ZRpH7NG95VoS/qkO5G8YXOrNr7pD/wmgKmz7e3p+FKoO+yT 9Fk/3MCaHyr5R3XnM6mX6YiOxlqIW99oHmKi9L9XXW9ARcqfaZZaGRPPln/OSq1khite+aa8HZ0XZ aAtQLrkGxkGtkKRH7cK6QeHLpGfgUiepH/OS76A0J2VxNo/mfMK8qVWCBi98qf0VECTiFDwYvGk3f HdK8kEH1IBhaSDuybpUA==; 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 1fFQnR-0005xw-D3; Sun, 06 May 2018 21:02:17 +0000 Received: from mail-vk0-f73.google.com ([209.85.213.73]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fEfFh-0006Hk-T1 for hostap@lists.infradead.org; Fri, 04 May 2018 18:16:19 +0000 Received: by mail-vk0-f73.google.com with SMTP id y22-v6so17297273vky.6 for ; Fri, 04 May 2018 11:16:07 -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=FtIID7Bf91ZYFyIQ1EK2HDcTRbNWdpvjJ+zBGaxyom4=; b=VHaWAZKqws0kcYC75vEW5tvZzSbdEblUMIMytfpCQDdKw3B0FH3G88OLsxUTpKxZCs lI+3UO0BTAtd1NKsTjNZy6mnRFHulm7zb1H1RRr+joHh2uzQk55uNbSw2pdtd4QzhGqy nNZMA0gPg4G0FJI8fE8opTo4EM4FeEWj4mxsOZPdRmZGC771hYmKvVb6mdQS8vNfsLyf ueQ2OPQ33hNKr3juUYajkL96ouHt814X1HPO1JcvGeuneBW7aS5A1S0QSF3eH+Cglptq Jg3eItV2InyfUSmcu5KvHnb1fJMQ3/3NGykmQ13jJUi46kFXLmMZobc2hvkZXsat3UJr HQvQ== X-Gm-Message-State: ALQs6tC+BPLieGI7ZFtFKis/9yWdgT/uxjT2gamD6rfOr1RHH/INF9VJ OQ+QwewHI/Kc7ygdKQ2ZUz5on/aX4dF7gwwx/hM= X-Google-Smtp-Source: AB8JxZpep6SWfkpIBe74jeKVhyyKWYTbvoMPZpv6Z4GrXTP90akzMmFjCXsOtRldyZD55tXXxm7ronCrLhArd/6MfmE= MIME-Version: 1.0 X-Received: by 10.176.18.197 with SMTP id o5mr14295219uac.82.1525457766490; Fri, 04 May 2018 11:16:06 -0700 (PDT) Date: Fri, 4 May 2018 11:16:02 -0700 Message-Id: <20180504181602.34764-1-matthewmwang@chromium.org> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog Subject: [PATCH RESEND] 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-20180504_111617_938548_E0195CA1 X-CRM114-Status: GOOD ( 14.59 ) 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_MSPIKE_H3 RBL: Good reputation (+3) [209.85.213.73 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.213.73 listed in list.dnswl.org] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Mailman-Approved-At: Sun, 06 May 2018 14:01:46 -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 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..64d2d0985 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 - u - (read)

    +

    The most recent roam time in milliseconds.

    +
  • + +
  • +

    RoamComplete - b - (read)

    +

    The most recent roam success or failure.

    +
  • + +
  • +

    SessionLength - u - (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..a50c7a540 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, "u", + 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, "u", + 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..e84acf230 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_uint32_t roam_time = wpa_s->roam_time.sec * 1000 + + wpa_s->roam_time.usec / 1000; + + return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT32, + &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_uint32_t session_length = wpa_s->session_length.sec * 1000 + + wpa_s->session_length.usec / 1000; + + return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_UINT32, + &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];