Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1947731ima; Thu, 25 Oct 2018 07:25:31 -0700 (PDT) X-Google-Smtp-Source: AJdET5fJauE5Ou99/Fw1D4F2di9ihzkagQpairWeod3tfoemPg0youLvxeVSHRXHMAPDTvnG4YVI X-Received: by 2002:a63:8c0b:: with SMTP id m11-v6mr1703056pgd.422.1540477531483; Thu, 25 Oct 2018 07:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540477531; cv=none; d=google.com; s=arc-20160816; b=VHsYPhWVm3GejXhmmeZGidu0g+IjZZWgCGcnhSIuKaYoRmRi2MJfJV7303euirG2S9 4X3432orUQoMP4ppGV0A+2qHwljM90HqoaqQLkUViWI1szc4uX6HC2kUtSmeSLeY+LcI YskN0aVNY5454z+5I9c9N9IeiQmHhQh+21PUT+EbFXOHp7SkiJc5KFmokjjGLVHzgiFT +0QeusOWqnbf+K8S3xAHLlE5m7bat3U5vCT2d8Cx5V1l+R666bkNucYhO6P25wU4X2Z5 hXRuEgcX1sRc5AYDkLF0CLLPdPKS3mizNqcuSWNRt45DlAvv/eb4DAVZOETFO8oz4/bU aLxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=7IDVnP1ewhVdeVg53e599fkdAg4k+2MRQRCc+GDCyn8=; b=i5ienIVSCv9py/Gr3091sDnqQSBqrRtRnSI5bigyM5D1AneqNIggUCGsMdapwyFO3D BbNcC7b37OvS2ciXm1J1oLZqYTBw8kFCoXchhM2UzzCtexst2Tz35OJqh2MMuPJV42u1 +Ost8OTzFJLPz98QXESiDYWaca68IHy6kvIS8Zws69bKfp0mWrtALP4f1cMFn4B0IbzO rrZuvSo6cSxKq/C8fI/7TcI4mah7Tbw2Or4yzAZDZN3lkbAgRzkrrQrr55tiDU8UwJw7 acnqOBpSAwjTWsv+ZV8z7m2GqfhtLRIv6vN5tMmOqFg9q9nYQf/dx1pY9qJj0INxHxLF 1w4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Thtd5SWK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9-v6si7655240plm.126.2018.10.25.07.24.51; Thu, 25 Oct 2018 07:25:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Thtd5SWK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731183AbeJYWxp (ORCPT + 99 others); Thu, 25 Oct 2018 18:53:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:36386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731173AbeJYWxp (ORCPT ); Thu, 25 Oct 2018 18:53:45 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 87EAE2086D; Thu, 25 Oct 2018 14:20:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540477246; bh=ZydLsMenvMivMoVWSLhnkc1EN6ohe7jwsHIUzuCRq4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Thtd5SWKNhOk1yoRo1gRrGhCGSOnyhBHqYx6AV+UQ4OO3GEBkoqHDZZDvXI1TQTEe tdCEFuPjCHBSP7ZMbZzc6y81mAHK/K54dzwVNbhbxpUtPsZy1rwS79I3eFSKx4xF6V y+QAnMJp4RSXJq/gnJrHsRZ1D5kOLX97EMOPJtRE= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Chris Mi , Cong Wang , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 3.18 74/98] selftests: Introduce a new script to generate tc batch file Date: Thu, 25 Oct 2018 10:18:29 -0400 Message-Id: <20181025141853.214051-74-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141853.214051-1-sashal@kernel.org> References: <20181025141853.214051-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Mi [ Upstream commit 7f071998474a9e5f7b98103d3058a1b8ca5887e6 ] # ./tdc_batch.py -h usage: tdc_batch.py [-h] [-n NUMBER] [-o] [-s] [-p] device file TC batch file generator positional arguments: device device name file batch file name optional arguments: -h, --help show this help message and exit -n NUMBER, --number NUMBER how many lines in batch file -o, --skip_sw skip_sw (offload), by default skip_hw -s, --share_action all filters share the same action -p, --prio all filters have different prio Acked-by: Jamal Hadi Salim Acked-by: Lucas Bates Signed-off-by: Chris Mi Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../testing/selftests/tc-testing/tdc_batch.py | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 tools/testing/selftests/tc-testing/tdc_batch.py diff --git a/tools/testing/selftests/tc-testing/tdc_batch.py b/tools/testing/selftests/tc-testing/tdc_batch.py new file mode 100755 index 000000000000..707c6bfef689 --- /dev/null +++ b/tools/testing/selftests/tc-testing/tdc_batch.py @@ -0,0 +1,62 @@ +#!/usr/bin/python3 + +""" +tdc_batch.py - a script to generate TC batch file + +Copyright (C) 2017 Chris Mi +""" + +import argparse + +parser = argparse.ArgumentParser(description='TC batch file generator') +parser.add_argument("device", help="device name") +parser.add_argument("file", help="batch file name") +parser.add_argument("-n", "--number", type=int, + help="how many lines in batch file") +parser.add_argument("-o", "--skip_sw", + help="skip_sw (offload), by default skip_hw", + action="store_true") +parser.add_argument("-s", "--share_action", + help="all filters share the same action", + action="store_true") +parser.add_argument("-p", "--prio", + help="all filters have different prio", + action="store_true") +args = parser.parse_args() + +device = args.device +file = open(args.file, 'w') + +number = 1 +if args.number: + number = args.number + +skip = "skip_hw" +if args.skip_sw: + skip = "skip_sw" + +share_action = "" +if args.share_action: + share_action = "index 1" + +prio = "prio 1" +if args.prio: + prio = "" + if number > 0x4000: + number = 0x4000 + +index = 0 +for i in range(0x100): + for j in range(0x100): + for k in range(0x100): + mac = ("%02x:%02x:%02x" % (i, j, k)) + src_mac = "e4:11:00:" + mac + dst_mac = "e4:12:00:" + mac + cmd = ("filter add dev %s %s protocol ip parent ffff: flower %s " + "src_mac %s dst_mac %s action drop %s" % + (device, prio, skip, src_mac, dst_mac, share_action)) + file.write("%s\n" % cmd) + index += 1 + if index >= number: + file.close() + exit(0) -- 2.17.1