From 9fcde632a77f43f024220227b5bafabe8f464ca9 Mon Sep 17 00:00:00 2001 From: Zhe Weng Date: Wed, 28 Feb 2024 16:25:54 +0800 Subject: [PATCH] netlib/iptables: Change matching to memcmp all related structs Compare both the struct ipt_ip, the match and the target, to support more entry types other than NAT entry. Signed-off-by: Zhe Weng --- netutils/netlib/netlib_iptables.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netutils/netlib/netlib_iptables.c b/netutils/netlib/netlib_iptables.c index a8579d86a..21331c9ad 100644 --- a/netutils/netlib/netlib_iptables.c +++ b/netutils/netlib/netlib_iptables.c @@ -515,9 +515,9 @@ int netlib_ipt_delete(FAR struct ipt_replace *repl, { if (e->next_offset == entry->next_offset && e->target_offset == entry->target_offset && - strcmp(e->ip.outiface, entry->ip.outiface) == 0 && - strcmp(IPT_TARGET(e)->u.user.name, - IPT_TARGET(entry)->u.user.name) == 0) + memcmp(&e->ip, &entry->ip, sizeof(struct ipt_ip)) == 0 && + memcmp(&e->elems, &entry->elems, + e->next_offset - offsetof(struct ipt_entry, elems)) == 0) { netlib_ipt_delete_internal(repl, e, hook); return OK;