Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5946993pxv; Wed, 7 Jul 2021 15:49:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBnwbXE0IkJL47VpUzg96N8QzcZ8OI77sIoQTb1MAiUAjpzbWrFo8a5El98e3XSE+I2s1j X-Received: by 2002:a05:6e02:1b8b:: with SMTP id h11mr21077910ili.212.1625698187180; Wed, 07 Jul 2021 15:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625698187; cv=none; d=google.com; s=arc-20160816; b=sdhN91YagzS7+EmK4Ye+uUswG/FtLn7jl9xb3Q511ODbM/02CrPpU4eUlUKbLOSgfp wDT74cCUOwokuishzQx/zsT2LjLdVDYvB6nGjrRdveUUmgGHMupvF2c4nLShYsdUBTjy cdbtD6dcwoIgnZmGMZpmmvCBtGO7uD4DPepVakUDdyBaTduqhJ1+CtbvwoNdNF/BwD/B /SNII0H+Zrs/eXWMIVyy23N4XitAAyt6J37PsB/xaTFwb4B1tc+7ep0PROVypdZjnyBK naYJ/M0/WU5RrZgZuZ53uB5OCu3LIvyc86ICRnIZSVKGgC8P5Lf1hqZT/1oSD4+f3wlx 2XYQ== 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=a5+YhNNILsNaLGJcn/Vl2gDcQBAX+fPbnVx8ML7cwEU=; b=LAdt9HqOJClgFbE3DwRgDcnXtc/XWQQH9KzJpYIs5pw8LW4KxuQgQZj0W9zS7Innlo PMqJMeBcxFyey1l7djH0SP3geIyqZ2V2RWdf2rjAfO8NdP4CJ7L90AEeDKr+HeImYS7j zikDHErAZQMPWVzlfuEA28BQSfmgAvU56xknIxB5/HZpG7MVO+6xecqPEv1GlCkAb5DY OnGJUMRR+9PpUE4ZyTVCpbDaF4SaOEcHEQFfnxx5N0MIHkwryT0rsc/u5M2A+sJdCRjc XAy8OQvXyrarZAPw/+OuEqYpkoeM0cSOZH8wL2496odibCN1kYTEolLYHu/OOPdFV1Wx OAeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QGWKs08J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p13si267860jam.87.2021.07.07.15.49.36; Wed, 07 Jul 2021 15:49:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QGWKs08J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230238AbhGGWZv (ORCPT + 99 others); Wed, 7 Jul 2021 18:25:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:58492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229956AbhGGWZv (ORCPT ); Wed, 7 Jul 2021 18:25:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4800961CD6; Wed, 7 Jul 2021 22:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625696590; bh=5/l44xHkURCHAD9g66CEvnyXk/coUzDcY6uOjA89jO8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=QGWKs08J3iEPfq66a6ZcCWCfINJw0ZCVJ2hPMW9SolR4r7uP1dVDosWaVyhc4nsPb UM+w/0nH5SnflXUqC1N0fX2O5jG0qhqKJgU7h4ZYttsHXNKXDJK1G7qNi9fbDlqd5t uIO81CBJwWvqou80xYV3/+ZyGeybcco/muhuDSjp6wU9OAr4qreqiqGtotzcbulkcB EGjQt91pwPReAaWKD+azxuXqI2MKd6hDlXbutbBfc4QcByuaPU66vnwxbEj0ulj4wC 7Azv/wSuXfhkCfrRzjGRAOBAGtWnX2mDSaHGQT2DE59ZFFiCtdneHM+ZX8BHkjxDav r6brr6DHo1PrQ== Received: by mail-wm1-f45.google.com with SMTP id k16-20020a05600c1c90b02901f4ed0fcfe7so2661196wms.5; Wed, 07 Jul 2021 15:23:10 -0700 (PDT) X-Gm-Message-State: AOAM530oeRqZ56/YceGzo/rNLxpAOB8AIIVee3q7xmyu+dVSNmxWlZUm j1NaIDhimsjdeQharl/Kmyeg+cUk7bNF/QMjMwY= X-Received: by 2002:a05:600c:4f53:: with SMTP id m19mr26994484wmq.176.1625696588806; Wed, 07 Jul 2021 15:23:08 -0700 (PDT) MIME-Version: 1.0 References: <20210707174022.517-1-royujjal@gmail.com> In-Reply-To: <20210707174022.517-1-royujjal@gmail.com> From: Song Liu Date: Wed, 7 Jul 2021 15:22:57 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] docs: bpf: Added more extension example To: UjjaL Roy Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "David S . Miller" , Jakub Kicinski , Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Nathan Chancellor , Nick Desaulniers , Networking , bpf , Linux Doc Mailing List , open list , linux-riscv@lists.infradead.org, clang-built-linux@googlegroups.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 7, 2021 at 10:50 AM UjjaL Roy wrote: > > From: "Roy, UjjaL" > > After reading this document observed that for new users it is > hard to find an example of "extension" easily. > > So, added a new heading for extensions for better readability. > Now, the new readers can easily identify "extension" examples. > Also, added one more example of filtering interface index. > > Signed-off-by: Roy, UjjaL Please prefix the subject with the target tree. In this case, the subject should say [PATCH bpf-next] xxx. Also, please revise the commit log as suggested in Documentation/process/submitting-patches.rst: Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behaviour. Otherwise, this change looks good to me. You can add my Acked-by tag in v2. (prefix v2 with [PATCH v2 bpf-next]. Thanks, Song Acked-by: Song Liu > --- > Documentation/networking/filter.rst | 23 ++++++++++++++++------- > 1 file changed, 16 insertions(+), 7 deletions(-) > > diff --git a/Documentation/networking/filter.rst b/Documentation/networking/filter.rst > index 3e2221f4abe4..5f13905b12e0 100644 > --- a/Documentation/networking/filter.rst > +++ b/Documentation/networking/filter.rst > @@ -320,13 +320,6 @@ Examples for low-level BPF: > ret #-1 > drop: ret #0 > > -**(Accelerated) VLAN w/ id 10**:: > - > - ld vlan_tci > - jneq #10, drop > - ret #-1 > - drop: ret #0 > - > **icmp random packet sampling, 1 in 4**:: > > ldh [12] > @@ -358,6 +351,22 @@ Examples for low-level BPF: > bad: ret #0 /* SECCOMP_RET_KILL_THREAD */ > good: ret #0x7fff0000 /* SECCOMP_RET_ALLOW */ > > +Examples for low-level BPF extension: > + > +**Packet for interface index 13**:: > + > + ld ifidx > + jneq #13, drop > + ret #-1 > + drop: ret #0 > + > +**(Accelerated) VLAN w/ id 10**:: > + > + ld vlan_tci > + jneq #10, drop > + ret #-1 > + drop: ret #0 > + > The above example code can be placed into a file (here called "foo"), and > then be passed to the bpf_asm tool for generating opcodes, output that xt_bpf > and cls_bpf understands and can directly be loaded with. Example with above > -- > 2.17.1 >