From patchwork Thu May 30 19:19:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Dziedzic X-Patchwork-Id: 1941791 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=n0tMCICZ; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=L6sZxUpV; 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 4Vqx0572B1z23vC for ; Fri, 31 May 2024 05:19:48 +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=P5y+s5AAZBuobIBATOoBEx85OZ5Coz1eJ7Pp3RroVf0=; b=n0tMCICZM5/TmM YU4I7SmfeiJVJTdOmLaikcqSGoNm+Ube5jEAqPfMDlbbBVYDqWqlOO3ScNMT8jXa0Im0BuOGuNMKL K4VIdfwVVHiwFNvbjBTbX2mZkkJPPjIaMBpCkfidezWXzBcQTBgmHgSqdNR/9ug8aGIvz1qhWhQgx py98lwhePqdivpBmLSsGRTreg7qGyzPoMj6R1qWElYS/WOLgVXxuPgMaKcUIuDhLRbWWSonxIKB1h HZ+/b5DyLChy8iiza04KU+4KrVif3sgLfUYjxbRHidVyVCjRzS382XEG+tg7/teIEbp5pJWUpf3gr WnFQR2IyBvNaiyz4ozQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sClJ2-00000008CTV-2SSi; Thu, 30 May 2024 19:19:20 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sClIv-00000008CQs-2nUi for hostap@lists.infradead.org; Thu, 30 May 2024 19:19:16 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a66e9eac48fso62790066b.2 for ; Thu, 30 May 2024 12:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717096751; x=1717701551; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k58A8n5XNJB+guP5SRtd7deDfb/O6tcIkYFGTbciqC0=; b=L6sZxUpVEOaYek71OOIpR8lRKb7PpmBqBZ9u/9w6yynmngAll4CMik3JvS829tS6QJ xPte5K0SHKck5R7xyraDp7L4bS3CuvbbBtSkA4s7oqXjtRMAUFkmxVVSMkGwcRnMt6QM +kSG6PsIQ4PoLdDlaq0DVclZiIzFazEi9+N0JjufO/Bex9veFtWGEE7Q5OyewfffaanS cxGP4BSbceKeO9vNsxk6r44UACcVB9FWPEMs4UTt/DqLEmp4/eTXzCRg5wE52uyV+biZ tIf9eYwIL6swMShjQhSUov85+sZAfOe9W6yaY+nqtdWudRnbYmsbti1YRFsneGYm3M5Q s8hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717096751; x=1717701551; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k58A8n5XNJB+guP5SRtd7deDfb/O6tcIkYFGTbciqC0=; b=sZES/rfmJ4g18OzQ+5524lfoRDmI+d0yXAn75JQ/LCOG7duOp5TPjXvaFwD2odgqdj 6AlEjnTCGeDagIpUdLJ8sHKvD2z7ntxOVHhGTWDBMiVoCEMSJQC8ZoBncpPIaN7sz2de 5zG6FmYPP+BlMC6/ywiadS0+cZU3xXkebW0bLcedizVUO9CXjgJ8BHMkvkGj8BuqVfgM ievohCSKRfmr4+a3svQ9AjaF+qbNqLyEwt6agOqPG9qV2CvJvUc0y+V7c0gzpPGbUjbC pt8KOthnpIK5VSh+zoATZ2v6xwp4yJqNLyLQFZI5+FE00zSqBG9LeFv9sAjlNTCBVpzI XF6A== X-Gm-Message-State: AOJu0Yx0sDsUWkoD0F6r+8SU7Qj2Qhtp+53iWhb3gQikGiugbEkpq+Qk qRiWjy9nA6BLpJiKb3k7GK9/F2K//0+7FiHx+R4Lm+gdJlRWYabZIF+GRQ== X-Google-Smtp-Source: AGHT+IEsJeRJcxoL4YVFtvFBqZLt4r3EzQm5XsdTfN2tiwF5pB6v5Xj2hOt3wKiPkf7+LWa+viN4lw== X-Received: by 2002:a17:906:dcd:b0:a5a:f16:32b1 with SMTP id a640c23a62f3a-a65e8e41a68mr174454666b.31.1717096751391; Thu, 30 May 2024 12:19:11 -0700 (PDT) Received: from e850.NAT.swidnica_mmp.vectranet.pl (178235177153.dynamic-4-waw-k-1-1-0.vectranet.pl. [178.235.177.153]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67e73fc1a5sm6629666b.53.2024.05.30.12.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 12:19:11 -0700 (PDT) From: Janusz Dziedzic To: hostap@lists.infradead.org Cc: j@w1.fi, Janusz Dziedzic Subject: [PATCH v2 3/5] tests: hostapd: allow to use remote wpa_cli Date: Thu, 30 May 2024 21:19:02 +0200 Message-Id: <20240530191904.1426538-3-janusz.dziedzic@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240530191904.1426538-1-janusz.dziedzic@gmail.com> References: <20240530191904.1426538-1-janusz.dziedzic@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240530_121913_755894_8C1EA23A X-CRM114-Status: GOOD ( 11.12 ) 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: Signed-off-by: Janusz Dziedzic --- tests/hwsim/hostapd.py | 65 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index ebb2e328a..6f94c00e6 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -15,6 +15,7 @@ import wpaspy import remoteho [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:630 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [janusz.dziedzic(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. 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 Signed-off-by: Janusz Dziedzic --- tests/hwsim/hostapd.py | 65 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index ebb2e328a..6f94c00e6 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -15,6 +15,7 @@ import wpaspy import remotehost import utils import subprocess +from remotectrl import RemoteCtrl logger = logging.getLogger() hapd_ctrl = '/var/run/hostapd' @@ -28,12 +29,18 @@ class HostapdGlobal: try: hostname = apdev['hostname'] port = apdev['port'] + if 'remote_cli' in apdev: + remote_cli = apdev['remote_cli'] + else: + remote_cli = False except: hostname = None port = 8878 + remote_cli = False self.host = remotehost.Host(hostname) self.hostname = hostname self.port = port + self.remote_cli = remote_cli if hostname is None: global_ctrl = hapd_global if global_ctrl_override: @@ -42,9 +49,17 @@ class HostapdGlobal: self.mon = wpaspy.Ctrl(global_ctrl) self.dbg = "" else: - self.ctrl = wpaspy.Ctrl(hostname, port) - self.mon = wpaspy.Ctrl(hostname, port) - self.dbg = hostname + "/" + str(port) + if remote_cli: + global_ctrl = hapd_global + if global_ctrl_override: + global_ctrl = global_ctrl_override + self.ctrl = RemoteCtrl(global_ctrl, port, hostname=hostname) + self.mon = RemoteCtrl(global_ctrl, port, hostname=hostname) + self.dbg = hostname + "/global" + else: + self.ctrl = wpaspy.Ctrl(hostname, port) + self.mon = wpaspy.Ctrl(hostname, port) + self.dbg = hostname + "/" + str(port) self.mon.attach() def cmd_execute(self, cmd_array, shell=False): @@ -119,6 +134,9 @@ class HostapdGlobal: if self.hostname is None: return None + if self.remote_cli: + return None + res = self.request("INTERFACES ctrl") lines = res.splitlines() found = False @@ -147,17 +165,22 @@ class HostapdGlobal: class Hostapd: def __init__(self, ifname, bssidx=0, hostname=None, ctrl=hapd_ctrl, - port=8877): + port=8877, remote_cli=False): self.hostname = hostname self.host = remotehost.Host(hostname, ifname) self.ifname = ifname + self.remote_cli = remote_cli if hostname is None: self.ctrl = wpaspy.Ctrl(os.path.join(ctrl, ifname)) self.mon = wpaspy.Ctrl(os.path.join(ctrl, ifname)) self.dbg = ifname else: - self.ctrl = wpaspy.Ctrl(hostname, port) - self.mon = wpaspy.Ctrl(hostname, port) + if remote_cli: + self.ctrl = RemoteCtrl(ctrl, port, hostname=hostname, ifname=ifname) + self.mon = RemoteCtrl(ctrl, port, hostname=hostname, ifname=ifname) + else: + self.ctrl = wpaspy.Ctrl(hostname, port) + self.mon = wpaspy.Ctrl(hostname, port) self.dbg = hostname + "/" + ifname self.mon.attach() self.bssid = None @@ -638,22 +661,30 @@ def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30, try: hostname = apdev['hostname'] port = apdev['port'] - logger.info("Starting AP " + hostname + "/" + port + " " + ifname) + if 'remote_cli' in apdev: + remote_cli = apdev['remote_cli'] + else: + remote_cli = False + if 'global_ctrl_override' in apdev: + global_ctrl_override = apdev['global_ctrl_override'] + logger.info("Starting AP " + hostname + "/" + port + " " + ifname + " remote_cli " + str(remote_cli)) except: logger.info("Starting AP " + ifname) hostname = None port = 8878 + remote_cli = False else: ifname = apdev logger.info("Starting AP " + ifname + " (old add_ap argument type)") hostname = None port = 8878 + remote_cli = False hapd_global = HostapdGlobal(apdev, global_ctrl_override=global_ctrl_override) hapd_global.remove(ifname) hapd_global.add(ifname, driver=driver) port = hapd_global.get_ctrl_iface_port(ifname) - hapd = Hostapd(ifname, hostname=hostname, port=port) + hapd = Hostapd(ifname, hostname=hostname, port=port, remote_cli=remote_cli) if not hapd.ping(): raise Exception("Could not ping hostapd") hapd.set_defaults(set_channel=set_channel) @@ -688,17 +719,22 @@ def add_bss(apdev, ifname, confname, ignore_error=False): try: hostname = apdev['hostname'] port = apdev['port'] - logger.info("Starting BSS " + hostname + "/" + port + " phy=" + phy + " ifname=" + ifname) + if 'remote_cli' in apdev: + remote_cli = apdev['remote_cli'] + else: + remote_cli = False + logger.info("Starting BSS " + hostname + "/" + port + " phy=" + phy + " ifname=" + ifname + " remote_cli=" + str(remote_cli)) except: logger.info("Starting BSS phy=" + phy + " ifname=" + ifname) hostname = None port = 8878 + remote_cli = False hapd_global = HostapdGlobal(apdev) confname = cfg_file(apdev, confname, ifname) hapd_global.send_file(confname, confname) hapd_global.add_bss(phy, confname, ignore_error) port = hapd_global.get_ctrl_iface_port(ifname) - hapd = Hostapd(ifname, hostname=hostname, port=port) + hapd = Hostapd(ifname, hostname=hostname, port=port, remote_cli=remote_cli) if not hapd.ping(): raise Exception("Could not ping hostapd") return hapd @@ -708,17 +744,22 @@ def add_iface(apdev, confname): try: hostname = apdev['hostname'] port = apdev['port'] - logger.info("Starting interface " + hostname + "/" + port + " " + ifname) + if 'remote_cli' in apdev: + remote_cli = apdev['remote_cli'] + else: + remote_cli = False + logger.info("Starting interface " + hostname + "/" + port + " " + ifname + "remote_cli=" + str(remote_cli)) except: logger.info("Starting interface " + ifname) hostname = None port = 8878 + remote_cli = False hapd_global = HostapdGlobal(apdev) confname = cfg_file(apdev, confname, ifname) hapd_global.send_file(confname, confname) hapd_global.add_iface(ifname, confname) port = hapd_global.get_ctrl_iface_port(ifname) - hapd = Hostapd(ifname, hostname=hostname, port=port) + hapd = Hostapd(ifname, hostname=hostname, port=port, remote_cli=remote_cli) if not hapd.ping(): raise Exception("Could not ping hostapd") return hapd