From patchwork Fri Dec 29 07:54:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Wythe" X-Patchwork-Id: 18599 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2435475dyb; Thu, 28 Dec 2023 23:55:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhuuewusPZmRqGxgjSb89Hv++DIqE92kh697uuECwg5fQm+3bKWZRKRQZ0RVkIm5AB1RI0 X-Received: by 2002:a17:906:1d0:b0:a23:6462:4d66 with SMTP id 16-20020a17090601d000b00a2364624d66mr5605246ejj.85.1703836528647; Thu, 28 Dec 2023 23:55:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703836528; cv=none; d=google.com; s=arc-20160816; b=Y7C73qJ/KE3tHtgSkTIe02ct9WUNDG9kXpxMyJV4u26zOUmDoCVRGWvl2zHKxZ+uZv I8aU/7+FcCKZBj0bJUZaaQwA/sww5dom/+UfzH81WI99Hh1UbDDKwEP6FhSnJSOpkCx7 fOIbdIpWitIkUpKF56qIGkXC0SKfxwr9LEHSo4jnAEn0E4+7X0qCEdWS1RdJ9HYJ1OpY HT1458sLolwM466Vn7e1YCJ6DO+XoPYj6iiC+oSHvt4GhqSbtIABQe2F7hI3i+LKtiju YOyIgCFdi7etrCOH6ncaz8bQpS/amiZ/WZTNjF5Mt4IGztZhol1+HwJAI5qpke2LKGlA ocKg== 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=8FtPT9vinpV1rFdFUWr9cv0FlNGj0hfyPUCWbxxj08o=; fh=0j9hEtKEGSulx/lgeQcpDl+4ujiVFr5DCPGOZLIRfAc=; b=VXZOR+HbxluHxZm7/hnjzFdi5pLVlLV6N/m68AcV4H/+H5Lmal0pvsAMThq6byd4ZN kHrSLBzYeix/EBbStSerCA/8mrHkiAYA9ufCOSv3zoKUs4O63n7yWEiHXr1XV6C9Nu0D 2AWyjd6ZNO2zM1ilv9a1o8LAf++pxx5ZwjTw4TDQpNWUEyi1e4XtzaxcGAca00Tfx+Na 9k7zYffQO7RIwGnVkKzL99xGWji8uisWaUFQf0YgYIntYHfA3O+MtfPsZmYp/A83Kdgh jAKaAhRzFYgUidQgQF7IiWA+BwLCyTmQXST/F8Gq0rDPwK0n/JWmAvJ/FBfGVUp8VDPK uqGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12978-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12978-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q23-20020a17090622d700b00a26aa2def95si7033288eja.116.2023.12.28.23.55.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 23:55:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12978-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12978-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12978-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4634F1F23A78 for ; Fri, 29 Dec 2023 07:55:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBB73C13D; Fri, 29 Dec 2023 07:54:22 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) (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 C559B63A3; Fri, 29 Dec 2023 07:54:17 +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=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=alibuda@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0VzQygPW_1703836449; Received: from j66a10360.sqa.eu95.tbsite.net(mailfrom:alibuda@linux.alibaba.com fp:SMTPD_---0VzQygPW_1703836449) by smtp.aliyun-inc.com; Fri, 29 Dec 2023 15:54:15 +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 v4 0/2] netfilter: bpf: support prog update Date: Fri, 29 Dec 2023 15:54:07 +0800 Message-Id: <1703836449-88705-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: 1786602091843470572 X-GMAIL-MSGID: 1786602091843470572 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. -- v3->v4: 1. remove mutex for link update, as it is unnecessary and can be replaced by atomic operations. -- D. Wythe (2): netfilter: bpf: support prog update selftests/bpf: Add netfilter link prog update test net/netfilter/nf_bpf_link.c | 50 ++++++++----- .../bpf/prog_tests/netfilter_link_update_prog.c | 83 ++++++++++++++++++++++ .../bpf/progs/test_netfilter_link_update_prog.c | 24 +++++++ 3 files changed, 141 insertions(+), 16 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