From patchwork Thu Apr 5 10:27:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 895344 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40Gznp3JBRz9s0q for ; Thu, 5 Apr 2018 20:38:38 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 826803E76B8 for ; Thu, 5 Apr 2018 12:38:35 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) by picard.linux.it (Postfix) with ESMTP id 3EAC83E72FD for ; Thu, 5 Apr 2018 12:38:33 +0200 (CEST) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-2.smtp.seeweb.it (Postfix) with ESMTP id 85D26601CDB for ; Thu, 5 Apr 2018 12:38:31 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="38628623" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 05 Apr 2018 18:38:22 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 37B1E4D0EFF5; Thu, 5 Apr 2018 18:38:17 +0800 (CST) Received: from RHEL7U5Alpha_SERVER.g08.fujitsu.local (10.167.220.185) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 5 Apr 2018 18:38:17 +0800 From: Xiao Yang To: Date: Thu, 5 Apr 2018 18:27:57 +0800 Message-ID: <1522924077-15028-1-git-send-email-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.167.220.185] X-yoursite-MailScanner-ID: 37B1E4D0EFF5.ABA5B X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com X-Spam-Status: No, score=-0.0 required=7.0 tests=T_RP_MATCHES_RCVD autolearn=disabled version=3.4.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH] sctp/sctp_big_chunk.c: Add a hint on failure with EINVAL X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" If two ipv6 addresses have same family, a buggy kernel(e.g. RHEL6) lacked the port check for them, and made this test get a failure with EINVAL: ------------------------------------------------------------------------- safe_net.c:160: BROK: sctp_big_chunk.c:77: setsockopt(4, 132, 100, 0x7ffdbaac83a0, 91644) failed: EINVAL ------------------------------------------------------------------------- If you want to know detailed info for the bug, please see the following commit: '40b4f0f (sctp: lack the check for ports in sctp_v6_cmp_addr)' We just want to hint users about the likely cause of the failure. Signed-off-by: Xiao Yang --- testcases/network/sctp/sctp_big_chunk.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/testcases/network/sctp/sctp_big_chunk.c b/testcases/network/sctp/sctp_big_chunk.c index 55a2969..7b314f4 100644 --- a/testcases/network/sctp/sctp_big_chunk.c +++ b/testcases/network/sctp/sctp_big_chunk.c @@ -19,6 +19,7 @@ * chunk in _sctp_make_chunk()") */ +#include #include #include #include @@ -58,7 +59,7 @@ static void setup_server(void) static void setup_client(void) { struct sockaddr_in6 addr_buf[addr_num]; - int i; + int i, res; cfd = SAFE_SOCKET(AF_INET6, SOCK_STREAM, IPPROTO_SCTP); rmt.sin6_family = AF_INET6; @@ -73,8 +74,23 @@ static void setup_client(void) addr_buf[i].sin6_addr = in6addr_loopback; } - SAFE_SETSOCKOPT(cfd, SOL_SCTP, SCTP_SOCKOPT_BINDX_ADD, addr_buf, - sizeof(addr_buf)); + res = setsockopt(cfd, SOL_SCTP, SCTP_SOCKOPT_BINDX_ADD, addr_buf, + sizeof(addr_buf)); + if (res) { + /* Without commit 40b4f0f, sctp_v6_cmp_addr() lacks the port + * check for two ipv6 addresses which have same family. that + * will make setsockopt(SCTP_SOCKOPT_BINDX_ADD) cannot work + * well. + */ + if (errno == EINVAL) { + tst_res(TINFO, "possibly kernel lacked the port check " + "for two ipv6 addresses which have same family"); + } + + tst_brk(TBROK | TERRNO, "setsockopt(%d, SOL_SCTP, " + "SCTP_SOCKOPT_BINDX_ADD, %p, %lu) failed", + cfd, addr_buf, sizeof(addr_buf)); + } } static void setup(void)