From 50b0efa58ad07c534e8e4862bcf5f3f83b36113d Mon Sep 17 00:00:00 2001 From: Christian Deacon Date: Sat, 22 Feb 2025 10:02:35 -0500 Subject: [PATCH] Add note about linked objects not working with __always_inline functions. --- src/xdp/utils/helpers.h | 2 ++ src/xdp/utils/rl.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/xdp/utils/helpers.h b/src/xdp/utils/helpers.h index dbd3992..82eaab6 100644 --- a/src/xdp/utils/helpers.h +++ b/src/xdp/utils/helpers.h @@ -30,4 +30,6 @@ static __always_inline u8 IsIpInRange(u32 src_ip, u32 net_ip, u8 cidr); +// NOTE: We include the C source file below because we can't link object files which includes the function logic into the main XDP program because we need to ensure the function is always inlined for performance which doesn't work with linked objects. +// More Info: https://stackoverflow.com/questions/24289599/always-inline-does-not-work-when-function-is-implemented-in-different-file #include "helpers.c" \ No newline at end of file diff --git a/src/xdp/utils/rl.h b/src/xdp/utils/rl.h index f1b9c92..8b98c10 100644 --- a/src/xdp/utils/rl.h +++ b/src/xdp/utils/rl.h @@ -9,4 +9,6 @@ static __always_inline void UpdateIpStats(__u64 *pps, __u64 *bps, u32 ip, u16 port, u8 protocol, u16 pkt_len, __u64 now); static __always_inline void UpdateIp6Stats(__u64 *pps, __u64 *bps, u128 *ip, u16 port, u8 protocol, u16 pkt_len, __u64 now); +// NOTE: We include the C source file below because we can't link object files which includes the function logic into the main XDP program because we need to ensure the function is always inlined for performance which doesn't work with linked objects. +// More Info: https://stackoverflow.com/questions/24289599/always-inline-does-not-work-when-function-is-implemented-in-different-file #include "rl.c" \ No newline at end of file