diff options
Diffstat (limited to 'dev-util/bpftool')
15 files changed, 80 insertions, 942 deletions
diff --git a/dev-util/bpftool/Manifest b/dev-util/bpftool/Manifest index 676091303c09..bea0966f83b3 100644 --- a/dev-util/bpftool/Manifest +++ b/dev-util/bpftool/Manifest @@ -1,21 +1,5 @@ -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 +AUX 7.5.0-setting-error-code-in-do_loader.patch 1810 BLAKE2B 1263ef7361d95642f25b9c343ddb085e32222a55c5656bdb06d67a21fad5e8cae46569a7ffc0a97621fc28f9119cb58311ed09f974a1abfeb3e400201277b040 SHA512 5fc294af2b642c4791bf839bd7a30bf5da113a56e00e20be7d49a0b0711399db3e7fab672f2dfdfcc540f124aaccf6998eb46d67c9867cfd20dd2b2e39d99353 DIST bpftool-libbpf-v7.5.0-sources.tar.gz 1510032 BLAKE2B cc9beac4034317f89ae3c1088d1b1a1948778bcdb51d7ed7f566e4e5ab720c1128ca467d51d0bc3ffe7b1f69800249362baef5dfaf858275050f96b744fdbca6 SHA512 db12c305b77fea3689dbc1ce94527f0f21fa9de21fcdb36385e3fe492137335bb393f90e456c06601495ccc984230a531c432709db6514b545e0aeeda7ca3c99 -DIST libbpf-1.4.7.tar.gz 1016441 BLAKE2B 10be52c7e97b2f08edd33cb263c4737bb52edfd2226f0c5b86d4f95b584b81f8f6b1ede469e9ad6c231e55b6d6b9a038160662606c3f30dc79b1336aaaa90e74 SHA512 f09ff28ac75b0d0c1bfe7d233aee6a00e5c21f185646b2afe11b7bd048d74962f893237437dd81a762768f9235b9f2a2a33cb297201b2aa3e98f7c6f58e5b365 -DIST linux-6.8.tar.xz 142502100 BLAKE2B c6f17f816cea16e629f63e9379b98888713f57b2c5173306926471f139a9d612a0c74e119341f8075390e55e203d787d9edeb4ad5a064b18870f6f0f7ffaafb2 SHA512 5c4eb4aa1d3f7d1ea01c0f7ddeadacdece6e144fd4bdfc16b2b925d3e10dc04de3a6db69320b79a96c3560052616f001d2c09e7a1bb4f7b731e2380a7ecce068 -DIST linux-6.9.tar.xz 144034416 BLAKE2B 4cf86c3cfe6e6534745d42dfaeca59b17ea1168c4e8b615c80e6d8aac735f11283cd85fa992b440b5d4452917e94b9f08397a64af0be5894e3df23c68892377e SHA512 fed3b4cd1fbfb4d94618587c1934273d2ecc8b6e42a3d586ff8a5f24980be930f2ef803aa2923ca3bfa5e4e619f967f3af315368f24fa76f610b10443624a579 -DIST patch-6.8.2.xz 247244 BLAKE2B a85078230548543c38550a5546689d0b44a54208cdad591ab34e10dec9348ce2f74e45bf85f373b14977d40556067e2e2c17ac4b6791fbb8aaba98feccd3cdac SHA512 a8e32b89f7680670c69c62f356846bb65b57614f979114627a9a2f945d7dc97c921d30197dffa993e5b18e499ba8c7196046ffdf0e721528a5378d1ee65a9ba5 -DIST patch-6.9.2.xz 16184 BLAKE2B 8a37e96c253b55b57c86f1654f2ea8bf65af96b1b38213e90032cb918bb8eea992d6ddbfa6a6774a229ab2e2288ab57bdb6cbad6e7e393c123f24850e06847c9 SHA512 a27af24f0caaa5de3811b6db5acc2d72b96df9ebb5c44bad99a949d871fb06c6ffd2be10cfc35b246d430c7be2291701f802aed47eaa8818ad12b8818a60f3ec -EBUILD bpftool-6.8.2.ebuild 3101 BLAKE2B 50490ba1c00ec62c230a859a90aa6daeb0e880cb3a32bafd3e4ef10664d16f3b972d58fff52d866a8ea028a622c3affe56f1cc6674dc58e2afa1ea51ccb91fee SHA512 10edfce63f2e085c97ffd1f7f7568ac17e609052edb34d1d33d54b422d489ef612d27f1d43d7581abeb186ce6bcd1b8dfb4fd5750c0beda15006a21cc310943c -EBUILD bpftool-6.9.2.ebuild 3125 BLAKE2B 753ad365e83123267ba7356b20b9694bc0fd7a938e6742835afff771c123178ad973ab750cdeccabcb7f9078cb3594426b18dfea37fbb01fa51def3b46f3b781 SHA512 774a947287bad794fdfa3890d3ee45a22c0089142a3a0eafde0439b9a979a3b545cc9d1d2479b8ac13e8279c491af00868109ae55cce3cd514f7603627f5143d -EBUILD bpftool-7.4.0.ebuild 3990 BLAKE2B 76697b7ff8bd2d70a6336e3e5886ecd50b4a470a6aa6b2bec0e57a15219b91409fd7e92c47fdb65e052da0624ad76d4faff759a1da1ace8ab0f28aba938a54ac SHA512 6296b0e6fb7aacad3972506ecc0f0a76303b2e14f8cf43a0280ac396e799092ded3b1ce3791bc94c4f658eb4534e5190688e7295b41603ba8f4f310dfe011cd3 -EBUILD bpftool-7.5.0.ebuild 3944 BLAKE2B 6b72857f8721496b2deb717c19c315bf41d226eed2aa457928efa6368cfda5a83f9e7dec9e6a0d8294b68dabf397ba242f1f279e467e2ae1163d43f7076724d9 SHA512 1e955167fe00c8e9f89d92c223ac26f75b6bba207e104486e2d68dd46906eec6af68eed3f7a07238f394148cdff986170239c6800b8d8f092f9bc38dd6c000e4 -EBUILD bpftool-9999.ebuild 3945 BLAKE2B 4362cdc1c5cc497bf841f8ed08cb8886aa11dbbae814e2f4125e1a3a55f45bf7dc88743af9d015a2038772d178ddfee2e71fe8366ba6d72054ce9cb133657a88 SHA512 287decf9d1520be4c854cafc67136d12ab81a85cf61017e35762a62f69095d05b2befeeb0ff21016bed2eb5271890550f8c8579f30af66fb576094ae12ad81ea +EBUILD bpftool-7.5.0-r1.ebuild 4721 BLAKE2B e504bfca022215d5551063a59091655498e186c758499dcaf6dcd29a830e33c94b111738fbabc920487c0526fe4529f25e58b4ae02703a0e7645f437b23ed81b SHA512 207e287318043fe900c483eb357f73c8bea7fb271eabcae23f4cfb6b7a81518afa9b47ce60f2139a74b268824460648fb29e28a9cf5d60b0af45087510c70e44 +EBUILD bpftool-9999.ebuild 4656 BLAKE2B cdddd1e1295865a595fa9264df8b947cedee2ef1386a9602f8164a0ddca3877120fa9a9b1a93c5400dc2a95086bc5c91781a433f7cbf214d90500c1a61e61187 SHA512 4bfb8ffc43012b4dcba5f0ae4e83a3c4c411745a4bc9e2be9c0351fa1fc52b2d22a1f1539417c67ef94fc88d7e18b62cf7a2eec5fe4deda7635b3923945273c8 MISC metadata.xml 856 BLAKE2B e6dc5ef24201089851540e7b295506e7ee948aad7f3e41f68a3936544cbb745f2d4994be48cb817c1c48bbf27d0d97ee0eda3ac8dd2453291f94617ec33cb494 SHA512 4d0000b89daf1e10146256e9e2479120c939cce271175f4c42588f0817bd6716dfcb85af38dded4d4ac34214fa424387f35ddddb3c8b6c619fd4d8a341debce9 diff --git a/dev-util/bpftool/bpftool-6.8.2.ebuild b/dev-util/bpftool/bpftool-6.8.2.ebuild deleted file mode 100644 index ddd4369edfec..000000000000 --- a/dev-util/bpftool/bpftool-6.8.2.ebuild +++ /dev/null @@ -1,123 +0,0 @@ -# Copyright 2021-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -PYTHON_COMPAT=( python3_{10..12} ) -inherit estack linux-info optfeature python-any-r1 bash-completion-r1 toolchain-funcs - -MY_PV="${PV/_/-}" -MY_PV="${MY_PV/-pre/-git}" - -DESCRIPTION="Tool for inspection and simple manipulation of eBPF programs and maps" -HOMEPAGE="https://kernel.org/" - -LINUX_V="${PV:0:1}.x" -LINUX_VER=$(ver_cut 1-2) -LINUX_PATCH=patch-${PV}.xz -SRC_URI="https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_PATCH}" - -LINUX_SOURCES="linux-${LINUX_VER}.tar.xz" -SRC_URI+=" https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_SOURCES}" - -S_K="${WORKDIR}/linux-${LINUX_VER}" -S="${S_K}/tools/bpf/bpftool" - -LICENSE="GPL-2" -SLOT="0" -KEYWORDS="amd64 arm arm64 ~loong ppc ppc64 ~riscv x86" -IUSE="caps +llvm" - -RDEPEND=" - sys-libs/binutils-libs:= - sys-libs/zlib:= - virtual/libelf:= - caps? ( sys-libs/libcap:= ) - llvm? ( llvm-core/llvm:= ) -" -DEPEND=" - ${RDEPEND} - >=sys-kernel/linux-headers-5.8 -" -BDEPEND=" - ${LINUX_PATCH+dev-util/patchutils} - ${PYTHON_DEPS} - app-arch/tar - dev-python/docutils -" - -CONFIG_CHECK="~DEBUG_INFO_BTF" - -# src_unpack and src_prepare are copied from dev-util/perf since -# it's building from the same tarball, please keep it in sync with perf -src_unpack() { - local paths=( - tools/bpf kernel/bpf - tools/{arch,build,include,lib,perf,scripts} {scripts,include,lib} "arch/*/lib" - ) - - # We expect the tar implementation to support the -j and --wildcards option - echo ">>> Unpacking ${LINUX_SOURCES} (${paths[*]}) to ${PWD}" - gtar --wildcards -xpf "${DISTDIR}"/${LINUX_SOURCES} \ - "${paths[@]/#/linux-${LINUX_VER}/}" || die - - if [[ -n ${LINUX_PATCH} ]] ; then - eshopts_push -o noglob - ebegin "Filtering partial source patch" - filterdiff -p1 ${paths[@]/#/-i } -z "${DISTDIR}"/${LINUX_PATCH} \ - > ${P}.patch - eend $? || die "filterdiff failed" - eshopts_pop - fi - - local a - for a in ${A}; do - [[ ${a} == ${LINUX_SOURCES} ]] && continue - [[ ${a} == ${LINUX_PATCH} ]] && continue - unpack ${a} - done -} - -src_prepare() { - default - - if [[ -n ${LINUX_PATCH} ]] ; then - pushd "${S_K}" >/dev/null || die - eapply "${WORKDIR}"/${P}.patch - popd || die - fi - - # Use rst2man or rst2man.py depending on which one exists (#930076) - type -P rst2man >/dev/null || sed -i -e 's/rst2man/rst2man.py/g' Documentation/Makefile || die - - # remove -Werror (bug 887981) - sed -i -e 's/\-Werror//g' ../../lib/bpf/Makefile || die -} - -bpftool_make() { - local arch=$(tc-arch-kernel) - tc-export AR CC LD - - emake V=1 VF=1 \ - HOSTCC="$(tc-getBUILD_CC)" HOSTLD="$(tc-getBUILD_LD)" \ - EXTRA_CFLAGS="${CFLAGS}" ARCH="${arch}" BPFTOOL_VERSION="${MY_PV}" \ - prefix="${EPREFIX}"/usr \ - bash_compdir="$(get_bashcompdir)" \ - feature-libcap="$(usex caps 1 0)" \ - feature-llvm="$(usex llvm 1 0)" \ - "$@" -} - -src_compile() { - bpftool_make - bpftool_make -C Documentation -} - -src_install() { - bpftool_make DESTDIR="${D}" install - bpftool_make mandir="${ED}"/usr/share/man -C Documentation install -} - -pkg_postinst() { - optfeature "clang-bpf-co-re support" llvm-core/clang[llvm_targets_BPF] -} diff --git a/dev-util/bpftool/bpftool-6.9.2.ebuild b/dev-util/bpftool/bpftool-6.9.2.ebuild deleted file mode 100644 index 7903cf92f37e..000000000000 --- a/dev-util/bpftool/bpftool-6.9.2.ebuild +++ /dev/null @@ -1,123 +0,0 @@ -# Copyright 2021-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -PYTHON_COMPAT=( python3_{10..12} ) -inherit estack linux-info optfeature python-any-r1 bash-completion-r1 toolchain-funcs - -MY_PV="${PV/_/-}" -MY_PV="${MY_PV/-pre/-git}" - -DESCRIPTION="Tool for inspection and simple manipulation of eBPF programs and maps" -HOMEPAGE="https://kernel.org/" - -LINUX_V="${PV:0:1}.x" -LINUX_VER=$(ver_cut 1-2) -LINUX_PATCH=patch-${PV}.xz -SRC_URI="https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_PATCH}" - -LINUX_SOURCES="linux-${LINUX_VER}.tar.xz" -SRC_URI+=" https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_SOURCES}" - -S_K="${WORKDIR}/linux-${LINUX_VER}" -S="${S_K}/tools/bpf/bpftool" - -LICENSE="GPL-2" -SLOT="0" -KEYWORDS="amd64 arm arm64 ~loong ppc ppc64 ~riscv x86" -IUSE="caps +llvm" - -RDEPEND=" - sys-libs/binutils-libs:= - sys-libs/zlib:= - virtual/libelf:= - caps? ( sys-libs/libcap:= ) - llvm? ( llvm-core/llvm:= ) -" -DEPEND=" - ${RDEPEND} - >=sys-kernel/linux-headers-5.8 -" -BDEPEND=" - ${LINUX_PATCH+dev-util/patchutils} - ${PYTHON_DEPS} - app-arch/tar - dev-python/docutils -" - -CONFIG_CHECK="~DEBUG_INFO_BTF" - -# src_unpack and src_prepare are copied from dev-util/perf since -# it's building from the same tarball, please keep it in sync with perf -src_unpack() { - local paths=( - kernel/bpf tools/{arch,bpf,build,include,lib,perf,scripts} - scripts include lib "arch/*/include" "arch/*/lib" "arch/*/tools" - ) - - # We expect the tar implementation to support the -j and --wildcards option - echo ">>> Unpacking ${LINUX_SOURCES} (${paths[*]}) to ${PWD}" - gtar --wildcards -xpf "${DISTDIR}"/${LINUX_SOURCES} \ - "${paths[@]/#/linux-${LINUX_VER}/}" || die - - if [[ -n ${LINUX_PATCH} ]] ; then - eshopts_push -o noglob - ebegin "Filtering partial source patch" - filterdiff -p1 ${paths[@]/#/-i } -z "${DISTDIR}"/${LINUX_PATCH} \ - > ${P}.patch - eend $? || die "filterdiff failed" - eshopts_pop - fi - - local a - for a in ${A}; do - [[ ${a} == ${LINUX_SOURCES} ]] && continue - [[ ${a} == ${LINUX_PATCH} ]] && continue - unpack ${a} - done -} - -src_prepare() { - default - - if [[ -n ${LINUX_PATCH} ]] ; then - pushd "${S_K}" >/dev/null || die - eapply "${WORKDIR}"/${P}.patch - popd || die - fi - - # Use rst2man or rst2man.py depending on which one exists (#930076) - type -P rst2man >/dev/null || sed -i -e 's/rst2man/rst2man.py/g' Documentation/Makefile || die - - # remove -Werror (bug 887981) - sed -i -e 's/\-Werror//g' ../../lib/bpf/Makefile || die -} - -bpftool_make() { - local arch=$(tc-arch-kernel) - tc-export AR CC LD - - emake V=1 VF=1 \ - HOSTCC="$(tc-getBUILD_CC)" HOSTLD="$(tc-getBUILD_LD)" \ - EXTRA_CFLAGS="${CFLAGS}" ARCH="${arch}" BPFTOOL_VERSION="${MY_PV}" \ - prefix="${EPREFIX}"/usr \ - bash_compdir="$(get_bashcompdir)" \ - feature-libcap="$(usex caps 1 0)" \ - feature-llvm="$(usex llvm 1 0)" \ - "$@" -} - -src_compile() { - bpftool_make - bpftool_make -C Documentation -} - -src_install() { - bpftool_make DESTDIR="${D}" install - bpftool_make mandir="${ED}"/usr/share/man -C Documentation install -} - -pkg_postinst() { - optfeature "clang-bpf-co-re support" llvm-core/clang[llvm_targets_BPF] -} diff --git a/dev-util/bpftool/bpftool-7.4.0.ebuild b/dev-util/bpftool/bpftool-7.4.0.ebuild deleted file mode 100644 index 743e919f4bb8..000000000000 --- a/dev-util/bpftool/bpftool-7.4.0.ebuild +++ /dev/null @@ -1,130 +0,0 @@ -# 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 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 'llvm-core/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 - $(llvm_gen_dep 'llvm-core/clang:${LLVM_SLOT}[llvm_targets_BPF]') -" - -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)" \ - CLANG="$(get_llvm_prefix -b)/bin/clang" \ - 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 -} diff --git a/dev-util/bpftool/bpftool-7.5.0.ebuild b/dev-util/bpftool/bpftool-7.5.0-r1.ebuild index 931ad8d588c5..2d8c0adfad31 100644 --- a/dev-util/bpftool/bpftool-7.5.0.ebuild +++ b/dev-util/bpftool/bpftool-7.5.0-r1.ebuild @@ -5,7 +5,7 @@ EAPI=8 LLVM_COMPAT=( {15..20} ) LLVM_OPTIONAL=1 -PYTHON_COMPAT=( python3_{10..13} ) +PYTHON_COMPAT=( python3_{11..13} ) inherit bash-completion-r1 linux-info llvm-r1 python-any-r1 toolchain-funcs @@ -36,7 +36,7 @@ else S="${WORKDIR}/bpftool-libbpf-v${PV}-sources" fi - KEYWORDS="amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86" + KEYWORDS="amd64 arm arm64 ~loong ppc ppc64 ~riscv x86" fi LICENSE="|| ( GPL-2 BSD-2 )" @@ -65,6 +65,8 @@ BDEPEND=" CONFIG_CHECK="~DEBUG_INFO_BTF" +PATCHES=( "${FILESDIR}/7.5.0-setting-error-code-in-do_loader.patch" ) + pkg_setup() { python-any-r1_pkg_setup use llvm && llvm-r1_pkg_setup @@ -88,7 +90,20 @@ src_prepare() { # remove hardcoded/unhelpful flags from bpftool sed -i -e '/CFLAGS += -O2/d' -e 's/-W //g' -e 's/-Wextra //g' src/Makefile || die + # always build bpf bits with std=gnu11 for kernel compatibility (bug 955156) + sed -i 's/-fno-stack-protector/& -std=gnu11/g' src/Makefile || die + if ! use clang; then + # make people aware of what they are doing + ewarn "Using bpf-toolchain instead of clang due to USE=-clang." + ewarn "Please report any odd behaviours you observe, since using gcc for BPF" + ewarn "is still under development in both the Linux kernel and gcc itself." + + # prevent attribute warning about preserve_access_index + # since gcc does not support '#pragma clang attribute push': + # https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=675b4e2 + sed -i 's/std=gnu11/& -DBPF_NO_PRESERVE_ACCESS_INDEX/g' src/Makefile || die + # remove bpf target & add assembly annotations to fix CO-RE feature detection sed -i -e 's/-target bpf/-dA/' src/Makefile.feature || die diff --git a/dev-util/bpftool/bpftool-9999.ebuild b/dev-util/bpftool/bpftool-9999.ebuild index fd1c3aebd4c6..0139c6ee78d9 100644 --- a/dev-util/bpftool/bpftool-9999.ebuild +++ b/dev-util/bpftool/bpftool-9999.ebuild @@ -1,11 +1,11 @@ -# Copyright 2021-2024 Gentoo Authors +# Copyright 2021-2025 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 LLVM_COMPAT=( {15..20} ) LLVM_OPTIONAL=1 -PYTHON_COMPAT=( python3_{10..13} ) +PYTHON_COMPAT=( python3_{11..13} ) inherit bash-completion-r1 linux-info llvm-r1 python-any-r1 toolchain-funcs @@ -88,7 +88,20 @@ src_prepare() { # remove hardcoded/unhelpful flags from bpftool sed -i -e '/CFLAGS += -O2/d' -e 's/-W //g' -e 's/-Wextra //g' src/Makefile || die + # always build bpf bits with std=gnu11 for kernel compatibility (bug 955156) + sed -i 's/-fno-stack-protector/& -std=gnu11/g' src/Makefile || die + if ! use clang; then + # make people aware of what they are doing + ewarn "Using bpf-toolchain instead of clang due to USE=-clang." + ewarn "Please report any odd behaviours you observe, since using gcc for BPF" + ewarn "is still under development in both the Linux kernel and gcc itself." + + # prevent attribute warning about preserve_access_index + # since gcc does not support '#pragma clang attribute push': + # https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=675b4e2 + sed -i 's/std=gnu11/& -DBPF_NO_PRESERVE_ACCESS_INDEX/g' src/Makefile || die + # remove bpf target & add assembly annotations to fix CO-RE feature detection sed -i -e 's/-target bpf/-dA/' src/Makefile.feature || die 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 deleted file mode 100644 index c874555d3799..000000000000 --- a/dev-util/bpftool/files/7.4-001-mount-bpffs-on-provided-dir-instead-of-parent-dir.patch +++ /dev/null @@ -1,255 +0,0 @@ -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 deleted file mode 100644 index 2eb6e72d0279..000000000000 --- a/dev-util/bpftool/files/7.4-002-set-DESTDIR-to-empty-when-building-libbpf.patch +++ /dev/null @@ -1,38 +0,0 @@ -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 deleted file mode 100644 index fc488aca5b02..000000000000 --- a/dev-util/bpftool/files/7.4-003-fix-typo-in-usage-help.patch +++ /dev/null @@ -1,30 +0,0 @@ -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 deleted file mode 100644 index 19dfa0c00746..000000000000 --- a/dev-util/bpftool/files/7.4-004-fix-the-wrong-format-specifier.patch +++ /dev/null @@ -1,38 +0,0 @@ -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 deleted file mode 100644 index 90c3499ec0b3..000000000000 --- a/dev-util/bpftool/files/7.4-005-fix-undefined-behavior-caused-by-shifting-into-the-sign-bit.patch +++ /dev/null @@ -1,47 +0,0 @@ -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 deleted file mode 100644 index 466258112b18..000000000000 --- a/dev-util/bpftool/files/7.4-006-fix-undefined-behavior-in-qsort.patch +++ /dev/null @@ -1,49 +0,0 @@ -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 deleted file mode 100644 index c88cbdf367c4..000000000000 --- a/dev-util/bpftool/files/7.4-007-define-PACKAGE-at-build-time-when-trying-to-detect-libbfd.patch +++ /dev/null @@ -1,48 +0,0 @@ -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 deleted file mode 100644 index 399b824ce06b..000000000000 --- a/dev-util/bpftool/files/7.4-008-always-disable-unused-CLI-arguments-warning-for-feature-probe.patch +++ /dev/null @@ -1,38 +0,0 @@ -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/files/7.5.0-setting-error-code-in-do_loader.patch b/dev-util/bpftool/files/7.5.0-setting-error-code-in-do_loader.patch new file mode 100644 index 000000000000..8b77603e13ba --- /dev/null +++ b/dev-util/bpftool/files/7.5.0-setting-error-code-in-do_loader.patch @@ -0,0 +1,45 @@ +Patch from: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=02a4694107b4c830d4bd6d194e98b3ac0bc86f29 +Adapted patch prefix to match the GH mirror sources. + +From 91588da58ed38e4ec870d479ab2d9467288893d2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin <sashal@kernel.org> +Date: Tue, 11 Mar 2025 12:12:37 +0900 +Subject: bpf: bpftool: Setting error code in do_loader() + +From: Sewon Nam <swnam0729@gmail.com> + +[ Upstream commit 02a4694107b4c830d4bd6d194e98b3ac0bc86f29 ] + +We are missing setting error code in do_loader() when +bpf_object__open_file() fails. This means the command's exit status code +will be successful, even though the operation failed. So make sure to +return the correct error code. To maintain consistency with other +locations where bpf_object__open_file() is called, return -1. + + [0] Closes: https://github.com/libbpf/bpftool/issues/156 + +Reported-by: Dan Carpenter <dan.carpenter@linaro.org> +Signed-off-by: Sewon Nam <swnam0729@gmail.com> +Signed-off-by: Andrii Nakryiko <andrii@kernel.org> +Tested-by: Quentin Monnet <qmo@kernel.org> +Reviewed-by: Quentin Monnet <qmo@kernel.org> +Link: https://lore.kernel.org/bpf/d3b5b4b4-19bb-4619-b4dd-86c958c4a367@stanley.mountain/t/#u +Link: https://lore.kernel.org/bpf/20250311031238.14865-1-swnam0729@gmail.com +Signed-off-by: Alexei Starovoitov <ast@kernel.org> +Signed-off-by: Sasha Levin <sashal@kernel.org> +--- + tools/bpf/bpftool/prog.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c +index e71be67f1d865..52ffb74ae4e89 100644 +--- a/src/prog.c ++++ b/src/prog.c +@@ -1928,6 +1928,7 @@ static int do_loader(int argc, char **argv) + + obj = bpf_object__open_file(file, &open_opts); + if (!obj) { ++ err = -1; + p_err("failed to open object file"); + goto err_close_obj; + } |