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 <wengzhe@xiaomi.com>
This commit is contained in:
Zhe Weng 2024-02-28 16:25:54 +08:00 committed by Xiang Xiao
parent bc68d954ad
commit 9fcde632a7

View File

@ -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;