From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: [PATCH net 01/10] bpf: offload: add comment warning developers about double destroy Date: Sun, 19 Nov 2017 20:55:13 -0800 Message-ID: <20171120045522.2188-2-jakub.kicinski@netronome.com> References: <20171120045522.2188-1-jakub.kicinski@netronome.com> Cc: alexei.starovoitov@gmail.com, daniel@iogearbox.net, Jakub Kicinski To: netdev@vger.kernel.org Return-path: Received: from mail-pg0-f66.google.com ([74.125.83.66]:33726 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751138AbdKTE4I (ORCPT ); Sun, 19 Nov 2017 23:56:08 -0500 Received: by mail-pg0-f66.google.com with SMTP id s75so6428832pgs.0 for ; Sun, 19 Nov 2017 20:56:08 -0800 (PST) In-Reply-To: <20171120045522.2188-1-jakub.kicinski@netronome.com> Sender: netdev-owner@vger.kernel.org List-ID: Offload state may get destroyed either because the device for which it was constructed is going away, or because the refcount of bpf program itself has reached 0. In both of those cases we will call __bpf_prog_offload_destroy() to unlink the offload from the device. We may in fact call it twice, which works just fine, but we should make clear this is intended and caution others trying to extend the function. Signed-off-by: Jakub Kicinski Reviewed-by: Quentin Monnet Acked-by: Alexei Starovoitov Acked-by: Daniel Borkmann --- kernel/bpf/offload.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c index 2816feb38be1..fd696d3dd429 100644 --- a/kernel/bpf/offload.c +++ b/kernel/bpf/offload.c @@ -85,6 +85,10 @@ static void __bpf_prog_offload_destroy(struct bpf_prog *prog) struct bpf_dev_offload *offload = prog->aux->offload; struct netdev_bpf data = {}; + /* Caution - if netdev is destroyed before the program, this function + * will be called twice. + */ + data.offload.prog = prog; if (offload->verifier_running) -- 2.14.1