From patchwork Thu May 4 21:52:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13231873 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D606C133 for ; Thu, 4 May 2023 21:52:53 +0000 (UTC) Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-61af33bdf1dso5398466d6.2 for ; Thu, 04 May 2023 14:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683237172; x=1685829172; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=d/Yt7HY6cejcOsUV6ARcKNMru60mwklhN1QVrjN7Khw=; b=ZSwjmqLlC19J2fOJsZY60KqyFoRaDVR1qpMyDt7defniuqAQSMUrRRzf13D9JM1lf9 pINtS5kN5SIKbI9V5QxNsNUPBN4IexMYfVKZUMl3L/Ve/MIr1iwDOl5ZDHmxywLN1vn7 CmNZiSZIMb6AQmZ3LQiP8LZ0fo8kcT5FF1zZ+J6ZCkqcDGAox/BbFGkpCkotPoxbafZq VZ9rBydlqbjurR5lKg8XLlmqy7lST2FgunxvRl1T7sht/cLR5BkvqV0xpozyH0eP4APP z7Ckpf+fm2SfH3gfRozbnaVfepPUlb8p/HPkEFIRyh4yPMEGt8aLTcCSpMOKdz6ozaDL ycQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683237172; x=1685829172; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d/Yt7HY6cejcOsUV6ARcKNMru60mwklhN1QVrjN7Khw=; b=TVEB4p94Dh50n0+HK7Dcu95m52VsvdTaL17zI0BO//MO7PBNNjl0LPo0WQgr65gllf PGGVXizxxHUugmEyG5X4QdODkgPZr3L2C9TzErc7LKvt1MLGuyJc5EFrujRtZcCqXxrn KQiMucgjEjHXm0xxc16TYEKYETA+hZw0g/A5ZqdIN5NwKWctTY/KzF+czWFBV5tOFyJQ g3VlFk1dwnQOsjxMMTBdFjj/+xg5Bt8ZzIYXFxD1Ehmsbu/a57emO50nT5YEcgn3K1T3 2aFSxJUub17i0pJplxm4YQSV4gPUAs2xSJJT8CU9D7a636SyGQEw/oEf7ootz8n4Lv1r VVQA== X-Gm-Message-State: AC+VfDyDz/Hiw9RcBwy6U0PwApbqsB0ALcNVpkbekVjI2u/TXalB1Ag5 tXprlMfTK7GpMM+gy3LvRJCV+cOaGNg= X-Google-Smtp-Source: ACHHUZ58huyNJxa5yVDJbt4anlB9j3YmOmFBHKBEgrs3edDYEjNODPQ1sUN0v88YY3xod8d4uBNEag== X-Received: by 2002:a05:6214:2689:b0:5cc:277c:b5e with SMTP id gm9-20020a056214268900b005cc277c0b5emr17715375qvb.33.1683237171871; Thu, 04 May 2023 14:52:51 -0700 (PDT) Received: from LOCLAP699.rst-02.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id v9-20020a0cdd89000000b0061b5b399d1csm52262qvk.104.2023.05.04.14.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 14:52:51 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 1/3] hwsim: remove 'optimization' sending to only known MACs Date: Thu, 4 May 2023 14:52:45 -0700 Message-Id: <20230504215247.581443-1-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Based on the comment hwsim would only send frames to known MACs which on its face seems reasonable. But in reality there shouldn't ever be frames going to unknown MACs, at least not unknown to the kernel. We can hit this case, though, when using network namespaces. Each namespace is siloed and hwsim instances only know about radios in that namespace. In order to support hwsim and namespaces, this restriction is being removed. --- tools/hwsim.c | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/tools/hwsim.c b/tools/hwsim.c index 47352ad4..10a9db5f 100644 --- a/tools/hwsim.c +++ b/tools/hwsim.c @@ -1501,43 +1501,10 @@ static void process_frame(struct hwsim_frame *frame) struct send_frame_info *send_info; bool drop = drop_mcast; uint32_t delay = 0; - const struct l_queue_entry *i; if (radio == frame->src_radio) continue; - /* - * The kernel hwsim medium passes multicast frames to all - * radios that are on the same frequency as this frame but - * the netlink medium API only lets userspace pass frames to - * radios by known hardware address. It does check that the - * receiving radio is on the same frequency though so we can - * send to all known addresses. - * - * If the frame's Receiver Address (RA) is a multicast - * address, then send the frame to every radio that is - * registered. If it's a unicast address then optimize - * by only forwarding the frame to the radios that have - * at least one interface with this specific address. - */ - if (!util_is_broadcast_address(frame->dst_ether_addr)) { - for (i = l_queue_get_entries(interface_info); - i; i = i->next) { - struct interface_info_rec *interface = i->data; - - if (interface->radio_rec != radio) - continue; - - if (!memcmp(interface->addr, - frame->dst_ether_addr, - ETH_ALEN)) - break; - } - - if (!i) - continue; - } - process_rules(frame->src_radio, radio, frame, false, &drop, &delay); From patchwork Thu May 4 21:52:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13231874 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A236C149 for ; Thu, 4 May 2023 21:52:54 +0000 (UTC) Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-74e07c2ee30so51140585a.1 for ; Thu, 04 May 2023 14:52:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683237173; x=1685829173; 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=IQuDwq4QcohWCNMiI2T2pNurGlqXf1VPAOlysnx3BpA=; b=S2FxDCxR/PJJcakKFzou1cZ4K2PAu0GZUWUO3o77W5gWwMKh5YQ0gNtuYBMf7abIDc wh+gIRW69BAF0offLymkmY4zaOog/zvFx8rqy7IaMdgkgVL5oS9sZgHS3Q4nBwHuLmSK qPL2oFy9Nl4gO3qlI6t5vbE/BMy2qpjDNIxH3cuVDIP1akk1T/EP6+9Uie+tH1o3QSNA 8WYENPMMhQgpxIWBCwy4dbR/ijqovE/tm/cHCGv1Lzois6mTfyj29bXyj0GAsQe92H4l XaU9YmBGjpnGW23T4iuNsO0wkJnSMVDJUuRrbgY+JhbS2rzNrHvnqo1G4/p8ltkFPLrq 2Wlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683237173; x=1685829173; 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=IQuDwq4QcohWCNMiI2T2pNurGlqXf1VPAOlysnx3BpA=; b=UXuwNQfxbALnttiLvwdqnWPOOyPb7P5IyFUSdZJOnhrOdXiBOFgBltbuP04sl7YBR9 eDvxIVEZ5g5J0KYl09erqJzkykELiMbRo7aAQVNEM2nNFUqsHR2qOVGIZwIrwBOD+n7n kAN5oUjdYt8o8vW+pSKeEfpcNmlAmKcB5i6G/OXI1nM/zxZlxRkwg2BYuh4/ZOapCLDS TLbMiyKWcspbjUyELJyLh55O5qOOgl0uA0jkF0lawj1n60BSPddIjGvV39mdyzj4b5k/ WbNP85hGDwutQJo6htrVbdk0junVDfFvK61sbH43XJlEoFYluvQmzJ71mjLMxBI/LGvy ZJ4Q== X-Gm-Message-State: AC+VfDwQyUhKZnU3xQjxrzLUNYLa8dS5Px2jFqQPMnAkuvi6vbOlM8F5 7fNvE4gXgV3sEPRTBRxzemi4RdJWPJg= X-Google-Smtp-Source: ACHHUZ4BF8SPR8O5Q1iyfni3apQwE7ssQ9ov6MUhsklTqX6w/18mJCa9rE6fux6GGGfUUjK+Z1VlZA== X-Received: by 2002:ad4:5fca:0:b0:5ef:5138:1e5d with SMTP id jq10-20020ad45fca000000b005ef51381e5dmr18637014qvb.49.1683237173036; Thu, 04 May 2023 14:52:53 -0700 (PDT) Received: from LOCLAP699.rst-02.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id v9-20020a0cdd89000000b0061b5b399d1csm52262qvk.104.2023.05.04.14.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 14:52:52 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 2/3] test-runner: allow hwsim in namespaces Date: Thu, 4 May 2023 14:52:46 -0700 Message-Id: <20230504215247.581443-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230504215247.581443-1-prestwoj@gmail.com> References: <20230504215247.581443-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Starts the hwsim daemon per-namespace rather than only in the root namespace. --- tools/run-tests | 16 ++++++++-------- tools/utils.py | 13 ++++++++++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/tools/run-tests b/tools/run-tests index 32c09723..ef316666 100755 --- a/tools/run-tests +++ b/tools/run-tests @@ -319,6 +319,7 @@ class TestContext(Namespace): self.namespaces = [] self._last_mem_available = 0 self._mem_chart = BarChart() + self.register_hwsim = False; def start_dbus_monitor(self): if not Process.is_verbose('dbus-monitor'): @@ -329,18 +330,16 @@ class TestContext(Namespace): def start_haveged(self): self.start_process(['haveged', '-F']) + def start_hwsim(self): + self.register_hwsim = self.hw_config['SETUP'].get('hwsim_medium', 'no') in ['no', '0', 'false'] + + super().start_hwsim(self.register_hwsim) + def create_radios(self): setup = self.hw_config['SETUP'] nradios = int(setup['num_radios']) args = ['hwsim'] - if self.hw_config['SETUP'].get('hwsim_medium', 'no') in ['no', '0', 'false']: - # register hwsim as medium - args.extend(['--no-register']) - - proc = self.start_process(args) - proc.wait_for_service(self, 'net.connman.hwsim', 20) - for i in range(nradios): name = 'rad%u' % i @@ -524,7 +523,7 @@ class TestContext(Namespace): # Remove radios from 'root' namespace self.radios = list(set(self.radios) - set(radios)) - self.namespaces.append(Namespace(self.args, key, radios)) + self.namespaces.append(Namespace(self.args, key, radios, self.register_hwsim)) def get_namespace(self, ns): for n in self.namespaces: @@ -865,6 +864,7 @@ def pre_test(ctx, test, copied): ctx.start_dbus() ctx.start_haveged() ctx.start_dbus_monitor() + ctx.start_hwsim() ctx.start_radios() ctx.create_namespaces() ctx.start_hostapd() diff --git a/tools/utils.py b/tools/utils.py index a07c3183..d2e1c33b 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -320,7 +320,7 @@ busconfig.dtd\"> ''' class Namespace: - def __init__(self, args, name, radios): + def __init__(self, args, name, radios, hwsim_register=False): self.dbus_address = None self.name = name self.radios = radios @@ -331,6 +331,7 @@ class Namespace: r.set_namespace(self) self.start_dbus() + self.start_hwsim(register=hwsim_register) def reset(self): self._bus = None @@ -458,6 +459,16 @@ class Namespace: return proc + def start_hwsim(self, register=False): + args = ['hwsim'] + + if register: + # register hwsim as medium + args.extend(['--no-register']) + + proc = self.start_process(args) + proc.wait_for_service(self, 'net.connman.hwsim', 20) + @staticmethod def non_block_wait(func, timeout, *args, exception=True): ''' From patchwork Thu May 4 21:52:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13231875 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79F8CC133 for ; Thu, 4 May 2023 21:52:55 +0000 (UTC) Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-61a35fdf61dso4969926d6.2 for ; Thu, 04 May 2023 14:52:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683237174; x=1685829174; 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=qVEzcMbtCFwrxQbeXo/PeVPLuMaklYLmcNuMwDsP/3I=; b=FoMZ2dVq/18D3MPB98A9IjKft1sfjtfj4+JWokPgfxVf97Ofg1zgJkFC+USgXtW4eh CBt5SsLuouKO58hT4DF9l4ziWkyafHKr/nKwBtpO7cJHH/pWT6+bpjubVrQAiano10d5 lMjBvNI7jbz1VhD9JmzEvr6EpfiIna0E8MMqqVZSm1USs4anvefxwDDu1VEyBmieZ/4I q01+eS+2Uo9L+HsKbCO0CcS39i0ozomRNfpVMGckubLxYywyz+FP2BkXEj9CBz/ZjUW6 59IuBOOy33s58/ACVv+C513up7aFi28bAZI2Z+2p9OTcHAGX7nT0ZXAq869UXz5hXaoy o9wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683237174; x=1685829174; 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=qVEzcMbtCFwrxQbeXo/PeVPLuMaklYLmcNuMwDsP/3I=; b=KOU83LbYYezpb59e9L5oH5XH1slBsrTiu8OnAxyz9HsD1ndixHe/2+zHNDD7jO2QFT /nfbH4ldt6EdyngiaQxII/oCbAPmcv5W8qixeAIeoALgzzgi6G+clW6jINRKTaNikWmR do6nYyFoka08+XTPDv1+xZXPo/wi5pmuvK55UXNZJ2DIYv/h2R6anWdAT5EuIOByCQuX L/w1t9R0GPu3xfY9Af4KVB0urwD/xRwzUiu4TDKbyhDoKrlVK1pfPbA54KUyNADp2Akz a/983Tcg6WFa5Dn4niw0XRNFNvZqrndNv0sgE/HUJaSGGMTvxWT1DZ/+bKFuktac7Rpn o2RQ== X-Gm-Message-State: AC+VfDwDKSSh+AesbmGeb+P5gAdHoMaVURX5SZTHKO4lynrmZY14ZNOM VOs17LrlZmg/PmyTvUEg5Q9EWTpz/J0= X-Google-Smtp-Source: ACHHUZ4Ptfpt3hDZkl0hXnVlkMXA/MeQf+/lwbDohb7gSTmBMgT4rRLro7YfnyBNF5CIH0n6K2PluA== X-Received: by 2002:a05:6214:3009:b0:61b:65f9:c1e6 with SMTP id ke9-20020a056214300900b0061b65f9c1e6mr16641624qvb.17.1683237174135; Thu, 04 May 2023 14:52:54 -0700 (PDT) Received: from LOCLAP699.rst-02.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id v9-20020a0cdd89000000b0061b5b399d1csm52262qvk.104.2023.05.04.14.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 14:52:53 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 3/3] test-runner: fix __str__ for namespace processes Date: Thu, 4 May 2023 14:52:47 -0700 Message-Id: <20230504215247.581443-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230504215247.581443-1-prestwoj@gmail.com> References: <20230504215247.581443-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When printing out a namespace the Process.get_all() call was returning all processes running, even those not in the namespace being printed. Modifying get_all() is tricky since its a class method (and used elsewhere for ALL processes) so instead filter the results to only show processes in the namespace being printed. --- tools/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/utils.py b/tools/utils.py index d2e1c33b..48d5d219 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -529,7 +529,8 @@ class Namespace: ret = 'Namespace: %s\n' % self.name ret += 'Processes:\n' for p in Process.get_all(): - ret += '\t%s' % str(p) + if p.namespace == self.name: + ret += '\t%s' % str(p) ret += 'Radios:\n' if len(self.radios) > 0: