From patchwork Fri Jun 9 14:29:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17040 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 0082381FED; Fri, 9 Jun 2017 16:30:18 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=narfation.org header.i=@narfation.org header.b="eSrsyrd4"; dkim-atps=neutral Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id 9B69181FBF for ; Fri, 9 Jun 2017 16:30:16 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593C2BAF90000000000004065.dip0.t-ipconnect.de [IPv6:2003:c5:93c2:baf9::4065]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 4C58F1100EA; Fri, 9 Jun 2017 16:30:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1497018616; bh=5KZjeLXSf6/clcyIVQNA4wvq4g+iWeGrmn+HeMwecFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eSrsyrd4qXyJfqI9de1MgTiuy+atZNo6yHDpjFShNqh6sZPRhu07Yni6fRWaJLaIt lRZSTQyT7CS804aDFXoNbAWWcicLBqxeY0BLBAi78m8F3wplEbeppdwnSnSI1VB4V3 zH6IYInFNVlcYzUKQEC2VYH/PnTT5lmEY3E7XJTo= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 9 Jun 2017 16:29:58 +0200 Message-Id: <20170609142958.22105-2-sven@narfation.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170609142958.22105-1-sven@narfation.org> References: <20170609142958.22105-1-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH v2 2/2] batman-adv: Accept only filled wifi station info X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" The wifi driver can decide to not provide parts of the station info. For example, the expected throughput of the station can be omitted when the used rate control doesn't provide this kind of information. The B.A.T.M.A.N. V implementation must therefore check the filled bitfield before it tries to access the expected_throughput of the returned station_info. Reported-by: Alvaro Antelo Fixes: 5c3245172c01 ("batman-adv: ELP - compute the metric based on the estimated throughput") Signed-off-by: Sven Eckelmann --- v2: - switched to BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT) for Linux 4.0+ compat-include/uapi/linux/nl80211.h | 16 ++++++++++++++++ net/batman-adv/bat_v_elp.c | 4 ++++ 2 files changed, 20 insertions(+) create mode 100644 compat-include/uapi/linux/nl80211.h diff --git a/compat-include/uapi/linux/nl80211.h b/compat-include/uapi/linux/nl80211.h new file mode 100644 index 00000000..06f5625a --- /dev/null +++ b/compat-include/uapi/linux/nl80211.h @@ -0,0 +1,16 @@ +#ifndef _NET_BATMAN_ADV_COMPAT_UAPI_LINUX_NL80211_H_ +#define _NET_BATMAN_ADV_COMPAT_UAPI_LINUX_NL80211_H_ + +#include +#include_next + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) + +/* for batadv_v_elp_get_throughput which would have used + * STATION_INFO_EXPECTED_THROUGHPUT in Linux 4.0.0 + */ +#define NL80211_STA_INFO_EXPECTED_THROUGHPUT 28 + +#endif /* < KERNEL_VERSION(4, 0, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_UAPI_LINUX_NL80211_H_ */ diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c index 96e73337..4729a68a 100644 --- a/net/batman-adv/bat_v_elp.c +++ b/net/batman-adv/bat_v_elp.c @@ -19,6 +19,7 @@ #include "main.h" #include +#include #include #include #include @@ -39,6 +40,7 @@ #include #include #include +#include #include "bat_algo.h" #include "bat_v_ogm.h" @@ -111,6 +113,8 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh) } if (ret) goto default_throughput; + if (!(sinfo.filled & BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT))) + goto default_throughput; return sinfo.expected_throughput / 100; }