From patchwork Wed Dec 20 14:09:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Wythe" X-Patchwork-Id: 18370 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2663412dyi; Wed, 20 Dec 2023 06:11:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYP2IZGCTmnYs4Vk6Nx1DwWF1rcDPIisl5ZQmcDyiOSGXYbHDWAkTeMidsGnBNW6t1tMDZ X-Received: by 2002:a17:902:d2ca:b0:1d3:840f:a065 with SMTP id n10-20020a170902d2ca00b001d3840fa065mr6054651plc.123.1703081515038; Wed, 20 Dec 2023 06:11:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703081515; cv=none; d=google.com; s=arc-20160816; b=A8K6Js+bAvGLKc47ngNXLapZU70zHD/7yNpdPBKJaJbHhF73SDByK+dedtBRT5oocV wRtY9VA7nwkMsJ/2/r4Dpbkxoi70LmFe4bhL+Z3Ua+cUDUT+hpS4rlaF9reFbYDfa1cW a3dB9H29yGiqe7Ri9poVexmADHBpwoRrPz6dBoE30vMpuDyR4RIslV93c4TScEehMN0J dtxNNwuVe6Rf/RTcVIv0QpdJAl+/kcAogzQ3if/H/d9EVeS7vaPndklVuLs3FiTQURTS XXDzg4x7tmWlzherRxBykxIX5FdtySkVaeq2Pai+0N0phPUOxX69m24KWpMtU8wNtWrv HWdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=dlktQI2x1iuHqEi9mxQbJvpBMkTLYa33rfJzRbMT61U=; fh=0j9hEtKEGSulx/lgeQcpDl+4ujiVFr5DCPGOZLIRfAc=; b=dh0v/K0QGeX5tbXNr4LEsbnzpHkxkxlB6wJxVOnJD+HR2ICvY+hDx0pNgmT6bu+H7d X0wTyzIK+3NQdmX0YVTjB4EYzdoV4L4ygRx1sIlnCJAo+51izHvDoUhNgThRlqtzAdaK +0IQSKxepylvkGBLGCCKhY7EAIXgUItTP+lHbzldbhyXuU85VAVUYn+jnSkP6Q1lCx19 D2sNQKWfHYnE5RepZDUdjM9nUFYtLzr/UvA0GCa9Z0ngh69ESpP1MYijaOcuyio6V350 Gh1hw5MrlQgFUnZ+qPkqXVIFKO0QJlhQ25A3Shto5JJ5iOErSiC7TbMpyzLJjmgebjDu qnRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7036-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7036-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d7-20020a170902cec700b001d065c68f06si22066977plg.494.2023.12.20.06.11.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 06:11:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7036-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7036-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7036-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 100B0B2352A for ; Wed, 20 Dec 2023 14:10:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 103F83B7B5; Wed, 20 Dec 2023 14:09:34 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07BCA39862; Wed, 20 Dec 2023 14:09:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=alibuda@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0VyumN1T_1703081351; Received: from j66a10360.sqa.eu95.tbsite.net(mailfrom:alibuda@linux.alibaba.com fp:SMTPD_---0VyumN1T_1703081351) by smtp.aliyun-inc.com; Wed, 20 Dec 2023 22:09:20 +0800 From: "D. Wythe" To: pablo@netfilter.org, kadlec@netfilter.org, fw@strlen.de Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, coreteam@netfilter.org, netfilter-devel@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org Subject: [RFC nf-next v3 0/2] netfilter: bpf: support prog update Date: Wed, 20 Dec 2023 22:09:09 +0800 Message-Id: <1703081351-85579-1-git-send-email-alibuda@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785591949006261938 X-GMAIL-MSGID: 1785810402930436370 From: "D. Wythe" This patches attempt to implements updating of progs within bpf netfilter link, allowing user update their ebpf netfilter prog in hot update manner. Besides, a corresponding test case has been added to verify whether the update works. --- v1: 1. remove unnecessary context, access the prog directly via rcu. 2. remove synchronize_rcu(), dealloc the nf_link via kfree_rcu. 3. check the dead flag during the update. -- v1->v2: 1. remove unnecessary nf_prog, accessing nf_link->link.prog in direct. -- v2->v3: 1. access nf_link->link.prog via rcu_dereference_raw to avoid warning. D. Wythe (2): netfilter: bpf: support prog update selftests/bpf: Add netfilter link prog update test net/netfilter/nf_bpf_link.c | 63 ++++++++++++---- .../bpf/prog_tests/netfilter_link_update_prog.c | 83 ++++++++++++++++++++++ .../bpf/progs/test_netfilter_link_update_prog.c | 24 +++++++ 3 files changed, 155 insertions(+), 15 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/netfilter_link_update_prog.c create mode 100644 tools/testing/selftests/bpf/progs/test_netfilter_link_update_prog.c