From patchwork Sat Dec 10 02:16:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1714343 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NTWjH2xFmz23yc for ; Sat, 10 Dec 2022 13:16:34 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5835A41BD1; Sat, 10 Dec 2022 02:16:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5835A41BD1 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AKk7q3V27qAd; Sat, 10 Dec 2022 02:16:31 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 1A65541BA5; Sat, 10 Dec 2022 02:16:30 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 1A65541BA5 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DE067C0081; Sat, 10 Dec 2022 02:16:29 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id BAAC4C0032 for ; Sat, 10 Dec 2022 02:16:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 95ED440984 for ; Sat, 10 Dec 2022 02:16:28 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 95ED440984 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ENGPgBw3V120 for ; Sat, 10 Dec 2022 02:16:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org A18684093E Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by smtp4.osuosl.org (Postfix) with ESMTPS id A18684093E for ; Sat, 10 Dec 2022 02:16:27 +0000 (UTC) Received: (Authenticated sender: i.maximets@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id F4147E0003; Sat, 10 Dec 2022 02:16:24 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Sat, 10 Dec 2022 03:16:15 +0100 Message-Id: <20221210021620.2699347-2-i.maximets@ovn.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221210021620.2699347-1-i.maximets@ovn.org> References: <20221210021620.2699347-1-i.maximets@ovn.org> MIME-Version: 1.0 Cc: Ilya Maximets Subject: [ovs-dev] [PATCH 1/6] ci: Fix overriding OPTS provided from the yml. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" For GCC builds we're overriding --disbale-ssl or --enable-shared options set up in the GHA yml file. Fix that by adding to EXTRA_OPTS instead. Signed-off-by: Ilya Maximets --- .ci/linux-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index 485109672..1f8896423 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -246,7 +246,7 @@ elif [ "$M32" ]; then # difference on 'configure' and 'make' stages. export CC="$CC -m32" elif [ "$TRAVIS_ARCH" != "aarch64" ]; then - OPTS="--enable-sparse" + EXTRA_OPTS="$EXTRA_OPTS --enable-sparse" if [ "$AFXDP" ]; then # netdev-afxdp uses memset for 64M for umem initialization. SPARSE_FLAGS="${SPARSE_FLAGS} -Wno-memcpy-max-count" From patchwork Sat Dec 10 02:16:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1714345 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NTWjQ5fXBz23np for ; Sat, 10 Dec 2022 13:16:42 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 55D0B4102B; Sat, 10 Dec 2022 02:16:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 55D0B4102B X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mUyL-I_ggLGB; Sat, 10 Dec 2022 02:16:39 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id D852540FC4; Sat, 10 Dec 2022 02:16:37 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D852540FC4 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AAAC4C0032; Sat, 10 Dec 2022 02:16:37 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1EFA5C0032 for ; Sat, 10 Dec 2022 02:16:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5B57F40298 for ; Sat, 10 Dec 2022 02:16:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5B57F40298 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UrtjLgO9xMMC for ; Sat, 10 Dec 2022 02:16:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org C36D040FF8 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by smtp2.osuosl.org (Postfix) with ESMTPS id C36D040FF8 for ; Sat, 10 Dec 2022 02:16:31 +0000 (UTC) Received: (Authenticated sender: i.maximets@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id 57951E0003; Sat, 10 Dec 2022 02:16:29 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Sat, 10 Dec 2022 03:16:16 +0100 Message-Id: <20221210021620.2699347-3-i.maximets@ovn.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221210021620.2699347-1-i.maximets@ovn.org> References: <20221210021620.2699347-1-i.maximets@ovn.org> MIME-Version: 1.0 Cc: Ilya Maximets Subject: [ovs-dev] [PATCH 2/6] netdev-afxdp: Allow building with libxdp and newer libbpf. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" AF_XDP functions was deprecated in libbpf 0.7 and moved to libxdp. Functions bpf_get/set_link_xdp_id() was deprecated in libbpf 0.8 and replaced with bpf_xdp_query_id() and bpf_xdp_attach/detach(). Updating configuration and source code to accommodate above changes and allow building OVS with AF_XDP support on newer systems: - Checking availability of the libxdp in a system by looking for a library providing libxdp_strerror(). - Checking for xsk.h header provided by libxdp-dev[el] first, fall back to xsk.h from libbpf if not found. - Check for the NEED_WAKEUP feature replaced with direct checking in the source code if XDP_USE_NEED_WAKEUP is defined. - Checking availability of bpf_xdp_query_id and bpf_xdp_detach and using them instead of deprecated APIs. Fall back to old functions if not found. - Dropped LIBBPF_LDADD variable as it makes library and function detection much harder without providing any actual benefits. AC_SEARCH_LIBS is used instead and it allows use of AC_CHECK_FUNCS. - Header includes moved around to files where they are actually used. - Removed libelf dependency as it is not really used. With these changes it should be possible to build OVS with either: - libbpf built from the kernel sources (5.19 or older). - libbpf < 0.7 provided in distributions. - libxdp and libbpf >= 0.7 provided in newer distributions. libxdp added as a build dependency for Fedora build since all supported versions of Fedora are packaging this library. Signed-off-by: Ilya Maximets --- NEWS | 2 ++ acinclude.m4 | 21 +++++++++--------- lib/automake.mk | 1 - lib/libopenvswitch.pc.in | 2 +- lib/netdev-afxdp-pool.c | 2 ++ lib/netdev-afxdp-pool.h | 5 ----- lib/netdev-afxdp.c | 38 ++++++++++++++++++++++++++------- rhel/openvswitch-fedora.spec.in | 2 +- 8 files changed, 46 insertions(+), 27 deletions(-) diff --git a/NEWS b/NEWS index 265375e1c..5d39c7d27 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ Post-v3.0.0 -------------------- + - AF_XDP: + * Added support for building with libxdp and libbpf >= 0.7. - ovs-appctl: * "ovs-appctl ofproto/trace" command can now display port names with the "--names" option. diff --git a/acinclude.m4 b/acinclude.m4 index aa9af5506..aed01c967 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -251,7 +251,7 @@ AC_DEFUN([OVS_FIND_DEPENDENCY], [ dnl OVS_CHECK_LINUX_AF_XDP dnl -dnl Check both Linux kernel AF_XDP and libbpf support +dnl Check both Linux kernel AF_XDP and libbpf/libxdp support AC_DEFUN([OVS_CHECK_LINUX_AF_XDP], [ AC_ARG_ENABLE([afxdp], [AS_HELP_STRING([--enable-afxdp], [Enable AF-XDP support])], @@ -270,23 +270,22 @@ AC_DEFUN([OVS_CHECK_LINUX_AF_XDP], [ AC_CHECK_HEADER([linux/if_xdp.h], [], [AC_MSG_ERROR([unable to find linux/if_xdp.h for AF_XDP support])]) - AC_CHECK_HEADER([bpf/xsk.h], [], - [AC_MSG_ERROR([unable to find bpf/xsk.h for AF_XDP support])]) + AC_CHECK_HEADER([xdp/xsk.h], + AC_DEFINE([HAVE_LIBXDP], [1], [xsk.h is supplied with libxdp]), + AC_CHECK_HEADER([bpf/xsk.h], [], + [AC_MSG_ERROR([unable to find xsk.h for AF_XDP support])])) AC_CHECK_FUNCS([pthread_spin_lock], [], [AC_MSG_ERROR([unable to find pthread_spin_lock for AF_XDP support])]) OVS_FIND_DEPENDENCY([numa_alloc_onnode], [numa], [libnuma]) + OVS_FIND_DEPENDENCY([libbpf_strerror], [bpf], [libbpf]) + AC_SEARCH_LIBS([libxdp_strerror], [xdp]) + + AC_CHECK_FUNCS([bpf_xdp_query_id bpf_xdp_detach]) AC_DEFINE([HAVE_AF_XDP], [1], [Define to 1 if AF_XDP support is available and enabled.]) - LIBBPF_LDADD=" -lbpf -lelf" - AC_SUBST([LIBBPF_LDADD]) - - AC_CHECK_DECL([xsk_ring_prod__needs_wakeup], [ - AC_DEFINE([HAVE_XDP_NEED_WAKEUP], [1], - [XDP need wakeup support detected in xsk.h.]) - ], [], [[#include ]]) fi AM_CONDITIONAL([HAVE_AF_XDP], test "$AF_XDP_ENABLE" = true) ]) @@ -357,7 +356,7 @@ AC_DEFUN([OVS_CHECK_DPDK], [ ], [], [[#include ]]) AC_CHECK_DECL([RTE_NET_AF_XDP], [ - LIBBPF_LDADD="-lbpf" + OVS_FIND_DEPENDENCY([libbpf_strerror], [bpf], [libbpf]) ], [], [[#include ]]) AC_CHECK_DECL([RTE_LIBRTE_VHOST_NUMA], [ diff --git a/lib/automake.mk b/lib/automake.mk index a0fabe38f..61bdc308f 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -9,7 +9,6 @@ lib_LTLIBRARIES += lib/libopenvswitch.la lib_libopenvswitch_la_LIBADD = $(SSL_LIBS) lib_libopenvswitch_la_LIBADD += $(CAPNG_LDADD) -lib_libopenvswitch_la_LIBADD += $(LIBBPF_LDADD) if WIN32 diff --git a/lib/libopenvswitch.pc.in b/lib/libopenvswitch.pc.in index 44fbb1f9f..a5f4d3947 100644 --- a/lib/libopenvswitch.pc.in +++ b/lib/libopenvswitch.pc.in @@ -7,5 +7,5 @@ Name: libopenvswitch Description: Open vSwitch library Version: @VERSION@ Libs: -L${libdir} -lopenvswitch -Libs.private: @LIBS@ @SSL_LIBS@ @CAPNG_LDADD@ @LIBBPF_LDADD@ +Libs.private: @LIBS@ @SSL_LIBS@ @CAPNG_LDADD@ Cflags: -I${includedir} diff --git a/lib/netdev-afxdp-pool.c b/lib/netdev-afxdp-pool.c index 3386d2dcf..f56a7b29e 100644 --- a/lib/netdev-afxdp-pool.c +++ b/lib/netdev-afxdp-pool.c @@ -15,6 +15,8 @@ */ #include +#include + #include "dp-packet.h" #include "netdev-afxdp-pool.h" #include "openvswitch/util.h" diff --git a/lib/netdev-afxdp-pool.h b/lib/netdev-afxdp-pool.h index f929b9489..6681cf539 100644 --- a/lib/netdev-afxdp-pool.h +++ b/lib/netdev-afxdp-pool.h @@ -19,12 +19,7 @@ #ifdef HAVE_AF_XDP -#include -#include -#include - #include "openvswitch/thread.h" -#include "ovs-atomic.h" /* LIFO ptr_array. */ struct umem_pool { diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c index ca3f2431e..6ced8a2b6 100644 --- a/lib/netdev-afxdp.c +++ b/lib/netdev-afxdp.c @@ -21,6 +21,11 @@ #include "netdev-afxdp.h" #include "netdev-afxdp-pool.h" +#ifdef HAVE_LIBXDP +#include +#else +#include +#endif #include #include #include @@ -29,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +50,7 @@ #include "openvswitch/list.h" #include "openvswitch/thread.h" #include "openvswitch/vlog.h" +#include "ovs-atomic.h" #include "ovs-numa.h" #include "packets.h" #include "socket-util.h" @@ -72,7 +79,7 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); #define PROD_NUM_DESCS XSK_RING_PROD__DEFAULT_NUM_DESCS #define CONS_NUM_DESCS XSK_RING_CONS__DEFAULT_NUM_DESCS -#ifdef HAVE_XDP_NEED_WAKEUP +#ifdef XDP_USE_NEED_WAKEUP #define NEED_WAKEUP_DEFAULT true #else #define NEED_WAKEUP_DEFAULT false @@ -169,7 +176,7 @@ struct netdev_afxdp_tx_lock { ); }; -#ifdef HAVE_XDP_NEED_WAKEUP +#ifdef XDP_USE_NEED_WAKEUP static inline void xsk_rx_wakeup_if_needed(struct xsk_umem_info *umem, struct netdev *netdev, int fd) @@ -201,7 +208,7 @@ xsk_tx_need_wakeup(struct xsk_socket_info *xsk_info) return xsk_ring_prod__needs_wakeup(&xsk_info->tx); } -#else /* !HAVE_XDP_NEED_WAKEUP */ +#else /* !XDP_USE_NEED_WAKEUP */ static inline void xsk_rx_wakeup_if_needed(struct xsk_umem_info *umem OVS_UNUSED, struct netdev *netdev OVS_UNUSED, @@ -215,7 +222,7 @@ xsk_tx_need_wakeup(struct xsk_socket_info *xsk_info OVS_UNUSED) { return true; } -#endif /* HAVE_XDP_NEED_WAKEUP */ +#endif /* XDP_USE_NEED_WAKEUP */ static void netdev_afxdp_cleanup_unused_pool(struct unused_pool *pool) @@ -351,7 +358,7 @@ xsk_configure_socket(struct xsk_umem_info *umem, uint32_t ifindex, cfg.bind_flags = xdp_modes[mode].bind_flags; cfg.xdp_flags = xdp_modes[mode].xdp_flags | XDP_FLAGS_UPDATE_IF_NOEXIST; -#ifdef HAVE_XDP_NEED_WAKEUP +#ifdef XDP_USE_NEED_WAKEUP if (use_need_wakeup) { cfg.bind_flags |= XDP_USE_NEED_WAKEUP; } @@ -377,7 +384,11 @@ xsk_configure_socket(struct xsk_umem_info *umem, uint32_t ifindex, } /* Make sure the built-in AF_XDP program is loaded. */ +#ifdef HAVE_BPF_XDP_QUERY_ID + ret = bpf_xdp_query_id(ifindex, cfg.xdp_flags, &prog_id); +#else ret = bpf_get_link_xdp_id(ifindex, &prog_id, cfg.xdp_flags); +#endif if (ret || !prog_id) { if (ret) { VLOG_ERR("Get XDP prog ID failed (%s)", ovs_strerror(errno)); @@ -630,9 +641,9 @@ netdev_afxdp_set_config(struct netdev *netdev, const struct smap *args, } need_wakeup = smap_get_bool(args, "use-need-wakeup", NEED_WAKEUP_DEFAULT); -#ifndef HAVE_XDP_NEED_WAKEUP +#ifndef XDP_USE_NEED_WAKEUP if (need_wakeup) { - VLOG_WARN("XDP need_wakeup is not supported in libbpf."); + VLOG_WARN("XDP need_wakeup is not supported in libbpf/libxdp."); need_wakeup = false; } #endif @@ -742,7 +753,11 @@ xsk_remove_xdp_program(uint32_t ifindex, enum afxdp_mode mode) uint32_t ret, prog_id = 0; /* Check whether XDP program is loaded. */ +#ifdef HAVE_BPF_XDP_QUERY_ID + ret = bpf_xdp_query_id(ifindex, flags, &prog_id); +#else ret = bpf_get_link_xdp_id(ifindex, &prog_id, flags); +#endif if (ret) { VLOG_ERR("Failed to get XDP prog id (%s)", ovs_strerror(errno)); return; @@ -753,7 +768,14 @@ xsk_remove_xdp_program(uint32_t ifindex, enum afxdp_mode mode) return; } - bpf_set_link_xdp_fd(ifindex, -1, flags); +#ifdef HAVE_BPF_XDP_DETACH + if (bpf_xdp_detach(ifindex, flags, NULL) != 0) { +#else + if (bpf_set_link_xdp_fd(ifindex, -1, flags) != 0) { +#endif + VLOG_ERR("Failed to detach XDP program (%s) at ifindex %d", + ovs_strerror(errno), ifindex); + } } void diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in index 4a3e6294b..6564d5252 100644 --- a/rhel/openvswitch-fedora.spec.in +++ b/rhel/openvswitch-fedora.spec.in @@ -75,7 +75,7 @@ BuildRequires: dpdk-devel >= 22.11 Provides: %{name}-dpdk = %{version}-%{release} %endif %if %{with afxdp} -BuildRequires: libbpf-devel numactl-devel +BuildRequires: libxdp-devel libbpf-devel numactl-devel %endif BuildRequires: unbound unbound-devel From patchwork Sat Dec 10 02:16:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1714347 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NTWjh3LVwz23np for ; Sat, 10 Dec 2022 13:16:56 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id F246541C61; Sat, 10 Dec 2022 02:16:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org F246541C61 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vOAz7q3apWjZ; Sat, 10 Dec 2022 02:16:52 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 6B36A41C07; Sat, 10 Dec 2022 02:16:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 6B36A41C07 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 39D85C0080; Sat, 10 Dec 2022 02:16:49 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 11847C0032 for ; Sat, 10 Dec 2022 02:16:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id A553840FDE for ; Sat, 10 Dec 2022 02:16:36 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A553840FDE X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XfehNavsQlfw for ; Sat, 10 Dec 2022 02:16:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 6D37141025 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by smtp2.osuosl.org (Postfix) with ESMTPS id 6D37141025 for ; Sat, 10 Dec 2022 02:16:35 +0000 (UTC) Received: (Authenticated sender: i.maximets@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id 13B5FE0002; Sat, 10 Dec 2022 02:16:31 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Sat, 10 Dec 2022 03:16:17 +0100 Message-Id: <20221210021620.2699347-4-i.maximets@ovn.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221210021620.2699347-1-i.maximets@ovn.org> References: <20221210021620.2699347-1-i.maximets@ovn.org> MIME-Version: 1.0 Cc: Ilya Maximets Subject: [ovs-dev] [PATCH 3/6] acinclude.m4: Build with AF_XDP support by default if possible. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" With this change we will try to detect all the netdev-afxdp dependencies and enable AF_XDP support by default if they are present at the build time. Configuration script behaves in a following way: - ./configure --enable-afxdp Will check for AF_XDP dependencies and fail if they are not available. - ./configure --disable-afxdp Disables checking for AF_XDP. Build will not support AF_XDP even if all dependencies are installed. - Just ./configure or ./configure --enable-afxdp=auto Will check for AF_XDP dependencies. Will print a warning if they are not available, but will continue without AF_XDP support. If dependencies are available in a system, this option is equal to --enable-afxdp, except that AF_XDP will not be enabled for libbpf >= 0.7 if libxdp is not available, to avoid deprecation warnings during the build. '--disable-afxdp' added to the debian and fedora package builds to keep predictable behavior. Signed-off-by: Ilya Maximets --- Documentation/intro/install/afxdp.rst | 3 +- NEWS | 3 + acinclude.m4 | 89 ++++++++++++++++++--------- debian/rules | 8 ++- rhel/openvswitch-fedora.spec.in | 2 + 5 files changed, 72 insertions(+), 33 deletions(-) diff --git a/Documentation/intro/install/afxdp.rst b/Documentation/intro/install/afxdp.rst index bfef49860..84f8aa5d7 100644 --- a/Documentation/intro/install/afxdp.rst +++ b/Documentation/intro/install/afxdp.rst @@ -30,8 +30,7 @@ This document describes how to build and install Open vSwitch using AF_XDP netdev. .. warning:: - The AF_XDP support of Open vSwitch is considered 'experimental', - and it is not compiled in by default. + The AF_XDP support of Open vSwitch is considered 'experimental'. Introduction diff --git a/NEWS b/NEWS index 5d39c7d27..d2bbae591 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ Post-v3.0.0 -------------------- - AF_XDP: * Added support for building with libxdp and libbpf >= 0.7. + * Support for AF_XDP is now enabled by default if all dependencies are + available at the build time. Use --disable-afxdp to disable. + Use --enable-afxdp to fail the build if dependencies are not present. - ovs-appctl: * "ovs-appctl ofproto/trace" command can now display port names with the "--names" option. diff --git a/acinclude.m4 b/acinclude.m4 index aed01c967..8411c0e6c 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -253,39 +253,72 @@ dnl OVS_CHECK_LINUX_AF_XDP dnl dnl Check both Linux kernel AF_XDP and libbpf/libxdp support AC_DEFUN([OVS_CHECK_LINUX_AF_XDP], [ - AC_ARG_ENABLE([afxdp], - [AS_HELP_STRING([--enable-afxdp], [Enable AF-XDP support])], - [], [enable_afxdp=no]) + AC_ARG_ENABLE( + [afxdp], + [AS_HELP_STRING([--disable-afxdp], [Disable AF-XDP support])], + [case "${enableval}" in + (yes | no | auto) ;; + (*) AC_MSG_ERROR([bad value ${enableval} for --enable-afxdp]) ;; + esac], + [enable_afxdp=auto]) + AC_MSG_CHECKING([whether AF_XDP is enabled]) - if test "$enable_afxdp" != yes; then + if test "$enable_afxdp" == no; then AC_MSG_RESULT([no]) AF_XDP_ENABLE=false else - AC_MSG_RESULT([yes]) + AC_MSG_RESULT([$enable_afxdp]) AF_XDP_ENABLE=true - - AC_CHECK_HEADER([bpf/libbpf.h], [], - [AC_MSG_ERROR([unable to find bpf/libbpf.h for AF_XDP support])]) - - AC_CHECK_HEADER([linux/if_xdp.h], [], - [AC_MSG_ERROR([unable to find linux/if_xdp.h for AF_XDP support])]) - - AC_CHECK_HEADER([xdp/xsk.h], - AC_DEFINE([HAVE_LIBXDP], [1], [xsk.h is supplied with libxdp]), - AC_CHECK_HEADER([bpf/xsk.h], [], - [AC_MSG_ERROR([unable to find xsk.h for AF_XDP support])])) - - AC_CHECK_FUNCS([pthread_spin_lock], [], - [AC_MSG_ERROR([unable to find pthread_spin_lock for AF_XDP support])]) - - OVS_FIND_DEPENDENCY([numa_alloc_onnode], [numa], [libnuma]) - OVS_FIND_DEPENDENCY([libbpf_strerror], [bpf], [libbpf]) - AC_SEARCH_LIBS([libxdp_strerror], [xdp]) - - AC_CHECK_FUNCS([bpf_xdp_query_id bpf_xdp_detach]) - - AC_DEFINE([HAVE_AF_XDP], [1], - [Define to 1 if AF_XDP support is available and enabled.]) + failed_dep=none + dnl Saving libs to restore in case we will end up not building with AF_XDP. + save_LIBS=$LIBS + + AC_CHECK_HEADER([bpf/libbpf.h], [], [failed_dep="bpf/libbpf.h"]) + + if test "$failed_dep" = none; then + AC_CHECK_HEADER([linux/if_xdp.h], [], [failed_dep="linux/if_xdp.h"]) + fi + + if test "$failed_dep" = none; then + AC_CHECK_HEADER([xdp/xsk.h], + AC_DEFINE([HAVE_LIBXDP], [1], [xsk.h is supplied with libxdp]), + AC_CHECK_HEADER([bpf/xsk.h], [], [failed_dep="xsk.h"])) + fi + + if test "$failed_dep" = none; then + AC_CHECK_FUNCS([pthread_spin_lock], [], [failed_dep="pthread_spin_lock"]) + fi + + if test "$failed_dep" = none; then + AC_SEARCH_LIBS([numa_alloc_onnode], [numa], [], [failed_dep="libnuma"]) + fi + if test "$failed_dep" = none; then + AC_SEARCH_LIBS([libbpf_strerror], [bpf], [], [failed_dep="libbpf"]) + fi + + if test "$failed_dep" = none; then + AC_CHECK_FUNCS([bpf_xdp_query_id bpf_xdp_detach]) + AC_SEARCH_LIBS([libxdp_strerror], [xdp], [], + [dnl Fail the auto discovery if we have libbpf >= 0.7 but not libxdp + dnl to avoid deprecation warnings during the build. + if test "$enable_afxdp" = auto -a "x$ac_cv_func_bpf_xdp_detach" = xyes; then + failed_dep="libxdp" + fi + ]) + fi + + if test "$failed_dep" = none; then + AC_DEFINE([HAVE_AF_XDP], [1], + [Define to 1 if AF_XDP support is available and enabled.]) + elif test "$enable_afxdp" = yes; then + AC_MSG_ERROR([Missing $failed_dep dependency for AF_XDP support]) + else + AC_MSG_WARN(m4_normalize( + [Cannot find $failed_dep, netdev-afxdp will not be supported + (you may use --disable-afxdp to suppress this warning).])) + AF_XDP_ENABLE=false + LIBS=$save_LIBS + fi fi AM_CONDITIONAL([HAVE_AF_XDP], test "$AF_XDP_ENABLE" = true) ]) diff --git a/debian/rules b/debian/rules index 971bc1775..7ed44d991 100755 --- a/debian/rules +++ b/debian/rules @@ -23,7 +23,8 @@ override_dh_auto_configure: test -d _debian || mkdir _debian cd _debian && ( \ test -e Makefile || \ - ../configure --prefix=/usr --localstatedir=/var --enable-ssl \ + ../configure --prefix=/usr --localstatedir=/var \ + --enable-ssl --disable-afxdp \ --sysconfdir=/etc \ $(DATAPATH_CONFIGURE_OPTS) \ $(EXTRA_CONFIGURE_OPTS) \ @@ -33,8 +34,9 @@ ifeq (,$(filter nodpdk, $(DEB_BUILD_OPTIONS))) test -d _dpdk || mkdir _dpdk cd _dpdk && ( \ test -e Makefile || \ - ../configure --prefix=/usr --localstatedir=/var --enable-ssl \ - --with-dpdk=shared --sysconfdir=/etc \ + ../configure --prefix=/usr --localstatedir=/var \ + --enable-ssl --disable-afxdp \ + --with-dpdk=shared --sysconfdir=/etc \ $(DATAPATH_CONFIGURE_OPTS) \ $(EXTRA_CONFIGURE_OPTS) \ ) diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in index 6564d5252..fbfcdcf63 100644 --- a/rhel/openvswitch-fedora.spec.in +++ b/rhel/openvswitch-fedora.spec.in @@ -171,6 +171,8 @@ This package provides IPsec tunneling support for OVS tunnels. %endif %if %{with afxdp} --enable-afxdp \ +%else + --disable-afxdp \ %endif --enable-ssl \ --disable-static \ From patchwork Sat Dec 10 02:16:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1714346 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NTWjc48Z4z23np for ; Sat, 10 Dec 2022 13:16:52 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A241160E4D; Sat, 10 Dec 2022 02:16:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A241160E4D X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id u5y1WMmb_QB0; Sat, 10 Dec 2022 02:16:49 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id A10616118F; Sat, 10 Dec 2022 02:16:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A10616118F Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7E5F2C0032; Sat, 10 Dec 2022 02:16:48 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 10F04C002D for ; Sat, 10 Dec 2022 02:16:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 677F061085 for ; Sat, 10 Dec 2022 02:16:38 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 677F061085 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jpI19NmM5FLr for ; Sat, 10 Dec 2022 02:16:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5275160BDC Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by smtp3.osuosl.org (Postfix) with ESMTPS id 5275160BDC for ; Sat, 10 Dec 2022 02:16:37 +0000 (UTC) Received: (Authenticated sender: i.maximets@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id E8801E0006; Sat, 10 Dec 2022 02:16:34 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Sat, 10 Dec 2022 03:16:18 +0100 Message-Id: <20221210021620.2699347-5-i.maximets@ovn.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221210021620.2699347-1-i.maximets@ovn.org> References: <20221210021620.2699347-1-i.maximets@ovn.org> MIME-Version: 1.0 Cc: Ilya Maximets Subject: [ovs-dev] [PATCH 4/6] github: Test AF_XDP build using libbpf instead of kernel sources. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" AF_XDP bits was removed from kernel's libbpf in 6.0. libbpf and libxdp are now primary way to build AF_XDP applications. Most of modern distributions are already packaging some version of libbpf, so it's better to test building with it instead of building old unsupported kernel tree. All the jobs will now try to build with AF_XDP support. One AF_XDP-specific job kept to fail explicitly if something is wrong in the configuration process, others will just skip building AF_XDP support in case of missing dependencies. Ubuntu started packaging libxdp only in 22.10, so not using it for now. Signed-off-by: Ilya Maximets --- .ci/linux-build.sh | 22 ++-------------------- .github/workflows/build-and-test.yml | 9 +++------ 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index 1f8896423..2904aadd2 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -76,22 +76,6 @@ function install_kernel() make net/bridge/ fi - if [ "$AFXDP" ]; then - sudo make headers_install INSTALL_HDR_PATH=/usr - pushd tools/lib/bpf/ - # Bulding with gcc because there are some issues in make files - # that breaks building libbpf with clang on Travis. - CC=gcc sudo make install - CC=gcc sudo make install_headers - sudo ldconfig - popd - # The Linux kernel defines __always_inline in stddef.h (283d7573), and - # sys/cdefs.h tries to re-define it. Older libc-dev package in xenial - # doesn't have a fix for this issue. Applying it manually. - sudo sed -i '/^# define __always_inline .*/i # undef __always_inline' \ - /usr/include/x86_64-linux-gnu/sys/cdefs.h || true - EXTRA_OPTS="${EXTRA_OPTS} --enable-afxdp" - fi popd } @@ -247,10 +231,8 @@ elif [ "$M32" ]; then export CC="$CC -m32" elif [ "$TRAVIS_ARCH" != "aarch64" ]; then EXTRA_OPTS="$EXTRA_OPTS --enable-sparse" - if [ "$AFXDP" ]; then - # netdev-afxdp uses memset for 64M for umem initialization. - SPARSE_FLAGS="${SPARSE_FLAGS} -Wno-memcpy-max-count" - fi + # netdev-afxdp uses memset for 64M for umem initialization. + SPARSE_FLAGS="${SPARSE_FLAGS} -Wno-memcpy-max-count" CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} ${SPARSE_FLAGS}" fi diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e08d7b1ba..5f28493c7 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -8,8 +8,7 @@ jobs: dependencies: | automake libtool gcc bc libjemalloc2 libjemalloc-dev \ libssl-dev llvm-dev libelf-dev libnuma-dev libpcap-dev \ - ninja-build selinux-policy-dev - AFXDP: ${{ matrix.afxdp }} + ninja-build selinux-policy-dev libbpf-dev ASAN: ${{ matrix.asan }} UBSAN: ${{ matrix.ubsan }} CC: ${{ matrix.compiler }} @@ -65,11 +64,9 @@ jobs: libs: -ljemalloc - compiler: gcc - afxdp: afxdp - kernel: 5.3 + opts: --enable-afxdp - compiler: clang - afxdp: afxdp - kernel: 5.3 + opts: --enable-afxdp - compiler: gcc dpdk: dpdk From patchwork Sat Dec 10 02:16:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1714348 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NTWjk4Wdkz23yc for ; Sat, 10 Dec 2022 13:16:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 57DC3611D1; Sat, 10 Dec 2022 02:16:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 57DC3611D1 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7pcxLPJ1StOZ; Sat, 10 Dec 2022 02:16:55 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 9BAED611B8; Sat, 10 Dec 2022 02:16:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9BAED611B8 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5FE98C0070; Sat, 10 Dec 2022 02:16:51 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 88A75C0083 for ; Sat, 10 Dec 2022 02:16:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 44B1941BF2 for ; Sat, 10 Dec 2022 02:16:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 44B1941BF2 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rjKmW0Dvg1uE for ; Sat, 10 Dec 2022 02:16:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 1263F41BFF Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp4.osuosl.org (Postfix) with ESMTPS id 1263F41BFF for ; Sat, 10 Dec 2022 02:16:39 +0000 (UTC) Received: (Authenticated sender: i.maximets@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id 761A3E0003; Sat, 10 Dec 2022 02:16:37 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Sat, 10 Dec 2022 03:16:19 +0100 Message-Id: <20221210021620.2699347-6-i.maximets@ovn.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221210021620.2699347-1-i.maximets@ovn.org> References: <20221210021620.2699347-1-i.maximets@ovn.org> MIME-Version: 1.0 Cc: Ilya Maximets Subject: [ovs-dev] [PATCH 5/6] Documentation/afxdp: Use packaged libbpf/libxdp for the build. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Necessary bits was removed from the kernel's libbpf in 6.0 release, so the instructions on how to build libbpf from kernel sources are now incorrect. Suggest to use libbpf and libxdp packaged by distributions instead. Signed-off-by: Ilya Maximets --- Documentation/intro/install/afxdp.rst | 40 +++++++-------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/Documentation/intro/install/afxdp.rst b/Documentation/intro/install/afxdp.rst index 84f8aa5d7..51c24bf5b 100644 --- a/Documentation/intro/install/afxdp.rst +++ b/Documentation/intro/install/afxdp.rst @@ -87,7 +87,7 @@ Build requirements In addition to the requirements described in :doc:`general`, building Open vSwitch with AF_XDP will require the following: -- libbpf from kernel source tree (kernel 5.0.0 or later) +- ``libbpf`` and ``libxdp`` (if version of ``libbpf`` if higher than ``0.6``). - Linux kernel XDP support, with the following options (required) @@ -124,40 +124,20 @@ vSwitch with AF_XDP will require the following: Installing ---------- For OVS to use AF_XDP netdev, it has to be configured with LIBBPF support. -First, clone a recent version of Linux bpf-next tree:: - git clone git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git +First, install ``libbpf`` and ``libxdp``. For example, on Fedora these +libraries along with development headers can be obtained by installing +``libbpf-devel`` and ``libxdp-devel`` packages. For Ubuntu that will be +``libbpf-dev`` package with additional ``libxdp-dev`` on Ubuntu 22.10 +or later. -Second, go into the Linux source directory and build libbpf in the tools -directory:: - - cd bpf-next/ - cd tools/lib/bpf/ - make && make install - make install_headers - -.. note:: - Make sure xsk.h and bpf.h are installed in system's library path, - e.g. /usr/local/include/bpf/ or /usr/include/bpf/ - -Make sure the libbpf.so is installed correctly:: - - ldconfig - ldconfig -p | grep libbpf - -.. note:: - Check /etc/ld.so.conf if libbpf is installed but can not be found by - ldconfig. - -Third, ensure the standard OVS requirements are installed and +Next, ensure the standard OVS requirements are installed and bootstrap/configure the package:: ./boot.sh && ./configure --enable-afxdp -.. note:: - If you encounter "WARNING: bpf/libbpf.h: present but cannot be compiled", - check the Linux headers are in line with libbpf. For example, in Ubuntu, - check the installed linux-headers* and linux-libc-dev* dpkg. +``--enable-afxdp`` here is optional, but it will ensure that all dependencies +are available at the build time. Finally, build and install OVS:: @@ -181,7 +161,7 @@ If a test case fails, check the log at:: Setup AF_XDP netdev ------------------- -Before running OVS with AF_XDP, make sure the libbpf, libelf, and libnuma are +Before running OVS with AF_XDP, make sure the libbpf and libnuma are set-up right:: ldd vswitchd/ovs-vswitchd From patchwork Sat Dec 10 02:16:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1714349 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NTWjp2Lz2z23np for ; Sat, 10 Dec 2022 13:17:02 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 8920B41054; Sat, 10 Dec 2022 02:16:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8920B41054 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HasVzU2hwC3Y; Sat, 10 Dec 2022 02:16:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 9A2314107F; Sat, 10 Dec 2022 02:16:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9A2314107F Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 40B7FC0083; Sat, 10 Dec 2022 02:16:53 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1C821C008D for ; Sat, 10 Dec 2022 02:16:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 95CF141C0B for ; Sat, 10 Dec 2022 02:16:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 95CF141C0B X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kMtEsrgRCrHv for ; Sat, 10 Dec 2022 02:16:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org A55FA415B5 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by smtp4.osuosl.org (Postfix) with ESMTPS id A55FA415B5 for ; Sat, 10 Dec 2022 02:16:42 +0000 (UTC) Received: (Authenticated sender: i.maximets@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id 23191E0005; Sat, 10 Dec 2022 02:16:39 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Sat, 10 Dec 2022 03:16:20 +0100 Message-Id: <20221210021620.2699347-7-i.maximets@ovn.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221210021620.2699347-1-i.maximets@ovn.org> References: <20221210021620.2699347-1-i.maximets@ovn.org> MIME-Version: 1.0 Cc: Ilya Maximets Subject: [ovs-dev] [PATCH 6/6] rhel: Enable AF_XDP by default in Fedora builds. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" All supported versions of Fedora do package libxdp and libbpf, so it makes sense to enable AF_XDP support. Control files for debian packaging are much less flexible, so its hard to enable AF_XDP builds while not breaking builds for version of Ubuntu and Debian that do not package libbpf or libxdp. Signed-off-by: Ilya Maximets --- rhel/openvswitch-fedora.spec.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in index fbfcdcf63..7676eb737 100644 --- a/rhel/openvswitch-fedora.spec.in +++ b/rhel/openvswitch-fedora.spec.in @@ -26,8 +26,8 @@ %bcond_without libcapng # To enable DPDK support, specify '--with dpdk' when building %bcond_with dpdk -# To enable AF_XDP support, specify '--with afxdp' when building -%bcond_with afxdp +# To disable AF_XDP support, specify '--without afxdp' when building +%bcond_without afxdp # If there is a need to automatically enable the package after installation, # specify the "--with autoenable"