From 217f881ca510d08b3f1eb441dd4b82bfd64d1665 Mon Sep 17 00:00:00 2001 From: code-agree <95141260+code-agree@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:30:43 +0000 Subject: [PATCH] build(dpdk): guard rte_timer_meta_init() for unmodified upstream DPDK F-Stack bundled DPDK provides a private rte_timer_meta_init() extension for secondary processes and graceful_reload, which does not exist in unmodified upstream DPDK releases. Auto-detect rte_timer_meta_init() availability in lib/Makefile so the bundled DPDK build remains unchanged. When building against unmodified upstream DPDK, validate rte_timer_subsystem_init() and fail fast if secondary process or graceful_reload mode is requested. --- lib/Makefile | 7 +++++++ lib/ff_dpdk_if.c | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/Makefile b/lib/Makefile index edec7d06c..c366dcbae 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -92,6 +92,13 @@ HOST_CFLAGS+= -DFF_KNI endif HOST_CFLAGS+= ${DPDK_CFLAGS} + +ifneq ($(MAKECMDGOALS),clean) +HAVE_RTE_TIMER_META_INIT := $(shell printf '#include \nvoid (*fn)(void) = rte_timer_meta_init;\n' | $(CC) -x c $(shell $(PKGCONF) --cflags libdpdk) -fsyntax-only - >/dev/null 2>&1 && echo 1 || echo 0) +ifeq ($(HAVE_RTE_TIMER_META_INIT),1) +HOST_CFLAGS+= -DHAVE_RTE_TIMER_META_INIT +endif +endif HOST_CFLAGS+= ${CONF_CFLAGS} ifdef FF_FDIR diff --git a/lib/ff_dpdk_if.c b/lib/ff_dpdk_if.c index c6c43b6e3..9efeab748 100644 --- a/lib/ff_dpdk_if.c +++ b/lib/ff_dpdk_if.c @@ -1547,8 +1547,22 @@ init_clock(void) return 0; } - rte_timer_subsystem_init(); + int timer_rc = rte_timer_subsystem_init(); + if (timer_rc != 0 && timer_rc != -EALREADY) { + rte_exit(EXIT_FAILURE, "timer subsystem initialization failed: %d\n", + timer_rc); + } +#ifdef HAVE_RTE_TIMER_META_INIT rte_timer_meta_init(); +#else + /* Unmodified upstream DPDK does not provide F-Stack's rte_timer_meta_init(). + * Fail fast if secondary process or graceful_reload is requested. */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY || + ff_global_cfg.dpdk.graceful_reload) { + rte_exit(EXIT_FAILURE, + "secondary process and graceful_reload require F-Stack bundled DPDK\n"); + } +#endif uint64_t hz = rte_get_timer_hz(); uint64_t intrs = US_PER_S / ff_global_cfg.freebsd.hz; uint64_t tsc = (hz + US_PER_S - 1) / US_PER_S * intrs;