From patchwork Mon Sep 25 07:22:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1838937 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=HwsrXA0t; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=MGrwUXex; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RvDs85Hjhz1ynF for ; Mon, 25 Sep 2023 17:24:28 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uxZBbloznWbbC0jZ4r2OG/KuiYZMVDyKlIHJpnDtdZY=; b=HwsrXA0tjMpRDo ngrTYL7YYkJFdGs2OC6jdvpMTYd/l52ScxhL1ZxwISZpmFqjICWugwy+u4XFFumDqYhUBPtpiBJwe Uh3GxdMtfirlBnuYjH2k6CzUJlEsUBwmBBQ9CJcOX6t6H2Z5hYnJNWWIF3D4+e6tfeYViGPYm+uOC 2VC9Zr3ifTMYmKcMtAnhLupmgBYffgJyc2t+FbztX/bulxDRW40KBdrdLtdUsH0LCJ8+5NoIZaMRI UjhUkpIRyasMHN+vw7utqfQvLwQnlevQFAOf50Bzu0BXHRhNrUeLxJp/fy1bbwCRUPZtybGm1BLxW m5/4wzFIhwFGEpE9tLgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qkfwi-00DZDT-0x; Mon, 25 Sep 2023 07:23:56 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qkfwd-00DZ6W-0v for hostap@lists.infradead.org; Mon, 25 Sep 2023 07:23:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=pQlwD8YdNGtyiFvqzxGD7M0kXHqAtQf5Jv2ECNq16aE=; t=1695626631; x=1696836231; b=MGrwUXex8S7lhSziqS08bMKNb38rnDrLmAbXRx04vZOCSoJ HA5vUxXXnh9IbjkHjLRAXyOlFy8RN5H5V2P3k9aRbyKr7mnFRlJx+6FJv7XFYkM0WWdwC0qEkVuT5 CfrkKfHA06SmwGlwP8TkrU9fGl24ig+lH0t8kRrUunQX/yGLnR1PdL3Clzki6XXETjaRRlxi419YF 7danlzao1pIL0pNmTpkCLnxGGcbsfW3E7idhcWNWJ3Xa2U9BCjWKCnmVBbZEL1/+Ka1EWkCJ82rwv +2BcyXQx7ZqG/dB+0Nrzpf/O4mLc04Lqpymr25+i0fuZKpPD85czCIRUMUdGJ8CQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1qkfwb-003GZ8-0a; Mon, 25 Sep 2023 09:23:49 +0200 From: Johannes Berg To: hostap@lists.infradead.org Cc: Johannes Berg Subject: [RFC PATCH 1/2] netlink: add netlink_process_one_event() Date: Mon, 25 Sep 2023 09:22:51 +0200 Message-ID: <20230925092249.b1b61a303de8.If32fddf88f23f3939bb73bc6926aad7f88804079@changeid> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230925072249.53167-3-johannes@sipsolutions.net> References: <20230925072249.53167-3-johannes@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230925_002351_323022_5AA4E9C9 X-CRM114-Status: GOOD ( 13.61 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Johannes Berg Add a new function to (blockingly) read and process a single netlink event, to be used in driver_nl80211. Signed-off-by: Johannes Berg --- src/drivers/netlink.c | 21 ++++++++++++++++----- src/drivers/netlink.h | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg Add a new function to (blockingly) read and process a single netlink event, to be used in driver_nl80211. Signed-off-by: Johannes Berg --- src/drivers/netlink.c | 21 ++++++++++++++++----- src/drivers/netlink.h | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/drivers/netlink.c b/src/drivers/netlink.c index 7780479c3e91..a7a5c9dd8d1d 100644 --- a/src/drivers/netlink.c +++ b/src/drivers/netlink.c @@ -32,20 +32,19 @@ static void netlink_receive_link(struct netlink_data *netlink, NLMSG_PAYLOAD(h, sizeof(struct ifinfomsg))); } - -static void netlink_receive(int sock, void *eloop_ctx, void *sock_ctx) +static void _netlink_process_one_event(struct netlink_data *netlink, int wait_single) { - struct netlink_data *netlink = eloop_ctx; char buf[8192]; int left; struct sockaddr_nl from; socklen_t fromlen; struct nlmsghdr *h; - int max_events = 10; + int max_events = wait_single ? 1 : 10; try_again: fromlen = sizeof(from); - left = recvfrom(sock, buf, sizeof(buf), MSG_DONTWAIT, + left = recvfrom(netlink->sock, buf, sizeof(buf), + wait_single ? 0 : MSG_DONTWAIT, (struct sockaddr *) &from, &fromlen); if (left < 0) { if (errno != EINTR && errno != EAGAIN) @@ -88,6 +87,18 @@ try_again: } +void netlink_process_one_event(struct netlink_data *netlink) +{ + _netlink_process_one_event(netlink, 1); +} + + +static void netlink_receive(int sock, void *eloop_ctx, void *sock_ctx) +{ + _netlink_process_one_event(eloop_ctx, 0); +} + + struct netlink_data * netlink_init(struct netlink_config *cfg) { struct netlink_data *netlink; diff --git a/src/drivers/netlink.h b/src/drivers/netlink.h index 3a7340e51534..1e9d62c516ad 100644 --- a/src/drivers/netlink.h +++ b/src/drivers/netlink.h @@ -21,6 +21,7 @@ struct netlink_config { }; struct netlink_data * netlink_init(struct netlink_config *cfg); +void netlink_process_one_event(struct netlink_data *netlink); void netlink_deinit(struct netlink_data *netlink); int netlink_send_oper_ifla(struct netlink_data *netlink, int ifindex, int linkmode, int operstate);