<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/tools/bpf/bpftool/net.c, branch linux-5.13.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.13.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.13.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2021-04-15T23:50:22Z</updated>
<entry>
<title>bpftool: Fix a clang compilation warning</title>
<updated>2021-04-15T23:50:22Z</updated>
<author>
<name>Yonghong Song</name>
</author>
<published>2021-04-13T15:34:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8af50142763c6e70d426e45278b23d7103e5b7a7'/>
<id>urn:sha1:8af50142763c6e70d426e45278b23d7103e5b7a7</id>
<content type='text'>
With clang compiler:
  make -j60 LLVM=1 LLVM_IAS=1  &lt;=== compile kernel
  # build selftests/bpf or bpftool
  make -j60 -C tools/testing/selftests/bpf LLVM=1 LLVM_IAS=1
  make -j60 -C tools/bpf/bpftool LLVM=1 LLVM_IAS=1
the following compilation warning showed up,
  net.c:160:37: warning: comparison of integers of different signs: '__u32' (aka 'unsigned int') and 'int' [-Wsign-compare]
                for (nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len);
                                                  ^~~~~~~~~~~~~~~~~
  .../tools/include/uapi/linux/netlink.h:99:24: note: expanded from macro 'NLMSG_OK'
                           (nlh)-&gt;nlmsg_len &lt;= (len))
                           ~~~~~~~~~~~~~~~~ ^   ~~~

In this particular case, "len" is defined as "int" and (nlh)-&gt;nlmsg_len is "unsigned int".
The macro NLMSG_OK is defined as below in uapi/linux/netlink.h.
  #define NLMSG_OK(nlh,len) ((len) &gt;= (int)sizeof(struct nlmsghdr) &amp;&amp; \
                             (nlh)-&gt;nlmsg_len &gt;= sizeof(struct nlmsghdr) &amp;&amp; \
                             (nlh)-&gt;nlmsg_len &lt;= (len))

The clang compiler complains the comparision "(nlh)-&gt;nlmsg_len &lt;= (len))",
but in bpftool/net.c, it is already ensured that "len &gt; 0" must be true.
So theoretically the compiler could deduce that comparison of
"(nlh)-&gt;nlmsg_len" and "len" is okay, but this really depends on compiler
internals. Let us add an explicit type conversion (from "int" to "unsigned int")
for "len" in NLMSG_OK to silence this warning right now.

Signed-off-by: Yonghong Song &lt;yhs@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20210413153435.3029635-1-yhs@fb.com
</content>
</entry>
<entry>
<title>bpftool: Fix compilation failure for net.o with older glibc</title>
<updated>2021-01-06T23:27:38Z</updated>
<author>
<name>Alan Maguire</name>
</author>
<published>2021-01-06T15:59:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6f02b540d7597f357bc6ee711346761045d4e108'/>
<id>urn:sha1:6f02b540d7597f357bc6ee711346761045d4e108</id>
<content type='text'>
For older glibc ~2.17, #include'ing both linux/if.h and net/if.h
fails due to complaints about redefinition of interface flags:

  CC       net.o
In file included from net.c:13:0:
/usr/include/linux/if.h:71:2: error: redeclaration of enumerator ‘IFF_UP’
  IFF_UP    = 1&lt;&lt;0,  /* sysfs */
  ^
/usr/include/net/if.h:44:5: note: previous definition of ‘IFF_UP’ was here
     IFF_UP = 0x1,  /* Interface is up.  */

The issue was fixed in kernel headers in [1], but since compilation
of net.c picks up system headers the problem can recur.

Dropping #include &lt;linux/if.h&gt; resolves the issue and it is
not needed for compilation anyhow.

[1] https://lore.kernel.org/netdev/1461512707-23058-1-git-send-email-mikko.rapeli__34748.27880641$1462831734$gmane$org@iki.fi/

Fixes: f6f3bac08ff9 ("tools/bpf: bpftool: add net support")
Signed-off-by: Alan Maguire &lt;alan.maguire@oracle.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Link: https://lore.kernel.org/bpf/1609948746-15369-1-git-send-email-alan.maguire@oracle.com
</content>
</entry>
<entry>
<title>tools, bpftool: Add missing close before bpftool net attach exit</title>
<updated>2020-11-13T14:59:13Z</updated>
<author>
<name>Wang Hai</name>
</author>
<published>2020-11-13T11:51:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=50431b45685b600fc2851a3f2b53e24643efe6d3'/>
<id>urn:sha1:50431b45685b600fc2851a3f2b53e24643efe6d3</id>
<content type='text'>
progfd is created by prog_parse_fd() in do_attach() and before the latter
returns in case of success, the file descriptor should be closed.

Fixes: 04949ccc273e ("tools: bpftool: add net attach command to attach XDP on interface")
Signed-off-by: Wang Hai &lt;wanghai38@huawei.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/20201113115152.53178-1-wanghai38@huawei.com
</content>
</entry>
<entry>
<title>tools/bpftool: Remove libbpf_internal.h usage in bpftool</title>
<updated>2020-08-19T01:38:25Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-08-19T01:36:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7084566a236fbc98beb11430d8d67dd08b2ac151'/>
<id>urn:sha1:7084566a236fbc98beb11430d8d67dd08b2ac151</id>
<content type='text'>
Most netlink-related functions were unique to bpftool usage, so I moved them
into net.c. Few functions are still used by both bpftool and libbpf itself
internally, so I've copy-pasted them (libbpf_nl_get_link,
libbpf_netlink_open). It's a bit of duplication of code, but better separation
of libbpf as a library with public API and bpftool, relying on unexposed
functions in libbpf.

Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200819013607.3607269-3-andriin@fb.com
</content>
</entry>
<entry>
<title>tools, bpftool: Clean subcommand help messages</title>
<updated>2020-06-01T21:38:18Z</updated>
<author>
<name>Quentin Monnet</name>
</author>
<published>2020-05-23T01:07:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=90040351a832acf862c8f1855c29411303d23755'/>
<id>urn:sha1:90040351a832acf862c8f1855c29411303d23755</id>
<content type='text'>
This is a clean-up for the formatting of the do_help functions for
bpftool's subcommands. The following fixes are included:

- Do not use argv[-2] for "iter" help message, as the help is shown by
  default if no "iter" action is selected, resulting in messages looking
  like "./bpftool bpftool pin...".

- Do not print unused HELP_SPEC_PROGRAM in help message for "bpftool
  link".

- Andrii used argument indexing to avoid having multiple occurrences of
  bin_name and argv[-2] in the fprintf() for the help message, for
  "bpftool gen" and "bpftool link". Let's reuse this for all other help
  functions. We can remove up to thirty arguments for the "bpftool map"
  help message.

- Harmonise all functions, e.g. use ending quotes-comma on a separate
  line.

Signed-off-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/20200523010751.23465-1-quentin@isovalent.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>bpftool: Use consistent include paths for libbpf</title>
<updated>2020-01-21T00:37:45Z</updated>
<author>
<name>Toke Høiland-Jørgensen</name>
</author>
<published>2020-01-20T13:06:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=229c3b47b794e7257744224b21a95d3d9938d00a'/>
<id>urn:sha1:229c3b47b794e7257744224b21a95d3d9938d00a</id>
<content type='text'>
Fix bpftool to include libbpf header files with the bpf/ prefix, to be
consistent with external users of the library. Also ensure that all
includes of exported libbpf header files (those that are exported on 'make
install' of the library) use bracketed includes instead of quoted.

To make sure no new files are introduced that doesn't include the bpf/
prefix in its include, remove tools/lib/bpf from the include path entirely,
and use tools/lib instead.

Fixes: 6910d7d3867a ("selftests/bpf: Ensure bpf_helper_defs.h are taken from selftests dir")
Signed-off-by: Toke Høiland-Jørgensen &lt;toke@redhat.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Link: https://lore.kernel.org/bpf/157952560684.1683545.4765181397974997027.stgit@toke.dk
</content>
</entry>
<entry>
<title>libbpf: Move non-public APIs from libbpf.h to libbpf_internal.h</title>
<updated>2019-12-15T23:58:04Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2019-12-14T01:43:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=612d05be250aa8804d3baba7a12445a267a580d3'/>
<id>urn:sha1:612d05be250aa8804d3baba7a12445a267a580d3</id>
<content type='text'>
Few libbpf APIs are not public but currently exposed through libbpf.h to be
used by bpftool. Move them to libbpf_internal.h, where intent of being
non-stable and non-public is much more obvious.

Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Link: https://lore.kernel.org/bpf/20191214014341.3442258-4-andriin@fb.com
</content>
</entry>
<entry>
<title>tools: bpftool: fix format string for p_err() in query_flow_dissector()</title>
<updated>2019-08-16T05:06:46Z</updated>
<author>
<name>Quentin Monnet</name>
</author>
<published>2019-08-15T14:32:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8a15d5ced8c626c0331974c7281c1d651f7b0d83'/>
<id>urn:sha1:8a15d5ced8c626c0331974c7281c1d651f7b0d83</id>
<content type='text'>
The format string passed to one call to the p_err() function in
query_flow_dissector() does not match the value that should be printed,
resulting in some garbage integer being printed instead of
strerror(errno) if /proc/self/ns/net cannot be open. Let's fix the
format string.

Fixes: 7f0c57fec80f ("bpftool: show flow_dissector attachment status")
Signed-off-by: Quentin Monnet &lt;quentin.monnet@netronome.com&gt;
Reviewed-by: Jakub Kicinski &lt;jakub.kicinski@netronome.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>tools: bpftool: add net detach command to detach XDP on interface</title>
<updated>2019-08-16T00:00:33Z</updated>
<author>
<name>Daniel T. Lee</name>
</author>
<published>2019-08-13T02:46:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=37c7f863ba92f0a7aa8bdfde9dfb6c392393fb83'/>
<id>urn:sha1:37c7f863ba92f0a7aa8bdfde9dfb6c392393fb83</id>
<content type='text'>
By this commit, using `bpftool net detach`, the attached XDP prog can
be detached. Detaching the BPF prog will be done through libbpf
'bpf_set_link_xdp_fd' with the progfd set to -1.

Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Signed-off-by: Daniel T. Lee &lt;danieltimlee@gmail.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>tools: bpftool: add net attach command to attach XDP on interface</title>
<updated>2019-08-16T00:00:33Z</updated>
<author>
<name>Daniel T. Lee</name>
</author>
<published>2019-08-13T02:46:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=04949ccc273e14d28aa004ac6954af0898ca3d12'/>
<id>urn:sha1:04949ccc273e14d28aa004ac6954af0898ca3d12</id>
<content type='text'>
By this commit, using `bpftool net attach`, user can attach XDP prog on
interface. New type of enum 'net_attach_type' has been made, as stat ted at
cover-letter, the meaning of 'attach' is, prog will be attached on interface.

With 'overwrite' option at argument, attached XDP program could be replaced.
Added new helper 'net_parse_dev' to parse the network device at argument.

BPF prog will be attached through libbpf 'bpf_set_link_xdp_fd'.

Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Signed-off-by: Daniel T. Lee &lt;danieltimlee@gmail.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
</feed>
