From f8bf9bbb38398434a6d3e880c3bc5ad40f295778 Mon Sep 17 00:00:00 2001 From: bol-van Date: Wed, 30 Oct 2024 09:01:14 +0300 Subject: [PATCH] nfqws,tpws: fix ipset reload if sets are empty --- nfq/ipset.c | 2 +- nfq/params.h | 1 + tpws/ipset.c | 2 +- tpws/params.h | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/nfq/ipset.c b/nfq/ipset.c index 7c7a4be..fec02ee 100644 --- a/nfq/ipset.c +++ b/nfq/ipset.c @@ -225,7 +225,7 @@ static bool IpsetCheck_(const struct ipset_collection_head *ips, const struct ip bool IpsetCheck(const struct desync_profile *dp, const struct in_addr *ipv4, const struct in6_addr *ipv6) { - if (PROFILE_IPSETS_EMPTY(dp)) return true; + if (PROFILE_IPSETS_ABSENT(dp)) return true; DLOG("* ipset check for profile %d\n",dp->n); return IpsetCheck_(&dp->ips_collection,&dp->ips_collection_exclude,ipv4,ipv6); } diff --git a/nfq/params.h b/nfq/params.h index 46c16df..e6ff5a6 100644 --- a/nfq/params.h +++ b/nfq/params.h @@ -80,6 +80,7 @@ struct desync_profile hostfail_pool *hostlist_auto_fail_counters; }; +#define PROFILE_IPSETS_ABSENT(dp) (!LIST_FIRST(&dp->ips_collection) && !LIST_FIRST(&dp->ips_collection_exclude)) #define PROFILE_IPSETS_EMPTY(dp) (ipset_collection_is_empty(&dp->ips_collection) && ipset_collection_is_empty(&dp->ips_collection_exclude)) #define PROFILE_HOSTLISTS_EMPTY(dp) (hostlist_collection_is_empty(&dp->hl_collection) && hostlist_collection_is_empty(&dp->hl_collection_exclude)) diff --git a/tpws/ipset.c b/tpws/ipset.c index 6a8e4c9..4cce327 100644 --- a/tpws/ipset.c +++ b/tpws/ipset.c @@ -225,7 +225,7 @@ static bool IpsetCheck_(const struct ipset_collection_head *ips, const struct ip bool IpsetCheck(const struct desync_profile *dp, const struct in_addr *ipv4, const struct in6_addr *ipv6) { - if (PROFILE_IPSETS_EMPTY(dp)) return true; + if (PROFILE_IPSETS_ABSENT(dp)) return true; VPRINT("* ipset check for profile %d\n",dp->n); return IpsetCheck_(&dp->ips_collection,&dp->ips_collection_exclude,ipv4,ipv6); } diff --git a/tpws/params.h b/tpws/params.h index 04ec7d9..4f30854 100644 --- a/tpws/params.h +++ b/tpws/params.h @@ -65,6 +65,7 @@ struct desync_profile hostfail_pool *hostlist_auto_fail_counters; }; +#define PROFILE_IPSETS_ABSENT(dp) (!LIST_FIRST(&dp->ips_collection) && !LIST_FIRST(&dp->ips_collection_exclude)) #define PROFILE_IPSETS_EMPTY(dp) (ipset_collection_is_empty(&dp->ips_collection) && ipset_collection_is_empty(&dp->ips_collection_exclude)) #define PROFILE_HOSTLISTS_EMPTY(dp) (hostlist_collection_is_empty(&dp->hl_collection) && hostlist_collection_is_empty(&dp->hl_collection_exclude))