Received: by 10.192.165.148 with SMTP id m20csp526483imm; Wed, 25 Apr 2018 03:41:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/eIjaAgs7xxRXonGMNU6VY6nR29Zos5ozY+e/fhafzll6jwHkNi1dzgMlO2LS20HKL1lb8 X-Received: by 10.98.204.8 with SMTP id a8mr26615277pfg.219.1524652887037; Wed, 25 Apr 2018 03:41:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524652887; cv=none; d=google.com; s=arc-20160816; b=g4NHKb7GyEjJOLjh1R+Akil0eyZ9rTLCvrwX4x/HcIooeggXmEUHNVQUaeYhaxKp/9 R3SBCnfaZmmvkvTtFi7fcM0rmP53KvAADmRDL+5YdAlvRxvvEx1Ja+PLnlVfpSU+b0v8 vcsOweCQeapAfWzqwDk8COa0YpQrgwuD494M+CfiAGMGNfBv9mX5lCLUc2GajX+dtb+a 3kKBlsUVuEoIAQgMDCT6WmLWvuW80BCWbqq/oJXWo/Rx9vTz2jbwIaDMd0S9ads4Xxhy Ql4aKdF6FsyXcOg5pfUNYZr0wVJLGFkcV61FJ6cSqRHTKQWxWOV6lMTU085i2ERRpwEF +PsQ== 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=RVgSsAr1uKAQ665ADRBnPJu5QPJWQsHRBHrhV9z5GaI=; b=O0OgAg9I3vvO+JstrEfP4PSldPX4aV7jR2Mc1+MMR11Fho1I2r08N7F2xwngpJjIlu L4xfZKZayMPkRqwgByEAR31PWABFty3W2teah/CLqfEkI6mdA5jxhcAA2SKyWu+OWY4X Ca3akeKJpgKcjf/DweVMnWxrGcd6vpU+y/9+6xw3laf0E2rwImDQk3Id9q+17zWiCUEn pXdoByL9V8RGC6G2qPrjZji7Lmtwkz092q9VYrb/A5Bou1mAq/Yj1v/LnEhUqanJRh3J YeoJEgjf6m8veCSxGEJSE5Bds/FbLE2JqQF7OZACgBXP3WTwKtv1rjXk5gpZVTVxpSvv RElA== 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 z13si9309126pfc.128.2018.04.25.03.41.13; Wed, 25 Apr 2018 03:41:27 -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 S1753436AbeDYKkN (ORCPT + 99 others); Wed, 25 Apr 2018 06:40:13 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52040 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753789AbeDYKkI (ORCPT ); Wed, 25 Apr 2018 06:40:08 -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 79476481; Wed, 25 Apr 2018 10:40:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Prashant Bhole , Daniel Borkmann , Sasha Levin Subject: [PATCH 4.14 077/183] bpf: test_maps: cleanup sockmaps when test ends Date: Wed, 25 Apr 2018 12:34:57 +0200 Message-Id: <20180425103245.604046986@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: Prashant Bhole [ Upstream commit 783687810e986a15ffbf86c516a1a48ff37f38f7 ] Bug: BPF programs and maps related to sockmaps test exist in memory even after test_maps ends. This patch fixes it as a short term workaround (sockmap kernel side needs real fixing) by empyting sockmaps when test ends. Fixes: 6f6d33f3b3d0f ("bpf: selftests add sockmap tests") Signed-off-by: Prashant Bhole [ daniel: Note on workaround. ] Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/bpf/test_maps.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) --- a/tools/testing/selftests/bpf/test_maps.c +++ b/tools/testing/selftests/bpf/test_maps.c @@ -463,7 +463,7 @@ static void test_devmap(int task, void * #define SOCKMAP_VERDICT_PROG "./sockmap_verdict_prog.o" static void test_sockmap(int tasks, void *data) { - int one = 1, map_fd_rx, map_fd_tx, map_fd_break, s, sc, rc; + int one = 1, map_fd_rx = 0, map_fd_tx = 0, map_fd_break, s, sc, rc; struct bpf_map *bpf_map_rx, *bpf_map_tx, *bpf_map_break; int ports[] = {50200, 50201, 50202, 50204}; int err, i, fd, udp, sfd[6] = {0xdeadbeef}; @@ -868,9 +868,12 @@ static void test_sockmap(int tasks, void goto out_sockmap; } - /* Test map close sockets */ - for (i = 0; i < 6; i++) + /* Test map close sockets and empty maps */ + for (i = 0; i < 6; i++) { + bpf_map_delete_elem(map_fd_tx, &i); + bpf_map_delete_elem(map_fd_rx, &i); close(sfd[i]); + } close(fd); close(map_fd_rx); bpf_object__close(obj); @@ -881,8 +884,13 @@ out: printf("Failed to create sockmap '%i:%s'!\n", i, strerror(errno)); exit(1); out_sockmap: - for (i = 0; i < 6; i++) + for (i = 0; i < 6; i++) { + if (map_fd_tx) + bpf_map_delete_elem(map_fd_tx, &i); + if (map_fd_rx) + bpf_map_delete_elem(map_fd_rx, &i); close(sfd[i]); + } close(fd); exit(1); }