mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-22 12:34:58 +02:00
ipset: update to 6.0
This commit is contained in:
@@ -43,8 +43,8 @@ static const uint16_t cmdflags[] = {
|
||||
[IPSET_CMD_FLUSH-1] = NLM_F_REQUEST|NLM_F_ACK,
|
||||
[IPSET_CMD_RENAME-1] = NLM_F_REQUEST|NLM_F_ACK,
|
||||
[IPSET_CMD_SWAP-1] = NLM_F_REQUEST|NLM_F_ACK,
|
||||
[IPSET_CMD_LIST-1] = NLM_F_REQUEST,
|
||||
[IPSET_CMD_SAVE-1] = NLM_F_REQUEST,
|
||||
[IPSET_CMD_LIST-1] = NLM_F_REQUEST|NLM_F_ACK,
|
||||
[IPSET_CMD_SAVE-1] = NLM_F_REQUEST|NLM_F_ACK,
|
||||
[IPSET_CMD_ADD-1] = NLM_F_REQUEST|NLM_F_ACK|NLM_F_EXCL,
|
||||
[IPSET_CMD_DEL-1] = NLM_F_REQUEST|NLM_F_ACK|NLM_F_EXCL,
|
||||
[IPSET_CMD_TEST-1] = NLM_F_REQUEST|NLM_F_ACK,
|
||||
@@ -83,7 +83,7 @@ ipset_mnl_fill_hdr(struct ipset_handle *handle, enum ipset_cmd cmd,
|
||||
nlh->nlmsg_flags = NLM_F_REQUEST;
|
||||
if (cmdflags[cmd-1] & NLM_F_ACK)
|
||||
nlh->nlmsg_flags |= NLM_F_ACK;
|
||||
nlh->nlmsg_seq = handle->seq = time(NULL);
|
||||
nlh->nlmsg_seq = ++handle->seq;
|
||||
|
||||
ghdr = mnl_nlmsg_put_extra_header(nlh, sizeof(struct genlmsghdr));
|
||||
ghdr->cmd = cmd;
|
||||
@@ -225,6 +225,7 @@ ipset_mnl_init(mnl_cb_t *cb_ctl, void *data)
|
||||
handle->portid = mnl_socket_get_portid(handle->h);
|
||||
handle->cb_ctl = cb_ctl;
|
||||
handle->data = data;
|
||||
handle->seq = time(NULL);
|
||||
|
||||
if (ipset_mnl_getid(handle, false) < 0)
|
||||
goto close_nl;
|
||||
|
@@ -1416,15 +1416,14 @@ ipset_parse_ignored(struct ipset_session *session,
|
||||
*/
|
||||
int
|
||||
ipset_call_parser(struct ipset_session *session,
|
||||
ipset_parsefn parse, const char *optstr,
|
||||
enum ipset_opt opt, const char *str)
|
||||
const struct ipset_arg *arg,
|
||||
const char *str)
|
||||
{
|
||||
if (ipset_data_flags_test(ipset_session_data(session),
|
||||
IPSET_FLAG(opt)))
|
||||
syntax_err("%s already specified", optstr);
|
||||
IPSET_FLAG(arg->opt)))
|
||||
syntax_err("%s already specified", arg->name[0]);
|
||||
|
||||
return parse(session, opt, parse == ipset_parse_ignored
|
||||
? optstr : str);
|
||||
return arg->parse(session, arg->opt, str);
|
||||
}
|
||||
|
||||
#define parse_elem(s, t, d, str) \
|
||||
|
@@ -158,7 +158,8 @@ __getnameinfo##f(char *buf, unsigned int len, \
|
||||
sizeof(saddr), \
|
||||
buf, len, NULL, 0, flags); \
|
||||
\
|
||||
if (err == EAI_AGAIN && !(flags & NI_NUMERICHOST)) \
|
||||
if (!(flags & NI_NUMERICHOST) && \
|
||||
(err == EAI_AGAIN || (err == 0 && strchr(buf, '-') != NULL))) \
|
||||
err = getnameinfo((const struct sockaddr *)&saddr, \
|
||||
sizeof(saddr), \
|
||||
buf, len, NULL, 0, \
|
||||
@@ -229,7 +230,7 @@ ipset_print_ip(char *buf, unsigned int len,
|
||||
D("CIDR: %u", cidr);
|
||||
} else
|
||||
cidr = family == AF_INET6 ? 128 : 32;
|
||||
flags = env & (1 << IPSET_ENV_RESOLVE) ? 0 : NI_NUMERICHOST;
|
||||
flags = (env & IPSET_ENV_RESOLVE) ? 0 : NI_NUMERICHOST;
|
||||
|
||||
ip = ipset_data_get(data, opt);
|
||||
assert(ip);
|
||||
@@ -296,7 +297,7 @@ ipset_print_ipaddr(char *buf, unsigned int len,
|
||||
cidr = *(const uint8_t *) ipset_data_get(data, cidropt);
|
||||
else
|
||||
cidr = family == AF_INET6 ? 128 : 32;
|
||||
flags = env & (1 << IPSET_ENV_RESOLVE) ? 0 : NI_NUMERICHOST;
|
||||
flags = (env & IPSET_ENV_RESOLVE) ? 0 : NI_NUMERICHOST;
|
||||
|
||||
ip = ipset_data_get(data, opt);
|
||||
assert(ip);
|
||||
|
@@ -441,13 +441,15 @@ ipset_type_add(struct ipset_type *type)
|
||||
|
||||
assert(type);
|
||||
|
||||
if (strlen(type->name) > IPSET_MAXNAMELEN - 1)
|
||||
return -EINVAL;
|
||||
|
||||
/* Add to the list: higher revision numbers first */
|
||||
for (t = typelist, prev = NULL; t != NULL; t = t->next) {
|
||||
if (STREQ(t->name, type->name)) {
|
||||
if (t->revision == type->revision) {
|
||||
errno = EEXIST;
|
||||
return -1;
|
||||
} else if (t->revision < type->revision) {
|
||||
if (t->revision == type->revision)
|
||||
return -EEXIST;
|
||||
else if (t->revision < type->revision) {
|
||||
type->next = t;
|
||||
if (prev)
|
||||
prev->next = type;
|
||||
@@ -457,10 +459,9 @@ ipset_type_add(struct ipset_type *type)
|
||||
}
|
||||
}
|
||||
if (t->next != NULL && STREQ(t->next->name, type->name)) {
|
||||
if (t->next->revision == type->revision) {
|
||||
errno = EEXIST;
|
||||
return -1;
|
||||
} else if (t->next->revision < type->revision) {
|
||||
if (t->next->revision == type->revision)
|
||||
return -EEXIST;
|
||||
else if (t->next->revision < type->revision) {
|
||||
type->next = t->next;
|
||||
t->next = type;
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user