<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    
    <title>Raymond P. Burkholder - Things I Do - bpf</title>
    <link>http://blog.raymond.burkholder.net/</link>
    <description>In And Around Technology and The Arts</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.7.2 - http://www.s9y.org/</generator>
    <pubDate>Mon, 27 Nov 2023 03:48:07 GMT</pubDate>

    <image>
        <url>http://blog.raymond.burkholder.net/templates/bulletproof/img/s9y_banner_small.png</url>
        <title>RSS: Raymond P. Burkholder - Things I Do - bpf - In And Around Technology and The Arts</title>
        <link>http://blog.raymond.burkholder.net/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>More eBPF</title>
    <link>http://blog.raymond.burkholder.net/index.php?/archives/1251-More-eBPF.html</link>
            <category>bpf</category>
    
    <comments>http://blog.raymond.burkholder.net/index.php?/archives/1251-More-eBPF.html#comments</comments>
    <wfw:comment>http://blog.raymond.burkholder.net/wfwcomment.php?cid=1251</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.raymond.burkholder.net/rss.php?version=2.0&amp;type=comments&amp;cid=1251</wfw:commentRss>
    

    <author>nospam@example.com (Raymond P. Burkholder)</author>
    <content:encoded>
    &lt;a href=&quot;https://lwn.net/Articles/949960/&quot; target=_blank&gt;The BPF-programmable network device&lt;/a&gt; from lwn.net.  The new device, named &quot;netkit&quot;, aims to short out some of that overhead. It is, in some sense, a typical virtual device in that a packet transmitted at one end will only pass through the host system&#039;s memory before being received at the other. 

&lt;p&gt;According to the &lt;a href=&quot;http://vger.kernel.org/bpfconf2023_material/tcx_meta_netdev_borkmann.pdf&quot; target=_blank&gt;slides from a 2023 Linux Storage, Filesystem, Memory-Management and BPF Summit talk&lt;/a&gt;, guests operating through the netkit device (which was called &quot;meta&quot; at that time) are able to attain TCP data-transmission rates that are just as high as can be had by running directly on the host. The performance penalty for running within a guest has, in other words, been entirely removed. 
    </content:encoded>

    <pubDate>Mon, 27 Nov 2023 03:44:18 +0000</pubDate>
    <guid isPermaLink="false">http://blog.raymond.burkholder.net/index.php?/archives/1251-guid.html</guid>
    
</item>
<item>
    <title>Re: [PATCH bpf-next] xsk: support AF_PACKET (XDP)</title>
    <link>http://blog.raymond.burkholder.net/index.php?/archives/1120-Re-PATCH-bpf-next-xsk-support-AF_PACKET-XDP.html</link>
            <category>bpf</category>
    
    <comments>http://blog.raymond.burkholder.net/index.php?/archives/1120-Re-PATCH-bpf-next-xsk-support-AF_PACKET-XDP.html#comments</comments>
    <wfw:comment>http://blog.raymond.burkholder.net/wfwcomment.php?cid=1120</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.raymond.burkholder.net/rss.php?version=2.0&amp;type=comments&amp;cid=1120</wfw:commentRss>
    

    <author>nospam@example.com (Raymond P. Burkholder)</author>
    <content:encoded>
    &lt;blockquote&gt;&lt;pre&gt;
&gt; In xsk mode, users cannot use AF_PACKET(tcpdump) to observe the current
&gt; rx/tx data packets. This feature is very important in many cases. So
&gt; this patch allows AF_PACKET to obtain xsk packages.
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;p&gt;You can use xdpdump to dump the packets from the XDP program before it
gets redirected into the XSK:
https://github.com/xdp-project/xdp-tools/tree/master/xdp-dump

&lt;p&gt;Doens&#039;t currently work on egress, but if/when we get a proper TX hook
that should be doable as well.

&lt;p&gt;Wiring up XSK to AF_PACKET sounds a bit nonsensical: XSK is already a
transport to userspace, why would you need a second one?
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;p&gt;Yes, it is rather cool (credit to Eelco).  Notice the extra info you
can capture from &#039;exit&#039;, like XDP return codes, if_index, rx_queue.

The tool uses the perf ring-buffer to send/copy data to userspace.
This is actually surprisingly fast, but I still think AF_XDP will be
faster (but it usually &#039;steals&#039; the packet).

&lt;p&gt;Another (crazy?) idea is to extend this (and xdpdump), is to leverage
Hangbin&#039;s recent XDP_REDIRECT extension e624d4ed4aa8 (&quot;xdp: Extend
xdp_redirect_map with broadcast support&quot;).  We now have a
xdp_redirect_map flag BPF_F_BROADCAST, what if we create a
BPF_F_CLONE_PASS flag?

&lt;p&gt;The semantic meaning of BPF_F_CLONE_PASS flag is to copy/clone the
packet for the specified map target index (e.g AF_XDP map), but
afterwards it does like veth/cpumap and creates an SKB from the
xdp_frame (see __xdp_build_skb_from_frame()) and send to netstack.
(Feel free to kick me if this doesn&#039;t make any sense)
&lt;/blockquote&gt;

&lt;blockquote&gt;&lt;pre&gt;
&gt; This would be a smooth way to implement clone support for AF_XDP. If
&gt; we had this and someone added AF_XDP support to libpcap, we could both
&gt; capture AF_XDP traffic with tcpdump (using this clone functionality in
&gt; the XDP program) and speed up tcpdump for dumping traffic destined for
&gt; regular sockets. Would that solve your use case Xuan? Note that I have
&gt; not looked into the BPF_F_CLONE_PASS code, so do not know at this
&gt; point what it would take to support this for XSKMAPs.
&lt;/pre&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
Recently also ended up with something similar for our XDP LB to record pcaps [0] &lt;img src=&quot;http://blog.raymond.burkholder.net/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;
My question is.. tcpdump doesn&#039;t really care where the packet data comes from,
so why not extending libpcap&#039;s Linux-related internals to either capture from
perf RB or BPF ringbuf rather than AF_PACKET sockets? Cloning is slow, and if
you need to end up creating an skb which is then cloned once again inside AF_PACKET
it&#039;s even worse. Just relying and reading out, say, perf RB you don&#039;t need any
clones at all. &lt;/blockquote&gt;

&lt;blockquote&gt;
Anyway, xdpdump does have a &quot;pipe pcap to stdout&quot; feature so you can do
`xdpdump | tcpdump` and get the interactive output; and it will also
save pcap information to disk, of course (using pcap-ng so it can also
save metadata like XDP program name and return code).
&lt;/blockquote&gt; 
    </content:encoded>

    <pubDate>Sat, 29 May 2021 15:52:54 +0000</pubDate>
    <guid isPermaLink="false">http://blog.raymond.burkholder.net/index.php?/archives/1120-guid.html</guid>
    
</item>
<item>
    <title>DP based BGP peering Router</title>
    <link>http://blog.raymond.burkholder.net/index.php?/archives/1076-DP-based-BGP-peering-Router.html</link>
            <category>bpf</category>
    
    <comments>http://blog.raymond.burkholder.net/index.php?/archives/1076-DP-based-BGP-peering-Router.html#comments</comments>
    <wfw:comment>http://blog.raymond.burkholder.net/wfwcomment.php?cid=1076</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.raymond.burkholder.net/rss.php?version=2.0&amp;type=comments&amp;cid=1076</wfw:commentRss>
    

    <author>nospam@example.com (Raymond P. Burkholder)</author>
    <content:encoded>
    &lt;a href=&quot;https://blog.apnic.net/2020/04/30/how-to-build-an-xdp-based-bgp-peering-router/&quot; target=_blank&gt;Build an XDP based BGP peering Router&lt;/a&gt; 
    </content:encoded>

    <pubDate>Thu, 22 Oct 2020 00:24:35 +0000</pubDate>
    <guid isPermaLink="false">http://blog.raymond.burkholder.net/index.php?/archives/1076-guid.html</guid>
    
</item>
<item>
    <title>eBPF Tools</title>
    <link>http://blog.raymond.burkholder.net/index.php?/archives/1073-eBPF-Tools.html</link>
            <category>bpf</category>
    
    <comments>http://blog.raymond.burkholder.net/index.php?/archives/1073-eBPF-Tools.html#comments</comments>
    <wfw:comment>http://blog.raymond.burkholder.net/wfwcomment.php?cid=1073</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.raymond.burkholder.net/rss.php?version=2.0&amp;type=comments&amp;cid=1073</wfw:commentRss>
    

    <author>nospam@example.com (Raymond P. Burkholder)</author>
    <content:encoded>
    &lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html&quot; target=_blank&gt;BPF Portability and CO-RE&lt;/a&gt; - Compile Once - Run Everywhere
  &lt;li&gt;&lt;a href=&quot;https://ebpf.io/&quot; target=_blank&gt;eBPF&lt;/a&gt; - Security, Tracing &amp;amp; Profiling, Networking, Observability &amp;amp; Monitoring
  &lt;/ul&gt;

&lt;p&gt;From 2020/08/22 bpf@vger.kernel.org mailing list

&lt;blockquote&gt;
&lt;p&gt;What Yonghong suggested is to deprecate bpf_load.c completely,
including a legacy way to attach kprobe, which will stay connected
without proper clean up, if the application crashes. This has been a
reason for multiple production problems so far and we&#039;ve moved away
from that, as a community.

&lt;p&gt;There is no need to import anything from BCC, libbpf already supports
this and much more. samples/bpf unfortunately are a bit outdated (and
any help to bring them more in line with modern libbpf usage would be
greatly appreciated!), the best place to look at better and more
modern examples would be tools/testing/selftests/bpf in Linux repo, or
for more realistic examples of building tracing tools, please check
[0].

&lt;p&gt;[0] &lt;a href=&quot;https://github.com/iovisor/bcc/tree/master/libbpf-tools&quot; target=_blank&gt;https://github.com/iovisor/bcc/tree/master/libbpf-tools&lt;/a&gt;
&lt;/blockquote&gt; 
    </content:encoded>

    <pubDate>Sun, 16 Aug 2020 18:05:11 +0000</pubDate>
    <guid isPermaLink="false">http://blog.raymond.burkholder.net/index.php?/archives/1073-guid.html</guid>
    
</item>
<item>
    <title>eBPF - Little Things</title>
    <link>http://blog.raymond.burkholder.net/index.php?/archives/1017-eBPF-Little-Things.html</link>
            <category>bpf</category>
    
    <comments>http://blog.raymond.burkholder.net/index.php?/archives/1017-eBPF-Little-Things.html#comments</comments>
    <wfw:comment>http://blog.raymond.burkholder.net/wfwcomment.php?cid=1017</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.raymond.burkholder.net/rss.php?version=2.0&amp;type=comments&amp;cid=1017</wfw:commentRss>
    

    <author>nospam@example.com (Raymond P. Burkholder)</author>
    <content:encoded>
    &lt;p&gt;A python program which explains the helpers, which, by default, pulls info from linux-4.19.39/include/uapi/linux/bpf.h:

&lt;blockquote&gt;
./linux-4.19.39/scripts/bpf_helpers_doc.py
&lt;/blockquote&gt;

&lt;p&gt;A refined clang invocation to build an ebpf kernel load:

&lt;blockquote&gt;&lt;pre&gt;
clang \
  -I /usr/include/x86_64-linux-gnu \
  -I linux-4.19.39 \
  -I /usr/src/linux-headers-4.19.0-5-common/include \
  -O2 -target bpf  -c sock_kern.c -o sock_kern.o
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;A refined clang invocation of the userland loader, which should run the samples in linux-4.19.39/samples/bpf/:

&lt;blockquote&gt;&lt;pre&gt;
SRC=linux-4.19.39 \
LIB=${SRC}/tools/lib/bpf/libbpf.a \
clang \
  -I ${SRC}/tools/lib/bpf \
  -I ${SRC}/tools/lib \
  -I ${SRC}/tools/include \
  -I ${SRC}/tools/perf \
  -I ${SRC}/samples \
  -I linux-5.2.7/tools/include \
  -O2 -Wall -g \
  -o sock_user \
  ${LIB} -lelf  \
  sock_user.c ${SRC}/samples/bpf/bpf_load.c
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;On Debian, rather than loading the libbpf package it can be build from the kernel source to obtain libbpf.a:

&lt;blockquote&gt;&lt;pre&gt;
# cd linux-4.19.39/tools/lib/bpf
# make

Auto-detecting system features:
...                        libelf: [ on  ]
...                           bpf: [ on  ]

  HOSTCC   fixdep.o
  HOSTLD   fixdep-in.o
  LINK     fixdep
  CC       libbpf.o
  CC       bpf.o
  CC       nlattr.o
  CC       btf.o
  CC       libbpf_errno.o
  CC       str_error.o
  LD       libbpf-in.o
  LINK     libbpf.a
  LINK     libbpf.so
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;It should be possible to do the same with linux-4.19.38/tools/bpf/bpftool, but fails on a missing bfd.h.  But does work on linux-5.2.7/tools/bpf/bpftool.

&lt;p&gt;&#039;bpftool feature&#039; will provide the features available in the current kernel.  bpftool also has a bash completion file.  

&lt;p&gt;Some other bpftool invocations:

&lt;blockquote&gt;&lt;pre&gt;
/bpftool feature
./bpftool map show
sudo apt install jq
./bpftool prog show --json id 52 | jq -c &#039;[.id, .type, .loaded_at]&#039;
# makes some things faster:
echo 1 &gt; /proc/sys/net/core/bpf_jit_enable
&lt;/pre&gt;&lt;/blockquote&gt; 
    </content:encoded>

    <pubDate>Fri, 16 Aug 2019 03:00:09 +0000</pubDate>
    <guid isPermaLink="false">http://blog.raymond.burkholder.net/index.php?/archives/1017-guid.html</guid>
    
</item>
<item>
    <title>eBPF Basics</title>
    <link>http://blog.raymond.burkholder.net/index.php?/archives/1000-eBPF-Basics.html</link>
            <category>bpf</category>
    
    <comments>http://blog.raymond.burkholder.net/index.php?/archives/1000-eBPF-Basics.html#comments</comments>
    <wfw:comment>http://blog.raymond.burkholder.net/wfwcomment.php?cid=1000</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.raymond.burkholder.net/rss.php?version=2.0&amp;type=comments&amp;cid=1000</wfw:commentRss>
    

    <author>nospam@example.com (Raymond P. Burkholder)</author>
    <content:encoded>
    &lt;p&gt;I saw a pre-release of &quot;Linux Observability with BPF&quot; by David Calavera and Lorenzo Fontana.  Well, I&#039;d say it is a release prior to pre-release.  Some good information it has, but teases the details.

&lt;p&gt;This post is about what it takes to get the first example functional: the things I saw, didn&#039;t see, and kludges I put in place.  With the understanding and first step in place, it can be cleaned up and additional progress can be now proceed.

&lt;p&gt;I have a mixed Debian Buster/Testing/Sid workstation installation.  A messy system due to the vagaries of getting Linux Stretch/Buster installed onto a new Intel NUC nuc8i7hvk01 when firmware and display drivers were just getting rolled out.  Kernel updates have made progress.  Given the inclination, a nice simple clean Buster rebuild will probably work this time around.  

&lt;p&gt;But enough of that.  Here is what I needed to do for building a simple eBPF program, building a simple installer, and getting it to install, pass the verifier, and achieve a successful conclusion.

 &lt;br /&gt;&lt;a href=&quot;http://blog.raymond.burkholder.net/index.php?/archives/1000-eBPF-Basics.html#extended&quot;&gt;Continue reading &quot;eBPF Basics&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sun, 05 May 2019 02:04:52 +0000</pubDate>
    <guid isPermaLink="false">http://blog.raymond.burkholder.net/index.php?/archives/1000-guid.html</guid>
    
</item>
<item>
    <title>Late To The Party - Better Late Than Never</title>
    <link>http://blog.raymond.burkholder.net/index.php?/archives/982-Late-To-The-Party-Better-Late-Than-Never.html</link>
            <category>bpf</category>
    
    <comments>http://blog.raymond.burkholder.net/index.php?/archives/982-Late-To-The-Party-Better-Late-Than-Never.html#comments</comments>
    <wfw:comment>http://blog.raymond.burkholder.net/wfwcomment.php?cid=982</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.raymond.burkholder.net/rss.php?version=2.0&amp;type=comments&amp;cid=982</wfw:commentRss>
    

    <author>nospam@example.com (Raymond P. Burkholder)</author>
    <content:encoded>
    &lt;p&gt;I was happily building some code to filter and manage traffic in Open vSwitch via 
&lt;a href=&quot;https://github.com/rburkholder/cppofc&quot; target=_blank&gt;C++ communicating via the OpenFlow interface&lt;/a&gt;. Then, ... well, I realized I was missing some things.  In OVS&#039;s documentation, much of it uses
the command line tools to inject the rules.  Some of those examples show automatic mac swaps and such.  hmm, Nicera extensions but not in the openflow specification.  Which means changing code to interface to other api bind points of OVS.

&lt;p&gt;I had also written some code to interface to the OVSDB so I could &lt;a href=&quot;https://github.com/rburkholder/cppofc/blob/master/ovsdb_impl.cpp&quot; target=_blank&gt;list interfaces, detect changes, and obtain statistics&lt;/a&gt;.

&lt;p&gt;In stepping back and thinking about this, I came across a youtube video on youtube: 
&lt;br /&gt; &lt;iframe width=&quot;640&quot; height=&quot;360&quot; src=&quot;https://www.youtube.com/embed/VorCVYRnCxM&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;br /&gt;
 which talks about Stratum and Next-Gen SDN.  I wasn&#039;t so interested in the Stratum concept in as much as I was interested in the &lt;a href=&quot;https://p4.org/&quot; target=_blank&gt;p4.org&lt;/a&gt; concept of writing code to filter packets.

&lt;p&gt;From a Linux network stack perspective, a little closer to home, there is eBGP and XDP.  The best diagram I&#039;ve seen of XDP and eBGP hook points is on page 3 of &lt;img src=&quot;http://blog.raymond.burkholder.net/uploads/xdp_in_linux_stack.png&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;https://github.com/tohojo/xdp-paper/blob/master/xdp-the-express-data-path.pdf&quot; target=_blank&gt;The eXpress Data Path: Fast Programmable Packet Processing inthe Operating System Kernel&lt;/a&gt; which was presented at 
&lt;a href=&quot;https://conferences2.sigcomm.org/co-next/2018/#!/program&quot; target=_blank&gt;2018 SigComm CoNEXT Conference&lt;/a&gt;.  As an aside, another interesting paper there is &quot;
Leveraging eBPF for programmable network functions with IPv6 Segment Routing&quot;.

&lt;p&gt;Other references:
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://docs.cilium.io/en/latest/bpf/&quot; target=_blank&gt;BPF and XDP Reference Guide&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/iovisor/bcc&quot; target=_blank&gt;BPF Compiler Collection (BCC)&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;http://vger.kernel.org/lpc-bpf.html&quot; target=_blank&gt;Linux Plumbers Conference 2018
BPF Microconference&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;http://vger.kernel.org/lpc-networking.html&quot; target=_blank&gt;Linux Plumbers Conference 2018
Networking Track&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.netdevconf.org/2.2/slides/prabhu-linuxbridge-tutorial.pdf&quot; target=_blank&gt;Linux Bridge, l2-overlays, 
E-VPN!&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;https://linuxplumbersconf.org/event/2/contributions/96/attachments/95/110/scaling_bridge_fdb_database_slidesV3.pdf&quot; target=_blank&gt;Scaling bridge 
forwarding database&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;https://facebookmicrosites.github.io/bpf/blog/2018/08/31/object-lifetime.html&quot; target=_blank&gt;Lifetime of BPF objects&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;https://p4.org/p4-spec/docs/P4-16-v1.1.0-spec.html&quot; target=_blank&gt;P4-16 Language Specification&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;https://lwn.net/Articles/747504/&quot; target=_blank&gt;net: add bpfilter&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.kernel.org/doc/html/latest/networking/af_xdp.html&quot; target=_blank&gt;AF_XDP&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.cs.ubc.ca/~fruffy/tu_lpc2018.pdf&quot; target=_blank&gt;Linux Network Programming with P4&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;http://man7.org/linux/man-pages/man2/bpf.2.html&quot; target=_blank&gt;bpf - perform a command on an extended BPF map or program&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;http://man7.org/linux/man-pages/man8/tc-bpf.8.html&quot; target=_blank&gt;BPF  -  BPF  programmable  classifier  and actions for ingress/egress queueing disciplines&lt;/a&gt;
  &lt;li&gt;&lt;a href=&quot;https://opensource.com/article/17/11/bccbpf-performance&quot; target=_blank&gt;7 tools for analyzing performance in Linux with bcc/BPF&lt;/a&gt; - gethostlatency, tcplife, biolatency, opensnoop, execsnoop, ...
  &lt;li&gt;&lt;a href=&quot;&quot; target=_blank&gt;&lt;/a&gt;
  &lt;/ul&gt;

&lt;p&gt;In Debian with Kernel &quot;4.19.0-1-amd64 #1 SMP Debian 4.19.12-1 (2018-12-22)&quot;, the following are set:

&lt;blockquote&gt;&lt;pre&gt;
# grep -i bpf /boot/config-4.19.0-1-amd64
CONFIG_CGROUP_BPF=y
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
# CONFIG_BPF_JIT_ALWAYS_ON is not set
CONFIG_IPV6_SEG6_BPF=y
CONFIG_NETFILTER_XT_MATCH_BPF=m
# CONFIG_BPFILTER is not set
CONFIG_NET_CLS_BPF=m
CONFIG_NET_ACT_BPF=m
CONFIG_BPF_JIT=y
# CONFIG_BPF_STREAM_PARSER is not set
CONFIG_LWTUNNEL_BPF=y
CONFIG_HAVE_EBPF_JIT=y
CONFIG_BPF_EVENTS=y
# CONFIG_BPF_KPROBE_OVERRIDE is not set
CONFIG_TEST_BPF=m
# grep -i xdp /boot/config-4.19.0-1-amd64
# CONFIG_XDP_SOCKETS is not set
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;Install the the BPF Compiler Tools with:

&lt;blockquote&gt;
apt install &lt;a href=&quot;https://packages.debian.org/buster/libbpfcc&quot; target=_blank&gt;libbpfcc&lt;/a&gt; &lt;a href=&quot;https://packages.debian.org/buster/libbpfcc-dev&quot; target=_blank&gt;libbpfcc-dev&lt;/a&gt; &lt;a href=&quot;https://packages.debian.org/buster/bpfcc-tools&quot; target=_blank&gt;bpfcc-tools&lt;/a&gt; &lt;a href=&quot;https://packages.debian.org/buster/python-bpfcc&quot; target=_blank&gt;python-bpfcc&lt;/a&gt;
&lt;/blockquote&gt;

&lt;p&gt;bcc header files are in &#039;/usr/include/bcc/&#039;.  Many tools with suffic &#039;bpfcc&#039; are installed in /usr/sbin. There is a man page for each.  Many many examples can be found in /usr/share/doc/bpfcc-tools/examples/doc/.

&lt;p&gt;&lt;a href=&quot;https://opensource.com/article/17/11/bccbpf-performance&quot; target=_blank&gt;7 tools for analyzing performance in Linux with bcc/BPF&lt;/a&gt; covers execsnoop, opensnoop, xfsslower, biolatency, tcplife, gethostlatency and trace.  The article also refers to 
&lt;a href=&quot;https://github.com/iovisor/bcc/blob/master/docs/tutorial_bcc_python_developer.md&quot; target=_blank&gt;bcc Python Developer Tutorial&lt;/a&gt;.  Also referenced was &lt;a href=&quot;https://github.com/iovisor/bpftrace&quot; target=_blank&gt;bpftrace&lt;/a&gt;.  A better page referencing these tools is
&lt;a href=&quot;http://www.brendangregg.com/ebpf.html&quot; target=_blank&gt;Linux Extended BPF (eBPF) Tracing Tools&lt;/a&gt;.  &lt;a href=&quot;http://www.brendangregg.com/blog/2015-05-15/ebpf-one-small-step.html&quot; target=_blank&gt;eBPF: One Small Step&lt;/a&gt; is an early Brendan Gregg article on eBPF tracing.

&lt;p&gt;Going even deeper into the woods, another tool referenced includes &lt;a href=&quot;https://sourceware.org/ml/systemtap/2017-q4/msg00096.html&quot; target=_blank&gt;SystemTap&lt;/a&gt; which has a &lt;a href=&quot;https://packages.debian.org/buster/systemtap&quot; target=_blank&gt;Debian Package&lt;/a&gt;.

&lt;p&gt;The BCC has a &lt;a href=&quot;https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md&quot; target=_blank&gt;reference guide&lt;/a&gt;.  Most of the preceding has to do with tracing.  Now to get to packet manipulation.

&lt;p&gt;For compiling, some packages:

&lt;blockquote&gt;&lt;pre&gt;
apt install clang llvm clang-7-doc ncurses-doc libomp-7-doc llvm-7-doc
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;Some items from &lt;a href=&quot;https://schd.ws/hosted_files/ossna2017/da/BPFandXDP.pdf&quot; target=_blank&gt;Making the Kernel’s Networking Data Path
Programmable with BPF and XDP&lt;/a&gt;:

&lt;ul&gt;
  &lt;li&gt;11 64bit registers, 32bit subregisters, up to 512bytes stack
  &lt;li&gt;Instructions 64bit wide, max 4096 per program
  &lt;li&gt;BPF calling convention for helpers allows for efficient mapping: a) R0 →return value from helper call, b) R1 - R5 →argument registers for helper call, c) R6 - R9 → callee saved, preserved on helper call
  &lt;li&gt;/proc/kallsyms exposure of JIT image as symbol for stack traces
  &lt;li&gt;Since LLVM 3.7: clang -O2 -target bpf -c foo.c -o foo.o
  &lt;li&gt;To show ability: llc --version | grep bpf
  &lt;li&gt;Assembler output through -S supported
  &lt;li&gt;llvm-objdump for disassembler and code annotations (via DWARF)
  &lt;li&gt;C example walkthrough:  tools/testing/selftests/bpf/testl_4lb.c
  &lt;li&gt;when attaching to generic XDP kernel driver via iproute2: ip link set dev eno1 xdpgeneric obj prog.o
  &lt;/ul&gt;

&lt;p&gt;2019/05/04 - &lt;a href=&quot;https://news.ycombinator.com/item?id=19818089&quot; target=_blank&gt;Hacker News&lt;/a&gt; had a reference to CloudFlare where they discussed &lt;a href=&quot;https://blog.cloudflare.com/ebpf-cant-count/&quot; target=_blank&gt;eBPF can&#039;t count?!&lt;/a&gt; - an article with references on how to debug eBPF code. 
    </content:encoded>

    <pubDate>Mon, 24 Dec 2018 15:01:56 +0000</pubDate>
    <guid isPermaLink="false">http://blog.raymond.burkholder.net/index.php?/archives/982-guid.html</guid>
    
</item>

</channel>
</rss>
