Skip to content

Commit 78650b5

Browse files
Tomaz Zamanigorpecovnik
authored andcommitted
gateway-dk-ask: use explicit xtables module list in build and packaging
Replace the libxt_*.c glob in the build step and libxt_qos*/libxt_QOS* glob in the packaging step with a single explicit list of module names. Both steps now reference the same ask_xtables_modules array, so adding or removing a module requires updating only one place per function. The packaging step now errors out if any expected .so is missing instead of silently skipping it. Also document why we don't use pkg-config for libxtables: these are dlopen()-loaded extensions that don't link against libxtables.so and use our local UAPI headers (xt_QOSMARK.h etc.) which aren't in libxtables-dev.
1 parent 881f982 commit 78650b5

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

extensions/gateway-dk-ask.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,18 +272,25 @@ function pre_customize_image__001_build_ask_userspace() {
272272
cp "${ASK_CACHE_DIR}/${ASK_DPA_APP_DIR}/files/etc/cdx_sp.xml" "${SDCARD}/etc/"
273273

274274
# --- xtables extensions (standalone .so files, not patching iptables) ---
275+
# Note: we don't use pkg-config for libxtables here. These are dlopen()-loaded
276+
# extensions — they don't link against libxtables.so, they use symbols resolved
277+
# from the iptables process that loads them. The -I./include picks up our local
278+
# xt_QOSMARK.h etc. UAPI headers which aren't in libxtables-dev (they're our
279+
# additions). Adding -lxtables would cause duplicate symbol issues at load time.
280+
local ask_xtables_modules=(libxt_qosmark libxt_QOSMARK libxt_qosconnmark libxt_QOSCONNMARK)
275281
display_alert "ASK extension" "building xtables extensions" "info"
276282
cp -a "${ASK_CACHE_DIR}/iptables-extensions" "${SDCARD}/tmp/ask-userspace/iptables-extensions"
277283
chroot_sdcard "cd /tmp/ask-userspace/iptables-extensions && \
278-
for src in libxt_*.c; do \
279-
name=\"\${src%.c}\"; \
284+
for name in ${ask_xtables_modules[*]}; do \
280285
gcc -shared -fPIC -O2 \
281286
-D_init=\${name}_init \
282287
-I./include \
283-
-o \"\${name}.so\" \"\${src}\" || exit 1; \
288+
-o \"\${name}.so\" \"\${name}.c\" || exit 1; \
284289
done && \
285290
install -d /usr/lib/${ASK_HOST_TRIPLET}/xtables && \
286-
install -m 644 libxt_*.so /usr/lib/${ASK_HOST_TRIPLET}/xtables/" \
291+
for name in ${ask_xtables_modules[*]}; do \
292+
install -m 644 \"\${name}.so\" /usr/lib/${ASK_HOST_TRIPLET}/xtables/ || exit 1; \
293+
done" \
287294
|| exit_with_error "xtables extensions build failed"
288295

289296
# --- Patched system libraries (must be before CMM which depends on patched libnetfilter-conntrack) ---
@@ -376,11 +383,13 @@ function pre_customize_image__001_build_ask_userspace() {
376383
done
377384
done
378385

379-
# xtables extensions (QOSMARK/QOSCONNMARK)
386+
# xtables extensions — use the same explicit list as the build step
387+
local ask_xtables_modules=(libxt_qosmark libxt_QOSMARK libxt_qosconnmark libxt_QOSCONNMARK)
380388
mkdir -p "${pkgdir}/usr/lib/${ASK_HOST_TRIPLET}/xtables"
381-
for f in "${SDCARD}/usr/lib/${ASK_HOST_TRIPLET}/xtables/"libxt_qos*.so \
382-
"${SDCARD}/usr/lib/${ASK_HOST_TRIPLET}/xtables/"libxt_QOS*.so; do
383-
[[ -f "$f" ]] && cp -a "$f" "${pkgdir}/usr/lib/${ASK_HOST_TRIPLET}/xtables/"
389+
for name in "${ask_xtables_modules[@]}"; do
390+
local src="${SDCARD}/usr/lib/${ASK_HOST_TRIPLET}/xtables/${name}.so"
391+
[[ -f "${src}" ]] || exit_with_error "xtables extension missing" "${name}.so"
392+
cp -a "${src}" "${pkgdir}/usr/lib/${ASK_HOST_TRIPLET}/xtables/"
384393
done
385394

386395
# Version: kernel version + build date — allows bugfix rebuilds without kernel change

0 commit comments

Comments
 (0)