Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions kernel-module/gen-rtpengine-kmod-flags
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,37 @@ if [ -z "${RTPENGINE_VERSION}" ]; then
fi
echo "RTPENGINE_VERSION := ${RTPENGINE_VERSION}"
fi

# Compile test: detect nft_expr_ops.validate callback signature.
# Distribution kernels (e.g. Ubuntu) may backport the 2-param validate
# callback (mainline commit eaf9b2c875ec, merged in 6.12) to earlier
# kernel versions without changing LINUX_VERSION_CODE. A compile test
# is the only reliable way to detect the actual API.
#
# The test tries to assign a 3-param function to .validate. If it
# compiles, the old API is present and we set the flag. If it fails
# (incompatible pointer types), the kernel has the new 2-param version.

# KERNELRELEASE is set by kbuild to the target kernel version, which
# may differ from the running kernel during DKMS cross-kernel builds.
KSRC="${KSRC:-/lib/modules/${KERNELRELEASE:-$(uname -r)}/build}"

if [ -d "${KSRC}" ]; then
nft_test_dir=$(mktemp -d)
cat > "${nft_test_dir}/nft_test.c" <<'TESTEOF'
#include <linux/module.h>
#include <net/netfilter/nf_tables.h>
static int test_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,
const struct nft_data **data) { return 0; }
static struct nft_expr_ops __attribute__((unused)) test_ops = {
.validate = test_validate };
MODULE_LICENSE("GPL");
TESTEOF
echo "obj-m := nft_test.o" > "${nft_test_dir}/Makefile"

if make -j1 -C "${KSRC}" M="${nft_test_dir}" modules >/dev/null 2>&1; then
echo "ccflags-y += -DNFT_EXPR_OPS_VALIDATE_HAS_DATA"
fi

rm -rf "${nft_test_dir}"
fi
2 changes: 1 addition & 1 deletion kernel-module/nft_rtpengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -6844,7 +6844,7 @@ static int rtpengine_expr_dump(struct sk_buff *skb, const struct nft_expr *expr
}

static int rtpengine_expr_validate(const struct nft_ctx *ctx, const struct nft_expr *expr
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,12,0)
#if defined(NFT_EXPR_OPS_VALIDATE_HAS_DATA)
, const struct nft_data **data
#endif
)
Expand Down