From patchwork Wed Jan 31 21:33:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 10194875 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F1D4760383 for ; Wed, 31 Jan 2018 21:33:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF4212887E for ; Wed, 31 Jan 2018 21:33:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D426428885; Wed, 31 Jan 2018 21:33:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74BFD2887F for ; Wed, 31 Jan 2018 21:33:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752323AbeAaVds (ORCPT ); Wed, 31 Jan 2018 16:33:48 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35038 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753124AbeAaVdr (ORCPT ); Wed, 31 Jan 2018 16:33:47 -0500 Received: by mail-pf0-f193.google.com with SMTP id t12so14007887pfg.2 for ; Wed, 31 Jan 2018 13:33:46 -0800 (PST) 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; bh=UyfYWJOEAo0gwM3xn6LveiByPCi6QHUJlG6plfrRecI=; b=OXlJBlJO+jV6ndv/OyfFxpVRVj9JgyHc/mOsv0PLvSIaxMJ2ZVdLKgRrwex0cl8nV1 8ivoHARBGoH9hZpz0AQcS9TaTbukLPTEBvHdA5cDABQ/kzm+Gejd1D60DSJ0tBaBynHt UIHXqXctDRMXsDEuFP7oIDLkt/DJM6R7k7+wpWdFqqHrUC6yORl/DX9W5Z0fkAQT/T5l FM9ZipprhWD8lEyNzenoYnzlL76Mmsm/wo/laBammaup9OiCPp9RS74OWUNiQAQRO2qd vO9hJi57RssEirgpjQ0Gav2Zy2iq0V4eS2DEdpMAGlkkkCV8OqRMygE1pzjsrGBgDM4m VJkQ== 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; bh=UyfYWJOEAo0gwM3xn6LveiByPCi6QHUJlG6plfrRecI=; b=WMlrBw1e8M5fvO67ttZN0e0E05dQHHGACHYP/ZqcHIDe6CFL+Ymp1XJPw6hI722Uht 5uJhgqcAws2Rednqs/YEaDrFNig2W9WS07rssBZFtoAeiLUYu3HOwAPJW51gnUmQa6GY TqneRf5B5h/P5hxNWX4TI9seZmJzeh5FMyedPDZe4I+manqvAjFxUdV5fsiGGcLNW2s7 2FBvlt3GjDXNUnsHIYeJH5A4MmGx+EHNQk67aNdUucvLrejeZcQkPl4Y3fIV9ALwXaYt SeJiF5wyW43d1j46U/beJx/xIg3lB9kxTgxFZVmzoRfddpAzqYXtI2tqT6R5fluRA1yS /Y5g== X-Gm-Message-State: AKwxytezcL/Tnj0Zv3xyA42eDWSVWLVAW0Rj4gPC0Q6ZrAAAzpd6SjzJ jX55gzbrekBJgQQVOXO8mobQep/g X-Google-Smtp-Source: AH8x2250sfOAc/2YxEJrHECxPm0CTqxq3KG/xvSjg/N4Uaj2i3uDHJLbS62WfYivpZazWbyk0YSTdA== X-Received: by 2002:a17:902:5e3:: with SMTP id f90-v6mr27461937plf.418.1517434426323; Wed, 31 Jan 2018 13:33:46 -0800 (PST) Received: from new-host-2.home.com ([134.134.139.82]) by smtp.gmail.com with ESMTPSA id h80sm44865112pfj.12.2018.01.31.13.33.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 Jan 2018 13:33:45 -0800 (PST) From: Denis Kenzior To: linux-wireless@vger.kernel.org Cc: Denis Kenzior Subject: [PATCH 6/6] mac80211: Add support for tx_control_port Date: Wed, 31 Jan 2018 15:33:29 -0600 Message-Id: <20180131213329.25322-7-denkenz@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180131213329.25322-1-denkenz@gmail.com> References: <20180131213329.25322-1-denkenz@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Denis Kenzior --- net/mac80211/cfg.c | 1 + net/mac80211/ieee80211_i.h | 3 +++ net/mac80211/main.c | 2 ++ net/mac80211/tx.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index f53bfb27295f..71cb45e517b0 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -3787,4 +3787,5 @@ const struct cfg80211_ops mac80211_config_ops = { .add_nan_func = ieee80211_add_nan_func, .del_nan_func = ieee80211_del_nan_func, .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast, + .tx_control_port = ieee80211_tx_control_port, }; diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 6f91aea6a4cb..be444305ef06 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1735,6 +1735,9 @@ void ieee80211_check_fast_xmit(struct sta_info *sta); void ieee80211_check_fast_xmit_all(struct ieee80211_local *local); void ieee80211_check_fast_xmit_iface(struct ieee80211_sub_if_data *sdata); void ieee80211_clear_fast_xmit(struct sta_info *sta); +int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev, + const u8 *buf, size_t len, + const u8 *dest, u16 proto, bool unencrypted); /* HT */ void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata, diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 0785d04a80bc..e5a51267c75d 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -554,6 +554,8 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len, NL80211_FEATURE_USERSPACE_MPM | NL80211_FEATURE_FULL_AP_CLIENT_STATE; wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_FILS_STA); + wiphy_ext_feature_set(wiphy, + NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211); if (!ops->hw_scan) wiphy->features |= NL80211_FEATURE_LOW_PRIORITY_SCAN | diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 25904af38839..031b27fa752c 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -4754,3 +4754,49 @@ void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata, ieee80211_xmit(sdata, NULL, skb); local_bh_enable(); } + +int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev, + const u8 *buf, size_t len, + const u8 *dest, u16 proto, bool unencrypted) +{ + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); + struct ieee80211_local *local = sdata->local; + struct sk_buff *skb; + struct ethhdr *ehdr; + u32 flags; + + /* Only accept CONTROL_PORT_PROTOCOL configured in CONNECT/ASSOCIATE + * or Pre-Authentication + */ + if (proto != sdata->control_port_protocol && + proto != cpu_to_be16(ETH_P_PREAUTH)) + return -EINVAL; + + if (unencrypted) + flags = IEEE80211_TX_INTFL_DONT_ENCRYPT; + else + flags = 0; + + skb = dev_alloc_skb(local->hw.extra_tx_headroom + + sizeof(struct ethhdr) + len); + if (!skb) + return -ENOMEM; + + skb_reserve(skb, local->hw.extra_tx_headroom + sizeof(struct ethhdr)); + + skb_put_data(skb, buf, len); + + ehdr = skb_push(skb, sizeof(struct ethhdr)); + memcpy(ehdr->h_dest, dest, ETH_ALEN); + memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); + ehdr->h_proto = proto; + + skb->dev = dev; + skb->protocol = htons(ETH_P_802_3); + skb_reset_network_header(skb); + skb_reset_mac_header(skb); + + __ieee80211_subif_start_xmit(skb, skb->dev, flags); + + return 0; +}