diff options
author | V3n3RiX <venerix@koprulu.sector> | 2024-10-31 03:04:18 +0000 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2024-10-31 03:04:18 +0000 |
commit | b846e1a1ef5685462a20abbc77cf57ead9064b85 (patch) | |
tree | ebf4581a96d87fbd1b7ab6cce8689ba4caa40e3b /dev-util/bpftool | |
parent | fb57e01054259b1160d01c3c7ed9efab7902ed7d (diff) |
gentoo auto-resync : 31:10:2024 - 03:04:18
Diffstat (limited to 'dev-util/bpftool')
12 files changed, 812 insertions, 1 deletions
diff --git a/dev-util/bpftool/Manifest b/dev-util/bpftool/Manifest index dcba96112e21..ecec4f4ed9fc 100644 --- a/dev-util/bpftool/Manifest +++ b/dev-util/bpftool/Manifest @@ -1,3 +1,13 @@ +AUX 7.4-001-mount-bpffs-on-provided-dir-instead-of-parent-dir.patch 7140 BLAKE2B 12166138aefdb8e9e9b99c8045181da9c35c453e2f628defee789be62f09f8a20af1c4dabb396c7821fe0223b7a876d70b2555580eb971e941f8a95d17b5ab45 SHA512 44f242d7245a1c2fbbdaab31f519244ee6f7ce6ce8c1a6e5bfcf7e3a305ec9555ab22831df503ad51f090772d739043ce9e6bfc8cb766660fe764e2b481a3176 +AUX 7.4-002-set-DESTDIR-to-empty-when-building-libbpf.patch 1798 BLAKE2B 8e355fa72c550dae8b76abeeb393c0980ea097ebbee475f3d256c37960782993c93ba5c7862863f3f73cbab0761b89acf6bef6c6eff34db59fba3c18fe0f740b SHA512 c28810572f7bfa22ccf27fbe69b9761eb78209ddac7913f9cef1bf4b59ebaab7abbb560f29bba73ecdd526a752549b5f78db95e486a6cb93f53b98f28fd09760 +AUX 7.4-003-fix-typo-in-usage-help.patch 1603 BLAKE2B f1efe3c8deca53a06a342262e1366c7f8dd3932541a76280afeb01960af0b2a1d57a2eebb5075f9769117e154a2145daa1482a3e57551a89ba511e101ae99896 SHA512 7162f0cea84e36d5758724d5290544312cbdd43d7785e10742a326d9b22878e43619002c26f03f3b7c827e43fb490ee829c893a379ac347ec435375f23a0c063 +AUX 7.4-004-fix-the-wrong-format-specifier.patch 1242 BLAKE2B d2077558f4f3901e499c2bc82194f8a0d202530579838d0202cfdf97ce4924032d9efe4e69e1e5d931e63d6ad372fe1f68c47a425da78d37d398e12efb437385 SHA512 e0e0a2b9ce73a1ee6a156892fc7c7dab3e879c94fa622628af6f0a4fc4ef47f04e7a5d39aa5531b84f4a299f5b51f3d222e9b82cd381574c0e92b232861c0c24 +AUX 7.4-005-fix-undefined-behavior-caused-by-shifting-into-the-sign-bit.patch 1778 BLAKE2B 546488479bd50da42273c07a5008c46f425739f4f989df9171cd7a195eb55c9d8ac2dba36b189e58db3e8665964b7dde6b0d43db9a0b0953395f390621969591 SHA512 d8c5d41b6dad8c5a7f9575a58c4f8fe1e19f0069cd807efc15083a6e1ae90368b8cc98189d1d262331224c84cb27b7698dea028f760516ce07ac6f8012ed4d83 +AUX 7.4-006-fix-undefined-behavior-in-qsort.patch 1922 BLAKE2B 52aab0ee6878c29bd99a60e0c264a6b6802ddb355010fcc35c45b92dbc8bc7af172fda0ef88f5aeb9f673e2254b68736af0ddc1aeaf5ddd5795047a176dad737 SHA512 9e748b1215aa2e93bda92cf818167150a543d89c5a19119eb2eeffa48b2659e5399be426d0d62c81f39b48fcf4ad7f9492bdfabdf29eed6b65bf3d3283210472 +AUX 7.4-007-define-PACKAGE-at-build-time-when-trying-to-detect-libbfd.patch 2268 BLAKE2B a537c0356ca2da4bdaf39a5dc77a0f5f0ef004a081c7620230edc55c407887a56f1a3bfcfb3036f24dd8b5a46ca7ee303c87332dc094556694ea8a201ba29ae4 SHA512 e96b0ce37ca5306dcd093ebbd185417d6f7830c5abb4ebadcc9c117066ebc43328752e6819bea211e92f4f4d6ce7d023b60db4c1ca11ce4f2e41877feb08c48a +AUX 7.4-008-always-disable-unused-CLI-arguments-warning-for-feature-probe.patch 1481 BLAKE2B 74e618cb84c3f62553b50b351b495993aa608508cbb54fefca667369c9f49a127742f27b2514a3bb7dae6bc09145068641f548710e9b9299fb14b0783bff4ba2 SHA512 dbeb9e5e2e0750220b69c07b15110c6af19e2ab049d484d73f676d14d321289d5c6bfc96bed6bd0fe717af09b2f75aff2ecee7e084985026a2f30c5fcbd57958 +DIST bpftool-7.4.0.tar.gz 472915 BLAKE2B ae7b6bc6cb742712981ba8972bcecccc63d440b2a77c5a14f91ba5106c013774313d65fd3f42b843ba4027ab17cf9d44d256270f7f8ad11907714f16f3149078 SHA512 08a3095b37a9b897400f2be7dbb9de10d129ae4eef193d03955fdf84017cd3a5d7419e856aa68a425e609419868e8b1dd5409b4f218cc24feeb059c1898cdff4 +DIST libbpf-1.4.7.tar.gz 1016441 BLAKE2B 10be52c7e97b2f08edd33cb263c4737bb52edfd2226f0c5b86d4f95b584b81f8f6b1ede469e9ad6c231e55b6d6b9a038160662606c3f30dc79b1336aaaa90e74 SHA512 f09ff28ac75b0d0c1bfe7d233aee6a00e5c21f185646b2afe11b7bd048d74962f893237437dd81a762768f9235b9f2a2a33cb297201b2aa3e98f7c6f58e5b365 DIST linux-6.10.tar.xz 145142812 BLAKE2B bb243ea7493b9d63aa2df2050a3f1ae2b89ee84a20015239cf157e3f4f51c7ac5efedc8a51132b2d7482f9276ac418de6624831c8a3b806130d9c2d2124c539b SHA512 baa2487954044f991d2ae254d77d14a1f0185dd62c9f0fcaff69f586c9f906823017b8db1c4588f27b076dfa3ebb606929fec859f60ea419e7974330b9289cc2 DIST linux-6.11.tar.xz 146900704 BLAKE2B e7750c0878d71a56a0ce52d4c4c912199dad5bf5e2e8f872585a6494afbb37cbd852e612a6858936d2dc9b7776a3933818f540db408d57e90d18ea5249bba7ab SHA512 329c1f94008742e3f0c2ce7e591a16316d1b2cb9ea4596d4f45604097e07b7aa2f64afa40630a07f321a858455c77aa32ba57b271932ddcf4dc27863f9081cea DIST linux-6.8.tar.xz 142502100 BLAKE2B c6f17f816cea16e629f63e9379b98888713f57b2c5173306926471f139a9d612a0c74e119341f8075390e55e203d787d9edeb4ad5a064b18870f6f0f7ffaafb2 SHA512 5c4eb4aa1d3f7d1ea01c0f7ddeadacdece6e144fd4bdfc16b2b925d3e10dc04de3a6db69320b79a96c3560052616f001d2c09e7a1bb4f7b731e2380a7ecce068 @@ -8,6 +18,8 @@ DIST patch-6.8.2.xz 247244 BLAKE2B a85078230548543c38550a5546689d0b44a54208cdad5 DIST patch-6.9.2.xz 16184 BLAKE2B 8a37e96c253b55b57c86f1654f2ea8bf65af96b1b38213e90032cb918bb8eea992d6ddbfa6a6774a229ab2e2288ab57bdb6cbad6e7e393c123f24850e06847c9 SHA512 a27af24f0caaa5de3811b6db5acc2d72b96df9ebb5c44bad99a949d871fb06c6ffd2be10cfc35b246d430c7be2291701f802aed47eaa8818ad12b8818a60f3ec EBUILD bpftool-6.8.2.ebuild 3101 BLAKE2B b032c5133f13d0a2f789a08fa054bd5d88cc729026974189d20b9d91f6295fdbad39056acc1223e78923b6201d91799c8cb833948135bccf25b84b4c25f00d5d SHA512 1efcf7572c1aa378394f38d2b939752aaf3215f92ffa227c493d0e3e9c8f945bcca82f759487386cd62e9c5996400395a944962f61af20fc62f8a206b57740d5 EBUILD bpftool-6.9.2.ebuild 3125 BLAKE2B a8395a94a01d8fe758246cc158713ca30f928aa4051380f6fbb4a285f7a16a223db02b199b422242adca3df4032d79daa20b9420f3a4543aeefca128e41ddfad SHA512 3931abd489a3cbb7aaaf4ea8fd004a45c4a27c8a645fb7eb5088fab3186ebc59b61d58e4b0704dd1c264eee50a95288ad1824af0aff482da306c282465d3013b +EBUILD bpftool-7.4.0.ebuild 3984 BLAKE2B aea7bd4c8939b32e2a866a291712191615e4eb96ece7ecf7c21bf073df59a027b041e7de5d32606cf0aafe1a61bdd2ef4cd9e67131f4a63f72539470c432c4d2 SHA512 dde442cf261513ff787eb15ee94da91287928daf7928679c530a930cbdb0d0351fa059c0ade10f11e7dc278aaace589ef6643956de21b9875889d0281fab4ce5 EBUILD bpftool-7.5.0-r1.ebuild 3405 BLAKE2B 74da665bc8e3ddd5ea372590455345ea6e75348500eefe7117926d313d8d4c75579e31635b8b67761ffe1ad3284788dfd19f524709f2a951b1f9790a41ea3b1e SHA512 a228790899d82206d7378d24aaf02257b6fb540983ea83157eb7a0ef4c09d420c57257849830c8352df4a1f55f482fad9490813d8657e6b512bbe28b46958429 EBUILD bpftool-7.5.0-r2.ebuild 3692 BLAKE2B 96f5e8a3d432141f2222e84bb7855e99dcfbec79dae69730fc59c43844dce96c0b062a0a5795148309f3da3fbe794c0ce4e58037a2d5d715708d60a4b16ad86f SHA512 e8238e2c69c00a0f398e31b22cb0433f424246725c3f5be779ba52abf0b838540cbf54c8b52ab545ce462d71294e11ec085a36ccc614efaab776a4a0c04d2421 -MISC metadata.xml 650 BLAKE2B 4e195974ef7cee9b087c5c5f58e1782ff6b884603c68042c3d28471d4e7eb92004e9963ecdf534b360579e475424e64dd905fa5e98a74385aaadbe132b598176 SHA512 4a9d57fc518a3dbe67b0c0436ba41a66cd25d970e9b4c1d0cb1c8120f8d02e1e4fcca7e68d878dd74ae16e7804952a68c486621a44d59e5782341d1800f2e142 +EBUILD bpftool-9999.ebuild 3383 BLAKE2B e58739227f533cc5e0f65bdfa1eebf3a45a73b980f27661607d036f5a7b9622be12c6194f8d6e8ec4eca61b68233dc64beee36c32a36e2444b1ed38e359df169 SHA512 b5b7782ab8dd50208d5e69acadfc509479024e1b524c35618afc8d2cd19f80f3bba3ae1acd8ae500062046f28f535ab8682730cf53dff20abc1902f32904467b +MISC metadata.xml 729 BLAKE2B 7a30c956e2e563b5a22b9301afa77f1025d93464c4f33f31aba6ec727b85857393318bc2941b2165fcf6c4258c318e48e66b1f1147f30e80a4ebcb63cb6f4b3f SHA512 799fcd5cf2da7c6dc67adb6766f73aa350f412444f1a2e8a911d2db6e6c7f228cf0863a09bd32a07fc8ef8d7fce68036239e779e78454285c36a2b95935afef6 diff --git a/dev-util/bpftool/bpftool-7.4.0.ebuild b/dev-util/bpftool/bpftool-7.4.0.ebuild new file mode 100644 index 000000000000..8f60dcd2b97d --- /dev/null +++ b/dev-util/bpftool/bpftool-7.4.0.ebuild @@ -0,0 +1,132 @@ +# Copyright 2021-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +LLVM_COMPAT=( {15..19} ) +LLVM_OPTIONAL=1 +PYTHON_COMPAT=( python3_{10..13} ) + +inherit bash-completion-r1 linux-info llvm-r1 optfeature python-any-r1 toolchain-funcs + +DESCRIPTION="Tool for inspection and simple manipulation of eBPF programs and maps" +HOMEPAGE="https://github.com/libbpf/bpftool" + +if [[ ${PV} == *9999* ]] ; then + inherit git-r3 + EGIT_REPO_URI="https://github.com/libbpf/bpftool.git" + EGIT_SUBMODULES=(libbpf) +else + # bpftool typically vendors whatever libbpf is current at the time + # of a release, while libbpf publishes minor updates more frequently. + # Uncomment the following to bundle an updated libbpf e.g. in case of + # security or crasher bugs in libbpf and to keep the two synchronized. + # This allows us to quickly update the vendored lib with a revbump. + # Currently bpftool-x.y vendors libbpf-1.y; DO NOT mix different y versions. + # See the libbpf repo (https://github.com/libbpf/libbpf) for possible updates. + LIBBPF_VERSION=1.4.7 + + if [[ ! -z ${LIBBPF_VERSION} ]] ; then + SRC_URI="https://github.com/libbpf/bpftool/archive/refs/tags/v${PV}.tar.gz -> bpftool-${PV}.tar.gz + https://github.com/libbpf/libbpf/archive/refs/tags/v${LIBBPF_VERSION}.tar.gz + -> libbpf-${LIBBPF_VERSION}.tar.gz" + else + # use tarball with bundled libbpf + SRC_URI="https://github.com/libbpf/bpftool/releases/download/v${PV}/bpftool-libbpf-v${PV}-sources.tar.gz" + S="${WORKDIR}/bpftool-libbpf-v${PV}-sources" + fi + + KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86" +fi + +LICENSE="|| ( GPL-2 BSD-2 )" +SLOT="0" +IUSE="caps llvm" +REQUIRED_USE="llvm? ( ${LLVM_REQUIRED_USE} )" + +RDEPEND=" + caps? ( sys-libs/libcap:= ) + llvm? ( $(llvm_gen_dep 'sys-devel/llvm:${LLVM_SLOT}') ) + !llvm? ( sys-libs/binutils-libs:= ) + sys-libs/zlib:= + virtual/libelf:= +" +DEPEND=" + ${RDEPEND} + >=sys-kernel/linux-headers-5.8 +" +BDEPEND=" + ${PYTHON_DEPS} + app-arch/tar + dev-python/docutils +" + +CONFIG_CHECK="~DEBUG_INFO_BTF" + +PATCHES=( + "${FILESDIR}"/7.4-001-mount-bpffs-on-provided-dir-instead-of-parent-dir.patch + "${FILESDIR}"/7.4-002-set-DESTDIR-to-empty-when-building-libbpf.patch + "${FILESDIR}"/7.4-003-fix-typo-in-usage-help.patch + "${FILESDIR}"/7.4-004-fix-the-wrong-format-specifier.patch + "${FILESDIR}"/7.4-005-fix-undefined-behavior-caused-by-shifting-into-the-sign-bit.patch + "${FILESDIR}"/7.4-006-fix-undefined-behavior-in-qsort.patch + "${FILESDIR}"/7.4-007-define-PACKAGE-at-build-time-when-trying-to-detect-libbfd.patch + "${FILESDIR}"/7.4-008-always-disable-unused-CLI-arguments-warning-for-feature-probe.patch +) + +pkg_setup() { + python-any-r1_pkg_setup + use llvm && llvm-r1_pkg_setup +} + +src_prepare() { + default + + # prepare libbpf if necessary + if [[ ! -z ${LIBBPF_VERSION} ]] ; then + rm -rf libbpf || die + ln -s "${WORKDIR}/libbpf-${LIBBPF_VERSION}" libbpf || die + fi + + # remove -Werror from libbpf (bug 887981) + sed -i -e 's/\-Werror//g' libbpf/src/Makefile || die + + # remove -Werror from bpftool feature detection + sed -i -e 's/-Werror//g' src/Makefile.feature || die + + # remove hardcoded/unhelpful flags from bpftool + sed -i -e '/CFLAGS += -O2/d' -e 's/-W //g' -e 's/-Wextra //g' src/Makefile || die + + # Use rst2man or rst2man.py depending on which one exists (#930076) + type -P rst2man >/dev/null || sed -i -e 's/rst2man/rst2man.py/g' docs/Makefile || die +} + +bpftool_make() { + tc-export AR CC LD + + emake \ + ARCH="$(tc-arch-kernel)" \ + HOSTAR="$(tc-getBUILD_AR)" \ + HOSTCC="$(tc-getBUILD_CC)" \ + HOSTLD="$(tc-getBUILD_LD)" \ + bash_compdir="$(get_bashcompdir)" \ + feature-libcap="$(usex caps 1 0)" \ + feature-llvm="$(usex llvm 1 0)" \ + prefix="${EPREFIX}"/usr \ + V=1 \ + "$@" +} + +src_compile() { + bpftool_make -C src + bpftool_make -C docs +} + +src_install() { + bpftool_make DESTDIR="${D}" -C src install + bpftool_make mandir="${ED}"/usr/share/man -C docs install +} + +pkg_postinst() { + optfeature "clang-bpf-co-re support" sys-devel/clang[llvm_targets_BPF] +} diff --git a/dev-util/bpftool/bpftool-9999.ebuild b/dev-util/bpftool/bpftool-9999.ebuild new file mode 100644 index 000000000000..03f97becf881 --- /dev/null +++ b/dev-util/bpftool/bpftool-9999.ebuild @@ -0,0 +1,121 @@ +# Copyright 2021-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +LLVM_COMPAT=( {15..19} ) +LLVM_OPTIONAL=1 +PYTHON_COMPAT=( python3_{10..13} ) + +inherit bash-completion-r1 linux-info llvm-r1 optfeature python-any-r1 toolchain-funcs + +DESCRIPTION="Tool for inspection and simple manipulation of eBPF programs and maps" +HOMEPAGE="https://github.com/libbpf/bpftool" + +if [[ ${PV} == *9999* ]] ; then + inherit git-r3 + EGIT_REPO_URI="https://github.com/libbpf/bpftool.git" + EGIT_SUBMODULES=(libbpf) +else + # bpftool typically vendors whatever libbpf is current at the time + # of a release, while libbpf publishes minor updates more frequently. + # Uncomment the following to bundle an updated libbpf e.g. in case of + # security or crasher bugs in libbpf and to keep the two synchronized. + # This allows us to quickly update the vendored lib with a revbump. + # Currently bpftool-x.y vendors libbpf-1.y; DO NOT mix different y versions. + # See the libbpf repo (https://github.com/libbpf/libbpf) for possible updates. + # LIBBPF_VERSION=1.5.0 + + if [[ ! -z ${LIBBPF_VERSION} ]] ; then + SRC_URI="https://github.com/libbpf/bpftool/archive/refs/tags/v${PV}.tar.gz -> bpftool-${PV}.tar.gz + https://github.com/libbpf/libbpf/archive/refs/tags/v${LIBBPF_VERSION}.tar.gz + -> libbpf-${LIBBPF_VERSION}.tar.gz" + else + # use tarball with bundled libbpf + SRC_URI="https://github.com/libbpf/bpftool/releases/download/v${PV}/bpftool-libbpf-v${PV}-sources.tar.gz" + S="${WORKDIR}/bpftool-libbpf-v${PV}-sources" + fi + + KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86" +fi + +LICENSE="|| ( GPL-2 BSD-2 )" +SLOT="0" +IUSE="caps llvm" +REQUIRED_USE="llvm? ( ${LLVM_REQUIRED_USE} )" + +RDEPEND=" + caps? ( sys-libs/libcap:= ) + llvm? ( $(llvm_gen_dep 'sys-devel/llvm:${LLVM_SLOT}') ) + !llvm? ( sys-libs/binutils-libs:= ) + sys-libs/zlib:= + virtual/libelf:= +" +DEPEND=" + ${RDEPEND} + >=sys-kernel/linux-headers-5.8 +" +BDEPEND=" + ${PYTHON_DEPS} + app-arch/tar + dev-python/docutils +" + +CONFIG_CHECK="~DEBUG_INFO_BTF" + +pkg_setup() { + python-any-r1_pkg_setup + use llvm && llvm-r1_pkg_setup +} + +src_prepare() { + default + + # prepare libbpf if necessary + if [[ ! -z ${LIBBPF_VERSION} ]] ; then + rm -rf libbpf || die + ln -s "${WORKDIR}/libbpf-${LIBBPF_VERSION}" libbpf || die + fi + + # remove -Werror from libbpf (bug 887981) + sed -i -e 's/\-Werror//g' libbpf/src/Makefile || die + + # remove -Werror from bpftool feature detection + sed -i -e 's/-Werror//g' src/Makefile.feature || die + + # remove hardcoded/unhelpful flags from bpftool + sed -i -e '/CFLAGS += -O2/d' -e 's/-W //g' -e 's/-Wextra //g' src/Makefile || die + + # Use rst2man or rst2man.py depending on which one exists (#930076) + type -P rst2man >/dev/null || sed -i -e 's/rst2man/rst2man.py/g' docs/Makefile || die +} + +bpftool_make() { + tc-export AR CC LD + + emake \ + ARCH="$(tc-arch-kernel)" \ + HOSTAR="$(tc-getBUILD_AR)" \ + HOSTCC="$(tc-getBUILD_CC)" \ + HOSTLD="$(tc-getBUILD_LD)" \ + bash_compdir="$(get_bashcompdir)" \ + feature-libcap="$(usex caps 1 0)" \ + feature-llvm="$(usex llvm 1 0)" \ + prefix="${EPREFIX}"/usr \ + V=1 \ + "$@" +} + +src_compile() { + bpftool_make -C src + bpftool_make -C docs +} + +src_install() { + bpftool_make DESTDIR="${D}" -C src install + bpftool_make mandir="${ED}"/usr/share/man -C docs install +} + +pkg_postinst() { + optfeature "clang-bpf-co-re support" sys-devel/clang[llvm_targets_BPF] +} diff --git a/dev-util/bpftool/files/7.4-001-mount-bpffs-on-provided-dir-instead-of-parent-dir.patch b/dev-util/bpftool/files/7.4-001-mount-bpffs-on-provided-dir-instead-of-parent-dir.patch new file mode 100644 index 000000000000..c874555d3799 --- /dev/null +++ b/dev-util/bpftool/files/7.4-001-mount-bpffs-on-provided-dir-instead-of-parent-dir.patch @@ -0,0 +1,255 @@ +From 54bcb7c7fecb33d40266223d4bba49ad38e59ee3 Mon Sep 17 00:00:00 2001 +From: Sahil Siddiq <icegambit91@gmail.com> +Date: Fri, 5 Apr 2024 00:52:19 +0530 +Subject: [PATCH] bpftool: Mount bpffs on provided dir instead of parent dir + +When pinning programs/objects under PATH (eg: during "bpftool prog +loadall") the bpffs is mounted on the parent dir of PATH in the +following situations: +- the given dir exists but it is not bpffs. +- the given dir doesn't exist and the parent dir is not bpffs. + +Mounting on the parent dir can also have the unintentional side- +effect of hiding other files located under the parent dir. + +If the given dir exists but is not bpffs, then the bpffs should +be mounted on the given dir and not its parent dir. + +Similarly, if the given dir doesn't exist and its parent dir is not +bpffs, then the given dir should be created and the bpffs should be +mounted on this new dir. + +Fixes: 2a36c26fe3b8 ("bpftool: Support bpffs mountpoint as pin path for prog loadall") +Signed-off-by: Sahil Siddiq <icegambit91@gmail.com> +Signed-off-by: Andrii Nakryiko <andrii@kernel.org> +Link: https://lore.kernel.org/bpf/2da44d24-74ae-a564-1764-afccf395eeec@isovalent.com/T/#t +Link: https://lore.kernel.org/bpf/20240404192219.52373-1-icegambit91@gmail.com + +Closes: https://github.com/libbpf/bpftool/issues/100 + +Changes since v1: + - Split "mount_bpffs_for_pin" into two functions. + This is done to improve maintainability and readability. + +Changes since v2: +- mount_bpffs_for_pin: rename to "create_and_mount_bpffs_dir". +- mount_bpffs_given_file: rename to "mount_bpffs_given_file". +- create_and_mount_bpffs_dir: + - introduce "dir_exists" boolean. + - remove new dir if "mnt_fs" fails. +- improve error handling and error messages. + +Changes since v3: +- Rectify function name. +- Improve error messages and formatting. +- mount_bpffs_for_file: + - Check if dir exists before block_mount check. + +Changes since v4: +- Use strdup instead of strcpy. +- create_and_mount_bpffs_dir: + - Use S_IRWXU instead of 0700. +- Improve error handling and formatting. +--- + src/common.c | 96 ++++++++++++++++++++++++++++++++++++++++++------ + src/iter.c | 2 +- + src/main.h | 3 +- + src/prog.c | 5 ++- + src/struct_ops.c | 2 +- + 5 files changed, 92 insertions(+), 16 deletions(-) + +diff --git a/src/common.c b/src/common.c +index cc6e6aae..958e92ac 100644 +--- a/src/common.c ++++ b/src/common.c +@@ -244,29 +244,101 @@ int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type) + return fd; + } + +-int mount_bpffs_for_pin(const char *name, bool is_dir) ++int create_and_mount_bpffs_dir(const char *dir_name) + { + char err_str[ERR_MAX_LEN]; +- char *file; +- char *dir; ++ bool dir_exists; + int err = 0; + +- if (is_dir && is_bpffs(name)) ++ if (is_bpffs(dir_name)) + return err; + +- file = malloc(strlen(name) + 1); +- if (!file) { ++ dir_exists = access(dir_name, F_OK) == 0; ++ ++ if (!dir_exists) { ++ char *temp_name; ++ char *parent_name; ++ ++ temp_name = strdup(dir_name); ++ if (!temp_name) { ++ p_err("mem alloc failed"); ++ return -1; ++ } ++ ++ parent_name = dirname(temp_name); ++ ++ if (is_bpffs(parent_name)) { ++ /* nothing to do if already mounted */ ++ free(temp_name); ++ return err; ++ } ++ ++ if (access(parent_name, F_OK) == -1) { ++ p_err("can't create dir '%s' to pin BPF object: parent dir '%s' doesn't exist", ++ dir_name, parent_name); ++ free(temp_name); ++ return -1; ++ } ++ ++ free(temp_name); ++ } ++ ++ if (block_mount) { ++ p_err("no BPF file system found, not mounting it due to --nomount option"); ++ return -1; ++ } ++ ++ if (!dir_exists) { ++ err = mkdir(dir_name, S_IRWXU); ++ if (err) { ++ p_err("failed to create dir '%s': %s", dir_name, strerror(errno)); ++ return err; ++ } ++ } ++ ++ err = mnt_fs(dir_name, "bpf", err_str, ERR_MAX_LEN); ++ if (err) { ++ err_str[ERR_MAX_LEN - 1] = '\0'; ++ p_err("can't mount BPF file system on given dir '%s': %s", ++ dir_name, err_str); ++ ++ if (!dir_exists) ++ rmdir(dir_name); ++ } ++ ++ return err; ++} ++ ++int mount_bpffs_for_file(const char *file_name) ++{ ++ char err_str[ERR_MAX_LEN]; ++ char *temp_name; ++ char *dir; ++ int err = 0; ++ ++ if (access(file_name, F_OK) != -1) { ++ p_err("can't pin BPF object: path '%s' already exists", file_name); ++ return -1; ++ } ++ ++ temp_name = strdup(file_name); ++ if (!temp_name) { + p_err("mem alloc failed"); + return -1; + } + +- strcpy(file, name); +- dir = dirname(file); ++ dir = dirname(temp_name); + + if (is_bpffs(dir)) + /* nothing to do if already mounted */ + goto out_free; + ++ if (access(dir, F_OK) == -1) { ++ p_err("can't pin BPF object: dir '%s' doesn't exist", dir); ++ err = -1; ++ goto out_free; ++ } ++ + if (block_mount) { + p_err("no BPF file system found, not mounting it due to --nomount option"); + err = -1; +@@ -276,12 +348,12 @@ int mount_bpffs_for_pin(const char *name, bool is_dir) + err = mnt_fs(dir, "bpf", err_str, ERR_MAX_LEN); + if (err) { + err_str[ERR_MAX_LEN - 1] = '\0'; +- p_err("can't mount BPF file system to pin the object (%s): %s", +- name, err_str); ++ p_err("can't mount BPF file system to pin the object '%s': %s", ++ file_name, err_str); + } + + out_free: +- free(file); ++ free(temp_name); + return err; + } + +@@ -289,7 +361,7 @@ int do_pin_fd(int fd, const char *name) + { + int err; + +- err = mount_bpffs_for_pin(name, false); ++ err = mount_bpffs_for_file(name); + if (err) + return err; + +diff --git a/src/iter.c b/src/iter.c +index 6b0e5202..5c39c2ed 100644 +--- a/src/iter.c ++++ b/src/iter.c +@@ -76,7 +76,7 @@ static int do_pin(int argc, char **argv) + goto close_obj; + } + +- err = mount_bpffs_for_pin(path, false); ++ err = mount_bpffs_for_file(path); + if (err) + goto close_link; + +diff --git a/src/main.h b/src/main.h +index b8bb08d1..9eb764fe 100644 +--- a/src/main.h ++++ b/src/main.h +@@ -142,7 +142,8 @@ const char *get_fd_type_name(enum bpf_obj_type type); + char *get_fdinfo(int fd, const char *key); + int open_obj_pinned(const char *path, bool quiet); + int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type); +-int mount_bpffs_for_pin(const char *name, bool is_dir); ++int mount_bpffs_for_file(const char *file_name); ++int create_and_mount_bpffs_dir(const char *dir_name); + int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(int *, char ***)); + int do_pin_fd(int fd, const char *name); + +diff --git a/src/prog.c b/src/prog.c +index 9cb42a33..4c4cf16a 100644 +--- a/src/prog.c ++++ b/src/prog.c +@@ -1778,7 +1778,10 @@ static int load_with_options(int argc, char **argv, bool first_prog_only) + goto err_close_obj; + } + +- err = mount_bpffs_for_pin(pinfile, !first_prog_only); ++ if (first_prog_only) ++ err = mount_bpffs_for_file(pinfile); ++ else ++ err = create_and_mount_bpffs_dir(pinfile); + if (err) + goto err_close_obj; + +diff --git a/src/struct_ops.c b/src/struct_ops.c +index d573f264..aa43dead 100644 +--- a/src/struct_ops.c ++++ b/src/struct_ops.c +@@ -515,7 +515,7 @@ static int do_register(int argc, char **argv) + if (argc == 1) + linkdir = GET_ARG(); + +- if (linkdir && mount_bpffs_for_pin(linkdir, true)) { ++ if (linkdir && create_and_mount_bpffs_dir(linkdir)) { + p_err("can't mount bpffs for pinning"); + return -1; + } diff --git a/dev-util/bpftool/files/7.4-002-set-DESTDIR-to-empty-when-building-libbpf.patch b/dev-util/bpftool/files/7.4-002-set-DESTDIR-to-empty-when-building-libbpf.patch new file mode 100644 index 000000000000..2eb6e72d0279 --- /dev/null +++ b/dev-util/bpftool/files/7.4-002-set-DESTDIR-to-empty-when-building-libbpf.patch @@ -0,0 +1,38 @@ +From 06c61eccd3b8a6ff3df3e451a2a93058913124fc Mon Sep 17 00:00:00 2001 +From: jinzhiguang <jinzhiguang@kylinos.cn> +Date: Sun, 7 Apr 2024 16:54:33 +0800 +Subject: [PATCH] mirror: Set DESTDIR to empty when building libbpf + +If a value is assigned to the variable DESTDIR when compiling bpftool, +this variable will be passed to libbpf's Makefile. + +In this case, libbpf's header files will be installed in an unexpected +directory, causing bpftool to be unable to find the header files. + +Signed-off-by: jinzhiguang <jinzhiguang@kylinos.cn> +--- + src/Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/Makefile b/src/Makefile +index a3bc6a0..d48d22f 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -42,7 +42,7 @@ $(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT) $(LIBBPF_HDRS_DI + + $(LIBBPF): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_OUTPUT) + $(Q)$(MAKE) -C $(BPF_DIR) OBJDIR=$(patsubst %/,%,$(LIBBPF_OUTPUT)) \ +- PREFIX=$(LIBBPF_DESTDIR:/=) $(LIBBPF) install_headers ++ DESTDIR="" PREFIX=$(LIBBPF_DESTDIR:/=) $(LIBBPF) install_headers + + $(LIBBPF_INTERNAL_HDRS): $(LIBBPF_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_HDRS_DIR) + $(call QUIET_INSTALL, $@) +@@ -50,7 +50,7 @@ $(LIBBPF_INTERNAL_HDRS): $(LIBBPF_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_HDRS_ + + $(LIBBPF_BOOTSTRAP): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_BOOTSTRAP_OUTPUT) + $(Q)$(MAKE) -C $(BPF_DIR) OBJDIR=$(patsubst %/,%,$(LIBBPF_BOOTSTRAP_OUTPUT)) \ +- PREFIX=$(LIBBPF_BOOTSTRAP_DESTDIR:/=) \ ++ DESTDIR="" PREFIX=$(LIBBPF_BOOTSTRAP_DESTDIR:/=) \ + ARCH= CROSS_COMPILE= CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" $@ install_headers + + $(LIBBPF_BOOTSTRAP_INTERNAL_HDRS): $(LIBBPF_BOOTSTRAP_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_BOOTSTRAP_HDRS_DIR) diff --git a/dev-util/bpftool/files/7.4-003-fix-typo-in-usage-help.patch b/dev-util/bpftool/files/7.4-003-fix-typo-in-usage-help.patch new file mode 100644 index 000000000000..fc488aca5b02 --- /dev/null +++ b/dev-util/bpftool/files/7.4-003-fix-typo-in-usage-help.patch @@ -0,0 +1,30 @@ +From a44a93bb7ed0d8e62220b534df92ea2a678fb4b7 Mon Sep 17 00:00:00 2001 +From: Donald Hunter <donald.hunter@gmail.com> +Date: Wed, 17 Jul 2024 14:45:08 +0100 +Subject: [PATCH] bpftool: Fix typo in usage help + +The usage help for "bpftool prog help" contains a ° instead of the _ +symbol for cgroup/sendmsg_unix. Fix the typo. + +Fixes: 8b3cba987e6d ("bpftool: Add support for cgroup unix socket address hooks") +Signed-off-by: Donald Hunter <donald.hunter@gmail.com> +Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> +Acked-by: Quentin Monnet <qmo@kernel.org> +Link: https://lore.kernel.org/bpf/20240717134508.77488-1-donald.hunter@gmail.com +--- + src/prog.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/prog.c b/src/prog.c +index 40ea743..2ff949e 100644 +--- a/src/prog.c ++++ b/src/prog.c +@@ -2489,7 +2489,7 @@ static int do_help(int argc, char **argv) + " cgroup/connect_unix | cgroup/getpeername4 | cgroup/getpeername6 |\n" + " cgroup/getpeername_unix | cgroup/getsockname4 | cgroup/getsockname6 |\n" + " cgroup/getsockname_unix | cgroup/sendmsg4 | cgroup/sendmsg6 |\n" +- " cgroup/sendmsg°unix | cgroup/recvmsg4 | cgroup/recvmsg6 | cgroup/recvmsg_unix |\n" ++ " cgroup/sendmsg_unix | cgroup/recvmsg4 | cgroup/recvmsg6 | cgroup/recvmsg_unix |\n" + " cgroup/getsockopt | cgroup/setsockopt | cgroup/sock_release |\n" + " struct_ops | fentry | fexit | freplace | sk_lookup }\n" + " ATTACH_TYPE := { sk_msg_verdict | sk_skb_verdict | sk_skb_stream_verdict |\n" diff --git a/dev-util/bpftool/files/7.4-004-fix-the-wrong-format-specifier.patch b/dev-util/bpftool/files/7.4-004-fix-the-wrong-format-specifier.patch new file mode 100644 index 000000000000..19dfa0c00746 --- /dev/null +++ b/dev-util/bpftool/files/7.4-004-fix-the-wrong-format-specifier.patch @@ -0,0 +1,38 @@ +From cb035aad23cf92254d8d3c7631e5b642e6805bd1 Mon Sep 17 00:00:00 2001 +From: Zhu Jun <zhujun2@cmss.chinamobile.com> +Date: Wed, 24 Jul 2024 04:11:20 -0700 +Subject: [PATCH] tools/bpf: Fix the wrong format specifier + +The format specifier of "unsigned int" in printf() should be "%u", not +"%d". + +Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com> +Signed-off-by: Andrii Nakryiko <andrii@kernel.org> +Acked-by: Quentin Monnet <qmo@kernel.org> +Link: https://lore.kernel.org/bpf/20240724111120.11625-1-zhujun2@cmss.chinamobile.com +--- + src/xlated_dumper.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/xlated_dumper.c b/src/xlated_dumper.c +index 567f56d..d009434 100644 +--- a/src/xlated_dumper.c ++++ b/src/xlated_dumper.c +@@ -349,7 +349,7 @@ void dump_xlated_plain(struct dump_data *dd, void *buf, unsigned int len, + + double_insn = insn[i].code == (BPF_LD | BPF_IMM | BPF_DW); + +- printf("% 4d: ", i); ++ printf("%4u: ", i); + print_bpf_insn(&cbs, insn + i, true); + + if (opcodes) { +@@ -415,7 +415,7 @@ void dump_xlated_for_graph(struct dump_data *dd, void *buf_start, void *buf_end, + } + } + +- printf("%d: ", insn_off); ++ printf("%u: ", insn_off); + print_bpf_insn(&cbs, cur, true); + + if (opcodes) { diff --git a/dev-util/bpftool/files/7.4-005-fix-undefined-behavior-caused-by-shifting-into-the-sign-bit.patch b/dev-util/bpftool/files/7.4-005-fix-undefined-behavior-caused-by-shifting-into-the-sign-bit.patch new file mode 100644 index 000000000000..90c3499ec0b3 --- /dev/null +++ b/dev-util/bpftool/files/7.4-005-fix-undefined-behavior-caused-by-shifting-into-the-sign-bit.patch @@ -0,0 +1,47 @@ +From a0f887bbdc525006f7662f4a83e240f2c46d3418 Mon Sep 17 00:00:00 2001 +From: Kuan-Wei Chiu <visitorckw@gmail.com> +Date: Sun, 8 Sep 2024 22:00:09 +0800 +Subject: [PATCH] bpftool: Fix undefined behavior caused by shifting into the sign bit + +Replace shifts of '1' with '1U' in bitwise operations within +__show_dev_tc_bpf() to prevent undefined behavior caused by shifting +into the sign bit of a signed integer. By using '1U', the operations +are explicitly performed on unsigned integers, avoiding potential +integer overflow or sign-related issues. + +Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com> +Signed-off-by: Andrii Nakryiko <andrii@kernel.org> +Acked-by: Quentin Monnet <qmo@kernel.org> +Link: https://lore.kernel.org/bpf/20240908140009.3149781-1-visitorckw@gmail.com +--- + src/net.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/net.c b/src/net.c +index 2a51f1c..3c50fc6 100644 +--- a/src/net.c ++++ b/src/net.c +@@ -486,9 +486,9 @@ static void __show_dev_tc_bpf(const struct ip_devname_ifindex *dev, + if (prog_flags[i] || json_output) { + NET_START_ARRAY("prog_flags", "%s "); + for (j = 0; prog_flags[i] && j < 32; j++) { +- if (!(prog_flags[i] & (1 << j))) ++ if (!(prog_flags[i] & (1U << j))) + continue; +- NET_DUMP_UINT_ONLY(1 << j); ++ NET_DUMP_UINT_ONLY(1U << j); + } + NET_END_ARRAY(""); + } +@@ -497,9 +497,9 @@ static void __show_dev_tc_bpf(const struct ip_devname_ifindex *dev, + if (link_flags[i] || json_output) { + NET_START_ARRAY("link_flags", "%s "); + for (j = 0; link_flags[i] && j < 32; j++) { +- if (!(link_flags[i] & (1 << j))) ++ if (!(link_flags[i] & (1U << j))) + continue; +- NET_DUMP_UINT_ONLY(1 << j); ++ NET_DUMP_UINT_ONLY(1U << j); + } + NET_END_ARRAY(""); + } diff --git a/dev-util/bpftool/files/7.4-006-fix-undefined-behavior-in-qsort.patch b/dev-util/bpftool/files/7.4-006-fix-undefined-behavior-in-qsort.patch new file mode 100644 index 000000000000..466258112b18 --- /dev/null +++ b/dev-util/bpftool/files/7.4-006-fix-undefined-behavior-in-qsort.patch @@ -0,0 +1,49 @@ +From 37e304df400c69347189449b38864705cc88b987 Mon Sep 17 00:00:00 2001 +From: Kuan-Wei Chiu <visitorckw@gmail.com> +Date: Tue, 10 Sep 2024 23:02:07 +0800 +Subject: [PATCH] bpftool: Fix undefined behavior in qsort(NULL, 0, ...) + +When netfilter has no entry to display, qsort is called with +qsort(NULL, 0, ...). This results in undefined behavior, as UBSan +reports: + +net.c:827:2: runtime error: null pointer passed as argument 1, which is declared to never be null + +Although the C standard does not explicitly state whether calling qsort +with a NULL pointer when the size is 0 constitutes undefined behavior, +Section 7.1.4 of the C standard (Use of library functions) mentions: + +"Each of the following statements applies unless explicitly stated +otherwise in the detailed descriptions that follow: If an argument to a +function has an invalid value (such as a value outside the domain of +the function, or a pointer outside the address space of the program, or +a null pointer, or a pointer to non-modifiable storage when the +corresponding parameter is not const-qualified) or a type (after +promotion) not expected by a function with variable number of +arguments, the behavior is undefined." + +To avoid this, add an early return when nf_link_info is NULL to prevent +calling qsort with a NULL pointer. + +Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com> +Signed-off-by: Andrii Nakryiko <andrii@kernel.org> +Reviewed-by: Quentin Monnet <qmo@kernel.org> +Link: https://lore.kernel.org/bpf/20240910150207.3179306-1-visitorckw@gmail.com +--- + src/net.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/net.c b/src/net.c +index 3c50fc6..d2242d9 100644 +--- a/src/net.c ++++ b/src/net.c +@@ -880,6 +880,9 @@ static void show_link_netfilter(void) + nf_link_count++; + } + ++ if (!nf_link_info) ++ return; ++ + qsort(nf_link_info, nf_link_count, sizeof(*nf_link_info), netfilter_link_compar); + + for (id = 0; id < nf_link_count; id++) { diff --git a/dev-util/bpftool/files/7.4-007-define-PACKAGE-at-build-time-when-trying-to-detect-libbfd.patch b/dev-util/bpftool/files/7.4-007-define-PACKAGE-at-build-time-when-trying-to-detect-libbfd.patch new file mode 100644 index 000000000000..c88cbdf367c4 --- /dev/null +++ b/dev-util/bpftool/files/7.4-007-define-PACKAGE-at-build-time-when-trying-to-detect-libbfd.patch @@ -0,0 +1,48 @@ +From bf9e0609acb97d73a7ebf3e8910b0119cd943dfb Mon Sep 17 00:00:00 2001 +From: Quentin Monnet <qmo@kernel.org> +Date: Mon, 14 Oct 2024 17:43:25 +0100 +Subject: [PATCH] mirror: Define PACKAGE at build time when trying to detect libbfd + +Feature detection from the Makefile.feature for libbfd (with the +different variants of the probe) may fail on some systems where the +bfd.h and dis-asm.h headers expect the PACKAGE or PACKAGE_VERSION macros +to be defined [0]. In the kernel tree, feature detection addresses it by +defining the PACKAGE macro when invoking the compiler [1]. Add a similar +definition for the mirror repository. + +Note that this issue has remained undetected for a while. This is +because the bfd.h included in some distributions (Debian/Ubuntu, for +example) does not contain the inclusion guard [2]. + +[0] https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/bfd-in.h;h=04e65aad5f0c235a5013513c545e57a01e96541f;hb=binutils-2_43_1#l27 +[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/build/feature/Makefile?h=v6.11#n114 +[2] https://git.launchpad.net/ubuntu/+source/binutils/tree/debian/rules?h=applied/2.43.1-5#n1031 + +Reported-by: Holger Hoffstätte <holger@applied-asynchrony.com> +Signed-off-by: Quentin Monnet <qmo@kernel.org> +--- + src/Makefile.feature | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/Makefile.feature b/src/Makefile.feature +index 131c67e..90f9e7c 100644 +--- a/src/Makefile.feature ++++ b/src/Makefile.feature +@@ -45,7 +45,7 @@ LIBBFD_PROBE += ' bfd_demangle(0, 0, 0);' + LIBBFD_PROBE += ' return 0;' + LIBBFD_PROBE += '}' + LIBBFD_PROBE_CMD = printf '%b\n' $(LIBBFD_PROBE) | \ +- $(CC) $(CFLAGS) -Wall -Werror -x c - $(1) -o /dev/null >/dev/null ++ $(CC) $(CFLAGS) -Wall -Werror -x c -DPACKAGE='"bpftool"' - $(1) -o /dev/null >/dev/null + + define libbfd_build + $(call detect,$(LIBBFD_PROBE_CMD)) +@@ -78,7 +78,7 @@ DISASSEMBLER_PROBE += ' return 0;' + DISASSEMBLER_PROBE += '}' + + DISASSEMBLER_PROBE_CMD = printf '%b\n' $(1) | \ +- $(CC) $(CFLAGS) -Wall -Werror -x c - -lbfd -lopcodes -S -o - >/dev/null ++ $(CC) $(CFLAGS) -Wall -Werror -x c -DPACKAGE='"bpftool"' - -lbfd -lopcodes -S -o - >/dev/null + define disassembler_build + $(call detect,$(DISASSEMBLER_PROBE_CMD)) + endef diff --git a/dev-util/bpftool/files/7.4-008-always-disable-unused-CLI-arguments-warning-for-feature-probe.patch b/dev-util/bpftool/files/7.4-008-always-disable-unused-CLI-arguments-warning-for-feature-probe.patch new file mode 100644 index 000000000000..399b824ce06b --- /dev/null +++ b/dev-util/bpftool/files/7.4-008-always-disable-unused-CLI-arguments-warning-for-feature-probe.patch @@ -0,0 +1,38 @@ +From 3be8ac358900c5f57028b2b6501407a14167a9bb Mon Sep 17 00:00:00 2001 +From: Quentin Monnet <qmo@kernel.org> +Date: Thu, 17 Oct 2024 11:22:14 +0100 +Subject: [PATCH] mirror: Always disable unused CLI arguments warning for feature probe + +In commit 8a2d7d510ccd ("mirror: Fix features detection for building +with clang") we prevented clang to error out when encountering unused +command-line arguments in the feature probes, because we do add unused +arguments for some of the probes when retrieving arguments from +llvm-config, and we don't want probes to fail because of that. + +At the time, the issue was apparent for the LLVM-based disassembler, so +we added -Wno-unused-command-line-argument when $(LLVM) was enabled, +only. We missed the case when we're building bpftool with clang instead +of gcc, without building the LLVM disassembler. Let's disable the +warning unconditionally instead to fix this case. + +Reported-by: Holger Hoffstätte <holger@applied-asynchrony.com> +Signed-off-by: Quentin Monnet <qmo@kernel.org> +--- + src/Makefile.feature | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/src/Makefile.feature b/src/Makefile.feature +index 90f9e7c..b08e7b9 100644 +--- a/src/Makefile.feature ++++ b/src/Makefile.feature +@@ -4,9 +4,7 @@ pound := \# + + CFLAGS_BACKUP := $(CFLAGS) + CFLAGS := $(EXTRA_CFLAGS) +-ifneq ($(LLVM),) +- CFLAGS += -Wno-unused-command-line-argument +-endif ++CFLAGS += -Wno-unused-command-line-argument + + ifeq ($(V),1) + LOG=$(warning $(1)) diff --git a/dev-util/bpftool/metadata.xml b/dev-util/bpftool/metadata.xml index a09ffc7b9425..1e8c354ad0e2 100644 --- a/dev-util/bpftool/metadata.xml +++ b/dev-util/bpftool/metadata.xml @@ -13,4 +13,7 @@ <flag name="caps">Use <pkg>sys-libs/libcap</pkg> to enable unprivileged run support</flag> <flag name="llvm">Use <pkg>sys-devel/llvm</pkg> instead of libbfd (<pkg>sys-libs/binutils-libs</pkg>) for JIT disassembly</flag> </use> + <upstream> + <remote-id type="github">libbpf/bpftool</remote-id> + </upstream> </pkgmetadata> |