Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp913785pxb; Wed, 6 Apr 2022 04:07:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwc8MgwvClJafhcMaQwPdjk8Go0zsSFqNE7cYRudvQhZC/zp5kYosHDQCpbnJe6H2DZL7Zd X-Received: by 2002:a17:902:868e:b0:156:547b:6485 with SMTP id g14-20020a170902868e00b00156547b6485mr8081333plo.168.1649243233250; Wed, 06 Apr 2022 04:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649243233; cv=none; d=google.com; s=arc-20160816; b=b5uxkanMzESdL7Ad3z3imTrRf/v34yczGD86SPVh/bVjKBAG+ghEKcIszyiCzb2l0o Z1zmR0r3QXpmeSSkJ180vEa2hoK5LZTryvYlWVQlKZr0OZWPCnEN0bdsnSx8NsAcW/2O VYgh2wUIgs03hbMyRuzY1dFIGNi1SZjMdichTTpfyY8vg63pKahULwOvp6K/S65Ud2OG YcRhg54axABPxQQtwEjqW1KzUuyxOmeBNwHY+pgrf94/DkR2kQcWIt+RVTsdkf09QL1D 0iQ5NhSDSOecKuAXsTNw2ezz9/2wfHi8eLO377a6q53sVRPH1yPIrF3jMWaYsCJw80+7 nZYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ehiG9kGEWjvLhwigNb3ghl5sUxq67wvQmREGmKFBB0s=; b=hqfgDNR2wOTHxhrCAkELf9WmWe8qS6KN2wEpGQGlp0jP/28nFh3naJVVJqIyA+8ihG Ei3NOGTHTPLI3cPzEnRyTiMtCZHGRjcale4BK7UNOn6jEoJY3H01NL3zEziBIRBpix+5 4/pg34au/rSH1CfVU6Aq2q4PDSaf16IReheiY8LpB6U4MpM+HDzXfQ6ZlKo638sDkpYP +Mz0bFpZ8QjVUK3cu7Z7zWQQ7f8ivRIEerze14DH2TMzsMZHKErr4725V0XzXfSwW/Lp smjOKU0Ho4Y6uca+70BLpkhFOirI0mSooa6j/kjWlfTsWa2hp4WaRVFpAl+agQgadzIm wxmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="KDuPES/2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t34-20020a632262000000b0038217a788ccsi15893223pgm.173.2022.04.06.04.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:07:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="KDuPES/2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A3A8B5C69F6; Wed, 6 Apr 2022 02:29:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1447074AbiDFAEp (ORCPT + 99 others); Tue, 5 Apr 2022 20:04:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348817AbiDEJsj (ORCPT ); Tue, 5 Apr 2022 05:48:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AFC0AC938; Tue, 5 Apr 2022 02:36:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2D22BB81B75; Tue, 5 Apr 2022 09:36:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 923A9C385A0; Tue, 5 Apr 2022 09:36:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151368; bh=K6geJeEW5QaOD+aLW/HKf6IJ3et2Chj97ahJ/fcGf9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KDuPES/2QE5aL6JRMbKTCG28nac+T6vQmZ/Z/ye4VvB/gjb2+JK16kg53k9Bu29dr DphVKwG4SvBeuS68qiBlkMQ3JBU1Q8AyGRfq8kOlAEQ2Y6g+f8PKxyUup042OEYTSo P5vUb+Uip+CQSq75LK7GJ5BFbIG6l8uii+2U2H88= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felix Maurer , Andrii Nakryiko , Jakub Sitnicki , Sasha Levin Subject: [PATCH 5.15 390/913] selftests: bpf: Fix bind on used port Date: Tue, 5 Apr 2022 09:24:12 +0200 Message-Id: <20220405070351.537975626@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Felix Maurer [ Upstream commit 8c0be0631d81e48f77d0ebf0534c86e32bef5f89 ] The bind_perm BPF selftest failed when port 111/tcp was already in use during the test. To fix this, the test now runs in its own network name space. To use unshare, it is necessary to reorder the includes. The style of the includes is adapted to be consistent with the other prog_tests. v2: Replace deprecated CHECK macro with ASSERT_OK Fixes: 8259fdeb30326 ("selftests/bpf: Verify that rebinding to port < 1024 from BPF works") Signed-off-by: Felix Maurer Signed-off-by: Andrii Nakryiko Reviewed-by: Jakub Sitnicki Link: https://lore.kernel.org/bpf/551ee65533bb987a43f93d88eaf2368b416ccd32.1642518457.git.fmaurer@redhat.com Signed-off-by: Sasha Levin --- .../selftests/bpf/prog_tests/bind_perm.c | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/bind_perm.c b/tools/testing/selftests/bpf/prog_tests/bind_perm.c index d0f06e40c16d..eac71fbb24ce 100644 --- a/tools/testing/selftests/bpf/prog_tests/bind_perm.c +++ b/tools/testing/selftests/bpf/prog_tests/bind_perm.c @@ -1,13 +1,24 @@ // SPDX-License-Identifier: GPL-2.0 -#include -#include "bind_perm.skel.h" - +#define _GNU_SOURCE +#include +#include #include #include #include +#include "test_progs.h" +#include "bind_perm.skel.h" + static int duration; +static int create_netns(void) +{ + if (!ASSERT_OK(unshare(CLONE_NEWNET), "create netns")) + return -1; + + return 0; +} + void try_bind(int family, int port, int expected_errno) { struct sockaddr_storage addr = {}; @@ -75,6 +86,9 @@ void test_bind_perm(void) struct bind_perm *skel; int cgroup_fd; + if (create_netns()) + return; + cgroup_fd = test__join_cgroup("/bind_perm"); if (CHECK(cgroup_fd < 0, "cg-join", "errno %d", errno)) return; -- 2.34.1