{"id":831020,"url":"http://patchwork.ozlabs.org/api/1.2/patches/831020/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20171027012443.3306-17-xiyou.wangcong@gmail.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20171027012443.3306-17-xiyou.wangcong@gmail.com>","list_archive_url":null,"date":"2017-10-27T01:24:43","name":"[net,16/16] selftests: Introduce a new test case to tc testsuite","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"d7bf09e4f8f72c55eaac75af91be210c89ef5b76","submitter":{"id":211,"url":"http://patchwork.ozlabs.org/api/1.2/people/211/?format=json","name":"Cong Wang","email":"xiyou.wangcong@gmail.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20171027012443.3306-17-xiyou.wangcong@gmail.com/mbox/","series":[{"id":10472,"url":"http://patchwork.ozlabs.org/api/1.2/series/10472/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=10472","date":"2017-10-27T01:24:27","name":"net_sched: fix races with RCU callbacks","version":1,"mbox":"http://patchwork.ozlabs.org/series/10472/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/831020/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/831020/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"it/TFCfL\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3yNR5k1cmWz9t2h\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 27 Oct 2017 12:25:46 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S932503AbdJ0BZo (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 26 Oct 2017 21:25:44 -0400","from mail-pf0-f193.google.com ([209.85.192.193]:46897 \"EHLO\n\tmail-pf0-f193.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S932433AbdJ0BZS (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Thu, 26 Oct 2017 21:25:18 -0400","by mail-pf0-f193.google.com with SMTP id p87so3779287pfj.3\n\tfor <netdev@vger.kernel.org>; Thu, 26 Oct 2017 18:25:18 -0700 (PDT)","from tw-172-25-30-113.office.twttr.net ([8.25.197.25])\n\tby smtp.gmail.com with ESMTPSA id\n\tb16sm13211973pfe.58.2017.10.26.18.25.16\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tThu, 26 Oct 2017 18:25:16 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=5Dr8q7W54F1v/fV6PAtP8gga4p/rn3AdI7lHm8MHt9Q=;\n\tb=it/TFCfLsK5BPc9QFP2MiI6WL6ctgh5+ZkjKrnj3KWKjS+Mgvt206n8M3IJZ0ZU0Pi\n\tN0TqXzlRNclg2QnoYcyPM8bVJA7oxeB4C1Jw02k++zKVvWS2cLGr79yUIr8IqEcUFa/2\n\tEvaMKQsW1RPOcaZ6CG5r3og6MJpHNyl9MBi7XBZA2u4wRayLmkEBYgs5+6WIF5mN5/5l\n\t3qtTm6X67wydrSPmJV769IjbOaP6C53s4g7mXNDIACDpgGA3pb1UcL7PtmS3cNst6Dun\n\tnajZiY7elGTl1m50zTIkfRSY0nW5lRKPdtqrvvqhJwUbRhCOIED+lCzRw0VRJJ4kC2BY\n\t1R5g==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=5Dr8q7W54F1v/fV6PAtP8gga4p/rn3AdI7lHm8MHt9Q=;\n\tb=mQORsJ7ZB9tTPkcwdvsf74nizqgtqudSOFd44LMCTmz2DX92ZDX/Do0hZk1S7u/m3C\n\tNF57JyX5I5S8y0O1USeRhM00+XbQs726Zv0C6j5Td0g+PUZtUvj9emOYu+MYzwgos7+p\n\tTkTRdkU4IKBCYRSU0Kk5uzplS4AbNhmCHk/nBAS+Ss4bdRZk64824uioj6zEReNIJs9P\n\tDkXyeDkBYmmMKe1Nty46mbjmiLk+NRtDnkpgy3401N8DEYJZAIt+laolxypNM6nLpLlC\n\tj+6MBki+P/J0RO6BX78GmDmdgw9rkSzOmgJpi+nkBVnhoTq9P0ZdQPRz0R7IL9BmdUOA\n\trObw==","X-Gm-Message-State":"AMCzsaXwNNN6/YotY5+0Bimvv5GTaG7miwBNiNf6SVA7RZA9Sujzamhr\n\tmOZjsjJUDH6FYZHGrxlnRsKTOG99","X-Google-Smtp-Source":"ABhQp+T38lJkecJdeKkZY/kCV/QQFw19v4qzKsYPzafx5XYdl6XBzrWYwW7JkHB3yGbHcBSAxaie0A==","X-Received":"by 10.98.31.215 with SMTP id l84mr7326135pfj.36.1509067517628;\n\tThu, 26 Oct 2017 18:25:17 -0700 (PDT)","From":"Cong Wang <xiyou.wangcong@gmail.com>","To":"netdev@vger.kernel.org","Cc":"Chris Mi <chrism@mellanox.com>, Cong Wang <xiyou.wangcong@gmail.com>","Subject":"[Patch net 16/16] selftests: Introduce a new test case to tc\n\ttestsuite","Date":"Thu, 26 Oct 2017 18:24:43 -0700","Message-Id":"<20171027012443.3306-17-xiyou.wangcong@gmail.com>","X-Mailer":"git-send-email 2.9.4","In-Reply-To":"<20171027012443.3306-1-xiyou.wangcong@gmail.com>","References":"<20171027012443.3306-1-xiyou.wangcong@gmail.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"From: Chris Mi <chrism@mellanox.com>\n\nIn this patchset, we fixed a tc bug. This patch adds the test case\nthat reproduces the bug. To run this test case, user should specify\nan existing NIC device:\n  # sudo ./tdc.py -d enp4s0f0\n\nThis test case belongs to category \"flower\". If user doesn't specify\na NIC device, the test cases belong to \"flower\" will not be run.\n\nIn this test case, we create 1M filters and all filters share the same\naction. When destroying all filters, kernel should not panic. It takes\nabout 18s to run it.\n\nAcked-by: Jamal Hadi Salim <jhs@mojatatu.com>\nAcked-by: Lucas Bates <lucasb@mojatatu.com>\nSigned-off-by: Chris Mi <chrism@mellanox.com>\nSigned-off-by: Cong Wang <xiyou.wangcong@gmail.com>\n---\n .../tc-testing/tc-tests/filters/tests.json         | 23 +++++++++++++++++++++-\n tools/testing/selftests/tc-testing/tdc.py          | 20 +++++++++++++++----\n tools/testing/selftests/tc-testing/tdc_config.py   |  2 ++\n 3 files changed, 40 insertions(+), 5 deletions(-)","diff":"diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/tests.json b/tools/testing/selftests/tc-testing/tc-tests/filters/tests.json\nindex c727b96a59b0..5fa02d86b35f 100644\n--- a/tools/testing/selftests/tc-testing/tc-tests/filters/tests.json\n+++ b/tools/testing/selftests/tc-testing/tc-tests/filters/tests.json\n@@ -17,5 +17,26 @@\n         \"teardown\": [\n             \"$TC qdisc del dev $DEV1 ingress\"\n         ]\n+    },\n+    {\n+        \"id\": \"d052\",\n+        \"name\": \"Add 1M filters with the same action\",\n+        \"category\": [\n+            \"filter\",\n+            \"flower\"\n+        ],\n+        \"setup\": [\n+            \"$TC qdisc add dev $DEV2 ingress\",\n+            \"./tdc_batch.py $DEV2 $BATCH_FILE --share_action -n 1000000\"\n+        ],\n+        \"cmdUnderTest\": \"$TC -b $BATCH_FILE\",\n+        \"expExitCode\": \"0\",\n+        \"verifyCmd\": \"$TC actions list action gact\",\n+        \"matchPattern\": \"action order 0: gact action drop.*index 1 ref 1000000 bind 1000000\",\n+        \"matchCount\": \"1\",\n+        \"teardown\": [\n+            \"$TC qdisc del dev $DEV2 ingress\",\n+            \"/bin/rm $BATCH_FILE\"\n+        ]\n     }\n-]\n\\ No newline at end of file\n+]\ndiff --git a/tools/testing/selftests/tc-testing/tdc.py b/tools/testing/selftests/tc-testing/tdc.py\nindex cd61b7844c0d..5f11f5d7456e 100755\n--- a/tools/testing/selftests/tc-testing/tdc.py\n+++ b/tools/testing/selftests/tc-testing/tdc.py\n@@ -88,7 +88,7 @@ USE_NS = True\n             exit(1)\n \n \n-def test_runner(filtered_tests):\n+def test_runner(filtered_tests, args):\n     \"\"\"\n     Driver function for the unit tests.\n \n@@ -105,6 +105,8 @@ USE_NS = True\n     for tidx in testlist:\n         result = True\n         tresult = \"\"\n+        if \"flower\" in tidx[\"category\"] and args.device == None:\n+            continue\n         print(\"Test \" + tidx[\"id\"] + \": \" + tidx[\"name\"])\n         prepare_env(tidx[\"setup\"])\n         (p, procout) = exec_cmd(tidx[\"cmdUnderTest\"])\n@@ -152,6 +154,10 @@ USE_NS = True\n         exec_cmd(cmd, False)\n         cmd = 'ip -s $NS link set $DEV1 up'\n         exec_cmd(cmd, False)\n+        cmd = 'ip link set $DEV2 netns $NS'\n+        exec_cmd(cmd, False)\n+        cmd = 'ip -s $NS link set $DEV2 up'\n+        exec_cmd(cmd, False)\n \n \n def ns_destroy():\n@@ -211,7 +217,8 @@ USE_NS = True\n                         help='Execute the single test case with specified ID')\n     parser.add_argument('-i', '--id', action='store_true', dest='gen_id',\n                         help='Generate ID numbers for new test cases')\n-    return parser\n+    parser.add_argument('-d', '--device',\n+                        help='Execute the test case in flower category')\n     return parser\n \n \n@@ -225,6 +232,8 @@ USE_NS = True\n \n     if args.path != None:\n          NAMES['TC'] = args.path\n+    if args.device != None:\n+         NAMES['DEV2'] = args.device\n     if not os.path.isfile(NAMES['TC']):\n         print(\"The specified tc path \" + NAMES['TC'] + \" does not exist.\")\n         exit(1)\n@@ -381,14 +390,17 @@ USE_NS = True\n             if (len(alltests) == 0):\n                 print(\"Cannot find a test case with ID matching \" + target_id)\n                 exit(1)\n-        catresults = test_runner(alltests)\n+        catresults = test_runner(alltests, args)\n         print(\"All test results: \" + \"\\n\\n\" + catresults)\n     elif (len(target_category) > 0):\n+        if (target_category == \"flower\") and args.device == None:\n+            print(\"Please specify a NIC device (-d) to run category flower\")\n+            exit(1)\n         if (target_category not in ucat):\n             print(\"Specified category is not present in this file.\")\n             exit(1)\n         else:\n-            catresults = test_runner(testcases[target_category])\n+            catresults = test_runner(testcases[target_category], args)\n             print(\"Category \" + target_category + \"\\n\\n\" + catresults)\n \n     ns_destroy()\ndiff --git a/tools/testing/selftests/tc-testing/tdc_config.py b/tools/testing/selftests/tc-testing/tdc_config.py\nindex 01087375a7c3..b6352515c1b5 100644\n--- a/tools/testing/selftests/tc-testing/tdc_config.py\n+++ b/tools/testing/selftests/tc-testing/tdc_config.py\n@@ -12,6 +12,8 @@ NAMES = {\n           # Name of veth devices to be created for the namespace\n           'DEV0': 'v0p0',\n           'DEV1': 'v0p1',\n+          'DEV2': '',\n+          'BATCH_FILE': './batch.txt',\n           # Name of the namespace to use\n           'NS': 'tcut'\n         }\n","prefixes":["net","16/16"]}