.\" Man page generated from reStructuredText.
.
.TH BPFTOOL-PROG 8 "" "" ""
.SH NAME
bpftool-prog \- tool for inspection and simple manipulation of eBPF progs
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.SH SYNOPSIS
.INDENT 0.0
.INDENT 3.5
\fBbpftool\fP [\fIOPTIONS\fP] \fBprog\fP \fICOMMAND\fP
.sp
\fIOPTIONS\fP := { { \fB\-j\fP | \fB\-\-json\fP } [{ \fB\-p\fP | \fB\-\-pretty\fP }] | { \fB\-f\fP | \fB\-\-bpffs\fP } }
.sp
\fICOMMANDS\fP :=
{ \fBshow\fP | \fBlist\fP | \fBdump xlated\fP | \fBdump jited\fP | \fBpin\fP | \fBload\fP | \fBhelp\fP }
.UNINDENT
.UNINDENT
.SH MAP COMMANDS
.nf
\fBbpftool\fP \fBprog { show | list }\fP [\fIPROG\fP]
\fBbpftool\fP \fBprog dump xlated\fP \fIPROG\fP [{\fBfile\fP \fIFILE\fP | \fBopcodes\fP | \fBvisual\fP}]
\fBbpftool\fP \fBprog dump jited\fP  \fIPROG\fP [{\fBfile\fP \fIFILE\fP | \fBopcodes\fP}]
\fBbpftool\fP \fBprog pin\fP \fIPROG\fP \fIFILE\fP
\fBbpftool\fP \fBprog load\fP \fIOBJ\fP \fIFILE\fP
\fBbpftool\fP \fBprog help\fP

\fIPROG\fP := { \fBid\fP \fIPROG_ID\fP | \fBpinned\fP \fIFILE\fP | \fBtag\fP \fIPROG_TAG\fP }
.fi
.sp
.SH DESCRIPTION
.INDENT 0.0
.INDENT 3.5
.INDENT 0.0
.TP
.B \fBbpftool prog { show | list }\fP [\fIPROG\fP]
Show information about loaded programs.  If \fIPROG\fP is
specified show information only about given program, otherwise
list all programs currently loaded on the system.
.sp
Output will start with program ID followed by program type and
zero or more named attributes (depending on kernel version).
.TP
.B \fBbpftool prog dump xlated\fP \fIPROG\fP [{ \fBfile\fP \fIFILE\fP | \fBopcodes\fP | \fBvisual\fP }]
Dump eBPF instructions of the program from the kernel. By
default, eBPF will be disassembled and printed to standard
output in human\-readable format. In this case, \fBopcodes\fP
controls if raw opcodes should be printed as well.
.sp
If \fBfile\fP is specified, the binary image will instead be
written to \fIFILE\fP\&.
.sp
If \fBvisual\fP is specified, control flow graph (CFG) will be
built instead, and eBPF instructions will be presented with
CFG in DOT format, on standard output.
.TP
.B \fBbpftool prog dump jited\fP  \fIPROG\fP [{ \fBfile\fP \fIFILE\fP | \fBopcodes\fP }]
Dump jited image (host machine code) of the program.
If \fIFILE\fP is specified image will be written to a file,
otherwise it will be disassembled and printed to stdout.
.sp
\fBopcodes\fP controls if raw opcodes will be printed.
.TP
.B \fBbpftool prog pin\fP \fIPROG\fP \fIFILE\fP
Pin program \fIPROG\fP as \fIFILE\fP\&.
.sp
Note: \fIFILE\fP must be located in \fIbpffs\fP mount.
.TP
.B \fBbpftool prog load\fP \fIOBJ\fP \fIFILE\fP
Load bpf program from binary \fIOBJ\fP and pin as \fIFILE\fP\&.
.sp
Note: \fIFILE\fP must be located in \fIbpffs\fP mount.
.TP
.B \fBbpftool prog help\fP
Print short help message.
.UNINDENT
.UNINDENT
.UNINDENT
.SH OPTIONS
.INDENT 0.0
.INDENT 3.5
.INDENT 0.0
.TP
.B \-h\fP,\fB  \-\-help
Print short generic help message (similar to \fBbpftool help\fP).
.TP
.B \-v\fP,\fB  \-\-version
Print version number (similar to \fBbpftool version\fP).
.TP
.B \-j\fP,\fB  \-\-json
Generate JSON output. For commands that cannot produce JSON, this
option has no effect.
.TP
.B \-p\fP,\fB  \-\-pretty
Generate human\-readable JSON output. Implies \fB\-j\fP\&.
.TP
.B \-f\fP,\fB  \-\-bpffs
Show file names of pinned programs.
.UNINDENT
.UNINDENT
.UNINDENT
.SH EXAMPLES
.sp
\fB# bpftool prog show\fP
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
10: xdp  name some_prog  tag 005a3d2123620c8b  gpl
      loaded_at Sep 29/20:11  uid 0
      xlated 528B  jited 370B  memlock 4096B  map_ids 10
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
\fB# bpftool \-\-json \-\-pretty prog show\fP
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
{
    "programs": [{
            "id": 10,
            "type": "xdp",
            "tag": "005a3d2123620c8b",
            "gpl_compatible": true,
            "loaded_at": "Sep 29/20:11",
            "uid": 0,
            "bytes_xlated": 528,
            "jited": true,
            "bytes_jited": 370,
            "bytes_memlock": 4096,
            "map_ids": [10
            ]
        }
    ]
}
.ft P
.fi
.UNINDENT
.UNINDENT
.nf

\fB# bpftool prog dump xlated id 10 file /tmp/t\fP
\fB# ls \-l /tmp/t\fP
.in +2
\-rw\-\-\-\-\-\-\- 1 root root 560 Jul 22 01:42 /tmp/t
.in -2
.fi
.sp
.sp
\fB# bpftool prog dum jited tag 005a3d2123620c8b\fP
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
push   %rbp
mov    %rsp,%rbp
sub    $0x228,%rsp
sub    $0x28,%rbp
mov    %rbx,0x0(%rbp)
.ft P
.fi
.UNINDENT
.UNINDENT
.nf

\fB# mount \-t bpf none /sys/fs/bpf/\fP
\fB# bpftool prog pin id 10 /sys/fs/bpf/prog\fP
\fB# bpftool prog load ./my_prog.o /sys/fs/bpf/prog2\fP
\fB# ls \-l /sys/fs/bpf/\fP
.in +2
\-rw\-\-\-\-\-\-\- 1 root root 0 Jul 22 01:43 prog
\-rw\-\-\-\-\-\-\- 1 root root 0 Jul 22 01:44 prog2
.in -2
.fi
.sp
.sp
\fB# bpftool prog dum jited pinned /sys/fs/bpf/prog opcodes\fP
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
push   %rbp
55
mov    %rsp,%rbp
48 89 e5
sub    $0x228,%rsp
48 81 ec 28 02 00 00
sub    $0x28,%rbp
48 83 ed 28
mov    %rbx,0x0(%rbp)
48 89 5d 00
.ft P
.fi
.UNINDENT
.UNINDENT
.SH SEE ALSO
.INDENT 0.0
.INDENT 3.5
\fBbpftool\fP(8), \fBbpftool\-map\fP(8), \fBbpftool\-cgroup\fP(8)
.UNINDENT
.UNINDENT
.\" Generated by docutils manpage writer.
.
