<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    [snip]<o:p></o:p>
    <blockquote type="cite"
cite="mid:DM6PR11MB3995A1F60439980E4717CE81A281A@DM6PR11MB3995.namprd11.prod.outlook.com">
      <div class="WordSection1">
        <div
style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
          <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
            <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
              <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
                <pre><o:p> </o:p></pre>
                <pre> Prerequisites<o:p></o:p></pre>
                <pre>@@ -224,7 +225,6 @@ Howto run dpdk-testpmd with CNI plugin:<o:p></o:p></pre>
                <pre>           capabilities:<o:p></o:p></pre>
                <pre>              add:<o:p></o:p></pre>
                <pre>                - CAP_NET_RAW<o:p></o:p></pre>
                <pre>-               - CAP_BPF<o:p></o:p></pre>
              </blockquote>
            </blockquote>
            <pre><o:p> </o:p></pre>
            <pre>Why the CAP_BPF is removed?<o:p></o:p></pre>
          </blockquote>
          <p><o:p> </o:p></p>
          <p>Good question. It's removed because in our case CAP_BPF is
            only needed when we want to load or unload the XDP program
            on the interface inside the Pod. In our case the CNI is
            loading the xdp program on the interface and then we are
            doing a handshake to get the xskmap file descriptor and so
            we don't need the CAP_BPF. <br>
            <br>
            You will find a detailed listing of the permissions used at
            different stages when utilizing an XDP prog in this article
            <a
href="https://next.redhat.com/2023/07/18/using-ebpf-in-unprivileged-pods/"
              moz-do-not-send="true" class="moz-txt-link-freetext">https://next.redhat.com/2023/07/18/using-ebpf-in-unprivileged-pods/</a>
            <br>
            <br>
            I'm currently also working on enabling pinned map sharing
            with the af_xdp vdev eal arguments so we can integrate with
            bpfman for centralized BPF program lifecycle management
            [currently under test].
            <o:p></o:p></p>
          <p><o:p> </o:p></p>
          <p>Correct me if I am wrong, Don’t we still need the CAP_BPF
            for bpf operations? </p>
        </div>
      </div>
    </blockquote>
    <p>The only BPF operation in the Pod (when using the AF_XDP CNI) is
      interacting with the BPF maps via bpf_map_update_elem(). <br>
    </p>
    <p>There's no BPF load/unload operations when you are using the
      AF_XDP DP and CNI (it does this for you) similar to what bpfman is
      doing in [1]. To interact with BPF maps you don't need CAP_BPF
      since the 5.19 Kernel please see [2], in addition to the previous
      links. In other words the only time you should need cap_bpf to
      access a map is if your kernel is <= 5.18. Which was the note I
      was referring to when I said I would update the documentation.</p>
    <p>I've tested this patch in pod on Fedora 38 Kernel version:
      6.5.12-200.fc38.x86_64 and there you don't need CAP_BPF.</p>
    <p>Additionally Ubuntu 22.04 LTS is now shipping with a 6.2 Kernel
      [3], so you will not need it there either.<br>
    </p>
    <p>We don't want to give the pods more permissions than they need.
      CAP_BPF is in IMO an elevated permission. <br>
    </p>
    <blockquote type="cite"
cite="mid:DM6PR11MB3995A1F60439980E4717CE81A281A@DM6PR11MB3995.namprd11.prod.outlook.com">
      <div class="WordSection1">
        <div
style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
          <p><o:p>
            </o:p></p>
          <p>If CAP_BPF is not need so do we need the CAP_NET_RAW also?<o:p></o:p></p>
        </div>
      </div>
    </blockquote>
    <p>You need the CAP_NET_RAW to create the AF_XDP socket. </p>
    <br>
    <br>
    <blockquote type="cite"
cite="mid:DM6PR11MB3995A1F60439980E4717CE81A281A@DM6PR11MB3995.namprd11.prod.outlook.com">
      <div class="WordSection1">
        <div
style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
          <p class="MsoNormal">[snip]</p>
        </div>
      </div>
    </blockquote>
    <br>
    <p>[1]
<a class="moz-txt-link-freetext" href="https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=c8644cd0efe7">https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=c8644cd0efe7</a>
      <br>
    </p>
    <p>[2]
<a class="moz-txt-link-freetext" href="https://bpfd.dev/developer-guide/linux-capabilities/#removing-cap_bpf-from-bpfman-clients">https://bpfd.dev/developer-guide/linux-capabilities/#removing-cap_bpf-from-bpfman-clients</a></p>
    <p>[3]
<a class="moz-txt-link-freetext" href="https://tuxcare.com/blog/ubuntu-22-04-3-is-here-with-linux-kernel-6-2/#:~:text=Initially%20released%20on%20April%2021,Ubuntu%2023.04%20(Lunar%20Lobster)">https://tuxcare.com/blog/ubuntu-22-04-3-is-here-with-linux-kernel-6-2/#:~:text=Initially%20released%20on%20April%2021,Ubuntu%2023.04%20(Lunar%20Lobster)</a>.</p>
    <p></p>
  </body>
</html>