diff --git a/backport-nftables-iproute2-config-path-adapt.patch b/backport-nftables-iproute2-config-path-adapt.patch new file mode 100644 index 0000000000000000000000000000000000000000..8a570db27e61509b282f9720db955d79a77705bf --- /dev/null +++ b/backport-nftables-iproute2-config-path-adapt.patch @@ -0,0 +1,123 @@ +From 3c997b0d77e59b9ea078f4f066b472e92025b7f4 Mon Sep 17 00:00:00 2001 +From: hdliu +Date: Tue, 19 Aug 2025 11:21:00 +0800 +Subject: [PATCH] datatype: Adapt iproute2 config path search to + /usr/share/iproute2 + +Signed-off-by: hdliu +--- + src/datatype.c | 38 ++++++++++++++++++++++++++++++++++---- + src/meta.c | 2 +- + src/rt.c | 2 +- + 3 files changed, 36 insertions(+), 6 deletions(-) + +diff --git a/src/datatype.c b/src/datatype.c +index f3e992b..4abadf4 100644 +--- a/src/datatype.c ++++ b/src/datatype.c +@@ -834,19 +834,47 @@ const struct datatype inet_service_type = { + + #define RT_SYM_TAB_INITIAL_SIZE 16 + ++static FILE *open_iproute2_db(const char *filename, char **path) ++{ ++ FILE *ret; ++ ++ if (filename[0] == '/') ++ return fopen(filename, "r"); ++ ++ if (asprintf(path, "/etc/iproute2/%s", filename) == -1) ++ goto fail; ++ ++ ret = fopen(*path, "r"); ++ if (ret) ++ return ret; ++ ++ free(*path); ++ if (asprintf(path, "/usr/share/iproute2/%s", filename) == -1) ++ goto fail; ++ ++ ret = fopen(*path, "r"); ++ if (ret) ++ return ret; ++ ++ free(*path); ++fail: ++ *path = NULL; ++ return NULL; ++} ++ + struct symbol_table *rt_symbol_table_init(const char *filename) + { ++ char buf[512], namebuf[512], *p, *path = NULL; + struct symbolic_constant s; + struct symbol_table *tbl; + unsigned int size, nelems, val; +- char buf[512], namebuf[512], *p; + FILE *f; + + size = RT_SYM_TAB_INITIAL_SIZE; + tbl = xmalloc(sizeof(*tbl) + size * sizeof(s)); + nelems = 0; + +- f = fopen(filename, "r"); ++ f = open_iproute2_db(filename, &path); + if (f == NULL) + goto out; + +@@ -861,7 +889,7 @@ struct symbol_table *rt_symbol_table_init(const char *filename) + sscanf(p, "%u %511s\n", &val, namebuf) != 2 && + sscanf(p, "%u %511s #", &val, namebuf) != 2) { + fprintf(stderr, "iproute database '%s' corrupted\n", +- filename); ++ path ?: filename); + break; + } + +@@ -878,6 +906,8 @@ struct symbol_table *rt_symbol_table_init(const char *filename) + + fclose(f); + out: ++ if (path) ++ free(path); + tbl->symbols[nelems] = SYMBOL_LIST_END; + return tbl; + } +@@ -893,7 +923,7 @@ void rt_symbol_table_free(const struct symbol_table *tbl) + + void mark_table_init(struct nft_ctx *ctx) + { +- ctx->output.tbl.mark = rt_symbol_table_init("/etc/iproute2/rt_marks"); ++ ctx->output.tbl.mark = rt_symbol_table_init("rt_marks"); + } + + void mark_table_exit(struct nft_ctx *ctx) +diff --git a/src/meta.c b/src/meta.c +index 011662f..b1c0007 100644 +--- a/src/meta.c ++++ b/src/meta.c +@@ -329,7 +329,7 @@ const struct datatype pkttype_type = { + + void devgroup_table_init(struct nft_ctx *ctx) + { +- ctx->output.tbl.devgroup = rt_symbol_table_init("/etc/iproute2/group"); ++ ctx->output.tbl.devgroup = rt_symbol_table_init("group"); + } + + void devgroup_table_exit(struct nft_ctx *ctx) +diff --git a/src/rt.c b/src/rt.c +index d7aa5ed..82f06e0 100644 +--- a/src/rt.c ++++ b/src/rt.c +@@ -26,7 +26,7 @@ + + void realm_table_rt_init(struct nft_ctx *ctx) + { +- ctx->output.tbl.realm = rt_symbol_table_init("/etc/iproute2/rt_realms"); ++ ctx->output.tbl.realm = rt_symbol_table_init("rt_realms"); + } + + void realm_table_rt_exit(struct nft_ctx *ctx) +-- +2.33.0 + diff --git a/nftables.spec b/nftables.spec index c9f85cc229d1843f4eefbd81f86a2be8d8778ea5..9fa494d6fff7ad152649c1c37f7e8bbe6dcec068 100644 --- a/nftables.spec +++ b/nftables.spec @@ -1,6 +1,6 @@ Name: nftables Version: 1.0.8 -Release: 7 +Release: 8 Epoch: 1 Summary: A subsystem of the Linux kernel processing network data License: GPLv2 @@ -73,6 +73,7 @@ Patch0058: backport-parser_json-fix-crash-in-json_parse_set_stmt_list.patch Patch0059: backport-parser_json-fix-handle-memleak-from-error-path.patch Patch0060: backport-parser_json-fix-several-expression-memleaks-from-error-path.patch Patch0061: backport-libnftables-Zero-ctx-vars-after-freeing-it.patch +Patch0062: backport-nftables-iproute2-config-path-adapt.patch BuildRequires: gcc flex bison libmnl-devel gmp-devel readline-devel libnftnl-devel docbook2X systemd BuildRequires: iptables-devel jansson-devel python3-devel @@ -172,6 +173,12 @@ echo "%{_libdir}" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf %{python3_sitelib}/nftables/ %changelog +* Fri Aug 22 2025 hdliu - 1:1.0.8-8 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:backport upstream patch to adapt iproute2 config path datatype: adjust rt_symbol_table_init() to search /usr/share/iproute2 update paths for rt_marks, group and rt_realms + * Wed Dec 11 2024 gaihuiying - 1:1.0.8-7 - Type:bugfix - CVE:NA