Currently, each protocol handler (TCP, TCP splice, ICMP/ping, UDP) has its own code to add or modify file descriptors in epoll. This leads to duplicated boilerplate across icmp.c, tcp.c, tcp_splice.c, and udp_flow.c, with each setting up epoll_ref unions and calling epoll_ctl() with flow-type-specific details. This series introduces flow_epoll_set() in flow.c to handle epoll operations for all flow types in a unified way. The function derives the epoll type from the flow type via a mapping array, providing a simpler interface where the caller only needs to pass the flow, command, events, file descriptor, and side index. The API is: int flow_epoll_set(const struct flow_common *f, int command, uint32_t events, int fd, unsigned int sidei); This centralized approach will be essential for queue pair migration in the upcoming multithreading work, where flows need to be moved between different epoll instances owned by different threads. Preparatory patches: - Patch 1 removes dead timer update code in tcp_epoll_ctl() - Patch 2 refactors TCP timer creation to use epoll_add() helper - Patch 3 removes unneeded epoll_ref indirection in udp_flow - Patch 4 refactors udp_flow_sock() to assign the socket internally - Patch 5 refactors tcp_splice_conn_epoll_events() to per-side computation Core patch: - Patch 6 introduces flow_epoll_set() used by all protocol handlers Changes in v3: - Added patch 2: "tcp: cleanup timer creation" refactoring tcp_timer_ctl() to use epoll_add() helper with improved error handling - Removed epoll type parameter from flow_epoll_set(): the type is now derived from the flow type via a new flow_epoll[] mapping array - Simplified function signature to flow_epoll_set(f, command, events, fd, sidei) - TCP timer no longer uses flow_epoll_set(), uses epoll_add() directly - Added Reviewed-by from David Gibson to patches 1 and 3 - Series now 6 patches (was 5) Changes in v2: - Added patch 1: Remove dead timer update in tcp_epoll_ctl() since flow table compaction was eliminated - Added patch 2: Remove unnecessary epoll_ref indirection in udp_flow.c - Dropped v1 patch 6 (compute events inside flow_epoll_set()) - Dropped v1 patch 7 (retrieve fd from flow structure) - Added epoll_ctl() command parameter (EPOLL_CTL_ADD/EPOLL_CTL_MOD) - Callers must set epollfd via flow_epollid_set() before calling flow_epoll_set() - Removed FLOW_EPOLL_TIMER_ADD/FLOW_EPOLL_TIMER_MOD constants - Reduced series from 7 to 5 patches Laurent Vivier (6): tcp: remove timer update in tcp_epoll_ctl() tcp: cleanup timer creation udp_flow: remove unneeded epoll_ref indirection udp_flow: Assign socket to flow inside udp_flow_sock() tcp_splice: Refactor tcp_splice_conn_epoll_events() to per-side computation flow: Introduce flow_epoll_set() to centralize epoll operations flow.c | 37 +++++++++++++++++ flow.h | 2 + icmp.c | 10 ++--- tcp.c | 88 ++++++++++++++++++++-------------------- tcp_splice.c | 111 +++++++++++++++++++++++---------------------------- udp_flow.c | 18 +++------ 6 files changed, 140 insertions(+), 126 deletions(-) -- 2.52.0