From patchwork Fri Mar 18 04:55:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 12784882 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58674C433EF for ; Fri, 18 Mar 2022 04:57:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232427AbiCRE6j (ORCPT ); Fri, 18 Mar 2022 00:58:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232424AbiCRE6j (ORCPT ); Fri, 18 Mar 2022 00:58:39 -0400 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F17A126D113 for ; Thu, 17 Mar 2022 21:57:21 -0700 (PDT) Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.1.2/8.16.1.2) with ESMTP id 22I0xJjq020272 for ; Thu, 17 Mar 2022 21:57:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=+Z4ptDeZoh7ulhNjp2+RoI7k6AN3UNexgvyGreqEV0U=; b=Lk4zP2FdyM69QBMlUfqaweSRVA+NKr8MmSlo81Lpzmcy99AyZEvaJC8DpNPJulyYrsoM 7Hvuv8TKSyOxrGLZwZVsppYsjO6RMj36wG+e75l1+7QgosGi2EB4IGuaOBWRy8jGyTMV BRf79josGYai2rXDJ9emV1YqUplz8Nl5xnE= Received: from mail.thefacebook.com ([163.114.132.120]) by m0001303.ppops.net (PPS) with ESMTPS id 3evg10rues-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 17 Mar 2022 21:57:21 -0700 Received: from twshared37304.07.ash9.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:21d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 17 Mar 2022 21:57:19 -0700 Received: by devbig010.atn6.facebook.com (Postfix, from userid 115148) id 94F8E9C8E690; Thu, 17 Mar 2022 21:57:10 -0700 (PDT) From: Joanne Koong To: CC: , , , , , , , , Joanne Koong Subject: [PATCH bpf-next v3 2/2] selftests/bpf: Test for associating multiple elements with the local storage Date: Thu, 17 Mar 2022 21:55:53 -0700 Message-ID: <20220318045553.3091807-3-joannekoong@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220318045553.3091807-1-joannekoong@fb.com> References: <20220318045553.3091807-1-joannekoong@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: TyCN6b8D7cptKkRHL3pFD95A1hh_Gwfu X-Proofpoint-ORIG-GUID: TyCN6b8D7cptKkRHL3pFD95A1hh_Gwfu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-18_05,2022-03-15_01,2022-02-23_01 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Joanne Koong This patch adds a few calls to the existing local storage selftest to test that we can associate multiple elements with the local storage. The sleepable program's call to bpf_sk_storage_get with sk_storage_map2 will lead to an allocation of a new selem under the GFP_KERNEL flag. Signed-off-by: Joanne Koong --- .../selftests/bpf/progs/local_storage.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/local_storage.c b/tools/testing/selftests/bpf/progs/local_storage.c index 9b1f9b75d5c2..19423ed862e3 100644 --- a/tools/testing/selftests/bpf/progs/local_storage.c +++ b/tools/testing/selftests/bpf/progs/local_storage.c @@ -36,6 +36,13 @@ struct { __type(value, struct local_storage); } sk_storage_map SEC(".maps"); +struct { + __uint(type, BPF_MAP_TYPE_SK_STORAGE); + __uint(map_flags, BPF_F_NO_PREALLOC | BPF_F_CLONE); + __type(key, int); + __type(value, struct local_storage); +} sk_storage_map2 SEC(".maps"); + struct { __uint(type, BPF_MAP_TYPE_TASK_STORAGE); __uint(map_flags, BPF_F_NO_PREALLOC); @@ -115,7 +122,19 @@ int BPF_PROG(socket_bind, struct socket *sock, struct sockaddr *address, if (storage->value != DUMMY_STORAGE_VALUE) sk_storage_result = -1; + /* This tests that we can associate multiple elements + * with the local storage. + */ + storage = bpf_sk_storage_get(&sk_storage_map2, sock->sk, 0, + BPF_LOCAL_STORAGE_GET_F_CREATE); + if (!storage) + return 0; + err = bpf_sk_storage_delete(&sk_storage_map, sock->sk); + if (err) + return 0; + + err = bpf_sk_storage_delete(&sk_storage_map2, sock->sk); if (!err) sk_storage_result = err;