Skip to content

Commit

Permalink
ipset: drop ipset_nest_start() and ipset_nest_end()
Browse files Browse the repository at this point in the history
After the previous commit, both ipset_nest_start() and ipset_nest_end() are
just aliases for nla_nest_start() and nla_nest_end() so that there is no
need to keep them.

Signed-off-by: Michal Kubecek <[email protected]>
Acked-by: Jozsef Kadlecsik <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
mkubecek authored and davem330 committed Apr 27, 2019
1 parent ae0be8d commit 12ad5f6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 28 deletions.
11 changes: 4 additions & 7 deletions include/linux/netfilter/ipset/ip_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,33 +401,30 @@ ip_set_get_h16(const struct nlattr *attr)
return ntohs(nla_get_be16(attr));
}

#define ipset_nest_start(skb, attr) nla_nest_start(skb, attr)
#define ipset_nest_end(skb, start) nla_nest_end(skb, start)

static inline int nla_put_ipaddr4(struct sk_buff *skb, int type, __be32 ipaddr)
{
struct nlattr *__nested = ipset_nest_start(skb, type);
struct nlattr *__nested = nla_nest_start(skb, type);
int ret;

if (!__nested)
return -EMSGSIZE;
ret = nla_put_in_addr(skb, IPSET_ATTR_IPADDR_IPV4, ipaddr);
if (!ret)
ipset_nest_end(skb, __nested);
nla_nest_end(skb, __nested);
return ret;
}

static inline int nla_put_ipaddr6(struct sk_buff *skb, int type,
const struct in6_addr *ipaddrptr)
{
struct nlattr *__nested = ipset_nest_start(skb, type);
struct nlattr *__nested = nla_nest_start(skb, type);
int ret;

if (!__nested)
return -EMSGSIZE;
ret = nla_put_in6_addr(skb, IPSET_ATTR_IPADDR_IPV6, ipaddrptr);
if (!ret)
ipset_nest_end(skb, __nested);
nla_nest_end(skb, __nested);
return ret;
}

Expand Down
14 changes: 7 additions & 7 deletions net/netfilter/ipset/ip_set_bitmap_gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ mtype_head(struct ip_set *set, struct sk_buff *skb)
struct nlattr *nested;
size_t memsize = mtype_memsize(map, set->dsize) + set->ext_size;

nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
nested = nla_nest_start(skb, IPSET_ATTR_DATA);
if (!nested)
goto nla_put_failure;
if (mtype_do_head(skb, map) ||
Expand All @@ -109,7 +109,7 @@ mtype_head(struct ip_set *set, struct sk_buff *skb)
goto nla_put_failure;
if (unlikely(ip_set_put_flags(skb, set)))
goto nla_put_failure;
ipset_nest_end(skb, nested);
nla_nest_end(skb, nested);

return 0;
nla_put_failure:
Expand Down Expand Up @@ -213,7 +213,7 @@ mtype_list(const struct ip_set *set,
u32 id, first = cb->args[IPSET_CB_ARG0];
int ret = 0;

adt = ipset_nest_start(skb, IPSET_ATTR_ADT);
adt = nla_nest_start(skb, IPSET_ATTR_ADT);
if (!adt)
return -EMSGSIZE;
/* Extensions may be replaced */
Expand All @@ -230,7 +230,7 @@ mtype_list(const struct ip_set *set,
#endif
ip_set_timeout_expired(ext_timeout(x, set))))
continue;
nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
nested = nla_nest_start(skb, IPSET_ATTR_DATA);
if (!nested) {
if (id == first) {
nla_nest_cancel(skb, adt);
Expand All @@ -244,9 +244,9 @@ mtype_list(const struct ip_set *set,
goto nla_put_failure;
if (ip_set_put_extensions(skb, set, x, mtype_is_filled(x)))
goto nla_put_failure;
ipset_nest_end(skb, nested);
nla_nest_end(skb, nested);
}
ipset_nest_end(skb, adt);
nla_nest_end(skb, adt);

/* Set listing finished */
cb->args[IPSET_CB_ARG0] = 0;
Expand All @@ -259,7 +259,7 @@ mtype_list(const struct ip_set *set,
cb->args[IPSET_CB_ARG0] = 0;
ret = -EMSGSIZE;
}
ipset_nest_end(skb, adt);
nla_nest_end(skb, adt);
out:
rcu_read_unlock();
return ret;
Expand Down
14 changes: 7 additions & 7 deletions net/netfilter/ipset/ip_set_hash_gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ mtype_head(struct ip_set *set, struct sk_buff *skb)
htable_bits = t->htable_bits;
rcu_read_unlock_bh();

nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
nested = nla_nest_start(skb, IPSET_ATTR_DATA);
if (!nested)
goto nla_put_failure;
if (nla_put_net32(skb, IPSET_ATTR_HASHSIZE,
Expand All @@ -1079,7 +1079,7 @@ mtype_head(struct ip_set *set, struct sk_buff *skb)
goto nla_put_failure;
if (unlikely(ip_set_put_flags(skb, set)))
goto nla_put_failure;
ipset_nest_end(skb, nested);
nla_nest_end(skb, nested);

return 0;
nla_put_failure:
Expand Down Expand Up @@ -1124,7 +1124,7 @@ mtype_list(const struct ip_set *set,
void *incomplete;
int i, ret = 0;

atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
atd = nla_nest_start(skb, IPSET_ATTR_ADT);
if (!atd)
return -EMSGSIZE;

Expand All @@ -1150,7 +1150,7 @@ mtype_list(const struct ip_set *set,
continue;
pr_debug("list hash %lu hbucket %p i %u, data %p\n",
cb->args[IPSET_CB_ARG0], n, i, e);
nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
nested = nla_nest_start(skb, IPSET_ATTR_DATA);
if (!nested) {
if (cb->args[IPSET_CB_ARG0] == first) {
nla_nest_cancel(skb, atd);
Expand All @@ -1163,10 +1163,10 @@ mtype_list(const struct ip_set *set,
goto nla_put_failure;
if (ip_set_put_extensions(skb, set, e, true))
goto nla_put_failure;
ipset_nest_end(skb, nested);
nla_nest_end(skb, nested);
}
}
ipset_nest_end(skb, atd);
nla_nest_end(skb, atd);
/* Set listing finished */
cb->args[IPSET_CB_ARG0] = 0;

Expand All @@ -1180,7 +1180,7 @@ mtype_list(const struct ip_set *set,
cb->args[IPSET_CB_ARG0] = 0;
ret = -EMSGSIZE;
} else {
ipset_nest_end(skb, atd);
nla_nest_end(skb, atd);
}
out:
rcu_read_unlock();
Expand Down
14 changes: 7 additions & 7 deletions net/netfilter/ipset/ip_set_list_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ list_set_head(struct ip_set *set, struct sk_buff *skb)
struct nlattr *nested;
size_t memsize = list_set_memsize(map, set->dsize) + set->ext_size;

nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
nested = nla_nest_start(skb, IPSET_ATTR_DATA);
if (!nested)
goto nla_put_failure;
if (nla_put_net32(skb, IPSET_ATTR_SIZE, htonl(map->size)) ||
Expand All @@ -476,7 +476,7 @@ list_set_head(struct ip_set *set, struct sk_buff *skb)
goto nla_put_failure;
if (unlikely(ip_set_put_flags(skb, set)))
goto nla_put_failure;
ipset_nest_end(skb, nested);
nla_nest_end(skb, nested);

return 0;
nla_put_failure:
Expand All @@ -494,7 +494,7 @@ list_set_list(const struct ip_set *set,
struct set_elem *e;
int ret = 0;

atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
atd = nla_nest_start(skb, IPSET_ATTR_ADT);
if (!atd)
return -EMSGSIZE;

Expand All @@ -506,19 +506,19 @@ list_set_list(const struct ip_set *set,
i++;
continue;
}
nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
nested = nla_nest_start(skb, IPSET_ATTR_DATA);
if (!nested)
goto nla_put_failure;
ip_set_name_byindex(map->net, e->id, name);
if (nla_put_string(skb, IPSET_ATTR_NAME, name))
goto nla_put_failure;
if (ip_set_put_extensions(skb, set, e, true))
goto nla_put_failure;
ipset_nest_end(skb, nested);
nla_nest_end(skb, nested);
i++;
}

ipset_nest_end(skb, atd);
nla_nest_end(skb, atd);
/* Set listing finished */
cb->args[IPSET_CB_ARG0] = 0;
goto out;
Expand All @@ -531,7 +531,7 @@ list_set_list(const struct ip_set *set,
ret = -EMSGSIZE;
} else {
cb->args[IPSET_CB_ARG0] = i;
ipset_nest_end(skb, atd);
nla_nest_end(skb, atd);
}
out:
rcu_read_unlock();
Expand Down

0 comments on commit 12ad5f6

Please sign in to comment.