Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp83950pxm; Fri, 4 Mar 2022 16:41:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUH7gZQJDFAH5XctW3cgMDOTdjzOlYI3C2udq4OpCI/+Lhikguz6bhjKdIZnoGR1JFw4pb X-Received: by 2002:a63:89c6:0:b0:37d:7ff8:6c0 with SMTP id v189-20020a6389c6000000b0037d7ff806c0mr813858pgd.196.1646440861514; Fri, 04 Mar 2022 16:41:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646440861; cv=none; d=google.com; s=arc-20160816; b=P5FqWbJ0dAXB7PcfUeDLhwdY8uXs1uF0jlQyT+IOgqELO2TK7qQMQg4mjsKQgFHx+g dSoEiGJffYNOLaNTTBiXdnSen8tSYY4pzI2uBJEpfUgDa9BAGDTqsDBI03q9krgeT7M9 hzA6hMk2NIT6cYmYrd+6c0jsQg1Rbx7uPB0l/yo2h+sN41aK5cIqWgR1JkjZFGYOah/5 ixzhT+iwhiAQV7sUjeMgAEo8qSiXq2pyCcfsRbH4kn8ktWuWyznptjZz0TdTlhIm8YmK 29EnVUtCr9q9WX+TxFJdjGlyBWtm6NxzgKQUmkBNcPtNOAxpqc8IFD/Yq6D/RGfO0gYT H9QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=14sIN4UpI1f+wkdhiWlQtVKn2dPlsrZCJdEI6z/Kd54=; b=vWxc8XrLCfN6QtHcDWu/y9a656hWAzBo373uySgCNGrKJqAdHifVY5XkEzMCiTzyQL 5h4sfjl9N1vonIkYzp6TjUSIZtYWKsTAV/lYYAbTLd4BhE3R8eWABUe4lXBQWkKs/ZQB q8dRpeXlCEnlKATpdRE44U831uQkRiTBPZXeeGHrw/1PBB6DL5Ef1TrnbvlLHzJmjF+2 7cawbybql2aD83JudjZzSLElctFavhW+iMJtGeuiIm2tVUcY6+HocNwuCTLzwFqmPjMI epbUQpXqbHYqetj4MCZ/iBDDeT9mvvjrNKNslsxdYoxFr6lO+ksQH9M7dQId47Yb+l/t N0kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AkPcC0Zw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g11-20020a63dd4b000000b00373835088a7si5898259pgj.322.2022.03.04.16.40.43; Fri, 04 Mar 2022 16:41:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AkPcC0Zw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbiCEAVv (ORCPT + 99 others); Fri, 4 Mar 2022 19:21:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbiCEAVs (ORCPT ); Fri, 4 Mar 2022 19:21:48 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43C74255F90; Fri, 4 Mar 2022 16:21:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D24F561F08; Sat, 5 Mar 2022 00:20:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3966BC340F3; Sat, 5 Mar 2022 00:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646439659; bh=B1FjitSdpbaZU/Y+cqd+b/Ws5YFB8gaS+fSH+7oHtf8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=AkPcC0ZwOkREUF8PF9uRiiiNHA7QlRzkeG0+/58FUt/Bs2Dg5/ng3PyE/ebAZzAoh 9PImjDhdfeq08e/rLq7O5oqeEERvLuQPpgqGBG1O9d76r41yXyfD7BVhoow2GGRJhO xthX6t7t5FB1Z4QNxK9v3Q/VcGsUNvJSqZeA4cHbq0y6ti/4ze3gapr5dpGJFGCvDK tfXuXVAEIg1lF5WS3DiCChbKXHUoU8ImQOXdxGUAvugVErm/aN6NG4GEUUZjAtl0I9 Kl3y5byOjiMbvzVoILroCewuKAVm4kTquniu5hsp1AeXhbjxFrwM7Y8Js5yLHKLZp6 Ie0PtP5GTiT7Q== Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-2d07ae0b1c4so108840637b3.11; Fri, 04 Mar 2022 16:20:59 -0800 (PST) X-Gm-Message-State: AOAM533oI7XdvvTyJrqldg7ZOpv7BbwtrmPWLoKAWWa5ouC6HSbV45q6 eAJfJYeO5GhI0KVgkntbiDI9T3hN0XpBaTKCC1o= X-Received: by 2002:a81:57d5:0:b0:2dc:62b3:1455 with SMTP id l204-20020a8157d5000000b002dc62b31455mr1007641ywb.73.1646439658179; Fri, 04 Mar 2022 16:20:58 -0800 (PST) MIME-Version: 1.0 References: <20220304172852.274126-1-benjamin.tissoires@redhat.com> <20220304172852.274126-3-benjamin.tissoires@redhat.com> In-Reply-To: <20220304172852.274126-3-benjamin.tissoires@redhat.com> From: Song Liu Date: Fri, 4 Mar 2022 16:20:46 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v2 02/28] bpf: introduce hid program type To: Benjamin Tissoires Cc: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Shuah Khan , Dave Marchevsky , Joe Stringer , Tero Kristo , open list , "open list:HID CORE LAYER" , Networking , bpf , linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 4, 2022 at 9:31 AM Benjamin Tissoires wrote: > [...] > +#endif > + > +static inline bool bpf_hid_link_empty(struct bpf_hid *bpf, > + enum bpf_hid_attach_type type) > +{ > + return list_empty(&bpf->links[type]); > +} > + > +struct bpf_hid_hooks { > + struct hid_device *(*hdev_from_fd)(int fd); > + int (*link_attach)(struct hid_device *hdev, enum bpf_hid_attach_type type); > + void (*array_detached)(struct hid_device *hdev, enum bpf_hid_attach_type type); shall we call this array_detach()? detached sounds like a function that checks the status of link/hook. [...] > --- /dev/null > +++ b/kernel/bpf/hid.c > @@ -0,0 +1,437 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * based on kernel/bpf/net-namespace.c > + */ I guess we don't need this comment. > + > +#include > +#include > +#include > +#include > +#include [...]