return NULL;
}
+
+bool
+fw3_check_ipset(struct fw3_ipset *set)
+{
+ bool rv = false;
+
+ socklen_t sz;
+ int s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
+ struct ip_set_req_version req_ver;
+ struct ip_set_req_get_set req_name;
+
+ if (s < 0 || fcntl(s, F_SETFD, FD_CLOEXEC))
+ goto out;
+
+ sz = sizeof(req_ver);
+ req_ver.op = IP_SET_OP_VERSION;
+
+ if (getsockopt(s, SOL_IP, SO_IP_SET, &req_ver, &sz))
+ goto out;
+
+ sz = sizeof(req_name);
+ req_name.op = IP_SET_OP_GET_BYNAME;
+ req_name.version = req_ver.version;
+ snprintf(req_name.set.name, IPSET_MAXNAMELEN - 1, "%s",
+ (set->external && *set->external) ? set->external : set->name);
+
+ if (getsockopt(s, SOL_IP, SO_IP_SET, &req_name, &sz))
+ goto out;
+
+ rv = ((sz == sizeof(req_name)) && (req_name.set.index != IPSET_INVALID_ID));
+
+out:
+ if (s >= 0)
+ close(s);
+
+ return rv;
+}
#ifndef __FW3_IPSETS_H
#define __FW3_IPSETS_H
+#include <linux/netfilter/ipset/ip_set.h>
+
#include "options.h"
#include "utils.h"
+
extern const struct fw3_option fw3_ipset_opts[];
struct fw3_ipset * fw3_alloc_ipset(void);
struct fw3_ipset * fw3_lookup_ipset(struct fw3_state *state, const char *name);
+bool fw3_check_ipset(struct fw3_ipset *set);
+
#define fw3_free_ipset(ipset) \
fw3_free_object(ipset, fw3_ipset_opts)
return;
}
+ if (!fw3_check_ipset(redir->_ipset))
+ {
+ info(" ! Skipping due to missing ipset '%s'",
+ (redir->_ipset->external && *redir->_ipset->external) ?
+ redir->_ipset->external : redir->_ipset->name);
+ return;
+ }
+
set(redir->_ipset->flags, family, family);
}
return;
}
+ if (!fw3_check_ipset(rule->_ipset))
+ {
+ info(" ! Skipping due to missing ipset '%s'",
+ (rule->_ipset->external && *rule->_ipset->external) ?
+ rule->_ipset->external : rule->_ipset->name);
+ return;
+ }
+
set(rule->_ipset->flags, family, family);
}