From patchwork Tue Nov 14 16:04:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13455573 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E69DF41A8A for ; Tue, 14 Nov 2023 16:05:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="fTZhr45d" Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29AA1130 for ; Tue, 14 Nov 2023 08:05:36 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1ce28faa92dso18802425ad.2 for ; Tue, 14 Nov 2023 08:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1699977935; x=1700582735; darn=vger.kernel.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=PHrdXDFfscyFpONrVdySqTIzV7FdjofUrEPw5mpTz68=; b=fTZhr45dQ5WEWlGF3pumK35igSV0yHto6Evz+jOFE3+gRK6YPJuTkGp5JFlJEPpvXn QSSCWtYiBcEua4GzYHhq+trNhZ8bw/MmFx7RprsncJuetDGbbf+3HvPrkZStHOheLcVN sjCUS5mN/OOZuisphDD/1CeLzvk6da3ZkL7w2a3J3X0Jlzvfvdiqzpfa5TJEYEdVBSM2 CCoItK8nKW+ZO4KSuWwYxaSN+uxNZi38MT9ct3IIgg2A2KLn2u466SZEK8QNEB/qC14e HCC7cVsJRPlsz8dzseg3BffNkhD8WInEf3zJVH/9vRy2VQ7IOtOzkRyVwqqv/PWEA1TJ vl3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699977935; x=1700582735; 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=PHrdXDFfscyFpONrVdySqTIzV7FdjofUrEPw5mpTz68=; b=XscNd4YnpkZP/fxf8YBoaFSOlYUHAkIA4mtwzRXlNgbmU07LOL1mTKGdhgcncgneuK 3cLjIGt8O6NQj4k0EgOwZPW9ypTd3RAxKYoLgRlvzFF103pMK0ZgKZg3OOmjLj7x5w52 0uh2YfkBv6wdOrOv9x0ct3bjs8p1MXZLlPkpuZfPOUv2NPN1MDxJ8bJ9RiqG6ms5ZYgN UUayGNrU1OtgJtzA8cBjV0AIu4TYH4VB2JDhRwJP3NYrdjZ9q+ILgz4BDOSvqhd6xpG4 WdDVwyVu0/xsu7rPd8tIlPeWiQG3lbIgv9xJIJtOtJRxiWEkxfbRLG1l3CxCaMZyQ2LV 4+VQ== X-Gm-Message-State: AOJu0Ywu5hrB5SZgkJIINwnBbH3LSdZLLtU1ABRDBhVGM1FNxR6E4Q7A +8cYsVZQ68gepJZu50mPkaSL1d4lMQo5c5AOPIU= X-Google-Smtp-Source: AGHT+IFTRchxdTp7Iwe2c/CyehJowEuuBYe6EGowewzANTEbwkqSUbUOyvE2L85jLtkNtYIGp1WPHg== X-Received: by 2002:a17:902:a407:b0:1cc:3a8a:f19b with SMTP id p7-20020a170902a40700b001cc3a8af19bmr2465360plq.14.1699977935393; Tue, 14 Nov 2023 08:05:35 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:fa3f:3165:385:80b3]) by smtp.gmail.com with ESMTPSA id t16-20020a170902e85000b001c46d04d001sm5833048plg.87.2023.11.14.08.05.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 08:05:35 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, pctammela@mojatatu.com, victor@mojatatu.com Subject: [PATCH net-next 1/4] selftests: tc-testing: drop '-N' argument from nsPlugin Date: Tue, 14 Nov 2023 13:04:39 -0300 Message-Id: <20231114160442.1023815-2-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231114160442.1023815-1-pctammela@mojatatu.com> References: <20231114160442.1023815-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This argument would bypass the net namespace creation and run the test in the root namespace, even if nsPlugin was specified. Drop it as it's the same as commenting out the nsPlugin from a test and adds additional complexity to the plugin code. Signed-off-by: Pedro Tammela Reviewed-by: Simon Horman --- .../tc-testing/plugin-lib/nsPlugin.py | 49 +++++-------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py b/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py index b62429b0fcdb..2297b4568ca9 100644 --- a/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py +++ b/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py @@ -28,10 +28,7 @@ def prepare_suite(obj, test): shadow['DEV2'] = original['DEV2'] obj.args.NAMES = shadow - if obj.args.namespace: - obj._ns_create() - else: - obj._ports_create() + obj._ns_create() # Make sure the netns is visible in the fs while True: @@ -75,10 +72,7 @@ class SubPlugin(TdcPlugin): if self.args.verbose: print('{}.post_case'.format(self.sub_class)) - if self.args.namespace: - self._ns_destroy() - else: - self._ports_destroy() + self._ns_destroy() def post_suite(self, index): if self.args.verbose: @@ -93,24 +87,11 @@ class SubPlugin(TdcPlugin): subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - def add_args(self, parser): - super().add_args(parser) - self.argparser_group = self.argparser.add_argument_group( - 'netns', - 'options for nsPlugin(run commands in net namespace)') - self.argparser_group.add_argument( - '-N', '--no-namespace', action='store_false', default=True, - dest='namespace', help='Don\'t run commands in namespace') - return self.argparser - def adjust_command(self, stage, command): super().adjust_command(stage, command) cmdform = 'list' cmdlist = list() - if not self.args.namespace: - return command - if self.args.verbose: print('{}.adjust_command'.format(self.sub_class)) @@ -144,8 +125,6 @@ class SubPlugin(TdcPlugin): cmds.append(self._replace_keywords('link add $DEV0 type veth peer name $DEV1')) cmds.append(self._replace_keywords('link set $DEV0 up')) cmds.append(self._replace_keywords('link add $DUMMY type dummy')) - if not self.args.namespace: - cmds.append(self._replace_keywords('link set $DEV1 up')) return cmds @@ -161,18 +140,17 @@ class SubPlugin(TdcPlugin): def _ns_create_cmds(self): cmds = [] - if self.args.namespace: - ns = self.args.NAMES['NS'] + ns = self.args.NAMES['NS'] - cmds.append(self._replace_keywords('netns add {}'.format(ns))) - cmds.append(self._replace_keywords('link set $DEV1 netns {}'.format(ns))) - cmds.append(self._replace_keywords('link set $DUMMY netns {}'.format(ns))) - cmds.append(self._replace_keywords('netns exec {} $IP link set $DEV1 up'.format(ns))) - cmds.append(self._replace_keywords('netns exec {} $IP link set $DUMMY up'.format(ns))) + cmds.append(self._replace_keywords('netns add {}'.format(ns))) + cmds.append(self._replace_keywords('link set $DEV1 netns {}'.format(ns))) + cmds.append(self._replace_keywords('link set $DUMMY netns {}'.format(ns))) + cmds.append(self._replace_keywords('netns exec {} $IP link set $DEV1 up'.format(ns))) + cmds.append(self._replace_keywords('netns exec {} $IP link set $DUMMY up'.format(ns))) - if self.args.device: - cmds.append(self._replace_keywords('link set $DEV2 netns {}'.format(ns))) - cmds.append(self._replace_keywords('netns exec {} $IP link set $DEV2 up'.format(ns))) + if self.args.device: + cmds.append(self._replace_keywords('link set $DEV2 netns {}'.format(ns))) + cmds.append(self._replace_keywords('netns exec {} $IP link set $DEV2 up'.format(ns))) return cmds @@ -192,9 +170,8 @@ class SubPlugin(TdcPlugin): Destroy the network namespace for testing (and any associated network devices as well) ''' - if self.args.namespace: - self._exec_cmd('post', self._ns_destroy_cmd()) - self._ports_destroy() + self._exec_cmd('post', self._ns_destroy_cmd()) + self._ports_destroy() @cached_property def _proc(self): From patchwork Tue Nov 14 16:04:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13455574 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E55954174B for ; Tue, 14 Nov 2023 16:05:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="qd9FBdgA" Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D0D213D for ; Tue, 14 Nov 2023 08:05:39 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1cc329ce84cso51864685ad.2 for ; Tue, 14 Nov 2023 08:05:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1699977939; x=1700582739; darn=vger.kernel.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=zfiY4VVFwJ9EGOwG+Y4qOUyYuus4s/HFryh1H4Lv07U=; b=qd9FBdgABGC1TgWB32Xhae29IjdcUVoS7ets1qhlh/pmqZjL5AGRj6YA2bUxPk8YE9 dlS9CLi1CKHM1/RbRLph/rHCRQ7OZmNZM7B3Usau+T3pk3qu7720l/QSPHGjIWAHRl4n LPj4gEKViEYHlmy7nQ7UStkyP/rERoLLGuuaEuY9qtkJwPMj/35GaMveDbGXlGvdcNDs SSdkUsTC3vVDypHptCnL+/grSvqvjeBQjFyrl+U6V7M0z/Brze2jVHEUbgAbfjSzwuTn UP7iDoEaElKJmjBtku69wLZ8Mr0hyqJ7EvptzTb0ejN+XPjvXxUOx7QUhjqML4xY5Zzi rOrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699977939; x=1700582739; 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=zfiY4VVFwJ9EGOwG+Y4qOUyYuus4s/HFryh1H4Lv07U=; b=Qbhq8HT5o1R8eRZhkMi0ycguWmzSVXbL/VkaETPfsKG8tL+L3imHG/Nfrmr/QwT6Hs OYuUx1gggC+cT+mT9WTgb9RvsLAyVDGMRoTLCMyOClV5619Xos+Zi2jgCHnUc4b19aLg wOwRfWYX3QE+MVsZvkL6qDuJb8vNmykX7H81zXbz3p5HiJsGqDTmtY75Z8y467cl/0S5 lHTEprQiOBaKA3baZUk85Q0jCMnMCLMROZJUIgl2idtQgCN9/x2Kn6G7ZgfLkg1+8Qha V6IHebqUzgsra1WBYiO+/V9S2fUUlt6NhHAWbRscVjxn5+T6rd2LPKbKGTFgGWYXLG8U hjWQ== X-Gm-Message-State: AOJu0Yyt5JWfwhAixkokykpd8cFGfLUho/mgAGpw6D7zULA9hz5k7fWb azCb1MxsLwM/FOHNXj8mtJryeQk44X+EqnWSP+k= X-Google-Smtp-Source: AGHT+IGMmaDK/L3Fu31bdemtqGN3xA9KIERntESyCN1g0Zi0q0R70gqRc5iNT3RrvcNuy4yRZDwzmQ== X-Received: by 2002:a17:902:e84a:b0:1cc:6a09:a495 with SMTP id t10-20020a170902e84a00b001cc6a09a495mr2987047plg.44.1699977938667; Tue, 14 Nov 2023 08:05:38 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:fa3f:3165:385:80b3]) by smtp.gmail.com with ESMTPSA id t16-20020a170902e85000b001c46d04d001sm5833048plg.87.2023.11.14.08.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 08:05:38 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, pctammela@mojatatu.com, victor@mojatatu.com Subject: [PATCH net-next 2/4] selftests: tc-testing: rework namespaces and devices setup Date: Tue, 14 Nov 2023 13:04:40 -0300 Message-Id: <20231114160442.1023815-3-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231114160442.1023815-1-pctammela@mojatatu.com> References: <20231114160442.1023815-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org As mentioned in the TC Workshop 0x17, our recent changes to tdc broke downstream CI systems like tuxsuite. The issue is the classic problem with rcu/workqueue objects where you can miss them if not enough wall time has passed. The latter is subjective to the system and kernel config, in my machine could be nanoseconds while in another could be microseconds or more. In order to make the suite deterministic, poll for the existence of the objects in a reasonable manner. Talking netlink directly is the the best solution in order to avoid paying the cost of multiple 'fork()' calls, so introduce a netlink based setup routine using pyroute2. We leave the iproute2 one as a fallback when pyroute2 is not available. Also rework the iproute2 side to mimic the netlink routine where it creates DEV0 as the peer of DEV1 and moves DEV1 into the net namespace. This way when the namespace is deleted DEV0 is also deleted automatically, leaving no margin for resource leaks. Another bonus of this change is that our setup time sped up by a factor of 2 when using netlink. Signed-off-by: Pedro Tammela Reviewed-by: Simon Horman --- .../tc-testing/plugin-lib/nsPlugin.py | 69 +++++++++++++------ 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py b/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py index 2297b4568ca9..62974bd3a4a5 100644 --- a/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py +++ b/tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py @@ -9,6 +9,14 @@ from TdcPlugin import TdcPlugin from tdc_config import * +try: + from pyroute2 import netns + from pyroute2 import IPRoute + netlink = True +except ImportError: + netlink = False + print("!!! Consider installing pyroute2 !!!") + def prepare_suite(obj, test): original = obj.args.NAMES @@ -28,7 +36,10 @@ def prepare_suite(obj, test): shadow['DEV2'] = original['DEV2'] obj.args.NAMES = shadow - obj._ns_create() + if netlink == True: + obj._nl_ns_create() + else: + obj._ns_create() # Make sure the netns is visible in the fs while True: @@ -67,7 +78,6 @@ class SubPlugin(TdcPlugin): if test_skip: return - def post_case(self): if self.args.verbose: print('{}.post_case'.format(self.sub_class)) @@ -119,23 +129,41 @@ class SubPlugin(TdcPlugin): print('adjust_command: return command [{}]'.format(command)) return command - def _ports_create_cmds(self): - cmds = [] + def _nl_ns_create(self): + ns = self.args.NAMES["NS"]; + dev0 = self.args.NAMES["DEV0"]; + dev1 = self.args.NAMES["DEV1"]; + dummy = self.args.NAMES["DUMMY"]; - cmds.append(self._replace_keywords('link add $DEV0 type veth peer name $DEV1')) - cmds.append(self._replace_keywords('link set $DEV0 up')) - cmds.append(self._replace_keywords('link add $DUMMY type dummy')) - - return cmds - - def _ports_create(self): - self._exec_cmd_batched('pre', self._ports_create_cmds()) - - def _ports_destroy_cmd(self): - return self._replace_keywords('link del $DEV0') - - def _ports_destroy(self): - self._exec_cmd('post', self._ports_destroy_cmd()) + if self.args.verbose: + print('{}._nl_ns_create'.format(self.sub_class)) + + netns.create(ns) + netns.pushns(newns=ns) + with IPRoute() as ip: + ip.link('add', ifname=dev1, kind='veth', peer={'ifname': dev0, 'net_ns_fd':'/proc/1/ns/net'}) + ip.link('add', ifname=dummy, kind='dummy') + while True: + try: + dev1_idx = ip.link_lookup(ifname=dev1)[0] + dummy_idx = ip.link_lookup(ifname=dummy)[0] + ip.link('set', index=dev1_idx, state='up') + ip.link('set', index=dummy_idx, state='up') + break + except: + time.sleep(0.1) + continue + netns.popns() + + with IPRoute() as ip: + while True: + try: + dev0_idx = ip.link_lookup(ifname=dev0)[0] + ip.link('set', index=dev0_idx, state='up') + break + except: + time.sleep(0.1) + continue def _ns_create_cmds(self): cmds = [] @@ -143,10 +171,13 @@ class SubPlugin(TdcPlugin): ns = self.args.NAMES['NS'] cmds.append(self._replace_keywords('netns add {}'.format(ns))) + cmds.append(self._replace_keywords('link add $DEV1 type veth peer name $DEV0')) cmds.append(self._replace_keywords('link set $DEV1 netns {}'.format(ns))) + cmds.append(self._replace_keywords('link add $DUMMY type dummy'.format(ns))) cmds.append(self._replace_keywords('link set $DUMMY netns {}'.format(ns))) cmds.append(self._replace_keywords('netns exec {} $IP link set $DEV1 up'.format(ns))) cmds.append(self._replace_keywords('netns exec {} $IP link set $DUMMY up'.format(ns))) + cmds.append(self._replace_keywords('link set $DEV0 up'.format(ns))) if self.args.device: cmds.append(self._replace_keywords('link set $DEV2 netns {}'.format(ns))) @@ -159,7 +190,6 @@ class SubPlugin(TdcPlugin): Create the network namespace in which the tests will be run and set up the required network devices for it. ''' - self._ports_create() self._exec_cmd_batched('pre', self._ns_create_cmds()) def _ns_destroy_cmd(self): @@ -171,7 +201,6 @@ class SubPlugin(TdcPlugin): devices as well) ''' self._exec_cmd('post', self._ns_destroy_cmd()) - self._ports_destroy() @cached_property def _proc(self): From patchwork Tue Nov 14 16:04:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13455575 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38A4341A96 for ; Tue, 14 Nov 2023 16:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="Bbpe7Klt" Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD6112C for ; Tue, 14 Nov 2023 08:05:42 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1cc3bb32b5dso51595375ad.3 for ; Tue, 14 Nov 2023 08:05:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1699977942; x=1700582742; darn=vger.kernel.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=gwMnw/NInSlyVCXH0aLYAutfComTPi7viklnzsawBKE=; b=Bbpe7KltVz/VDwKB0jlbhOrkq/ZXhhFE6g96fH1f0U4c5X5PVkomy8tAZxYO7CHFwZ ZhwR/flly/KjbuheWnL3eiLcMRcg5ho38Cf5y7wuHIjf3uGnlYq6iXVMMEuYuLueBszk 69FAUyQn6kdajQ2C7jYsvKsLgOlFZZagbfxiy393ATWpXspd26YPJ6KLdW7BoSkhvZ38 Imri4PiVx5pHZIfHbKSbFeu3xep3LNQDS3YhNZSzjjnTz/1sS9uFUCU7MNbi7jPgVxwL g5iK609b3l1auSxPyCi96plW1maz6MjK6QcWeLr5nNLg6X0Bs1IQD0G4Krl2fG6g3DbM fYpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699977942; x=1700582742; 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=gwMnw/NInSlyVCXH0aLYAutfComTPi7viklnzsawBKE=; b=tMT8B2BEikCHWiGi2x32QpY1vFmdio+tBu3mV+iLpJRdlA8OFbApPr7Th0GxeCWmEh iuZYmsnqgdZlhhqod48DzY5DkP4jpqobFKKoslrGvnEgywsnN52KpbehR6oe3AnOgfba OPnriiFzNeA2NcCHJ+yuhHK41hwKaui4keP3OtMKL+LoW91NqcvAB8QrrcmujQwvsm3u Sd/Ej+uTrVPrxyqyKPxn+N4tkGQp6ToAlcSkR2JDjtoCz4FipArI7GT3lXm++qJJZMqL /XqGWu2C6d+LgOxvtoNrrurQxraJLTFN2vayHfWvMUQEGZQscMyHy1qEV3eQRZcqsnDW 7utA== X-Gm-Message-State: AOJu0YyAdhJZmOjhMC5pA3neVSLVSqHw/vkBbTKRTwtUn5ssAcRHg5Q9 Rgo/iNH+vtVe8JfpDx5U/K0ISdNg5B0tT9YNfwY= X-Google-Smtp-Source: AGHT+IHmA4VURn9OSeOirFAqOJABH+8KZmMenEN0bY/EuuEAzNRkJUWY/ilfdaOLl155MzbEKGxz+A== X-Received: by 2002:a17:902:ce90:b0:1cc:787f:fb7 with SMTP id f16-20020a170902ce9000b001cc787f0fb7mr3569642plg.19.1699977941956; Tue, 14 Nov 2023 08:05:41 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:fa3f:3165:385:80b3]) by smtp.gmail.com with ESMTPSA id t16-20020a170902e85000b001c46d04d001sm5833048plg.87.2023.11.14.08.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 08:05:41 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, pctammela@mojatatu.com, victor@mojatatu.com Subject: [PATCH net-next 3/4] selftests: tc-testing: preload all modules in kselftests Date: Tue, 14 Nov 2023 13:04:41 -0300 Message-Id: <20231114160442.1023815-4-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231114160442.1023815-1-pctammela@mojatatu.com> References: <20231114160442.1023815-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org While running tdc tests in parallel it can race over the module loading done by tc and fail the run with random errors. So avoid this by preloading all modules before running tdc in kselftests. Signed-off-by: Pedro Tammela Reviewed-by: Simon Horman --- tools/testing/selftests/tc-testing/tdc.sh | 65 ++++++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/tc-testing/tdc.sh b/tools/testing/selftests/tc-testing/tdc.sh index eb357bd7923c..ae08b7a47c42 100755 --- a/tools/testing/selftests/tc-testing/tdc.sh +++ b/tools/testing/selftests/tc-testing/tdc.sh @@ -1,7 +1,68 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 -modprobe netdevsim -modprobe sch_teql +# If a module is required and was not compiled +# the test that requires it will fail anyways +try_modprobe() { + modprobe -q -R "$1" + if [ $? -ne 0 ]; then + echo "Module $1 not found... skipping." + else + modprobe "$1" + fi +} + +try_modprobe netdevsim +try_modprobe act_bpf +try_modprobe act_connmark +try_modprobe act_csum +try_modprobe act_ct +try_modprobe act_ctinfo +try_modprobe act_gact +try_modprobe act_gate +try_modprobe act_ipt +try_modprobe act_mirred +try_modprobe act_mpls +try_modprobe act_nat +try_modprobe act_pedit +try_modprobe act_police +try_modprobe act_sample +try_modprobe act_simple +try_modprobe act_skbedit +try_modprobe act_skbmod +try_modprobe act_tunnel_key +try_modprobe act_vlan +try_modprobe cls_basic +try_modprobe cls_bpf +try_modprobe cls_cgroup +try_modprobe cls_flow +try_modprobe cls_flower +try_modprobe cls_fw +try_modprobe cls_matchall +try_modprobe cls_route +try_modprobe cls_u32 +try_modprobe em_canid +try_modprobe em_cmp +try_modprobe em_ipset +try_modprobe em_ipt +try_modprobe em_meta +try_modprobe em_nbyte +try_modprobe em_text +try_modprobe em_u32 +try_modprobe sch_cake +try_modprobe sch_cbs +try_modprobe sch_choke +try_modprobe sch_codel +try_modprobe sch_drr +try_modprobe sch_etf +try_modprobe sch_ets +try_modprobe sch_fq +try_modprobe sch_fq_codel +try_modprobe sch_fq_pie +try_modprobe sch_gred +try_modprobe sch_hfsc +try_modprobe sch_hhf +try_modprobe sch_htb +try_modprobe sch_teql ./tdc.py -c actions --nobuildebpf ./tdc.py -c qdisc From patchwork Tue Nov 14 16:04:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13455576 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD3A141A99 for ; Tue, 14 Nov 2023 16:05:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="HOHakC3R" Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD8FB130 for ; Tue, 14 Nov 2023 08:05:45 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1cc5b6d6228so37022355ad.2 for ; Tue, 14 Nov 2023 08:05:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1699977945; x=1700582745; darn=vger.kernel.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=xhHfdkW2/Y1xfD2GKm3JgoAOLUVQZBd2aUZA20+v5Vg=; b=HOHakC3R5wlvubsSt5+kTEcndbdHvOwLIL7D9sKuJwpyYRuwf/BIiqbc79SWi7UOnE nVvewnWltnD6Esw/JJdzTJjIzrTBaqZ+va0/qlQo0PnH2vQa3HOk0nYAk4EDPKRAGISn vo4QNWH9QVQEei8QvtC12aP2VTBtqMxh5bv6xTyDMbUdGnRMug6aOMHNnXI7N6ZFaq6g v8GKhsWfFmtDA8uaA3Yx4yIqQ43D5QmPL7ogf/z4DcdW+NIDmi7/ZPDl/YHuYWAr1DIU Nob/6kA3pYWu7NRAUpiX9wGyRm/CgpV6fyWeUf6/tU4kEYsqrxaat7bnlIjZxNba7VwT m81A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699977945; x=1700582745; 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=xhHfdkW2/Y1xfD2GKm3JgoAOLUVQZBd2aUZA20+v5Vg=; b=nc15rWuvp4vtByEBhB52O+6RBZL7TCXbWyuB5VfX3si8hHmSpoH8hBSedvo0zvyfMO wIDMLd0xRB0hl7J8CaiBCXeyCjmCfh0ae/9ZsFyz0T3CNag4MKJqfVZon8uyQbzq702Q Bo9Ybqir5HXkF++xzohMDW+hnvSfeFJPaVyvebQJb7velToLcCM67u3b2P7dKn29PfL+ 5d0eJ+1KcNgI0+0ALUxoFx6bobzK7IdunYsxtOk350Ae0oMlSzGJT6DXi4lrNKXTr4e8 Z8GP79qPhmdYny77KLsyzbO8NhaLDu9hzzZ/BNYM3mwW+gxcSV35M/PjFUaYsTZu3KIK CiZg== X-Gm-Message-State: AOJu0Yy8qwFRRsjpZwo6h7ctcniJb8XS7+BEEFGQKhLz+ZL+2Xl5nYk0 QZIKHBe6ahvDk+HA2HjX+b53bg5izl+d/GozvRY= X-Google-Smtp-Source: AGHT+IGdqIkKhhM4KryQwXZBnbATQnB5BzGQXNG1aNLGHFRIuCg52G877Lg0eFrdhEiYpXDSh1z50g== X-Received: by 2002:a17:903:1247:b0:1cc:52ca:2e01 with SMTP id u7-20020a170903124700b001cc52ca2e01mr3288855plh.16.1699977945186; Tue, 14 Nov 2023 08:05:45 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:fa3f:3165:385:80b3]) by smtp.gmail.com with ESMTPSA id t16-20020a170902e85000b001c46d04d001sm5833048plg.87.2023.11.14.08.05.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 08:05:44 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, pctammela@mojatatu.com, victor@mojatatu.com Subject: [PATCH net-next 4/4] selftests: tc-testing: use parallel tdc in kselftests Date: Tue, 14 Nov 2023 13:04:42 -0300 Message-Id: <20231114160442.1023815-5-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231114160442.1023815-1-pctammela@mojatatu.com> References: <20231114160442.1023815-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Leverage parallel tests in kselftests using all the available cpus. We tested this in tuxsuite and locally extensively and it seems it's ready for prime time. Signed-off-by: Pedro Tammela Reviewed-by: Simon Horman --- tools/testing/selftests/tc-testing/tdc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/tc-testing/tdc.sh b/tools/testing/selftests/tc-testing/tdc.sh index ae08b7a47c42..4dbe50bde5a0 100755 --- a/tools/testing/selftests/tc-testing/tdc.sh +++ b/tools/testing/selftests/tc-testing/tdc.sh @@ -64,5 +64,5 @@ try_modprobe sch_hfsc try_modprobe sch_hhf try_modprobe sch_htb try_modprobe sch_teql -./tdc.py -c actions --nobuildebpf -./tdc.py -c qdisc +./tdc.py -J`nproc` -c actions --nobuildebpf +./tdc.py -J`nproc` -c qdisc