From: "Tobin C. Harding" <me@tobin.cc>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <ast@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
"David S. Miller" <davem@davemloft.net>,
linux-doc@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next 05/13] docs: net: Fix indentation issues for code snippets
Date: Mon, 6 Aug 2018 10:22:20 +1000 [thread overview]
Message-ID: <20180806002220.GJ3088@eros> (raw)
In-Reply-To: <8d166300-78f3-db60-c097-4f7c587856f4@iogearbox.net>
On Fri, Aug 03, 2018 at 10:44:23AM +0200, Daniel Borkmann wrote:
> On 08/01/2018 07:09 AM, Tobin C. Harding wrote:
> [...]
> > -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 [<n>]
> > -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 [-<n>, +<n>]
> > - 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 <n>
> > - 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.
>
> Here for the bpf_dbg howto, it would be good to separate explanation from
> the cmdline code snippets. This would more easily clarify the commands
> themselves if we already go the rst route, so I'd prefer splitting this up.
Sure thing. Will do as suggested. Thanks for the review.
Tobin
next prev parent reply other threads:[~2018-08-06 0:22 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-01 5:08 [PATCH bpf-next 00/13] docs: Convert BPF filter.txt to RST Tobin C. Harding
2018-08-01 5:08 ` [PATCH bpf-next 01/13] docs: net: Rename filter.txt to filter.rst Tobin C. Harding
2018-08-01 5:08 ` [PATCH bpf-next 02/13] docs: Update references " Tobin C. Harding
2018-08-01 5:08 ` [PATCH bpf-next 03/13] docs: net: Add filter to index toctree Tobin C. Harding
2018-08-01 13:52 ` Jonathan Corbet
2018-08-01 22:32 ` Tobin C. Harding
2018-08-01 5:08 ` [PATCH bpf-next 04/13] docs: net: Use correct heading adornments Tobin C. Harding
2018-08-01 5:09 ` [PATCH bpf-next 05/13] docs: net: Fix indentation issues for code snippets Tobin C. Harding
2018-08-03 8:44 ` Daniel Borkmann
2018-08-06 0:22 ` Tobin C. Harding [this message]
2018-08-01 5:09 ` [PATCH bpf-next 06/13] docs: net: Remove non-standard identifiers Tobin C. Harding
2018-08-01 5:09 ` [PATCH bpf-next 07/13] docs: net: Use double ticks instead of single quote Tobin C. Harding
2018-08-01 5:09 ` [PATCH bpf-next 08/13] docs: net: Use double ticks instead of single tick Tobin C. Harding
2018-08-01 5:09 ` [PATCH bpf-next 09/13] docs: net: Use lowercase 'k' for kernel Tobin C. Harding
2018-08-01 5:09 ` [PATCH bpf-next 10/13] docs: net: Embed reference to seccomp_filter Tobin C. Harding
2018-08-01 5:09 ` [PATCH bpf-next 11/13] docs: net: Use correct RST list construct Tobin C. Harding
2018-08-01 5:09 ` [PATCH bpf-next 12/13] docs: net: Fix various minor typos Tobin C. Harding
2018-08-03 8:41 ` Daniel Borkmann
2018-08-06 0:23 ` Tobin C. Harding
2018-08-08 1:42 ` Tobin C. Harding
2018-08-08 13:23 ` Jonathan Corbet
2018-08-08 13:45 ` Daniel Borkmann
2018-08-08 16:26 ` Markus Heiser
2018-08-08 22:21 ` Tobin C. Harding
2018-08-01 5:09 ` [PATCH bpf-next 13/13] docs: net: Fix authors list to render as a list Tobin C. Harding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180806002220.GJ3088@eros \
--to=me@tobin.cc \
--cc=ast@kernel.org \
--cc=corbet@lwn.net \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox