Repository navigation
feat(api): add ff_set_auto_cleanup() and ff_cleanup() for deferred EA… - #1103
Open
code-agree wants to merge 1 commit into
Open
code-agree wants to merge 1 commit into
code-agree wants to merge 1 commit into
Conversation
…L teardown ff_dpdk_run() currently tears down config and DPDK EAL before returning to the caller, which can invalidate resources if the application closes BSD sockets or epoll fds after ff_run() returns (e.g., C++ RAII). Keep the default behavior unchanged (auto-cleanup enabled), and expose ff_set_auto_cleanup(int) plus an idempotent ff_cleanup() so applications can explicitly control teardown ordering while preserving primary_slim semantics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
ff_set_auto_cleanup(int enable)and idempotentff_cleanup(void)so applications can close BSD sockets and epoll fds afterff_run()returns before tearing down config and DPDK EAL, while keeping the defaultff_run()behavior 100% backward-compatible.
Motivation
In F-Stack 2.0,
ff_dpdk_run()runsff_unload_config(),rte_eal_cleanup(), andff_log_close()before returning. In default mode, DPDK queues and EAL are already released before the caller can invokeff_close()on itssockets/epoll fds (for example, in C++ RAII destructors).
Changes
lib/ff_api.h/lib/ff_init.c/lib/ff_dpdk_if.h: Exposeff_set_auto_cleanup(int enable)andff_cleanup(void)following the existingff_init/ff_run/ff_stop_runlayering.lib/ff_dpdk_if.c:ff_auto_cleanup = 1(zero behavioral change for existing callers).ff_dpdk_cleanup(), preserving the existingprimary_slim && RTE_PROC_PRIMARYguard and returningrte_eal_cleanup()'s status.Verification
Built
libfstack.acleanly with GCC 15.1.0 (-Wall -Wextra -Werror), verified exported symbols vianm, and ran a live AWS ENA reproducer (ff_init -> ff_epoll_create + ff_socket -> ff_run/ff_stop_run -> ff_close -> ff_cleanup):auto_cleanup=1) — DPDK queues are released beforeff_run()returns: