From patchwork Wed Aug 1 05:08:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 951926 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tobin.cc Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tobin.cc header.i=@tobin.cc header.b="IHkwkIfq"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="kGDctlFW"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41gLvk0y1qz9s3q for ; Wed, 1 Aug 2018 15:09:38 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733092AbeHAGxO (ORCPT ); Wed, 1 Aug 2018 02:53:14 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:37101 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733001AbeHAGxN (ORCPT ); Wed, 1 Aug 2018 02:53:13 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id B3DA4441; Wed, 1 Aug 2018 01:09:29 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 01 Aug 2018 01:09:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=wwKYmbWul3LpjtYHq qe8vdzXC3qzlJeRL6ETnOpzEck=; b=IHkwkIfqCOHUQXKuRg3H+vTqWr2HT0Jrv t1Cro8uC3qJ767JIwX5gFQhCZIihqr9CuveEoA2aBZLvJL9REA2MxUs0OPQHKFl3 VV4bzNOOsz15pxo8bQ+caRbQ6WLiWnkRz+VVxu2gMZ+Mb/iZqBnW+RaVHgsu1iD8 8qxNNNlYJyUa6ot1d7CZ6W98NzfGa0L7ETMjzuvnyt3G2EWz75SuHO2KCnCTBC0e +4ZsgLnvOwoqjptMs1TTyuuCBH+zuIXH68YzB6JOLTrcg96WAf13OCWCYEAyPdxg myNcF0SewxQ+EhvBEx22wrj8Ufq3pjSFTh3S2ajXLtbCxJ08rdmgg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=wwKYmbWul3LpjtYHqqe8vdzXC3qzlJeRL6ETnOpzEck=; b=kGDctlFW CmnMNvEgZH1jIhx+V5/DdUh330OaiFb54VoU9RXmVHuphoL/9Q6RLzARp2wLNlg1 ljQWa4lQXowrqXCq6s7Q+uOlzFIVcIVby8aMV/UUqfO9PQjrzxHYWsVNj3lKQADH 6FmL/HEkV5ukFKryhxyC5Q8TnHMukhVkGPPxEHcsLVKPBIpP4Lxc082uklxTrpfy rvXtSvM4iARMZVh0xhoyRZ6WVAWWBDdzTNxq3gks3MLHjWRYibTQVwfEC7IDD9dx e5VKjM+rDayrVgu40N81D61ja9z6gR1H1t6iISv6TqeliaZ7buRyWIL7uxRoV8mC BVzN4czklDVhfQ== X-ME-Proxy: X-ME-Sender: Received: from localhost (124-169-17-12.dyn.iinet.net.au [124.169.17.12]) by mail.messagingengine.com (Postfix) with ESMTPA id 6DBF010269; Wed, 1 Aug 2018 01:09:28 -0400 (EDT) From: "Tobin C. Harding" To: Daniel Borkmann , Alexei Starovoitov Cc: "Tobin C. Harding" , Jonathan Corbet , "David S. Miller" , linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 01/13] docs: net: Rename filter.txt to filter.rst Date: Wed, 1 Aug 2018 15:08:56 +1000 Message-Id: <20180801050908.29970-2-me@tobin.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180801050908.29970-1-me@tobin.cc> References: <20180801050908.29970-1-me@tobin.cc> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In preparation for conversion to RST format. Rename file in a single commit to ease review. Rename Documentation/networking/filter.txt to Documentation/networking/filter.rst Signed-off-by: Tobin C. Harding --- Documentation/networking/00-INDEX | 2 -- Documentation/networking/{filter.txt => filter.rst} | 0 MAINTAINERS | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) rename Documentation/networking/{filter.txt => filter.rst} (100%) diff --git a/Documentation/networking/00-INDEX b/Documentation/networking/00-INDEX index 1e5153ed8990..37c65b3a90be 100644 --- a/Documentation/networking/00-INDEX +++ b/Documentation/networking/00-INDEX @@ -78,8 +78,6 @@ eql.txt - serial IP load balancing fib_trie.txt - Level Compressed Trie (LC-trie) notes: a structure for routing. -filter.txt - - Linux Socket Filtering fore200e.txt - FORE Systems PCA-200E/SBA-200E ATM NIC driver info. framerelay.txt diff --git a/Documentation/networking/filter.txt b/Documentation/networking/filter.rst similarity index 100% rename from Documentation/networking/filter.txt rename to Documentation/networking/filter.rst diff --git a/MAINTAINERS b/MAINTAINERS index fce04d747a1a..a95431e90ab9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2746,7 +2746,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git Q: https://patchwork.ozlabs.org/project/netdev/list/?delegate=77147 S: Supported F: arch/x86/net/bpf_jit* -F: Documentation/networking/filter.txt +F: Documentation/networking/filter.rst F: Documentation/bpf/ F: include/linux/bpf* F: include/linux/filter.h From patchwork Wed Aug 1 05:08:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 951927 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tobin.cc Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tobin.cc header.i=@tobin.cc header.b="g6jcI+Pj"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="PBcHNmWR"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41gLvl4cdPz9s3q for ; Wed, 1 Aug 2018 15:09:39 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733115AbeHAGxS (ORCPT ); Wed, 1 Aug 2018 02:53:18 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:36585 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731897AbeHAGxR (ORCPT ); Wed, 1 Aug 2018 02:53:17 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 6B34457E; Wed, 1 Aug 2018 01:09:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 01 Aug 2018 01:09:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=2wmxxDv2UY+esS3EU JV2LGCmrVOUVjGbcEiL+i4pkDI=; b=g6jcI+Pj6sEBqBOS1Wzqy0oJi8V8g+w+l tl2cZWu0j3GBKYzFIpijM2ltLzrtrEu5vzyLHXGwGPAsDnJyBJF5J2VkfZywPbxV CGhw7AiwxprEDUjOxq5fFQ+Yi6Z7MsWCwW78OBqaQbhfa65/+/LiQlrau9pajhIL 7iDVlIrODhjfJEZ8h7cudQKn55jyNNkgwqBBJUYaseE6vX3Ri4jPjI3k33OHgK9j QtuUCAnXEqRXIc3kD91JkvJQXts4dUJunx8N1CkjUt6oqnma0bT+PTpVFGuxZ5JU s0I9M3EGBjJfxbIwjETdqcc6HEvzpgF4M5IEvv/npYcc4fEeLorQQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=2wmxxDv2UY+esS3EUJV2LGCmrVOUVjGbcEiL+i4pkDI=; b=PBcHNmWR SeIigchJhWMVn3Ma2RSaIaHMpxdd3tvIbnUYbGJuiD/8mm+cDHWD9dW3nKCLxn0f g2xBRYucOi57G25aGqkWL4LdrcGaBh2GhyXegLa8+gJdDhJeWWK2t1JWuuNAqYAS bWIXjQT50CE4Cf5DJqBTpXenIWGgvHP42DL0BgGYinimLWhi1H3znngSb4uSrqZv UiEWLaA+GgBFQgTGoKyzKuMKLygdlgtbslXi9aCzOXxE2Q4gnmowQjRE32s+s/DK oUfiF7GTmZ/kgJlLsThl/yV2kq2SSpgLwMp/V1tT/4X3To+e+D9ig5xrJSx7DhZN YjvMDIe49tDTBQ== X-ME-Proxy: X-ME-Sender: Received: from localhost (124-169-17-12.dyn.iinet.net.au [124.169.17.12]) by mail.messagingengine.com (Postfix) with ESMTPA id 2A3141026B; Wed, 1 Aug 2018 01:09:31 -0400 (EDT) From: "Tobin C. Harding" To: Daniel Borkmann , Alexei Starovoitov Cc: "Tobin C. Harding" , Jonathan Corbet , "David S. Miller" , linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 02/13] docs: Update references to filter.rst Date: Wed, 1 Aug 2018 15:08:57 +1000 Message-Id: <20180801050908.29970-3-me@tobin.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180801050908.29970-1-me@tobin.cc> References: <20180801050908.29970-1-me@tobin.cc> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Documentation/networking/filter.rst was just renamed. In order to use RST references we need to add a label to filter.rst Add label and update references from filter.txt to filter.rst Signed-off-by: Tobin C. Harding --- Documentation/bpf/index.rst | 9 ++++----- Documentation/networking/filter.rst | 2 ++ Documentation/networking/packet_mmap.txt | 2 +- tools/bpf/bpf_asm.c | 2 +- tools/bpf/bpf_dbg.c | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Documentation/bpf/index.rst b/Documentation/bpf/index.rst index 00a8450a602f..192393135c61 100644 --- a/Documentation/bpf/index.rst +++ b/Documentation/bpf/index.rst @@ -7,10 +7,10 @@ Filter) facility, with a focus on the extended BPF version (eBPF). This kernel side documentation is still work in progress. The main textual documentation is (for historical reasons) described in -`Documentation/networking/filter.txt`_, which describe both classical -and extended BPF instruction-set. -The Cilium project also maintains a `BPF and XDP Reference Guide`_ -that goes into great technical depth about the BPF Architecture. +:ref:`Documentation/networking/filter.rst `, which describe +both classical and extended BPF instruction-set. The Cilium project also +maintains a `BPF and XDP Reference Guide`_ that goes into great technical +depth about the BPF Architecture. The primary info for the bpf syscall is available in the `man-pages`_ for `bpf(2)`_. @@ -30,7 +30,6 @@ Two sets of Questions and Answers (Q&A) are maintained. .. Links: -.. _Documentation/networking/filter.txt: ../networking/filter.txt .. _man-pages: https://www.kernel.org/doc/man-pages/ .. _bpf(2): http://man7.org/linux/man-pages/man2/bpf.2.html .. _BPF and XDP Reference Guide: http://cilium.readthedocs.io/en/latest/bpf/ diff --git a/Documentation/networking/filter.rst b/Documentation/networking/filter.rst index e6b4ebb2b243..14ce8901c245 100644 --- a/Documentation/networking/filter.rst +++ b/Documentation/networking/filter.rst @@ -1,6 +1,8 @@ Linux Socket Filtering aka Berkeley Packet Filter (BPF) ======================================================= +.. _bpf_filter: + Introduction ------------ diff --git a/Documentation/networking/packet_mmap.txt b/Documentation/networking/packet_mmap.txt index 999eb41da81d..494614573c67 100644 --- a/Documentation/networking/packet_mmap.txt +++ b/Documentation/networking/packet_mmap.txt @@ -1051,7 +1051,7 @@ for more information on hardware timestamps. ------------------------------------------------------------------------------- - Packet sockets work well together with Linux socket filters, thus you also - might want to have a look at Documentation/networking/filter.txt + might want to have a look at Documentation/networking/filter.rst -------------------------------------------------------------------------------- + THANKS diff --git a/tools/bpf/bpf_asm.c b/tools/bpf/bpf_asm.c index c15aef097b04..5040875735db 100644 --- a/tools/bpf/bpf_asm.c +++ b/tools/bpf/bpf_asm.c @@ -10,7 +10,7 @@ * * How to get into it: * - * 1) read Documentation/networking/filter.txt + * 1) read Documentation/networking/filter.rst * 2) Run `bpf_asm [-c] ` to translate into binary * blob that is loadable with xt_bpf, cls_bpf et al. Note: -c will * pretty print a C-like construct. diff --git a/tools/bpf/bpf_dbg.c b/tools/bpf/bpf_dbg.c index 61b9aa5d6415..d05d8df0ce3b 100644 --- a/tools/bpf/bpf_dbg.c +++ b/tools/bpf/bpf_dbg.c @@ -12,7 +12,7 @@ * for making a verdict when multiple simple BPF programs are combined * into one in order to prevent parsing same headers multiple times. * - * More on how to debug BPF opcodes see Documentation/networking/filter.txt + * More on how to debug BPF opcodes see Documentation/networking/filter.rst * which is the main document on BPF. Mini howto for getting started: * * 1) `./bpf_dbg` to enter the shell (shell cmds denoted with '>'): From patchwork Wed Aug 1 05:08:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 951938 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tobin.cc Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tobin.cc header.i=@tobin.cc header.b="a0a2nBE9"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="rUe/5EFa"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41gLxG3csNz9s0R for ; Wed, 1 Aug 2018 15:10:58 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733122AbeHAGxW (ORCPT ); Wed, 1 Aug 2018 02:53:22 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:35859 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731897AbeHAGxV (ORCPT ); Wed, 1 Aug 2018 02:53:21 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 3083B538; Wed, 1 Aug 2018 01:09:37 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 01 Aug 2018 01:09:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=JqP8d7TU92I9vNIwv lUxWVoxQatjgeXMpluA1xZ1Y2Q=; b=a0a2nBE9kU/yLCi7wBoIf3Qn73mAV38M/ fthoLbl4jPR8K87rgqCbgoV0B5OhHwd6z6y6eXigUo2zD36ib5q3RwXUQQuWizU5 bpep905fRKTyuAgRdZEpX4zhoFVodMAE2You/iyzjoAOmwJTMVm1KOUVUQGfWmIm iqZIiYXYm3RYII7Tx/qdIHIVH0JNdncg9u5FVhLCcIu7BcG70Spd0bVFh3T2hFc8 zVLlbDK52h/ECYQ5lTAL2bwBuM6/U+4EgBLeSadG3sYIa0kT2DD2TkdP+EtaPTfv kv/poGYjIBKSgr63o4NC1Wv3rUQGELy8YrJohAjPaoccEIYkpuW6w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=JqP8d7TU92I9vNIwvlUxWVoxQatjgeXMpluA1xZ1Y2Q=; b=rUe/5EFa LBqwGnJ6O3XRwgbG7XgECBa985jD+m6CL19fxXA28izHovwvTrcRVd4JDCUaiYUh C5tjFqO/2zsyUiwRP3r8/TNIKHFW+9T1MZmKQy//xZDOImaBL14AaCfOC9XPCZDC UM5mitwr3ZnMMBXDaD/vNug9wYBYGJMFBONFRNp0QFZPzoiFshxaH+72AszZgr7X xlE6Mh6i2BJ2LOwjxIxLa5In8cZmMAbyZwajPB3Vc9IAgArwyBLvVn4QaV+OI80G MaTSrAmRVHPchkWrJRiN8E4uekX7gBPGiXigfg62uM124GNeLh4Vu4Biak7J/9m/ dFnlTdR6w52GtQ== X-ME-Proxy: X-ME-Sender: Received: from localhost (124-169-17-12.dyn.iinet.net.au [124.169.17.12]) by mail.messagingengine.com (Postfix) with ESMTPA id 00C73E462B; Wed, 1 Aug 2018 01:09:35 -0400 (EDT) From: "Tobin C. Harding" To: Daniel Borkmann , Alexei Starovoitov Cc: "Tobin C. Harding" , Jonathan Corbet , "David S. Miller" , linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 03/13] docs: net: Add filter to index toctree Date: Wed, 1 Aug 2018 15:08:58 +1000 Message-Id: <20180801050908.29970-4-me@tobin.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180801050908.29970-1-me@tobin.cc> References: <20180801050908.29970-1-me@tobin.cc> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org filter.rst was just created (from filter.txt). We should include it in the networking docs toctree. Add filter to Documentation/networking/index.rst toctree. Signed-off-by: Tobin C. Harding --- Documentation/networking/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/networking/index.rst b/Documentation/networking/index.rst index f0ae9b65dfba..1f926bb347b1 100644 --- a/Documentation/networking/index.rst +++ b/Documentation/networking/index.rst @@ -19,6 +19,7 @@ Contents: net_failover alias bridge + filter .. only:: subproject From patchwork Wed Aug 1 05:08:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 951937 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tobin.cc Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tobin.cc header.i=@tobin.cc header.b="p6t3kZFN"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="ZbVNqFrU"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41gLxB2Hbpz9s0R for ; Wed, 1 Aug 2018 15:10:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733145AbeHAGxZ (ORCPT ); Wed, 1 Aug 2018 02:53:25 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:44371 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731897AbeHAGxY (ORCPT ); Wed, 1 Aug 2018 02:53:24 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id C0CE7574; Wed, 1 Aug 2018 01:09:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 01 Aug 2018 01:09:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=qrD9GhAtyQU1PiLoE wDAejckBknIIG7czvjwUJ1Ik14=; b=p6t3kZFNQ95s+kWhWjgkIV3slCrfTZzCA FXKlLZdCNtm01QgwqqnY7RhpiuQstBW5yzPotu3/0bOlKaNp/KEZLiy1BtyPVlVr ditzXiv36Tnd9aAoI3EJMxz2pSnBG3XgMY5WiRYnvuy+JWwVX+Xfht4XezroffZc HM35w9NL8xNC1blBLVvDR+sjBAQL/ke/CK/7eWKbEsCMUNONYmZ7wQJjJB86+71I 9xv4watdIieDCAKgm93uArAapi/e9Q+XVS+/QogJf7vB2RwK9YbouG+/izysG3x1 RLPC8c6kzxFmYKNNoWvxoVpjvWVZvzC9vcMSO/L6hmcBzU9s1N0lQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=qrD9GhAtyQU1PiLoEwDAejckBknIIG7czvjwUJ1Ik14=; b=ZbVNqFrU tpKpE4WLTtfeEDgXTOL2z9g8Tb6Zr0QgTG7QbSAaDWCo7/HaB69jNC1cME2Qq0uU eSzZeiaFwN5fHtd5cZA0PAfPqLkHFIjqet2sqOJOO4j7VKkcKC9zB1T+00lsphJ4 573wi7yzqzdzF2WDhYMJo/oqF0zpnMDBOvX7AYMCC07+DE8cQHsWZ1egQ1ikTW8v f27izTOLKSn3lkflbQXVAjNgPUR43oxO3FXJoAyNTxS5jElmtc9HYMRKEqkHi9eL nilK/YmU6SpYuMlPc7IsjY8zK5c1BlgLvTwzZZrbcHm0vn4Qm7zAeQzY466ngdkM fooJjf5Q609N3w== X-ME-Proxy: X-ME-Sender: Received: from localhost (124-169-17-12.dyn.iinet.net.au [124.169.17.12]) by mail.messagingengine.com (Postfix) with ESMTPA id 8882E10268; Wed, 1 Aug 2018 01:09:39 -0400 (EDT) From: "Tobin C. Harding" To: Daniel Borkmann , Alexei Starovoitov Cc: "Tobin C. Harding" , Jonathan Corbet , "David S. Miller" , linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 04/13] docs: net: Use correct heading adornments Date: Wed, 1 Aug 2018 15:08:59 +1000 Message-Id: <20180801050908.29970-5-me@tobin.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180801050908.29970-1-me@tobin.cc> References: <20180801050908.29970-1-me@tobin.cc> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Conversion to RST format requires the use of correct RST heading adornments. While we are at it we can make sure spacing around headings is uniform. Choose to use one empty line after any heading. Use correct levels of heading adornment. Signed-off-by: Tobin C. Harding --- Documentation/networking/filter.rst | 36 +++++++++++++++++------------ 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/Documentation/networking/filter.rst b/Documentation/networking/filter.rst index 14ce8901c245..19325286780b 100644 --- a/Documentation/networking/filter.rst +++ b/Documentation/networking/filter.rst @@ -1,10 +1,11 @@ +======================================================= Linux Socket Filtering aka Berkeley Packet Filter (BPF) ======================================================= .. _bpf_filter: Introduction ------------- +============ Linux Socket Filtering (LSF) is derived from the Berkeley Packet Filter. Though there are some distinct differences between the BSD and Linux @@ -58,7 +59,7 @@ Conference Proceedings (USENIX'93). USENIX Association, Berkeley, CA, USA, 2-2. [http://www.tcpdump.org/papers/bpf-usenix93.pdf] Structure ---------- +========= User space applications include which contains the following relevant structures: @@ -169,7 +170,7 @@ implementors may wish to manually write test cases and thus need low-level access to BPF code as well. BPF engine and instruction set ------------------------------- +============================== Under tools/bpf/ there's a small helper tool called bpf_asm which can be used to write low-level filters for example scenarios mentioned in the @@ -462,7 +463,7 @@ breakpoints: 0 1 Exits bpf_dbg. JIT compiler ------------- +============ The Linux kernel has a built-in BPF JIT compiler for x86_64, SPARC, PowerPC, ARM, ARM64, MIPS and s390 and can be enabled through CONFIG_BPF_JIT. The JIT @@ -569,7 +570,8 @@ For BPF JIT developers, bpf_jit_disasm, bpf_asm and bpf_dbg provides a useful toolchain for developing and testing the kernel's JIT compiler. BPF kernel internals --------------------- +==================== + Internally, for the kernel interpreter, a different instruction set format with similar underlying principles from BPF described in previous paragraphs is being used. However, the instruction set format is modelled @@ -843,7 +845,7 @@ descends all possible paths. It simulates execution of every insn and observes the state change of registers and stack. eBPF opcode encoding --------------------- +==================== eBPF is reusing most of the opcode encoding from classic to simplify conversion of classic BPF to eBPF. For arithmetic and jump instructions the 8-bit 'code' @@ -1014,7 +1016,8 @@ Classic BPF has similar instruction: BPF_LD | BPF_W | BPF_IMM which loads 32-bit immediate value into a register. eBPF verifier -------------- +============= + The safety of the eBPF program is determined in two steps. First step does DAG check to disallow loops and other CFG validation. @@ -1107,7 +1110,8 @@ all use cases. See details of eBPF verifier in kernel/bpf/verifier.c Register value tracking ------------------------ +======================= + In order to determine the safety of an eBPF program, the verifier must track the range of possible values in each register and also in each stack slot. This is done with 'struct bpf_reg_state', defined in include/linux/ @@ -1175,7 +1179,7 @@ bytes (NET_IP_ALIGN) gives a 4-byte alignment and so word-sized accesses through that pointer are safe. Direct packet access --------------------- +==================== In cls_bpf and act_bpf programs the verifier allows direct access to the packet data via skb->data and skb->data_end pointers. Ex: @@ -1261,7 +1265,8 @@ which makes such programs easier to write comparing to LD_ABS insn and significantly faster. eBPF maps ---------- +========= + 'maps' is a generic storage of different types for sharing data between kernel and userspace. @@ -1300,7 +1305,8 @@ The map is defined by: . value size in bytes Pruning -------- +======= + The verifier does not actually walk all possible paths through the program. For each new branch to analyse, the verifier looks at all the states it's previously been in when at this instruction. If any of them contain the current state as a @@ -1316,7 +1322,7 @@ registers it may hold). They must all be safe for the branch to be pruned. This is implemented in states_equal(). Understanding eBPF verifier messages ------------------------------------- +==================================== The following are few examples of invalid eBPF programs and verifier error messages as seen in the log: @@ -1447,7 +1453,7 @@ Error: R0 invalid mem access 'imm' Testing -------- +======= Next to the BPF toolchain, the kernel also ships a test module that contains various test cases for classic and internal BPF that can be executed against @@ -1461,13 +1467,13 @@ via insmod or modprobe against 'test_bpf' module. Results of the test cases including timings in nsec can be found in the kernel log (dmesg). Misc ----- +==== Also trinity, the Linux syscall fuzzer, has built-in support for BPF and SECCOMP-BPF kernel fuzzing. Written by ----------- +========== The document was written in the hope that it is found useful and in order to give potential BPF hackers or security auditors a better overview of From patchwork Wed Aug 1 05:09:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 951928 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tobin.cc Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tobin.cc header.i=@tobin.cc header.b="Zv4PU7CR"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="KmnGbmJv"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41gLvy4BzTz9s3Z for ; Wed, 1 Aug 2018 15:09:50 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733181AbeHAGxa (ORCPT ); Wed, 1 Aug 2018 02:53:30 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:42769 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731897AbeHAGx3 (ORCPT ); Wed, 1 Aug 2018 02:53:29 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 0A0EF578; Wed, 1 Aug 2018 01:09:44 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 01 Aug 2018 01:09:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=S2r2y5vqKZBG1sEh7 JePq6jUNUINM0oRL3IJ1B1GzCg=; b=Zv4PU7CR8URtY93EPE64q5PItKWHXDIdb 07Txhkj2XG0spLaGkLielMPuk9wtXSaClYr5LavF0YgXQanf5yH2tNeFqNYvmTt/ h63xaqnFAK+Rx+eyl5VtglDKao5tXftc6knMNlBnTvKPoHL6e2Wr0iMCkrRf9tH7 6a+HrGCx42Mf9AQaqMPFxrRYnLfdVadurMo2Ju2GmaasXUX59UsV8h6nqzu3YTzN 7t4ytABSHP1sG/7wc4Yd0COZx1JI9PGP9uLHRUKOdj+YuPTLVpTypYTRWWEWcJUg yLZ6TK6wEOTGRAMI9dDP5IH1SnzUycyy3c89bAFa6noMO0y3S6Gyw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=S2r2y5vqKZBG1sEh7JePq6jUNUINM0oRL3IJ1B1GzCg=; b=KmnGbmJv khkcBxH1OeMoxjgm2SRMGMetQXPJUaF1i2G41etH/tHFy8uLbBVpnkeePcSdrdnV qOZLkemjDAUWSebKBAcTlHy6di5vXz+QZJVe2oS5pY1daRRJHuB9uEr0tY14NUbO gF1PhKrsxN3bwJy9jGw0lSHo8eBmpi0Yo8Yv80KYZrSd8EFvPCL5oQOMt/eCq+lE J6/j8EYap5WSwGaFLfdyrJcL5x0N+dPIcButEWOrxLXfj0FXuwHbz7MpLgeLnkMr km7fVRq2wx5NCh5VlLuRwY18//G6+MbvHEVYHd/EOxuJpAxPAlBh5+mk5deiZ1tr otsxKlQu0IlL9Q== X-ME-Proxy: X-ME-Sender: Received: from localhost (124-169-17-12.dyn.iinet.net.au [124.169.17.12]) by mail.messagingengine.com (Postfix) with ESMTPA id 579D61027B; Wed, 1 Aug 2018 01:09:43 -0400 (EDT) From: "Tobin C. Harding" To: Daniel Borkmann , Alexei Starovoitov Cc: "Tobin C. Harding" , Jonathan Corbet , "David S. Miller" , linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 05/13] docs: net: Fix indentation issues for code snippets Date: Wed, 1 Aug 2018 15:09:00 +1000 Message-Id: <20180801050908.29970-6-me@tobin.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180801050908.29970-1-me@tobin.cc> References: <20180801050908.29970-1-me@tobin.cc> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Recent conversion of filter.txt to RST format did not fix indentation. Sphinx emits various warnings about indentation. We should prefix all code snippets with the RST identifier '::' and indent first column of snippets 2 characters (inline with other docs in RST format). Fix indentation issues for code snippets (including spaces to tabs when appropriate). Signed-off-by: Tobin C. Harding --- Documentation/networking/filter.rst | 746 +++++++++++++++------------- 1 file changed, 398 insertions(+), 348 deletions(-) diff --git a/Documentation/networking/filter.rst b/Documentation/networking/filter.rst index 19325286780b..916e7ac01576 100644 --- a/Documentation/networking/filter.rst +++ b/Documentation/networking/filter.rst @@ -62,38 +62,40 @@ Structure ========= User space applications include which contains the -following relevant structures: +following relevant structures:: -struct sock_filter { /* Filter block */ + struct sock_filter { /* Filter block */ __u16 code; /* Actual filter code */ __u8 jt; /* Jump true */ __u8 jf; /* Jump false */ __u32 k; /* Generic multiuse field */ -}; + }; Such a structure is assembled as an array of 4-tuples, that contains a code, jt, jf and k value. jt and jf are jump offsets and k a generic value to be used for a provided code. +:: -struct sock_fprog { /* Required for SO_ATTACH_FILTER. */ + struct sock_fprog { /* Required for SO_ATTACH_FILTER. */ unsigned short len; /* Number of filter blocks */ struct sock_filter __user *filter; -}; + }; For socket filtering, a pointer to this structure (as shown in follow-up example) is being passed to the kernel through setsockopt(2). Example ------- +:: -#include -#include -#include -#include -/* ... */ + #include + #include + #include + #include + /* ... */ -/* From the example above: tcpdump -i em1 port 22 -dd */ -struct sock_filter code[] = { + /* From the example above: tcpdump -i em1 port 22 -dd */ + struct sock_filter code[] = { { 0x28, 0, 0, 0x0000000c }, { 0x15, 0, 8, 0x000086dd }, { 0x30, 0, 0, 0x00000014 }, @@ -118,23 +120,23 @@ struct sock_filter code[] = { { 0x15, 0, 1, 0x00000016 }, { 0x06, 0, 0, 0x0000ffff }, { 0x06, 0, 0, 0x00000000 }, -}; + }; -struct sock_fprog bpf = { + struct sock_fprog bpf = { .len = ARRAY_SIZE(code), .filter = code, -}; + }; -sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); -if (sock < 0) + sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); + if (sock < 0) /* ... bail out ... */ -ret = setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &bpf, sizeof(bpf)); -if (ret < 0) + ret = setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &bpf, sizeof(bpf)); + if (ret < 0) /* ... bail out ... */ -/* ... */ -close(sock); + /* ... */ + close(sock); The above example code attaches a socket filter for a PF_PACKET socket in order to let all IPv4/IPv6 packets with port 22 pass. The rest will @@ -179,17 +181,17 @@ bpf_asm and will be used for further explanations (instead of dealing with less readable opcodes directly, principles are the same). The syntax is closely modelled after Steven McCanne's and Van Jacobson's BPF paper. -The BPF architecture consists of the following basic elements: +The BPF architecture consists of the following basic elements:: - Element Description + Element Description - A 32 bit wide accumulator - X 32 bit wide X register - M[] 16 x 32 bit wide misc registers aka "scratch memory - store", addressable from 0 to 15 + A 32 bit wide accumulator + X 32 bit wide X register + M[] 16 x 32 bit wide misc registers aka "scratch memory + store", addressable from 0 to 15 A program, that is translated by bpf_asm into "opcodes" is an array that -consists of the following elements (as already mentioned): +consists of the following elements (as already mentioned):: op:16, jt:8, jf:8, k:32 @@ -202,7 +204,7 @@ ways depending on the given instruction in op. The instruction set consists of load, store, branch, alu, miscellaneous and return instructions that are also represented in bpf_asm syntax. This table lists all bpf_asm instructions available resp. what their underlying -opcodes as defined in linux/filter.h stand for: +opcodes as defined in linux/filter.h stand for:: Instruction Addressing mode Description @@ -245,7 +247,7 @@ opcodes as defined in linux/filter.h stand for: ret 4, 9 Return -The next table shows addressing formats from the 2nd column: +The next table shows addressing formats from the 2nd column:: Addressing mode Syntax Description @@ -266,7 +268,7 @@ with the class of load instructions by "overloading" the k argument with a negative offset + a particular extension offset. The result of such BPF extensions are loaded into A. -Possible BPF extensions are shown in the following table: +Possible BPF extensions are shown in the following table:: Extension Description @@ -290,14 +292,14 @@ Possible BPF extensions are shown in the following table: These extensions can also be prefixed with '#'. Examples for low-level BPF: -** ARP packets: +** ARP packets:: ldh [12] jne #0x806, drop ret #-1 drop: ret #0 -** IPv4 TCP packets: +** IPv4 TCP packets:: ldh [12] jne #0x800, drop @@ -306,14 +308,15 @@ Examples for low-level BPF: ret #-1 drop: ret #0 -** (Accelerated) VLAN w/ id 10: +** (Accelerated) VLAN w/ id 10:: ld vlan_tci jneq #10, drop ret #-1 drop: ret #0 -** icmp random packet sampling, 1 in 4 +** icmp random packet sampling, 1 in 4:: + ldh [12] jne #0x800, drop ldb [23] @@ -325,7 +328,7 @@ Examples for low-level BPF: ret #-1 drop: ret #0 -** SECCOMP filter example: +** SECCOMP filter example:: ld [4] /* offsetof(struct seccomp_data, arch) */ jne #0xc000003e, bad /* AUDIT_ARCH_X86_64 */ @@ -346,18 +349,18 @@ Examples for low-level BPF: 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 -ARP code: +ARP code:: -$ ./bpf_asm foo -4,40 0 0 12,21 0 1 2054,6 0 0 4294967295,6 0 0 0, + $ ./bpf_asm foo + 4,40 0 0 12,21 0 1 2054,6 0 0 4294967295,6 0 0 0, -In copy and paste C-like output: +In copy and paste C-like output:: -$ ./bpf_asm -c foo -{ 0x28, 0, 0, 0x0000000c }, -{ 0x15, 0, 1, 0x00000806 }, -{ 0x06, 0, 0, 0xffffffff }, -{ 0x06, 0, 0, 0000000000 }, + $ ./bpf_asm -c foo + { 0x28, 0, 0, 0x0000000c }, + { 0x15, 0, 1, 0x00000806 }, + { 0x06, 0, 0, 0xffffffff }, + { 0x06, 0, 0, 0000000000 }, In particular, as usage with xt_bpf or cls_bpf can result in more complex BPF filters that might not be obvious at first, it's good to test filters before @@ -366,9 +369,9 @@ bpf_dbg under tools/bpf/ in the kernel source directory. This debugger allows for testing BPF filters against given pcap files, single stepping through the BPF code on the pcap's packets and to do BPF machine register dumps. -Starting bpf_dbg is trivial and just requires issuing: +Starting bpf_dbg is trivial and just requires issuing:: -# ./bpf_dbg + # ./bpf_dbg In case input and output do not equal stdin/stdout, bpf_dbg takes an alternative stdin source as a first argument, and an alternative stdout @@ -381,86 +384,87 @@ file "~/.bpf_dbg_init" and the command history is stored in the file Interaction in bpf_dbg happens through a shell that also has auto-completion support (follow-up example commands starting with '>' denote bpf_dbg shell). The usual workflow would be to ... - -> load bpf 6,40 0 0 12,21 0 3 2048,48 0 0 23,21 0 1 1,6 0 0 65535,6 0 0 0 - Loads a BPF filter from standard output of bpf_asm, or transformed via - e.g. `tcpdump -iem1 -ddd port 22 | tr '\n' ','`. Note that for JIT - debugging (next section), this command creates a temporary socket and - loads the BPF code into the kernel. Thus, this will also be useful for - JIT developers. - -> load pcap foo.pcap - Loads standard tcpdump pcap file. - -> run [] -bpf passes:1 fails:9 - Runs through all packets from a pcap to account how many passes and fails - the filter will generate. A limit of packets to traverse can be given. - -> disassemble -l0: ldh [12] -l1: jeq #0x800, l2, l5 -l2: ldb [23] -l3: jeq #0x1, l4, l5 -l4: ret #0xffff -l5: ret #0 - Prints out BPF code disassembly. - -> dump -/* { op, jt, jf, k }, */ -{ 0x28, 0, 0, 0x0000000c }, -{ 0x15, 0, 3, 0x00000800 }, -{ 0x30, 0, 0, 0x00000017 }, -{ 0x15, 0, 1, 0x00000001 }, -{ 0x06, 0, 0, 0x0000ffff }, -{ 0x06, 0, 0, 0000000000 }, - Prints out C-style BPF code dump. - -> breakpoint 0 -breakpoint at: l0: ldh [12] -> breakpoint 1 -breakpoint at: l1: jeq #0x800, l2, l5 - ... - Sets breakpoints at particular BPF instructions. Issuing a `run` command - will walk through the pcap file continuing from the current packet and - break when a breakpoint is being hit (another `run` will continue from - the currently active breakpoint executing next instructions): - - > run - -- register dump -- - pc: [0] <-- program counter - code: [40] jt[0] jf[0] k[12] <-- plain BPF code of current instruction - curr: l0: ldh [12] <-- disassembly of current instruction - A: [00000000][0] <-- content of A (hex, decimal) - X: [00000000][0] <-- content of X (hex, decimal) - M[0,15]: [00000000][0] <-- folded content of M (hex, decimal) - -- packet dump -- <-- Current packet from pcap (hex) - len: 42 - 0: 00 19 cb 55 55 a4 00 14 a4 43 78 69 08 06 00 01 - 16: 08 00 06 04 00 01 00 14 a4 43 78 69 0a 3b 01 26 - 32: 00 00 00 00 00 00 0a 3b 01 01 - (breakpoint) - > - -> breakpoint -breakpoints: 0 1 - Prints currently set breakpoints. - -> step [-, +] - Performs single stepping through the BPF program from the current pc - offset. Thus, on each step invocation, above register dump is issued. - This can go forwards and backwards in time, a plain `step` will break - on the next BPF instruction, thus +1. (No `run` needs to be issued here.) - -> select - Selects a given packet from the pcap file to continue from. Thus, on - the next `run` or `step`, the BPF program is being evaluated against - the user pre-selected packet. Numbering starts just as in Wireshark - with index 1. - -> quit -# - Exits bpf_dbg. +:: + + > load bpf 6,40 0 0 12,21 0 3 2048,48 0 0 23,21 0 1 1,6 0 0 65535,6 0 0 0 + Loads a BPF filter from standard output of bpf_asm, or transformed via + e.g. `tcpdump -iem1 -ddd port 22 | tr '\n' ','`. Note that for JIT + debugging (next section), this command creates a temporary socket and + loads the BPF code into the kernel. Thus, this will also be useful for + JIT developers. + + > load pcap foo.pcap + Loads standard tcpdump pcap file. + + > run [] + bpf passes:1 fails:9 + Runs through all packets from a pcap to account how many passes and fails + the filter will generate. A limit of packets to traverse can be given. + + > disassemble + l0: ldh [12] + l1: jeq #0x800, l2, l5 + l2: ldb [23] + l3: jeq #0x1, l4, l5 + l4: ret #0xffff + l5: ret #0 + Prints out BPF code disassembly. + + > dump + /* { op, jt, jf, k }, */ + { 0x28, 0, 0, 0x0000000c }, + { 0x15, 0, 3, 0x00000800 }, + { 0x30, 0, 0, 0x00000017 }, + { 0x15, 0, 1, 0x00000001 }, + { 0x06, 0, 0, 0x0000ffff }, + { 0x06, 0, 0, 0000000000 }, + Prints out C-style BPF code dump. + + > breakpoint 0 + breakpoint at: l0: ldh [12] + > breakpoint 1 + breakpoint at: l1: jeq #0x800, l2, l5 + ... + Sets breakpoints at particular BPF instructions. Issuing a `run` command + will walk through the pcap file continuing from the current packet and + break when a breakpoint is being hit (another `run` will continue from + the currently active breakpoint executing next instructions): + + > run + -- register dump -- + pc: [0] <-- program counter + code: [40] jt[0] jf[0] k[12] <-- plain BPF code of current instruction + curr: l0:ldh [12] <-- disassembly of current instruction + A: [00000000][0] <-- content of A (hex, decimal) + X: [00000000][0] <-- content of X (hex, decimal) + M[0,15]: [00000000][0] <-- folded content of M (hex, decimal) + -- packet dump -- <-- Current packet from pcap (hex) + len: 42 + 0: 00 19 cb 55 55 a4 00 14 a4 43 78 69 08 06 00 01 + 16: 08 00 06 04 00 01 00 14 a4 43 78 69 0a 3b 01 26 + 32: 00 00 00 00 00 00 0a 3b 01 01 + (breakpoint) + > + + > breakpoint + breakpoints: 0 1 + Prints currently set breakpoints. + + > step [-, +] + Performs single stepping through the BPF program from the current pc + offset. Thus, on each step invocation, above register dump is issued. + This can go forwards and backwards in time, a plain `step` will break + on the next BPF instruction, thus +1. (No `run` needs to be issued here.) + + > select + Selects a given packet from the pcap file to continue from. Thus, on + the next `run` or `step`, the BPF program is being evaluated against + the user pre-selected packet. Numbering starts just as in Wireshark + with index 1. + + > quit + # + Exits bpf_dbg. JIT compiler ============ @@ -468,23 +472,23 @@ JIT compiler The Linux kernel has a built-in BPF JIT compiler for x86_64, SPARC, PowerPC, ARM, ARM64, MIPS and s390 and can be enabled through CONFIG_BPF_JIT. The JIT compiler is transparently invoked for each attached filter from user space -or for internal kernel users if it has been previously enabled by root: +or for internal kernel users if it has been previously enabled by root:: echo 1 > /proc/sys/net/core/bpf_jit_enable For JIT developers, doing audits etc, each compile run can output the generated -opcode image into the kernel log via: +opcode image into the kernel log via:: echo 2 > /proc/sys/net/core/bpf_jit_enable -Example output from dmesg: +Example output from dmesg:: -[ 3389.935842] flen=6 proglen=70 pass=3 image=ffffffffa0069c8f -[ 3389.935847] JIT code: 00000000: 55 48 89 e5 48 83 ec 60 48 89 5d f8 44 8b 4f 68 -[ 3389.935849] JIT code: 00000010: 44 2b 4f 6c 4c 8b 87 d8 00 00 00 be 0c 00 00 00 -[ 3389.935850] JIT code: 00000020: e8 1d 94 ff e0 3d 00 08 00 00 75 16 be 17 00 00 -[ 3389.935851] JIT code: 00000030: 00 e8 28 94 ff e0 83 f8 01 75 07 b8 ff ff 00 00 -[ 3389.935852] JIT code: 00000040: eb 02 31 c0 c9 c3 + [ 3389.935842] flen=6 proglen=70 pass=3 image=ffffffffa0069c8f + [ 3389.935847] JIT code: 00000000: 55 48 89 e5 48 83 ec 60 48 89 5d f8 44 8b 4f 68 + [ 3389.935849] JIT code: 00000010: 44 2b 4f 6c 4c 8b 87 d8 00 00 00 be 0c 00 00 00 + [ 3389.935850] JIT code: 00000020: e8 1d 94 ff e0 3d 00 08 00 00 75 16 be 17 00 00 + [ 3389.935851] JIT code: 00000030: 00 e8 28 94 ff e0 83 f8 01 75 07 b8 ff ff 00 00 + [ 3389.935852] JIT code: 00000040: eb 02 31 c0 c9 c3 When CONFIG_BPF_JIT_ALWAYS_ON is enabled, bpf_jit_enable is permanently set to 1 and setting any other value than that will return in failure. This is even the case for @@ -493,77 +497,77 @@ is discouraged and introspection through bpftool (under tools/bpf/bpftool/) is t generally recommended approach instead. In the kernel source tree under tools/bpf/, there's bpf_jit_disasm for -generating disassembly out of the kernel log's hexdump: - -# ./bpf_jit_disasm -70 bytes emitted from JIT compiler (pass:3, flen:6) -ffffffffa0069c8f + : - 0: push %rbp - 1: mov %rsp,%rbp - 4: sub $0x60,%rsp - 8: mov %rbx,-0x8(%rbp) - c: mov 0x68(%rdi),%r9d - 10: sub 0x6c(%rdi),%r9d - 14: mov 0xd8(%rdi),%r8 - 1b: mov $0xc,%esi - 20: callq 0xffffffffe0ff9442 - 25: cmp $0x800,%eax - 2a: jne 0x0000000000000042 - 2c: mov $0x17,%esi - 31: callq 0xffffffffe0ff945e - 36: cmp $0x1,%eax - 39: jne 0x0000000000000042 - 3b: mov $0xffff,%eax - 40: jmp 0x0000000000000044 - 42: xor %eax,%eax - 44: leaveq - 45: retq +generating disassembly out of the kernel log's hexdump:: + + # ./bpf_jit_disasm + 70 bytes emitted from JIT compiler (pass:3, flen:6) + ffffffffa0069c8f + : + 0: push %rbp + 1: mov %rsp,%rbp + 4: sub $0x60,%rsp + 8: mov %rbx,-0x8(%rbp) + c: mov 0x68(%rdi),%r9d + 10: sub 0x6c(%rdi),%r9d + 14: mov 0xd8(%rdi),%r8 + 1b: mov $0xc,%esi + 20: callq 0xffffffffe0ff9442 + 25: cmp $0x800,%eax + 2a: jne 0x0000000000000042 + 2c: mov $0x17,%esi + 31: callq 0xffffffffe0ff945e + 36: cmp $0x1,%eax + 39: jne 0x0000000000000042 + 3b: mov $0xffff,%eax + 40: jmp 0x0000000000000044 + 42: xor %eax,%eax + 44: leaveq + 45: retq Issuing option `-o` will "annotate" opcodes to resulting assembler -instructions, which can be very useful for JIT developers: +instructions, which can be very useful for JIT developers:: -# ./bpf_jit_disasm -o -70 bytes emitted from JIT compiler (pass:3, flen:6) -ffffffffa0069c8f + : - 0: push %rbp + # ./bpf_jit_disasm -o + 70 bytes emitted from JIT compiler (pass:3, flen:6) + ffffffffa0069c8f + : + 0: push %rbp 55 - 1: mov %rsp,%rbp + 1: mov %rsp,%rbp 48 89 e5 - 4: sub $0x60,%rsp + 4: sub $0x60,%rsp 48 83 ec 60 - 8: mov %rbx,-0x8(%rbp) + 8: mov %rbx,-0x8(%rbp) 48 89 5d f8 - c: mov 0x68(%rdi),%r9d + c: mov 0x68(%rdi),%r9d 44 8b 4f 68 - 10: sub 0x6c(%rdi),%r9d + 10: sub 0x6c(%rdi),%r9d 44 2b 4f 6c - 14: mov 0xd8(%rdi),%r8 + 14: mov 0xd8(%rdi),%r8 4c 8b 87 d8 00 00 00 - 1b: mov $0xc,%esi + 1b: mov $0xc,%esi be 0c 00 00 00 - 20: callq 0xffffffffe0ff9442 + 20: callq 0xffffffffe0ff9442 e8 1d 94 ff e0 - 25: cmp $0x800,%eax + 25: cmp $0x800,%eax 3d 00 08 00 00 - 2a: jne 0x0000000000000042 + 2a: jne 0x0000000000000042 75 16 - 2c: mov $0x17,%esi + 2c: mov $0x17,%esi be 17 00 00 00 - 31: callq 0xffffffffe0ff945e + 31: callq 0xffffffffe0ff945e e8 28 94 ff e0 - 36: cmp $0x1,%eax + 36: cmp $0x1,%eax 83 f8 01 - 39: jne 0x0000000000000042 + 39: jne 0x0000000000000042 75 07 - 3b: mov $0xffff,%eax + 3b: mov $0xffff,%eax b8 ff ff 00 00 - 40: jmp 0x0000000000000044 + 40: jmp 0x0000000000000044 eb 02 - 42: xor %eax,%eax + 42: xor %eax,%eax 31 c0 - 44: leaveq + 44: leaveq c9 - 45: retq + 45: retq c3 For BPF JIT developers, bpf_jit_disasm, bpf_asm and bpf_dbg provides a useful @@ -663,9 +667,18 @@ Some core changes of the new internal format: - Conditional jt/jf targets replaced with jt/fall-through: - While the original design has constructs such as "if (cond) jump_true; - else jump_false;", they are being replaced into alternative constructs like - "if (cond) jump_true; /* else fall-through */". + While the original design has constructs such as:: + + if (cond) + jump_true; + else + jump_false; + + they are being replaced into alternative constructs like:: + + if (cond) + jump_true; + /* else fall-through */ - Introduces bpf_call insn and register passing convention for zero overhead calls from/to other kernel functions: @@ -684,30 +697,30 @@ Some core changes of the new internal format: a return value of the function. Since R6 - R9 are callee saved, their state is preserved across the call. - For example, consider three C functions: + For example, consider three C functions:: - u64 f1() { return (*_f2)(1); } - u64 f2(u64 a) { return f3(a + 1, a); } - u64 f3(u64 a, u64 b) { return a - b; } + u64 f1() { return (*_f2)(1); } + u64 f2(u64 a) { return f3(a + 1, a); } + u64 f3(u64 a, u64 b) { return a - b; } - GCC can compile f1, f3 into x86_64: + GCC can compile f1, f3 into x86_64:: - f1: - movl $1, %edi - movq _f2(%rip), %rax - jmp *%rax - f3: - movq %rdi, %rax - subq %rsi, %rax - ret + f1: + movl $1, %edi + movq _f2(%rip), %rax + jmp *%rax + f3: + movq %rdi, %rax + subq %rsi, %rax + ret - Function f2 in eBPF may look like: + Function f2 in eBPF may look like:: - f2: - bpf_mov R2, R1 - bpf_add R1, 1 - bpf_call f3 - bpf_exit + f2: + bpf_mov R2, R1 + bpf_add R1, 1 + bpf_call f3 + bpf_exit If f2 is JITed and the pointer stored to '_f2'. The calls f1 -> f2 -> f3 and returns will be seamless. Without JIT, __bpf_prog_run() interpreter needs to @@ -720,7 +733,7 @@ Some core changes of the new internal format: in the future. On 64-bit architectures all register map to HW registers one to one. For - example, x86_64 JIT compiler can map them as ... + example, x86_64 JIT compiler can map them as ... :: R0 - rax R1 - rdi @@ -737,7 +750,7 @@ Some core changes of the new internal format: ... since x86_64 ABI mandates rdi, rsi, rdx, rcx, r8, r9 for argument passing and rbx, r12 - r15 are callee saved. - Then the following internal BPF pseudo-program: + Then the following internal BPF pseudo-program:: bpf_mov R6, R1 /* save ctx */ bpf_mov R2, 2 @@ -755,7 +768,7 @@ Some core changes of the new internal format: bpf_add R0, R7 bpf_exit - After JIT to x86_64 may look like: + After JIT to x86_64 may look like:: push %rbp mov %rsp,%rbp @@ -781,11 +794,11 @@ Some core changes of the new internal format: leaveq retq - Which is in this example equivalent in C to: + Which is in this example equivalent in C to:: u64 bpf_filter(u64 ctx) { - return foo(ctx, 2, 3, 4, 5) + bar(ctx, 6, 7, 8, 9); + return foo(ctx, 2, 3, 4, 5) + bar(ctx, 6, 7, 8, 9); } In-kernel functions foo() and bar() with prototype: u64 (*)(u64 arg1, u64 @@ -795,7 +808,7 @@ Some core changes of the new internal format: interpreter. R0-R5 are scratch registers, so eBPF program needs to preserve them across the calls as defined by calling convention. - For example the following program is invalid: + For example the following program is invalid:: bpf_mov R1, 1 bpf_call foo @@ -814,7 +827,7 @@ The input context pointer for invoking the interpreter function is generic, its content is defined by a specific use case. For seccomp register R1 points to seccomp_data, for converted BPF filters R1 points to a skb. -A program, that is translated internally consists of the following elements: +A program, that is translated internally consists of the following elements:: op:16, jt:8, jf:8, k:32 ==> op:8, dst_reg:4, src_reg:4, off:16, imm:32 @@ -849,7 +862,7 @@ eBPF opcode encoding eBPF is reusing most of the opcode encoding from classic to simplify conversion of classic BPF to eBPF. For arithmetic and jump instructions the 8-bit 'code' -field is divided into three parts: +field is divided into three parts:: +----------------+--------+--------------------+ | 4 bits | 1 bit | 3 bits | @@ -857,7 +870,7 @@ field is divided into three parts: +----------------+--------+--------------------+ (MSB) (LSB) -Three LSB bits store instruction class which is one of: +Three LSB bits store instruction class which is one of:: Classic BPF classes: eBPF classes: @@ -871,23 +884,24 @@ Three LSB bits store instruction class which is one of: BPF_MISC 0x07 BPF_ALU64 0x07 When BPF_CLASS(code) == BPF_ALU or BPF_JMP, 4th bit encodes source operand ... +:: BPF_K 0x00 BPF_X 0x08 - * in classic BPF, this means: +in classic BPF, this means:: BPF_SRC(code) == BPF_X - use register X as source operand BPF_SRC(code) == BPF_K - use 32-bit immediate as source operand - * in eBPF, this means: +in eBPF, this means:: BPF_SRC(code) == BPF_X - use 'src_reg' register as source operand BPF_SRC(code) == BPF_K - use 32-bit immediate as source operand ... and four MSB bits store operation code. -If BPF_CLASS(code) == BPF_ALU or BPF_ALU64 [ in eBPF ], BPF_OP(code) is one of: +If BPF_CLASS(code) == BPF_ALU or BPF_ALU64 [ in eBPF ], BPF_OP(code) is one of:: BPF_ADD 0x00 BPF_SUB 0x10 @@ -904,7 +918,7 @@ If BPF_CLASS(code) == BPF_ALU or BPF_ALU64 [ in eBPF ], BPF_OP(code) is one of: BPF_ARSH 0xc0 /* eBPF only: sign extending shift right */ BPF_END 0xd0 /* eBPF only: endianness conversion */ -If BPF_CLASS(code) == BPF_JMP, BPF_OP(code) is one of: +If BPF_CLASS(code) == BPF_JMP, BPF_OP(code) is one of:: BPF_JA 0x00 BPF_JEQ 0x10 @@ -941,7 +955,7 @@ in eBPF means function exit only. The eBPF program needs to store return value into register R0 before doing a BPF_EXIT. Class 6 in eBPF is currently unused and reserved for future use. -For load and store instructions the 8-bit 'code' field is divided as: +For load and store instructions the 8-bit 'code' field is divided as:: +--------+--------+-------------------+ | 3 bits | 2 bits | 3 bits | @@ -949,21 +963,21 @@ For load and store instructions the 8-bit 'code' field is divided as: +--------+--------+-------------------+ (MSB) (LSB) -Size modifier is one of ... +Size modifier is one of ... :: BPF_W 0x00 /* word */ BPF_H 0x08 /* half word */ BPF_B 0x10 /* byte */ BPF_DW 0x18 /* eBPF only, double word */ -... which encodes size of load/store operation: +... which encodes size of load/store operation:: - B - 1 byte - H - 2 byte - W - 4 byte - DW - 8 byte (eBPF only) + B - 1 byte + H - 2 byte + W - 4 byte + DW - 8 byte (eBPF only) -Mode modifier is one of: +Mode modifier is one of:: BPF_IMM 0x00 /* used for 32-bit mov in classic BPF and 64-bit in eBPF */ BPF_ABS 0x20 @@ -991,20 +1005,20 @@ the interpreter will abort the execution of the program. JIT compilers therefore must preserve this property. src_reg and imm32 fields are explicit inputs to these instructions. -For example: +For example:: BPF_IND | BPF_W | BPF_LD means: R0 = ntohl(*(u32 *) (((struct sk_buff *) R6)->data + src_reg + imm32)) and R1 - R5 were scratched. -Unlike classic BPF instruction set, eBPF has generic load/store operations: +Unlike classic BPF instruction set, eBPF has generic load/store operations:: -BPF_MEM | | BPF_STX: *(size *) (dst_reg + off) = src_reg -BPF_MEM | | BPF_ST: *(size *) (dst_reg + off) = imm32 -BPF_MEM | | BPF_LDX: dst_reg = *(size *) (src_reg + off) -BPF_XADD | BPF_W | BPF_STX: lock xadd *(u32 *)(dst_reg + off16) += src_reg -BPF_XADD | BPF_DW | BPF_STX: lock xadd *(u64 *)(dst_reg + off16) += src_reg + BPF_MEM | | BPF_STX: *(size *) (dst_reg + off) = src_reg + BPF_MEM | | BPF_ST: *(size *) (dst_reg + off) = imm32 + BPF_MEM | | BPF_LDX: dst_reg = *(size *) (src_reg + off) + BPF_XADD | BPF_W | BPF_STX: lock xadd *(u32 *)(dst_reg + off16) += src_reg + BPF_XADD | BPF_DW | BPF_STX: lock xadd *(u64 *)(dst_reg + off16) += src_reg Where size is one of: BPF_B or BPF_H or BPF_W or BPF_DW. Note that 1 and 2 byte atomic increments are not supported. @@ -1037,29 +1051,35 @@ since addition of two valid pointers makes invalid pointer. (In 'secure' mode verifier will reject any type of pointer arithmetic to make sure that kernel addresses don't leak to unprivileged users) -If register was never written to, it's not readable: +If register was never written to, it's not readable:: + bpf_mov R0 = R2 bpf_exit + will be rejected, since R2 is unreadable at the start of the program. After kernel function call, R1-R5 are reset to unreadable and R0 has a return type of the function. -Since R6-R9 are callee saved, their state is preserved across the call. +Since R6-R9 are callee saved, their state is preserved across the call. :: + bpf_mov R6 = 1 bpf_call foo bpf_mov R0 = R6 bpf_exit + is a correct program. If there was R1 instead of R6, it would have been rejected. load/store instructions are allowed only with registers of valid types, which are PTR_TO_CTX, PTR_TO_MAP, PTR_TO_STACK. They are bounds and alignment checked. -For example: +For example:: + bpf_mov R1 = 1 bpf_mov R2 = 2 bpf_xadd *(u32 *)(R1 + 3) += R2 bpf_exit + will be rejected, since R1 doesn't have a valid pointer type at the time of execution of instruction bpf_xadd. @@ -1067,8 +1087,10 @@ At the start R1 type is PTR_TO_CTX (a pointer to generic 'struct bpf_context') A callback is used to customize verifier to restrict eBPF program access to only certain fields within ctx structure with specified size and alignment. -For example, the following insn: +For example, the following insn:: + bpf_ld R0 = *(u32 *)(R6 + 8) + intends to load a word from address R6 + 8 and store it into R0 If R6=PTR_TO_CTX, via is_valid_access() callback the verifier will know that offset 8 of size 4 bytes can be accessed for reading, otherwise @@ -1080,9 +1102,11 @@ so it will fail verification, since it's out of bounds. The verifier will allow eBPF program to read data from stack only after it wrote into it. Classic BPF verifier does similar check with M[0-15] memory slots. -For example: +For example:: + bpf_ld R0 = *(u32 *)(R10 - 4) bpf_exit + is invalid program. Though R10 is correct read-only register and has type PTR_TO_STACK and R10 - 4 is within stack bounds, there were no stores into that location. @@ -1118,19 +1142,21 @@ This is done with 'struct bpf_reg_state', defined in include/linux/ bpf_verifier.h, which unifies tracking of scalar and pointer values. Each register state has a type, which is either NOT_INIT (the register has not been written to), SCALAR_VALUE (some value which is not usable as a pointer), or a -pointer type. The types of pointers describe their base, as follows: +pointer type. The types of pointers describe their base, as follows:: + PTR_TO_CTX Pointer to bpf_context. CONST_PTR_TO_MAP Pointer to struct bpf_map. "Const" because arithmetic - on these pointers is forbidden. + on these pointers is forbidden. PTR_TO_MAP_VALUE Pointer to the value stored in a map element. PTR_TO_MAP_VALUE_OR_NULL - Either a pointer to a map value, or NULL; map accesses - (see section 'eBPF maps', below) return this type, - which becomes a PTR_TO_MAP_VALUE when checked != NULL. - Arithmetic on these pointers is forbidden. + Either a pointer to a map value, or NULL; map accesses + (see section 'eBPF maps', below) return this type, + which becomes a PTR_TO_MAP_VALUE when checked != NULL. + Arithmetic on these pointers is forbidden. PTR_TO_STACK Frame pointer. PTR_TO_PACKET skb->data. PTR_TO_PACKET_END skb->data + headlen; arithmetic forbidden. + However, a pointer may be offset from this base (as a result of pointer arithmetic), and this is tracked in two parts: the 'fixed offset' and 'variable offset'. The former is used when an exactly-known value (e.g. an immediate @@ -1182,14 +1208,15 @@ Direct packet access ==================== In cls_bpf and act_bpf programs the verifier allows direct access to the packet data via skb->data and skb->data_end pointers. -Ex: -1: r4 = *(u32 *)(r1 +80) /* load skb->data_end */ -2: r3 = *(u32 *)(r1 +76) /* load skb->data */ -3: r5 = r3 -4: r5 += 14 -5: if r5 > r4 goto pc+16 -R1=ctx R3=pkt(id=0,off=0,r=14) R4=pkt_end R5=pkt(id=0,off=14,r=14) R10=fp -6: r0 = *(u16 *)(r3 +12) /* access 12 and 13 bytes of the packet */ +Ex:: + + 1: r4 = *(u32 *)(r1 +80) /* load skb->data_end */ + 2: r3 = *(u32 *)(r1 +76) /* load skb->data */ + 3: r5 = r3 + 4: r5 += 14 + 5: if r5 > r4 goto pc+16 + R1=ctx R3=pkt(id=0,off=0,r=14) R4=pkt_end R5=pkt(id=0,off=14,r=14) R10=fp + 6: r0 = *(u16 *)(r3 +12) /* access 12 and 13 bytes of the packet */ this 2byte load from the packet is safe to do, since the program author did check 'if (skb->data + 14 > skb->data_end) goto err' at insn #5 which @@ -1204,23 +1231,25 @@ to the packet data, but constant 14 was added to the register, so it now points to 'skb->data + 14' and accessible range is [R5, R5 + 14 - 14) which is zero bytes. -More complex packet access may look like: - R0=inv1 R1=ctx R3=pkt(id=0,off=0,r=14) R4=pkt_end R5=pkt(id=0,off=14,r=14) R10=fp - 6: r0 = *(u8 *)(r3 +7) /* load 7th byte from the packet */ - 7: r4 = *(u8 *)(r3 +12) - 8: r4 *= 14 - 9: r3 = *(u32 *)(r1 +76) /* load skb->data */ -10: r3 += r4 -11: r2 = r1 -12: r2 <<= 48 -13: r2 >>= 48 -14: r3 += r2 -15: r2 = r3 -16: r2 += 8 -17: r1 = *(u32 *)(r1 +80) /* load skb->data_end */ -18: if r2 > r1 goto pc+2 - R0=inv(id=0,umax_value=255,var_off=(0x0; 0xff)) R1=pkt_end R2=pkt(id=2,off=8,r=8) R3=pkt(id=2,off=0,r=8) R4=inv(id=0,umax_value=3570,var_off=(0x0; 0xfffe)) R5=pkt(id=0,off=14,r=14) R10=fp -19: r1 = *(u8 *)(r3 +4) +More complex packet access may look like:: + + R0=inv1 R1=ctx R3=pkt(id=0,off=0,r=14) R4=pkt_end R5=pkt(id=0,off=14,r=14) R10=fp + 6: r0 = *(u8 *)(r3 +7) /* load 7th byte from the packet */ + 7: r4 = *(u8 *)(r3 +12) + 8: r4 *= 14 + 9: r3 = *(u32 *)(r1 +76) /* load skb->data */ + 10: r3 += r4 + 11: r2 = r1 + 12: r2 <<= 48 + 13: r2 >>= 48 + 14: r3 += r2 + 15: r2 = r3 + 16: r2 += 8 + 17: r1 = *(u32 *)(r1 +80) /* load skb->data_end */ + 18: if r2 > r1 goto pc+2 + R0=inv(id=0,umax_value=255,var_off=(0x0; 0xff)) R1=pkt_end R2=pkt(id=2,off=8,r=8) R3=pkt(id=2,off=0,r=8) R4=inv(id=0,umax_value=3570,var_off=(0x0; 0xfffe)) R5=pkt(id=0,off=14,r=14) R10=fp + 19: r1 = *(u8 *)(r3 +4) + The state of the register R3 is R3=pkt(id=2,off=0,r=8) id=2 means that two 'r3 += rX' instructions were seen, so r3 points to some offset within a packet and since the program author did @@ -1246,7 +1275,8 @@ which calls adjust_ptr_min_max_vals() for adding pointer to scalar (or vice versa) and adjust_scalar_min_max_vals() for operations on two scalars. The end result is that bpf program author can access packet directly -using normal C code as: +using normal C code as:: + void *data = (void *)(long)skb->data; void *data_end = (void *)(long)skb->data_end; struct eth_hdr *eth = data; @@ -1254,13 +1284,14 @@ using normal C code as: struct udphdr *udp = data + sizeof(*eth) + sizeof(*iph); if (data + sizeof(*eth) + sizeof(*iph) + sizeof(*udp) > data_end) - return 0; + return 0; if (eth->h_proto != htons(ETH_P_IP)) - return 0; + return 0; if (iph->protocol != IPPROTO_UDP || iph->ihl != 5) - return 0; + return 0; if (udp->dest == 53 || udp->source == 9) - ...; + ...; + which makes such programs easier to write comparing to LD_ABS insn and significantly faster. @@ -1271,6 +1302,7 @@ eBPF maps and userspace. The maps are accessed from user space via BPF syscall, which has commands: + - create a map with given type and attributes map_fd = bpf(BPF_MAP_CREATE, union bpf_attr *attr, u32 size) using attr->map_type, attr->key_size, attr->value_size, attr->max_entries @@ -1327,66 +1359,79 @@ Understanding eBPF verifier messages The following are few examples of invalid eBPF programs and verifier error messages as seen in the log: -Program with unreachable instructions: -static struct bpf_insn prog[] = { - BPF_EXIT_INSN(), - BPF_EXIT_INSN(), -}; -Error: - unreachable insn 1 +Program with unreachable instructions:: + + static struct bpf_insn prog[] = { + BPF_EXIT_INSN(), + BPF_EXIT_INSN(), + }; + + Error: + unreachable insn 1 + +Program that reads uninitialized register:: -Program that reads uninitialized register: BPF_MOV64_REG(BPF_REG_0, BPF_REG_2), BPF_EXIT_INSN(), -Error: - 0: (bf) r0 = r2 - R2 !read_ok -Program that doesn't initialize R0 before exiting: + Error: + 0: (bf) r0 = r2 + R2 !read_ok + +Program that doesn't initialize R0 before exiting:: + BPF_MOV64_REG(BPF_REG_2, BPF_REG_1), BPF_EXIT_INSN(), -Error: - 0: (bf) r2 = r1 - 1: (95) exit - R0 !read_ok -Program that accesses stack out of bounds: + Error: + 0: (bf) r2 = r1 + 1: (95) exit + R0 !read_ok + +Program that accesses stack out of bounds:: + BPF_ST_MEM(BPF_DW, BPF_REG_10, 8, 0), BPF_EXIT_INSN(), -Error: - 0: (7a) *(u64 *)(r10 +8) = 0 - invalid stack off=8 size=8 -Program that doesn't initialize stack before passing its address into function: + Error: + 0: (7a) *(u64 *)(r10 +8) = 0 + invalid stack off=8 size=8 + +Program that doesn't initialize stack before passing its address into function:: + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), BPF_LD_MAP_FD(BPF_REG_1, 0), BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), BPF_EXIT_INSN(), -Error: - 0: (bf) r2 = r10 - 1: (07) r2 += -8 - 2: (b7) r1 = 0x0 - 3: (85) call 1 - invalid indirect read from stack off -8+0 size 8 - -Program that uses invalid map_fd=0 while calling to map_lookup_elem() function: + + Error: + 0: (bf) r2 = r10 + 1: (07) r2 += -8 + 2: (b7) r1 = 0x0 + 3: (85) call 1 + invalid indirect read from stack off -8+0 size 8 + +Program that uses invalid map_fd=0 while calling to map_lookup_elem() function:: + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), BPF_LD_MAP_FD(BPF_REG_1, 0), BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), BPF_EXIT_INSN(), -Error: - 0: (7a) *(u64 *)(r10 -8) = 0 - 1: (bf) r2 = r10 - 2: (07) r2 += -8 - 3: (b7) r1 = 0x0 - 4: (85) call 1 - fd 0 is not pointing to valid bpf_map + + Error: + 0: (7a) *(u64 *)(r10 -8) = 0 + 1: (bf) r2 = r10 + 2: (07) r2 += -8 + 3: (b7) r1 = 0x0 + 4: (85) call 1 + fd 0 is not pointing to valid bpf_map Program that doesn't check return value of map_lookup_elem() before accessing -map element: +map element:: + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), @@ -1394,17 +1439,19 @@ map element: BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 0), BPF_EXIT_INSN(), -Error: - 0: (7a) *(u64 *)(r10 -8) = 0 - 1: (bf) r2 = r10 - 2: (07) r2 += -8 - 3: (b7) r1 = 0x0 - 4: (85) call 1 - 5: (7a) *(u64 *)(r0 +0) = 0 - R0 invalid mem access 'map_value_or_null' + + Error: + 0: (7a) *(u64 *)(r10 -8) = 0 + 1: (bf) r2 = r10 + 2: (07) r2 += -8 + 3: (b7) r1 = 0x0 + 4: (85) call 1 + 5: (7a) *(u64 *)(r0 +0) = 0 + R0 invalid mem access 'map_value_or_null' Program that correctly checks map_lookup_elem() returned value for NULL, but -accesses the memory with incorrect alignment: +accesses the memory with incorrect alignment:: + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), @@ -1413,20 +1460,22 @@ accesses the memory with incorrect alignment: BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 1), BPF_ST_MEM(BPF_DW, BPF_REG_0, 4, 0), BPF_EXIT_INSN(), -Error: - 0: (7a) *(u64 *)(r10 -8) = 0 - 1: (bf) r2 = r10 - 2: (07) r2 += -8 - 3: (b7) r1 = 1 - 4: (85) call 1 - 5: (15) if r0 == 0x0 goto pc+1 - R0=map_ptr R10=fp - 6: (7a) *(u64 *)(r0 +4) = 0 - misaligned access off 4 size 8 + + Error: + 0: (7a) *(u64 *)(r10 -8) = 0 + 1: (bf) r2 = r10 + 2: (07) r2 += -8 + 3: (b7) r1 = 1 + 4: (85) call 1 + 5: (15) if r0 == 0x0 goto pc+1 + R0=map_ptr R10=fp + 6: (7a) *(u64 *)(r0 +4) = 0 + misaligned access off 4 size 8 Program that correctly checks map_lookup_elem() returned value for NULL and accesses memory with correct alignment in one side of 'if' branch, but fails -to do so in the other side of 'if' branch: +to do so in the other side of 'if' branch:: + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), @@ -1437,20 +1486,21 @@ to do so in the other side of 'if' branch: BPF_EXIT_INSN(), BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 1), BPF_EXIT_INSN(), -Error: - 0: (7a) *(u64 *)(r10 -8) = 0 - 1: (bf) r2 = r10 - 2: (07) r2 += -8 - 3: (b7) r1 = 1 - 4: (85) call 1 - 5: (15) if r0 == 0x0 goto pc+2 - R0=map_ptr R10=fp - 6: (7a) *(u64 *)(r0 +0) = 0 - 7: (95) exit - - from 5 to 8: R0=imm0 R10=fp - 8: (7a) *(u64 *)(r0 +0) = 1 - R0 invalid mem access 'imm' + + Error: + 0: (7a) *(u64 *)(r10 -8) = 0 + 1: (bf) r2 = r10 + 2: (07) r2 += -8 + 3: (b7) r1 = 1 + 4: (85) call 1 + 5: (15) if r0 == 0x0 goto pc+2 + R0=map_ptr R10=fp + 6: (7a) *(u64 *)(r0 +0) = 0 + 7: (95) exit + + from 5 to 8: R0=imm0 R10=fp + 8: (7a) *(u64 *)(r0 +0) = 1 + R0 invalid mem access 'imm' Testing ======= @@ -1458,7 +1508,7 @@ Testing Next to the BPF toolchain, the kernel also ships a test module that contains various test cases for classic and internal BPF that can be executed against the BPF interpreter and JIT compiler. It can be found in lib/test_bpf.c and -enabled via Kconfig: +enabled via Kconfig:: CONFIG_TEST_BPF=m From patchwork Wed Aug 1 05:09:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 951929 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tobin.cc Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tobin.cc header.i=@tobin.cc header.b="I34rT4TA"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="gcX5wWLO"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41gLw40dDTz9s3Z for ; Wed, 1 Aug 2018 15:09:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733190AbeHAGxd (ORCPT ); Wed, 1 Aug 2018 02:53:33 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:43197 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731897AbeHAGxd (ORCPT ); Wed, 1 Aug 2018 02:53:33 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id B32465A9; Wed, 1 Aug 2018 01:09:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 01 Aug 2018 01:09:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=z1R3eoUnFc0Tiga+5 CjudKJUG+S+fK7wqMn3SI49NC8=; b=I34rT4TAYbhrfeqX3OPXQB+ai724BT902 dVYXLB3AU+Ta5ALCKPotMFK0VC/UUFCKF+rCD3VO2kp4YRI9of2eRgA6TGZtvTyd X/8GQHKl4LfktoRc449hur10gDnf3IihqztwjpMae53w4deOs3IoR1AUUn2DygM0 ESIb8/tGPQnBk0JFN5TBLxLsIAV+I/8duFt+OAPz4aRbY/lZmklpjuewAKQj6kS1 NJrE+w27wzcY0B8iF6+dtEu5Ik5M9Q/y7PIyqrvye5ystP8Ta3FGqNoHjhDmeXz4 N6A+uKUgRXAlC6U91PqSkh8pG5VpyDJOkvGDUKkS2vl0YNDgjX0CA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=z1R3eoUnFc0Tiga+5CjudKJUG+S+fK7wqMn3SI49NC8=; b=gcX5wWLO DXMVlwiep2MnRTQERf2xz6aOCeir2MX585W0rLR8p3cKdTBkrizvIxI4Mt84ZcAX pDVl/4aVPbF/6w+y7+Q0GUFvLBE90fLHAXZZ+7Uc2dfXPOUYREO3qK5g60sV2eTa GHQUAfrNFBvy5CjI3KCXtZsTQhJLdlp8Msj1eS0lJt4SbcszQ6khcKEt/ZXa4dKB W4nXRl1NDILnAvC1xvQHpg+P6faYHfNXkzsL2rwuD69EeoMKu01rIZ+8kqw+5OCE sFNwHDUJWucJFTMuKgguzPEZ3qewO8C1bm6fq6MsIlhf0SOlCebXRj9ziMeUpoaM i8mdGWwhRaEBZA== X-ME-Proxy: X-ME-Sender: Received: from localhost (124-169-17-12.dyn.iinet.net.au [124.169.17.12]) by mail.messagingengine.com (Postfix) with ESMTPA id 3BCD11026B; Wed, 1 Aug 2018 01:09:46 -0400 (EDT) From: "Tobin C. Harding" To: Daniel Borkmann , Alexei Starovoitov Cc: "Tobin C. Harding" , Jonathan Corbet , "David S. Miller" , linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 06/13] docs: net: Remove non-standard identifiers Date: Wed, 1 Aug 2018 15:09:01 +1000 Message-Id: <20180801050908.29970-7-me@tobin.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180801050908.29970-1-me@tobin.cc> References: <20180801050908.29970-1-me@tobin.cc> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org File uses a custom identifier '**'. Documentation build is cleaner if we use standard identifiers. Usage is not _really_ a list and its not _really_ a section header. Lets just remove the double stars since we just added code snippet format for following text so the identifiers are redundant now. Remove non-standard identifiers '**'. Signed-off-by: Tobin C. Harding --- Documentation/networking/filter.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/networking/filter.rst b/Documentation/networking/filter.rst index 916e7ac01576..62630e8f023a 100644 --- a/Documentation/networking/filter.rst +++ b/Documentation/networking/filter.rst @@ -292,14 +292,14 @@ Possible BPF extensions are shown in the following table:: These extensions can also be prefixed with '#'. Examples for low-level BPF: -** ARP packets:: +ARP packets:: ldh [12] jne #0x806, drop ret #-1 drop: ret #0 -** IPv4 TCP packets:: +IPv4 TCP packets:: ldh [12] jne #0x800, drop @@ -308,14 +308,14 @@ Examples for low-level BPF: ret #-1 drop: ret #0 -** (Accelerated) VLAN w/ id 10:: +(Accelerated) VLAN w/ id 10:: ld vlan_tci jneq #10, drop ret #-1 drop: ret #0 -** icmp random packet sampling, 1 in 4:: +icmp random packet sampling, 1 in 4:: ldh [12] jne #0x800, drop @@ -328,7 +328,7 @@ Examples for low-level BPF: ret #-1 drop: ret #0 -** SECCOMP filter example:: +SECCOMP filter example:: ld [4] /* offsetof(struct seccomp_data, arch) */ jne #0xc000003e, bad /* AUDIT_ARCH_X86_64 */ From patchwork Wed Aug 1 05:09:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 951936 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tobin.cc Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tobin.cc header.i=@tobin.cc header.b="T/1NkHaV"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="Io0tdNOb"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41gLx03rwtz9s0R for ; Wed, 1 Aug 2018 15:10:44 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733206AbeHAGxh (ORCPT ); Wed, 1 Aug 2018 02:53:37 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:38253 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733201AbeHAGxg (ORCPT ); Wed, 1 Aug 2018 02:53:36 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 14C82690; Wed, 1 Aug 2018 01:09:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 01 Aug 2018 01:09:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=pGznYWx2BfXKBRCC2 WGyCsSAlL6XIJll52rwqvBceLY=; b=T/1NkHaVukDojjX2tdANwSRB7KWQjT4uH Gz+w0m40lavVblcbHSiBOp3g0WTjI6jm/Es83rOceO/Dmr2iPoV2gAA2UeHoDi+u fU61IYSPa9YnKC1BO4L+mP0WytV/tJqwGf+4SLK9eD74U2Mere5hOHvx2jhBPrlB lbk6FSbsGUmOFZESKMOR+/PxoSyFbJ03ZmyV+yGPyj+bHtppabdjuGZ9Ks7dZ3wz zO1wlz6vENwaRf1hU8yNnN87GmFYWTqdaYaYowl5zfi6VBwCbHFddzsbgZhBufmz uyzE5SPwnn90dD8ebTRTHsqF5mLw0whxKeKFkpAodT8M13R/iUsLQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=pGznYWx2BfXKBRCC2WGyCsSAlL6XIJll52rwqvBceLY=; b=Io0tdNOb DAHr31uyNzTH5bkYQcR8n5gUVXsIZc+8ygWOmrw26v4Uz6+yPPFXK7yOlzNHFrVD Myfw7TIAgV7p5Pa6QXgmfmwM3xpSGxlAMOHcC3bLnRvfeS5HjBFkF0ktHG+vbeVZ bYW+H1yOmmbyx+rbJaYXR6Pes+4rOJKvA7/rz5IpSXIJ1BvkPbNu59Zu2/0NOs2W vtjcR/nwKuw1Ep9M/4DYsgaFvyyFe7qxHm0/X9m+Mqs4a9eehmg8W8HD/Fjd8MdR Gs+t0xuu5OSWoXXwxf7pKZcinzdxwXv7vAhQUQSw2GtDgyJoBRQqUMEzmj9Wnmpy PqMJv19AW3d+/A== X-ME-Proxy: X-ME-Sender: Received: from localhost (124-169-17-12.dyn.iinet.net.au [124.169.17.12]) by mail.messagingengine.com (Postfix) with ESMTPA id C97DF10269; Wed, 1 Aug 2018 01:09:50 -0400 (EDT) From: "Tobin C. Harding" To: Daniel Borkmann , Alexei Starovoitov Cc: "Tobin C. Harding" , Jonathan Corbet , "David S. Miller" , linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 07/13] docs: net: Use double ticks instead of single quote Date: Wed, 1 Aug 2018 15:09:02 +1000 Message-Id: <20180801050908.29970-8-me@tobin.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180801050908.29970-1-me@tobin.cc> References: <20180801050908.29970-1-me@tobin.cc> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently there are many places that use single quote to guard text. RST has the double tick for code. Also the document is full of identifiers. Using too many double ticks hinders reading the file in text format. For this reason we only change a few select cases to use the double tick. Sphinx also emits a bunch of cryptic warnings due to not correctly wrapping lines. These two fixes touch the same lines so its all in one patch. Use double ticks instead of single quote to guard inline code. Signed-off-by: Tobin C. Harding --- Documentation/networking/filter.rst | 100 ++++++++++++++-------------- 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/Documentation/networking/filter.rst b/Documentation/networking/filter.rst index 62630e8f023a..f9ec58144ed3 100644 --- a/Documentation/networking/filter.rst +++ b/Documentation/networking/filter.rst @@ -289,7 +289,7 @@ Possible BPF extensions are shown in the following table:: vlan_tpid skb->vlan_proto rand prandom_u32() -These extensions can also be prefixed with '#'. +These extensions can also be prefixed with ``#``. Examples for low-level BPF: ARP packets:: @@ -382,7 +382,7 @@ file "~/.bpf_dbg_init" and the command history is stored in the file "~/.bpf_dbg_history". Interaction in bpf_dbg happens through a shell that also has auto-completion -support (follow-up example commands starting with '>' denote bpf_dbg shell). +support (follow-up example commands starting with ``>`` denote bpf_dbg shell). The usual workflow would be to ... :: @@ -689,7 +689,7 @@ Some core changes of the new internal format: to in-kernel function. If R1 - R5 registers are mapped to CPU registers that are used for argument passing on given architecture, the JIT compiler doesn't need to emit extra moves. Function arguments will be in the correct - registers and BPF_CALL instruction will be JITed as single 'call' HW + registers and BPF_CALL instruction will be JITed as single ``call`` HW instruction. This calling convention was picked to cover common call situations without performance penalty. @@ -803,7 +803,7 @@ Some core changes of the new internal format: In-kernel functions foo() and bar() with prototype: u64 (*)(u64 arg1, u64 arg2, u64 arg3, u64 arg4, u64 arg5); will receive arguments in proper - registers and place their return value into '%rax' which is R0 in eBPF. + registers and place their return value into ``%rax`` which is R0 in eBPF. Prologue and epilogue are emitted by JIT and are implicit in the interpreter. R0-R5 are scratch registers, so eBPF program needs to preserve them across the calls as defined by calling convention. @@ -831,7 +831,7 @@ A program, that is translated internally consists of the following elements:: op:16, jt:8, jf:8, k:32 ==> op:8, dst_reg:4, src_reg:4, off:16, imm:32 -So far 87 internal BPF instructions were implemented. 8-bit 'op' opcode field +So far 87 internal BPF instructions were implemented. 8-bit ``op`` opcode field has room for new instructions. Some of them may use 16/24/32 byte encoding. New instructions must be multiple of 8 bytes to preserve backward compatibility. @@ -992,7 +992,7 @@ eBPF has two non-generic instructions: (BPF_ABS | | BPF_LD) and They had to be carried over from classic to have strong performance of socket filters running in eBPF interpreter. These instructions can only -be used when interpreter context is a pointer to 'struct sk_buff' and +be used when interpreter context is a pointer to ``struct sk_buff`` and have seven implicit operands. Register R6 is an implicit input that must contain pointer to sk_buff. Register R0 is an implicit output which contains the data fetched from the packet. Registers R1-R5 are scratch registers @@ -1024,7 +1024,7 @@ Where size is one of: BPF_B or BPF_H or BPF_W or BPF_DW. Note that 1 and 2 byte atomic increments are not supported. eBPF has one 16-byte instruction: BPF_LD | BPF_DW | BPF_IMM which consists -of two consecutive 'struct bpf_insn' 8-byte blocks and interpreted as single +of two consecutive ``struct bpf_insn`` 8-byte blocks and interpreted as single instruction that loads 64-bit immediate value into a dst_reg. Classic BPF has similar instruction: BPF_LD | BPF_W | BPF_IMM which loads 32-bit immediate value into a register. @@ -1083,7 +1083,7 @@ For example:: will be rejected, since R1 doesn't have a valid pointer type at the time of execution of instruction bpf_xadd. -At the start R1 type is PTR_TO_CTX (a pointer to generic 'struct bpf_context') +At the start R1 type is PTR_TO_CTX (a pointer to generic ``struct bpf_context``) A callback is used to customize verifier to restrict eBPF program access to only certain fields within ctx structure with specified size and alignment. @@ -1138,7 +1138,7 @@ Register value tracking In order to determine the safety of an eBPF program, the verifier must track the range of possible values in each register and also in each stack slot. -This is done with 'struct bpf_reg_state', defined in include/linux/ +This is done with ``struct bpf_reg_state``, defined in include/linux/ bpf_verifier.h, which unifies tracking of scalar and pointer values. Each register state has a type, which is either NOT_INIT (the register has not been written to), SCALAR_VALUE (some value which is not usable as a pointer), or a @@ -1219,7 +1219,7 @@ Ex:: 6: r0 = *(u16 *)(r3 +12) /* access 12 and 13 bytes of the packet */ this 2byte load from the packet is safe to do, since the program author -did check 'if (skb->data + 14 > skb->data_end) goto err' at insn #5 which +did check ``if (skb->data + 14 > skb->data_end) goto err`` at insn #5 which means that in the fall-through case the register R3 (which points to skb->data) has at least 14 directly accessible bytes. The verifier marks it as R3=pkt(id=0,off=0,r=14). @@ -1228,7 +1228,7 @@ off=0 means that no additional constants were added. r=14 is the range of safe access which means that bytes [R3, R3 + 14) are ok. Note that R5 is marked as R5=pkt(id=0,off=14,r=14). It also points to the packet data, but constant 14 was added to the register, so -it now points to 'skb->data + 14' and accessible range is [R5, R5 + 14 - 14) +it now points to ``skb->data + 14`` and accessible range is [R5, R5 + 14 - 14) which is zero bytes. More complex packet access may look like:: @@ -1250,29 +1250,30 @@ More complex packet access may look like:: R0=inv(id=0,umax_value=255,var_off=(0x0; 0xff)) R1=pkt_end R2=pkt(id=2,off=8,r=8) R3=pkt(id=2,off=0,r=8) R4=inv(id=0,umax_value=3570,var_off=(0x0; 0xfffe)) R5=pkt(id=0,off=14,r=14) R10=fp 19: r1 = *(u8 *)(r3 +4) -The state of the register R3 is R3=pkt(id=2,off=0,r=8) -id=2 means that two 'r3 += rX' instructions were seen, so r3 points to some -offset within a packet and since the program author did -'if (r3 + 8 > r1) goto err' at insn #18, the safe range is [R3, R3 + 8). -The verifier only allows 'add'/'sub' operations on packet registers. Any other -operation will set the register state to 'SCALAR_VALUE' and it won't be -available for direct packet access. -Operation 'r3 += rX' may overflow and become less than original skb->data, -therefore the verifier has to prevent that. So when it sees 'r3 += rX' -instruction and rX is more than 16-bit value, any subsequent bounds-check of r3 -against skb->data_end will not give us 'range' information, so attempts to read -through the pointer will give "invalid access to packet" error. -Ex. after insn 'r4 = *(u8 *)(r3 +12)' (insn #7 above) the state of r4 is -R4=inv(id=0,umax_value=255,var_off=(0x0; 0xff)) which means that upper 56 bits -of the register are guaranteed to be zero, and nothing is known about the lower -8 bits. After insn 'r4 *= 14' the state becomes -R4=inv(id=0,umax_value=3570,var_off=(0x0; 0xfffe)), since multiplying an 8-bit -value by constant 14 will keep upper 52 bits as zero, also the least significant -bit will be zero as 14 is even. Similarly 'r2 >>= 48' will make -R2=inv(id=0,umax_value=65535,var_off=(0x0; 0xffff)), since the shift is not sign -extending. This logic is implemented in adjust_reg_min_max_vals() function, -which calls adjust_ptr_min_max_vals() for adding pointer to scalar (or vice -versa) and adjust_scalar_min_max_vals() for operations on two scalars. +The state of the register R3 is R3=pkt(id=2,off=0,r=8) id=2 means that +two ``r3 += rX`` instructions were seen, so r3 points to some offset within +a packet and since the program author did ``if (r3 + 8 > r1) goto err`` at +insn #18, the safe range is [R3, R3 + 8). The verifier only allows +'add'/'sub' operations on packet registers. Any other operation will set +the register state to 'SCALAR_VALUE' and it won't be available for direct +packet access. Operation ``r3 += rX`` may overflow and become less than +original skb->data, therefore the verifier has to prevent that. So when it +sees ``r3 += rX`` instruction and rX is more than 16-bit value, any +subsequent bounds-check of r3 against skb->data_end will not give us +'range' information, so attempts to read through the pointer will give +"invalid access to packet" error. Ex. after insn ``r4 = *(u8 *)(r3 +12)`` +(insn #7 above) the state of r4 is +R4=inv(id=0,umax_value=255,var_off=(0x0; 0xff)) which means that upper +56 bits of the register are guaranteed to be zero, and nothing is known +about the lower 8 bits. After insn ``r4 *= 14`` the state becomes +R4=inv(id=0,umax_value=3570,var_off=(0x0; 0xfffe)), since multiplying +an 8-bit value by constant 14 will keep upper 52 bits as zero, also the +least significant bit will be zero as 14 is even. Similarly ``r2 >>= 48`` +will make R2=inv(id=0,umax_value=65535,var_off=(0x0; 0xffff)), since +the shift is not sign extending. This logic is implemented in +adjust_reg_min_max_vals() function, which calls adjust_ptr_min_max_vals() +for adding pointer to scalar (or vice versa) and +adjust_scalar_min_max_vals() for operations on two scalars. The end result is that bpf program author can access packet directly using normal C code as:: @@ -1303,27 +1304,24 @@ and userspace. The maps are accessed from user space via BPF syscall, which has commands: -- create a map with given type and attributes - map_fd = bpf(BPF_MAP_CREATE, union bpf_attr *attr, u32 size) - using attr->map_type, attr->key_size, attr->value_size, attr->max_entries - returns process-local file descriptor or negative error +- create a map with given type and attributes ``map_fd = + bpf(BPF_MAP_CREATE, union bpf_attr *attr, u32 size)`` using + attr->map_type, attr->key_size, attr->value_size, attr->max_entries + returns process-local file descriptor or negative error. -- lookup key in a given map - err = bpf(BPF_MAP_LOOKUP_ELEM, union bpf_attr *attr, u32 size) - using attr->map_fd, attr->key, attr->value - returns zero and stores found elem into value or negative error +- lookup key in a given map ``err = bpf(BPF_MAP_LOOKUP_ELEM, union bpf_attr + *attr, u32 size)`` using attr->map_fd, attr->key, attr->value returns + zero and stores found elem into value or negative error. -- create or update key/value pair in a given map - err = bpf(BPF_MAP_UPDATE_ELEM, union bpf_attr *attr, u32 size) - using attr->map_fd, attr->key, attr->value - returns zero or negative error +- create or update key/value pair in a given map ``err = + bpf(BPF_MAP_UPDATE_ELEM, union bpf_attr *attr, u32 size)`` using + attr->map_fd, attr->key, attr->value returns zero or negative error. -- find and delete element by key in a given map - err = bpf(BPF_MAP_DELETE_ELEM, union bpf_attr *attr, u32 size) - using attr->map_fd, attr->key +- find and delete element by key in a given map ``err = + bpf(BPF_MAP_DELETE_ELEM, union bpf_attr *attr, u32 size)`` using + attr->map_fd, attr->key. -- to delete map: close(fd) - Exiting process will delete maps automatically +- to delete map: close(fd) Exiting process will delete maps automatically. userspace programs use this syscall to create/access maps that eBPF programs are concurrently updating. From patchwork Wed Aug 1 05:09:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 951935 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tobin.cc Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tobin.cc header.i=@tobin.cc header.b="XCt9uXLm"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="kks7xD3D"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41gLwv6Vfqz9s0R for ; Wed, 1 Aug 2018 15:10:39 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733226AbeHAGxk (ORCPT ); Wed, 1 Aug 2018 02:53:40 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:52085 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733057AbeHAGxk (ORCPT ); Wed, 1 Aug 2018 02:53:40 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id D7E2562F; Wed, 1 Aug 2018 01:09:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 01 Aug 2018 01:09:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=3uLJA6MooOOL7a/1v 1Xk7G0pce3uXZf93kbLuAP1i2E=; b=XCt9uXLmQVhFe0VPsWGw2tyTepYG8ZbQ6 O/jW+U5IG5XbIUHJONE+4STTKbGChq6i3h2697/7GhEyUHY8RL9vGcrwGvsGzM1f TLqFV3UkCPwvz2omy++ByUEXnxuYORBolRiOK68B2YxsRgicIaGQpq1eQOCvx3kP vM+zTfqOcP1W/F4w5feO4qUJAh87/DTEYAc8vIk752zga9JN86ZZJqts/19XuAei 2kYVY2V9hpO4+XZ4iKEj0itDNpapwxiWAyLLbmE/owTvDvxdmzLINLsveiaBh1LG gMQcd28U+2lEdixdc/DAUtAAW0ivh7mr1FSYQ3tXdAN9lHgzNIF3w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=3uLJA6MooOOL7a/1v1Xk7G0pce3uXZf93kbLuAP1i2E=; b=kks7xD3D yioEpN1ylHbCDADIkmlA8Bkpezf0o2Y4/5ioK50pk1uAUAIaEoCvd+hRg6Xa3/JX 5zBNATDTggTt4y0AUAFEiEDi6ANcZUgPa+xusStkGlpAl7C0p7/Rc0aqqoGK6hxV udgaMqkH42bM52t7lwwJpk/i0J+gvSf0aYJ+JBAfkBc2gvYSpYYF5bW4LHSb+W9R LMcUjPLJVWTU5SOpCoyEHXcbceuwoqp/a/zH8CQH4K5bb0upT81eRp1G+0iFYgga WBYbkmD7EtQsPjBJG0OmZFOPyU2/YSDAsYHvlObSzJ3QHYoug5WANiPL8zkgE6Ja Ld/0himhtvFqjQ== X-ME-Proxy: X-ME-Sender: Received: from localhost (124-169-17-12.dyn.iinet.net.au [124.169.17.12]) by mail.messagingengine.com (Postfix) with ESMTPA id 97858E4621; Wed, 1 Aug 2018 01:09:54 -0400 (EDT) From: "Tobin C. Harding" To: Daniel Borkmann , Alexei Starovoitov Cc: "Tobin C. Harding" , Jonathan Corbet , "David S. Miller" , linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 08/13] docs: net: Use double ticks instead of single tick Date: Wed, 1 Aug 2018 15:09:03 +1000 Message-Id: <20180801050908.29970-9-me@tobin.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180801050908.29970-1-me@tobin.cc> References: <20180801050908.29970-1-me@tobin.cc> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Single tick around a command should be converted to a double tick for RST files (excluding ticks in a code snippet section). Use double ticks instead of single tick. Signed-off-by: Tobin C. Harding --- Documentation/networking/filter.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/networking/filter.rst b/Documentation/networking/filter.rst index f9ec58144ed3..dda1afdb5f26 100644 --- a/Documentation/networking/filter.rst +++ b/Documentation/networking/filter.rst @@ -38,9 +38,9 @@ setup a socket, attach a filter, lock it then drop privileges and be assured that the filter will be kept until the socket is closed. The biggest user of this construct might be libpcap. Issuing a high-level -filter command like `tcpdump -i em1 port 22` passes through the libpcap +filter command like ``tcpdump -i em1 port 22`` passes through the libpcap internal compiler that generates a structure that can eventually be loaded -via SO_ATTACH_FILTER to the kernel. `tcpdump -i em1 port 22 -ddd` +via SO_ATTACH_FILTER to the kernel. ``tcpdump -i em1 port 22 -ddd`` displays what is being placed into this structure. Although we were only speaking about sockets here, BPF in Linux is used @@ -375,7 +375,7 @@ Starting bpf_dbg is trivial and just requires issuing:: In case input and output do not equal stdin/stdout, bpf_dbg takes an alternative stdin source as a first argument, and an alternative stdout -sink as a second one, e.g. `./bpf_dbg test_in.txt test_out.txt`. +sink as a second one, e.g. ``./bpf_dbg test_in.txt test_out.txt``. Other than that, a particular libreadline configuration can be set via file "~/.bpf_dbg_init" and the command history is stored in the file @@ -388,7 +388,7 @@ The usual workflow would be to ... > load bpf 6,40 0 0 12,21 0 3 2048,48 0 0 23,21 0 1 1,6 0 0 65535,6 0 0 0 Loads a BPF filter from standard output of bpf_asm, or transformed via - e.g. `tcpdump -iem1 -ddd port 22 | tr '\n' ','`. Note that for JIT + e.g. tcpdump -iem1 -ddd port 22 | tr '\n' ','`. Note that for JIT debugging (next section), this command creates a temporary socket and loads the BPF code into the kernel. Thus, this will also be useful for JIT developers. @@ -523,7 +523,7 @@ generating disassembly out of the kernel log's hexdump:: 44: leaveq 45: retq -Issuing option `-o` will "annotate" opcodes to resulting assembler +Issuing option ``-o`` will "annotate" opcodes to resulting assembler instructions, which can be very useful for JIT developers:: # ./bpf_jit_disasm -o From patchwork Wed Aug 1 05:09:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 951930 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tobin.cc Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tobin.cc header.i=@tobin.cc header.b="JrdxOi7+"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="oX3jNJoX"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41gLwD5zPKz9s3q for ; Wed, 1 Aug 2018 15:10:04 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733252AbeHAGxn (ORCPT ); Wed, 1 Aug 2018 02:53:43 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:57167 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733057AbeHAGxn (ORCPT ); Wed, 1 Aug 2018 02:53:43 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 5DE3E57E; Wed, 1 Aug 2018 01:09:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 01 Aug 2018 01:09:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=l0shLeptNupfOvx/i eZtlDPz1a0bI2fXG5YS5l7Rxm4=; b=JrdxOi7+7rmiuSQw9lPTZgiMUuVOkuXpq 2H7a84Ae6bAqhnX7YwRyPS/+u+TDcPQagSHzMGJxOv6lHtO7mvW1J/GrAcO0WLE1 oxAZvWTMhXoNnj2wIYLdl6d/R3ALFYZJgo7EHPaEV1bq11Y9nLpNe7DlZfOV5rqg MbYmNCtSOUbvpXQPm/SjDz0LHPbmDJ8XvxclPi5CWQfZm5VtMzJXe6eMtH7/FCqq DqmXJzCkji4OS3xeyziUjIpIHRrGU95DwR08GujOiIzyH3l+/7LFznFB5YMhD51U Km/j7FodRVZkz0WOlC/O2BK6WSvfp3azUzNglKbUvo69Ne/QR69XQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=l0shLeptNupfOvx/ieZtlDPz1a0bI2fXG5YS5l7Rxm4=; b=oX3jNJoX SN34+NuUNyfdCfdPI0P0C1AYf2jozq8g8txLQmFUsPbXnwlZ/6+NPqRbxYdXQS8Q VpmpHEQ9VxzS1m02YNLttD7ye35cXXWq5NHLVL45fKKFk9TAiuDvqwFhRunc8Zxq YxgilkPvRgj+c1/niBjzKvM7NvPcnqQJmiJkOpWFXh4U4I1VzGCXjED0Wr/NpjAz TWw2E7Dr4Vk8vG0hqecKRIZDhs06xJtQK2iX8ztMJALGB9dJ0xIT+8ccXPoPCorz 3aRzimKhbOVODEe2Il/i3R2oenZGhnRfbBs5JFaFwK6G9z6+lbZxiKDHLw/yXNuP KsFwWHfsYiyNiQ== X-ME-Proxy: X-ME-Sender: Received: from localhost (124-169-17-12.dyn.iinet.net.au [124.169.17.12]) by mail.messagingengine.com (Postfix) with ESMTPA id 297CE10255; Wed, 1 Aug 2018 01:09:57 -0400 (EDT) From: "Tobin C. Harding" To: Daniel Borkmann , Alexei Starovoitov Cc: "Tobin C. Harding" , Jonathan Corbet , "David S. Miller" , linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 09/13] docs: net: Use lowercase 'k' for kernel Date: Wed, 1 Aug 2018 15:09:04 +1000 Message-Id: <20180801050908.29970-10-me@tobin.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180801050908.29970-1-me@tobin.cc> References: <20180801050908.29970-1-me@tobin.cc> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The whole document uses a lowercase 'k' for 'kernel' except in one instance. The kernel community also favours a lowercase 'k'. Use lowercase 'k' for kernel instead of uppercase 'K'. Signed-off-by: Tobin C. Harding --- Documentation/networking/filter.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/networking/filter.rst b/Documentation/networking/filter.rst index dda1afdb5f26..10c4eab042df 100644 --- a/Documentation/networking/filter.rst +++ b/Documentation/networking/filter.rst @@ -9,7 +9,7 @@ Introduction Linux Socket Filtering (LSF) is derived from the Berkeley Packet Filter. Though there are some distinct differences between the BSD and Linux -Kernel filtering, but when we speak of BPF or LSF in Linux context, we +kernel filtering, but when we speak of BPF or LSF in Linux context, we mean the very same mechanism of filtering in the Linux kernel. BPF allows a user-space program to attach a filter onto any socket and From patchwork Wed Aug 1 05:09:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 951931 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tobin.cc Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tobin.cc header.i=@tobin.cc header.b="hOM1vLZm"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="aV0217+C"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41gLwN1H6Hz9s7Q for ; Wed, 1 Aug 2018 15:10:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733270AbeHAGxt (ORCPT ); Wed, 1 Aug 2018 02:53:49 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:48259 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733055AbeHAGxs (ORCPT ); Wed, 1 Aug 2018 02:53:48 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 9FB653D4; Wed, 1 Aug 2018 01:10:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 01 Aug 2018 01:10:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=BLhz9q5Br0APWXDfc 9o6H1xQibD1cp8+XYJD9ekkLUw=; b=hOM1vLZmuXVbfAgPVvdokhy1tHTPvovSn cliTooTSK8TKKKQFEAYZ03UH9+a88egTTC0WuZ0RnAFxvLqY+nAltpQAN84KHdUX E1793IcsmvDVgPcHCVvcRUW+fsnNfwGAStrVAXnH0olmMqFu5092iLGrIF00vhaZ +W3jiTEX37MPbOogD156720KCWc3gJTL0DfkkhGeld+RMbIN26lWkjWcG7BQZeGX gte1dbhwyJ3cQaWdqdpKAo5F5J7MyDW0tS6G5TWflvnf4qLzF8HWkvtvR/bMDXeX H98NmK+OvJxo4zOgxrkoBna/6EtiniXb+zxbWOFf4ov8vgO2AEERQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=BLhz9q5Br0APWXDfc9o6H1xQibD1cp8+XYJD9ekkLUw=; b=aV0217+C 28tSLZ9TJq/UduOnnEma5kYLq2SDxrx1IewHDV5ZqzTVyxySf059eOz1XtlQGvH2 mfZw3ZFMcpm8uUJmCgqPfV1EHMay7PwhDm17kBbGE5ppCbCHvXBFiqo0Gwta+9Ad uDCuZly6psiN3bdZ2/voCXun9evxi7vUQwyrMW/EedtoAzI1ynojeVnAcy88YVBT xdt2usxqpbBUtRDonVBoVvRBjrpw0B6GYh6oQ51NSoPD9SbW69wV0a3VIzTPxP2x I+RoczXFPXkQnfQw6g/C0Hl5sKCgyDBnwnMEsHjCiho2p4cC1fweWTS/9Fn78yJQ hzqAamV0KSNDrw== X-ME-Proxy: X-ME-Sender: Received: from localhost (124-169-17-12.dyn.iinet.net.au [124.169.17.12]) by mail.messagingengine.com (Postfix) with ESMTPA id 161B7E405A; Wed, 1 Aug 2018 01:10:01 -0400 (EDT) From: "Tobin C. Harding" To: Daniel Borkmann , Alexei Starovoitov Cc: "Tobin C. Harding" , Jonathan Corbet , "David S. Miller" , linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next 10/13] docs: net: Embed reference to seccomp_filter Date: Wed, 1 Aug 2018 15:09:05 +1000 Message-Id: <20180801050908.29970-11-me@tobin.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180801050908.29970-1-me@tobin.cc> References: <20180801050908.29970-1-me@tobin.cc> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Typical RST documents embed the reference link straight in the text. Currently document uses a '[1]' with the reference below that paragraph. Use RST :ref:`path/to/file`