From patchwork Thu Feb 1 01:04:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 10194975 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 25D6D603B4 for ; Thu, 1 Feb 2018 01:04:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E84E8285A8 for ; Thu, 1 Feb 2018 01:04:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD3F028609; Thu, 1 Feb 2018 01:04:37 +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 CAC5D285FC for ; Thu, 1 Feb 2018 01:04:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932166AbeBABEg (ORCPT ); Wed, 31 Jan 2018 20:04:36 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:45063 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932141AbeBABEe (ORCPT ); Wed, 31 Jan 2018 20:04:34 -0500 Received: by mail-pf0-f193.google.com with SMTP id a88so14473015pfe.12 for ; Wed, 31 Jan 2018 17:04:34 -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=U6UkJ6FAaLeRM8w4W0hQKoJ4RPKaTpphJQy0Hl33n7c=; b=Ti/DGZIO+Y4LAgtLlTnooz5285dRWF2JZNSrXWOHBNR2fw2LWqdHG0e8d0DDAmoNSG PjWgN7dsF5pcbtKdNfCBObcCdqkXWGygvuqEezGtQ1wNO7mltrc4DvNDFoFdCb///oZ3 iaBTV4OG/K2UkuqqWpEkYYCbgvlkOURElbqvtbPcQN8Wq/LeYE2lfHly/wEbPS2LXyKR JVc4eR/JQkUU4YnK/DgKv9B2GMew4Xky6Hxv5W0WMkGqpyyS2CBAfkO+hL+Azp3Y1LxM llRS43Afm338egryDUsYZdnihgTJVrAwnr5Rokn4K9LzvAvhLtRVnAsmGTzw5Lcjh5zC hgcg== 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=U6UkJ6FAaLeRM8w4W0hQKoJ4RPKaTpphJQy0Hl33n7c=; b=olcIonxx9/XGYvjbwuZs+eyWMQ2w/sDhhMFqkj6rbV6YAfe8tNJmNduBzGGNDmtJhs LE7U4nTAixXv/t5z2Qinp3EUkbvi8d0k8J0lPzs275lQu8nDf32J2X3xDxXDdK1t/6ug t7/Q6z2+zmP7GeF7a0+DTDNhPRc3OW8tBP9Cx1qtjJ4MLjhnmHCS8ShXiO+pgMpfbAaY +iIdodIcN7MTXMEi01V3/KI0WAk5LaqViwed5tQcz9FLf9T2EY3/TDaqlcLRMhogEkWE edXIPRp9dgouFrvPo37B7GLqM5CvtQSrtEcaSqD26UJiAZxHGLxXjjzOcAiEwLXU//Lv X/PQ== X-Gm-Message-State: AKwxytd33Kgu63miayyCju62IQ3vhVvSaLzN7Z39Gc5QKNvz3cYYzuj/ IecjilpFosW6XOhE3MwG7Iu5tA== X-Google-Smtp-Source: AH8x226UK7Vo6CT8OFrvKGgEww1fJd2xULeAt4348H9lf7Tx1DLlSKmIuPnv1PFF8bCNktezRLQ2MA== X-Received: by 10.98.106.10 with SMTP id f10mr22137643pfc.42.1517447073645; Wed, 31 Jan 2018 17:04:33 -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 n66sm41249456pfn.111.2018.01.31.17.04.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 Jan 2018 17:04:32 -0800 (PST) From: Denis Kenzior To: linux-wireless@vger.kernel.org Cc: Denis Kenzior Subject: [RFC v4 5/6] mac80211: Add support for tx_control_port Date: Wed, 31 Jan 2018 19:04:19 -0600 Message-Id: <20180201010420.6102-6-denkenz@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180201010420.6102-1-denkenz@gmail.com> References: <20180201010420.6102-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/tx.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 46028e12e216..fb3cf38d674f 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -3785,4 +3785,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 26900025de2f..c78f30555b6d 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1734,6 +1734,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, __be16 proto, bool unencrypted); /* HT */ void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata, diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 25904af38839..99934bc3cd83 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, __be16 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; +}