From patchwork Wed Jan 10 17:09:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 10155711 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 9667560231 for ; Wed, 10 Jan 2018 17:10:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 808712852E for ; Wed, 10 Jan 2018 17:10:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72A8528560; Wed, 10 Jan 2018 17:10:01 +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 034D02852E for ; Wed, 10 Jan 2018 17:10:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934371AbeAJRJ7 (ORCPT ); Wed, 10 Jan 2018 12:09:59 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:36472 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934363AbeAJRJx (ORCPT ); Wed, 10 Jan 2018 12:09:53 -0500 Received: by mail-pl0-f68.google.com with SMTP id q2so377374pll.3 for ; Wed, 10 Jan 2018 09:09:53 -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=3VIcEnOezkwIhuG7u7GTgJ/n4hdXIr4VgzBJUqfkc+8=; b=bnTaXkVkBbyTfHoPt1OWrsikq4ltrZu9M/BsEOdFy9iRn6w8Bx1kTOnBI2hmBrWZP3 HBvH1Vj0tZELvUTGBJ2uKnK20J2DJLnpbzccZiAeQJXlHsCt9oFK1hbUjcs9QwlhyaNL KpeuxW7oRxIKY4JGkbU3uBnQ/g4N8wTAQY9JQ5P5YJRlPDmnRh38GVqQuhfvJ9IFuXWS txRAo4hPfsIr6Hg5J6dhKFGT3+0h/BX7oHxrK8hZXroTHqeQ2jmAof51enj0JcIDjMe4 0PRJpVeUhuR9u6eP35YhMVFG/H3qqbZfQHvSssVtk7GG8Ara1si0B6AI4bhtGRhFPgoN aiXg== 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=3VIcEnOezkwIhuG7u7GTgJ/n4hdXIr4VgzBJUqfkc+8=; b=K5qfleArDxramKPBLIlx+7RYOOxMUJnb1RAWl3NAwoteKa0UN/i8DWZjBvzGF05vjM jk9GrldI0IHslEAND3JeB0xxPTMZ7jgmCGeOskNwo/iBCpUoQ4xeUXYzdkU63UI+umys NrP3AGUG1FNmKhOtJc6fO/U/cUUd6vljYw0bdDEZKQnZkLuqDvXplzC/fgo30aFOdxmg XyRaCdwYHa85n0pNMQumK33wjlsfpV+8aZ0e2K0fgJWwJWJx4uaM4LtOLrAvOLki/5wx II5QGELLOqKnbi8K/Br/oB43mzg9wkUa4CvbmVzBupzp4IFo2TFNKOfePcHlbRRkY4DF La8Q== X-Gm-Message-State: AKGB3mJvFBqlSlakgezWVRZV7mqqxCqiR9zIZhiuLTSKxPWqai8Kofxo Rrj07zNQkcsJAcLKG+xzpnz4xg== X-Google-Smtp-Source: ACJfBovCNmpRF7RjVvGYjdH1ZqnuUyyJFPIJnyS2CVqzWNlWMOfUs2OVC634896EhJkxwfR1BZQrBQ== X-Received: by 10.84.177.129 with SMTP id x1mr19600139plb.361.1515604192913; Wed, 10 Jan 2018 09:09:52 -0800 (PST) Received: from new-host-2.home.com (cpe-70-114-247-242.austin.res.rr.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id a15sm20029874pfi.55.2018.01.10.09.09.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jan 2018 09:09:52 -0800 (PST) From: Denis Kenzior To: linux-wireless@vger.kernel.org Cc: Denis Kenzior Subject: [RFC v2 5/5] mac80211: Add support for tx_control_port Date: Wed, 10 Jan 2018 11:09:38 -0600 Message-Id: <20180110170938.2341-6-denkenz@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180110170938.2341-1-denkenz@gmail.com> References: <20180110170938.2341-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 | 1 + net/mac80211/tx.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 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..fe163c31d431 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -976,6 +976,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) /* mac80211 supports control port protocol changing */ local->hw.wiphy->flags |= WIPHY_FLAG_CONTROL_PORT_PROTOCOL; + local->hw.wiphy->flags |= WIPHY_FLAG_CONTROL_PORT_OVER_NL80211; if (ieee80211_hw_check(&local->hw, SIGNAL_DBM)) { local->hw.wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 25904af38839..c22d2fa02d76 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(0x88c7)) + 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; +}