diff options
author | Thomas Haller <thaller@redhat.com> | 2023-08-18 16:08:19 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-08-20 23:48:26 +0200 |
commit | 7076523e482110d59c4456f4a795581a2ca39c41 (patch) | |
tree | 9b1cf7707f110fd3402dae19419b17722f66dfd2 /src/rule.c | |
parent | 4646d656466b1f05bd765bbfb4d6d7bf1529bdbd (diff) |
nftutils: add and use wrappers for getprotoby{name,number}_r(), getservbyport_r()
We should aim to use the thread-safe variants of getprotoby{name,number}
and getservbyport(). However, they may not be available with other libc,
so it requires a configure check. As that is cumbersome, add wrappers
that do that at one place.
These wrappers are thread-safe, if libc provides the reentrant versions.
Use them.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/rule.c')
-rw-r--r-- | src/rule.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -27,6 +27,7 @@ #include <cache.h> #include <owner.h> #include <intervals.h> +#include "nftutils.h" #include <libnftnl/common.h> #include <libnftnl/ruleset.h> @@ -1666,10 +1667,10 @@ struct obj *obj_lookup_fuzzy(const char *obj_name, static void print_proto_name_proto(uint8_t l4, struct output_ctx *octx) { - const struct protoent *p = getprotobynumber(l4); + char name[NFT_PROTONAME_MAXSIZE]; - if (p) - nft_print(octx, "%s", p->p_name); + if (nft_getprotobynumber(l4, name, sizeof(name))) + nft_print(octx, "%s", name); else nft_print(octx, "%d", l4); } |