Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1304213ybl; Fri, 16 Aug 2019 12:27:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaTFtaf1rzTM9wpzmh34XXq67iwmP+v8lmSyp8V3JNB99TseuAOVLgOz9cGiMz5oqVNHqz X-Received: by 2002:aa7:8a47:: with SMTP id n7mr12838659pfa.182.1565983666309; Fri, 16 Aug 2019 12:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565983666; cv=none; d=google.com; s=arc-20160816; b=HbGB97UoRb8eAMHatTzhzyFvxyrnHcuSso1b9/r59fHvT91KentGftY+KzabfnfGrr 046feHsAxrt1rZJMcPAeNv3NzRgAJ3gAJp+eluOF6qh+PziCzDH5yrGPtDyx0/DQlJ5t MSydiXEhLbchdjdwkaL4DWp5Yze5w7djXxH4uRHrlQP8Jn3rwCU6JgT2A5hcxLBXHyHp JlBjUCmm0RltT9ddDTxUAzIrgg1gOkFDriVbIuFEVKIxPc5EMq2kqP1aKdVvlB1pSqNl CAP6RuJsijk4styaP6Mjx4IP0E3nGk26UOE4zt0qlmYIrz8VENaNUxBqDyMT6pEAP2W+ TYlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lV6b4NFPt1H5Uz0Gj9pMlQD51ObVB2EGvGiPBfGimzI=; b=qzLMtCEIItRNwKX709MqQBlcDOYyIPDysdr5LbuWGR00t2iY9XtxQGLi+srqwtrH9J St6aAc16EngOoTUU51ry/0Y99dD0sWR1/UgRwnFESR8ecZkhxPOqp3V90gsc2olYCXEK t1Z+6x88fSgDuqSF2MdvjtA7lLI0buhHNQH68D1mgcVcxUMmdP9Eks8N/NxN7JzQVR5l JcgHdDLpM5MRxqiC3moqXSmjCE141/zQf9KCgFh4/y6pf2pX+3B4rIPM4deVq4wVaYvC h/0SCLC/3PQhFE9YfVr9dKMLVTRHIkIX9zm7l4vhIKFFR/ELTWhpXZXTqTSi1W05Sc4v ChaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ftkevl+s; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si4428887pgu.504.2019.08.16.12.27.25; Fri, 16 Aug 2019 12:27:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ftkevl+s; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727608AbfHPT1N (ORCPT + 99 others); Fri, 16 Aug 2019 15:27:13 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:39932 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727605AbfHPT1N (ORCPT ); Fri, 16 Aug 2019 15:27:13 -0400 Received: by mail-oi1-f196.google.com with SMTP id 16so5602453oiq.6 for ; Fri, 16 Aug 2019 12:27:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lV6b4NFPt1H5Uz0Gj9pMlQD51ObVB2EGvGiPBfGimzI=; b=Ftkevl+sGbaIBrJ8p+3FkoBYLVXm3QiCIH1NSGQ1PKDJWg+jHF55shpJjklzSv3XjZ LL7kFiipln+pZWRFXDca7joUuxi58MLNZH/0HgKktYmn4hfosvEyj5MkvSyGipsJNz/h YlcB1g8cBiOCdAw9nEZpA8z6AFuX+ToSCQfKQwT5o5ofxko9cbfPH0tUf3kEP1c5cRQL A+zumO33dF/3RgeRYQyUEjVBMkaWbfDAmCXOSOx1f38ZZvMa5pbF/PSP/IWYWLUSYm4E Wd0lrI5vY3BhQozSjEp9lBdETRPswwq0suAMqu9e/UJKOTBdjYVRXOY9cLNvYtgPBgzv fKUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lV6b4NFPt1H5Uz0Gj9pMlQD51ObVB2EGvGiPBfGimzI=; b=ObB0CTO7mKP0VZt2jmE4w5xH19UfFP3yMvOiT9M26lzah2Rdkg0nRiTLINSSmypRif vVWY2zHqG3rnz9LjP3X7HKch/rhrfxd4id9A8sgCI2LAYFp8YULArGlzIp3AK1qbVMr9 oF5osiuYGZrcJFokQ6nO9d6KY4Z7gdPpbk/5DM9Jf0l9PDJhO9H2DsqbEXgiNNWJtDUA EI2LxPO1k9GmsEbUqeOVXBo8NsKsEMvuSELuPEM9aRCarQiGnTM4cvkOhNFTaGWCP+Zi VR8zMq0DtH1BNGIxFc1kSXcsz++moF66Rn9PvIMzlLtv4ee25nFnGAt8uumNuGqWaepi gSbQ== X-Gm-Message-State: APjAAAX+plsH8dfs4lGNB+YgQP/l7RyLIcMM07kyyOAVLF/DZ4ixPZ64 rrUBXBLY4He0vdn1PoKL9UBrcUk3 X-Received: by 2002:aca:bfd4:: with SMTP id p203mr6269269oif.95.1565983632224; Fri, 16 Aug 2019 12:27:12 -0700 (PDT) Received: from localhost.localdomain (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id b10sm2452246oti.61.2019.08.16.12.27.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2019 12:27:11 -0700 (PDT) From: Denis Kenzior To: linux-wireless@vger.kernel.org, johannes@sipsolutions.net Cc: Denis Kenzior Subject: [RFCv2 2/4] nl80211: Support >4096 byte NEW_WIPHY event nlmsg Date: Fri, 16 Aug 2019 14:27:01 -0500 Message-Id: <20190816192703.12445-2-denkenz@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190816192703.12445-1-denkenz@gmail.com> References: <20190816192703.12445-1-denkenz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org For historical reasons, NEW_WIPHY messages generated by dumps or GET_WIPHY commands were limited to 4096 bytes due to userspace tools using limited buffers. Once the sizes NEW_WIPHY messages exceeded these sizes, split dumps were introduced. All any non-legacy data was added only to messages using split-dumps (including filtered dumps). However, split-dumping has quite a significant overhead. On cards tested, split dumps generated message sizes 1.7-1.8x compared to non-split dumps, while still comfortably fitting into an 8k buffer. The kernel now expects userspace to provide 16k buffers by default, and 32k buffers are possible. Introduce a concept of a large message, so that if the kernel detects that userspace has provided a buffer of sufficient size, a non-split message could be generated. Signed-off-by: Denis Kenzior --- net/wireless/nl80211.c | 51 ++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index b9b0199b5ec6..682a095415eb 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1839,6 +1839,7 @@ struct nl80211_dump_wiphy_state { long start; long split_start, band_start, chan_start, capa_start; bool split; + bool large_message; }; static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, @@ -2027,7 +2028,8 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, if (nl80211_msg_put_channel( msg, &rdev->wiphy, chan, - state->split)) + state->split || + state->large_message)) goto nla_put_failure; nla_nest_end(msg, nl_freq); @@ -2072,7 +2074,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, i = nl80211_add_commands_unsplit(rdev, msg); if (i < 0) goto nla_put_failure; - if (state->split) { + if (state->split || state->large_message) { CMD(crit_proto_start, CRIT_PROTOCOL_START); CMD(crit_proto_stop, CRIT_PROTOCOL_STOP); if (rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH) @@ -2111,7 +2113,8 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, /* fall through */ case 6: #ifdef CONFIG_PM - if (nl80211_send_wowlan(msg, rdev, state->split)) + if (nl80211_send_wowlan(msg, rdev, + state->split || state->large_message)) goto nla_put_failure; state->split_start++; if (state->split) @@ -2126,7 +2129,8 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, goto nla_put_failure; if (nl80211_put_iface_combinations(&rdev->wiphy, msg, - state->split)) + state->split || + state->large_message)) goto nla_put_failure; state->split_start++; @@ -2145,7 +2149,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, * dump is split, otherwise it makes it too big. Therefore * only advertise it in that case. */ - if (state->split) + if (state->split || state->large_message) features |= NL80211_FEATURE_ADVERTISE_CHAN_LIMITS; if (nla_put_u32(msg, NL80211_ATTR_FEATURE_FLAGS, features)) goto nla_put_failure; @@ -2170,13 +2174,20 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, * * We still increment split_start so that in the split * case we'll continue with more data in the next round, - * but break unconditionally so unsplit data stops here. + * but break unless large_messages are requested, so + * legacy unsplit data stops here. */ state->split_start++; - if (!state->split) + if (state->split) + break; + + if (!state->large_message) { state->split_start = 0; - break; + break; + } + + /* Fall through */ case 9: if (rdev->wiphy.extended_capabilities && (nla_put(msg, NL80211_ATTR_EXT_CAPA, @@ -2218,7 +2229,9 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, } state->split_start++; - break; + if (state->split) + break; + /* Fall through */ case 10: if (nl80211_send_coalesce(msg, rdev)) goto nla_put_failure; @@ -2234,7 +2247,9 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, goto nla_put_failure; state->split_start++; - break; + if (state->split) + break; + /* Fall through */ case 11: if (rdev->wiphy.n_vendor_commands) { const struct nl80211_vendor_cmd_info *info; @@ -2270,7 +2285,9 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, nla_nest_end(msg, nested); } state->split_start++; - break; + if (state->split) + break; + /* Fall through */ case 12: if (rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH && nla_put_u8(msg, NL80211_ATTR_MAX_CSA_COUNTERS, @@ -2312,7 +2329,9 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, } state->split_start++; - break; + if (state->split) + break; + /* Fall through */ case 13: if (rdev->wiphy.num_iftype_ext_capab && rdev->wiphy.iftype_ext_capab) { @@ -2380,13 +2399,17 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, } state->split_start++; - break; + if (state->split) + break; + /* Fall through */ case 14: if (nl80211_send_pmsr_capa(rdev, msg)) goto nla_put_failure; state->split_start++; - break; + if (state->split) + break; + /* Fall through */ case 15: if (rdev->wiphy.akm_suites && nla_put(msg, NL80211_ATTR_AKM_SUITES, -- 2.21.0