From patchwork Fri Sep 22 10:17:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orson Zhai X-Patchwork-Id: 114013 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp2910667edb; Fri, 22 Sep 2017 03:19:01 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDg4YlzM35uXKtdvsTWfx7PfkSZ1YtGu8uKixQ0vniEUYL1U0QMkZe/qYsb0eANNbo25XoY X-Received: by 10.99.183.67 with SMTP id w3mr8849273pgt.245.1506075541508; Fri, 22 Sep 2017 03:19:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506075541; cv=none; d=google.com; s=arc-20160816; b=IQ7ZOUFlqMvqRrQl9Tkc+AizqLf6Uy1Q8tf8WrTJWtMQ6ksa4otulFwDkJ8ckR+G9j p/ujdpayklAaG7xLxzGNCWbUP/6Ec4how8G1vO/UNBxKveqL19vnQ4j/1HFEdxyoYT3p eI4+rPFm8nJW8zBRwWLmIdfU+RXQCcSE1JohVyz6Tgf9VL39qlW75ageytmE5TAXzfX3 VcaVpzhBxsGiUh0TnL26ftivd0U72EhnLBtScX2Wv1mv3kZplTvAEt+95cg2tKQ8TOLT L3SvOriLn8wqclem1KHHOHQxslNW+NQFPoXByf/HuE+Z0HwYzTBmiMc4s1vXYqk7Da4Y pvNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=Mv+IbroZA4NjLhFgR/8sCKEyivxPaNxkhUM2Zma+KO4=; b=ZgVDDgfHl/6VY3UhwyqgoCYBljnH8PCONJ0uEYjSh8JOttdisXbdGsLAs78oa6fnr0 5UA9mTKEq2nvgbaraTN61QrxKzUnYzhnfQSC8gHplHQkQrAsZNwynQBTa/MdUnQe9pQL lSTxOzexqERbYZgY0z/hxR5C69In1qVaJiI8gED/EiDc2ReM0MH1sObgACLHPwrgw0h4 RHTgQw1Pz9Ox0IhYmVS77tyjGhoLzkhnq4bMVpXJs09m/QtVrUGg0pEoNzOl0Be1GRyR HOD7YeNIGDwoOt6/2kp8X3PQPRNUhXJQPNp8oBtr8F/aM7r3uNHY4VDzLXNGd0rAp093 vmBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si2769004pgs.88.2017.09.22.03.19.01; Fri, 22 Sep 2017 03:19:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752030AbdIVKS7 (ORCPT + 8 others); Fri, 22 Sep 2017 06:18:59 -0400 Received: from sci-ig2.spreadtrum.com ([222.66.158.135]:11848 "EHLO SHSQR01.spreadtrum.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751977AbdIVKS6 (ORCPT ); Fri, 22 Sep 2017 06:18:58 -0400 Received: from ig2.spreadtrum.com (shmbx03.spreadtrum.com [10.0.1.208]) by SHSQR01.spreadtrum.com with ESMTP id v8MAI8FS003554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 22 Sep 2017 18:18:08 +0800 (CST) (envelope-from Orson.Zhai@spreadtrum.com) Received: from SHCAS02.spreadtrum.com (10.0.1.202) by SHMBX03.spreadtrum.com (10.0.1.208) with Microsoft SMTP Server (TLS) id 15.0.847.32; Fri, 22 Sep 2017 18:18:16 +0800 Received: from localhost (10.0.73.143) by SHCAS02.spreadtrum.com (10.0.1.250) with Microsoft SMTP Server (TLS) id 15.0.847.32 via Frontend Transport; Fri, 22 Sep 2017 18:18:16 +0800 From: Orson Zhai To: Shuah Khan CC: "David S . Miller" , , , , , Orson Zhai Subject: tools: selftests: psock_tpacket: skip un-supported tpacket_v3 test Date: Fri, 22 Sep 2017 18:17:17 +0800 Message-ID: <20170922101717.11933-1-orson.zhai@linaro.org> X-Mailer: git-send-email 2.12.2 MIME-Version: 1.0 X-MAIL: SHSQR01.spreadtrum.com v8MAI8FS003554 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The TPACKET_V3 test of PACKET_TX_RING will fail with kernel version lower than v4.11. Supported code of tx ring was add with commit id <7f953ab2ba46: af_packet: TX_RING support for TPACKET_V3> at Jan. 3 of 2017. So skip this item test instead of reporting failing for old kernels. Signed-off-by: Orson Zhai --- tools/testing/selftests/net/psock_tpacket.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) -- 2.12.2 diff --git a/tools/testing/selftests/net/psock_tpacket.c b/tools/testing/selftests/net/psock_tpacket.c index 7f6cd9fdacf3..f0cfc18c3726 100644 --- a/tools/testing/selftests/net/psock_tpacket.c +++ b/tools/testing/selftests/net/psock_tpacket.c @@ -57,6 +57,7 @@ #include #include #include +#include #include "psock_lib.h" @@ -676,7 +677,7 @@ static void __v3_fill(struct ring *ring, unsigned int blocks, int type) ring->flen = ring->req3.tp_block_size; } -static void setup_ring(int sock, struct ring *ring, int version, int type) +static int setup_ring(int sock, struct ring *ring, int version, int type) { int ret = 0; unsigned int blocks = 256; @@ -703,7 +704,11 @@ static void setup_ring(int sock, struct ring *ring, int version, int type) if (ret == -1) { perror("setsockopt"); - exit(1); + if (errno == EINVAL) { + printf("[SKIP] This type seems un-supported in current kernel, skipped.\n"); + return -1; + } else + exit(1); } ring->rd_len = ring->rd_num * sizeof(*ring->rd); @@ -715,6 +720,7 @@ static void setup_ring(int sock, struct ring *ring, int version, int type) total_packets = 0; total_bytes = 0; + return 0; } static void mmap_ring(int sock, struct ring *ring) @@ -830,7 +836,12 @@ static int test_tpacket(int version, int type) sock = pfsocket(version); memset(&ring, 0, sizeof(ring)); - setup_ring(sock, &ring, version, type); + if(setup_ring(sock, &ring, version, type)) { + /* skip test when error of invalid argument */ + close(sock); + return 0; + } + mmap_ring(sock, &ring); bind_ring(sock, &ring); walk_ring(sock, &ring);