From patchwork Sat Apr 11 10:25:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 1269306 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tu-ilmenau.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=qPX+93KD; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48zrfr4SZBz9sSt for ; Sat, 11 Apr 2020 20:27:32 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jCMA8QG6TpH2B5cpJQYL42rLOpAkOokjiYb+vCQXWjQ=; b=qPX+93KD5VO8Z2 1fIq4y2woR1jDmHMs8xz2WFSgRfpkKA0K1fSXfG1q7NorsxshdQrqDkJ9QBSULhQCyDIO3ypFwKpK GAW7DrGZo+BPkvvAb5gUg8x0nStehQxtTz0U6/2ajpWQm59TnFppd6Xgqi7Z26Er4JXlIlmkTZ8Nd jKiCNyyG45JmlNAi5q5pJu22jOg/oy+GRmn5bMNs/6rWklDvGZ0hYTpHRDo8MCacC2ljDVDrZRJ3J T1JgD16zlZJBRy87oVLpklnvsQA5nG1u0k77URNctDy2OfsTXYN+COuesod+jiHx9E6sndPzEphaK hdgPQ/R7xQZ4wgxNQxdQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jNDM9-00046O-Tk; Sat, 11 Apr 2020 10:27:21 +0000 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jNDKd-0002b1-GA for hostap@lists.infradead.org; Sat, 11 Apr 2020 10:25:49 +0000 Received: from isengard.fritz.box (unknown [87.147.56.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPSA id E4BD458007D; Sat, 11 Apr 2020 12:25:32 +0200 (CEST) From: Markus Theil To: hostap@lists.infradead.org Subject: [PATCH v2 06/11] nl80211: add method for sending messages with connection owner attributes set Date: Sat, 11 Apr 2020 12:25:22 +0200 Message-Id: <20200411102527.154154-7-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200411102527.154154-1-markus.theil@tu-ilmenau.de> References: <20200411102527.154154-1-markus.theil@tu-ilmenau.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200411_032547_701829_C07559CF X-CRM114-Status: GOOD ( 13.00 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [141.24.186.67 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Theil Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org In order to receive nl80211 control port frames, the nl_sock* has to register with some attributes set. Add a helper method for this operation. Signed-off-by: Markus Theil --- src/drivers/driver_nl80211.c | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 7e481d757..14a7e465e 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -437,6 +437,46 @@ int send_and_recv_msgs(struct wpa_driver_nl80211_data *drv, valid_handler, valid_data); } +/* use this method to mark, that it is necessary to own the connection/interface + * for this operation. + * handle may be set to NULL, to get the same behavior as send_and_recv_msgs + * set_owner can be used to mark this socket for receiving control port frames + */ +int send_and_recv_msgs_as_owner(struct wpa_driver_nl80211_data *drv, + struct nl_msg *msg, + struct nl_sock *handle, Boolean set_owner, + int (*valid_handler)(struct nl_msg *, void *), + void *valid_data) +{ + int ret = -1; + + /* Control port over nl80211 needs the flags and attributes below. + * + * The Linux kernel has initial checks for them (in nl80211.c) like: + * validate_pae_over_nl80211(...) + * or final checks like: + * dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid + * + * Initial operations like () + * Final operations (e.g. disassociate) don't need to set these + * attributes, but they have to be performed on the socket, which + * has the connection owner property set in the kernel. + */ + if (drv->capa.flags & WPA_DRIVER_FLAGS_CONTROL_PORT && + handle && set_owner) + if (nla_put_flag(msg, NL80211_ATTR_CONTROL_PORT_OVER_NL80211) || + nla_put_flag(msg, NL80211_ATTR_SOCKET_OWNER) || + nla_put_u16(msg, NL80211_ATTR_CONTROL_PORT_ETHERTYPE, + ETH_P_PAE)) + goto out; + + return send_and_recv(drv->global, handle ? handle : drv->global->nl, + msg, valid_handler, valid_data); + +out: + return ret; +} + struct family_data { const char *group;