Received: by 10.192.165.148 with SMTP id m20csp530013imm; Wed, 25 Apr 2018 03:45:38 -0700 (PDT) X-Google-Smtp-Source: AIpwx48GygJxf3ZJTAMho1j3d3MoafvdJGP2I0zcyy0W9Maxo0ymjmzpjGtEiAyxrJJuJRmurIMY X-Received: by 10.101.74.132 with SMTP id b4mr9734868pgu.36.1524653138189; Wed, 25 Apr 2018 03:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524653138; cv=none; d=google.com; s=arc-20160816; b=ozFjUe4VNbPgOysFVPdJ5OYMreCcKcyzXBWJymfl/CODT/GDKyeyafQcel4aPuTEvB ZHdkLjhalBLsRHnuF2nNFHtG2EqNQngX0F7BMdNdT2Gr2r1Fvt5pyaj7agidYgIz1OJL QdwDANgsj1KuiSRLkEMaMIJ6kZ5xf/sXMuN3O8tcwHrBqhrF7kdNIvPMBJhEQCpzG3nQ dVq5vKvtYEO03H4nkmopHGL9rKwZGt/O7d8M88j7EGh61ibzJ3/0DZszMNTvFT2OjybV lpqdBEXs9tgpypz+kfN16/y0hx1N6KcVXMDR2soqIVC5n52/cRGs08edjW6R6q/6Lkko bbMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=zAI7xYbKXpiZyDdGERLn6tl5ol9+JbghutCCVWvWUQo=; b=DrnGGdZrpDXVshOEud9TQzaZYVEEmz8vsiQBjkbj7ORq1tjx8B0aVL4zda77HC/Vh6 BBtQdIGVI8Klu4XzFpkQokk1t+vtrZyUUUB77fHScVS6WUceeov0uKksiHFS9yeHe/j/ cp1UIdO1uoHlsr9CvC3lvDmQTvKfskm8wsXvEX1xqV1OohoOpyrr5T3GQSAkKiV0qq5y e5LL9oUGDOY0nkmS/lFbIShob9zjFC0DidBC1WJc5YmIhsSBQmkE8jvh9TM32PVMCqqh PTK89mGVK9NRCu6UKZWZoSlN0UA1+8B33ScmeK1snY56wbrgO2ux8DeUb5O/FwgLJq9p 3s6A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f75si11182176pfh.90.2018.04.25.03.45.24; Wed, 25 Apr 2018 03:45:38 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754294AbeDYKoC (ORCPT + 99 others); Wed, 25 Apr 2018 06:44:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53142 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754277AbeDYKnx (ORCPT ); Wed, 25 Apr 2018 06:43:53 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9C91E412; Wed, 25 Apr 2018 10:43:52 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Naresh Kamboju , Daniel Borkmann , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 160/183] bpf: fix rlimit in reuseport net selftest Date: Wed, 25 Apr 2018 12:36:20 +0200 Message-Id: <20180425103248.962678024@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Borkmann [ Upstream commit 941ff6f11c020913f5cddf543a9ec63475d7c082 ] Fix two issues in the reuseport_bpf selftests that were reported by Linaro CI: [...] + ./reuseport_bpf ---- IPv4 UDP ---- Testing EBPF mod 10... Reprograming, testing mod 5... ./reuseport_bpf: ebpf error. log: 0: (bf) r6 = r1 1: (20) r0 = *(u32 *)skb[0] 2: (97) r0 %= 10 3: (95) exit processed 4 insns : Operation not permitted + echo FAIL [...] ---- IPv4 TCP ---- Testing EBPF mod 10... ./reuseport_bpf: failed to bind send socket: Address already in use + echo FAIL [...] For the former adjust rlimit since this was the cause of failure for loading the BPF prog, and for the latter add SO_REUSEADDR. Reported-by: Naresh Kamboju Link: https://bugs.linaro.org/show_bug.cgi?id=3502 Signed-off-by: Daniel Borkmann Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/net/reuseport_bpf.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) --- a/tools/testing/selftests/net/reuseport_bpf.c +++ b/tools/testing/selftests/net/reuseport_bpf.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #ifndef ARRAY_SIZE @@ -190,11 +191,14 @@ static void send_from(struct test_params struct sockaddr * const saddr = new_any_sockaddr(p.send_family, sport); struct sockaddr * const daddr = new_loopback_sockaddr(p.send_family, p.recv_port); - const int fd = socket(p.send_family, p.protocol, 0); + const int fd = socket(p.send_family, p.protocol, 0), one = 1; if (fd < 0) error(1, errno, "failed to create send socket"); + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) + error(1, errno, "failed to set reuseaddr"); + if (bind(fd, saddr, sockaddr_size())) error(1, errno, "failed to bind send socket"); @@ -433,6 +437,21 @@ void enable_fastopen(void) } } +static struct rlimit rlim_old, rlim_new; + +static __attribute__((constructor)) void main_ctor(void) +{ + getrlimit(RLIMIT_MEMLOCK, &rlim_old); + rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20); + rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20); + setrlimit(RLIMIT_MEMLOCK, &rlim_new); +} + +static __attribute__((destructor)) void main_dtor(void) +{ + setrlimit(RLIMIT_MEMLOCK, &rlim_old); +} + int main(void) { fprintf(stderr, "---- IPv4 UDP ----\n");