]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
set_elem: don't add NFTA_SET_ELEM_LIST_ELEMENTS attribute if set is empty
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 4 Oct 2016 06:48:37 +0000 (08:48 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 17 Oct 2016 15:51:55 +0000 (17:51 +0200)
If the set is empty, don't send an empty NFTA_SET_ELEM_LIST_ELEMENTS
netlink attributes with no elements.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/set_elem.c

index 46fb7c6e424bc2ff2f89122d0f2a046b9f3717cf..4d2b4f6074b7c729d66f2e8ba1b705194309cbc6 100644 (file)
@@ -304,6 +304,9 @@ void nftnl_set_elems_nlmsg_build_payload(struct nlmsghdr *nlh, struct nftnl_set
 
        nftnl_set_elem_nlmsg_build_def(nlh, s);
 
+       if (list_empty(&s->element_list))
+               return;
+
        nest1 = mnl_attr_nest_start(nlh, NFTA_SET_ELEM_LIST_ELEMENTS);
        list_for_each_entry(elem, &s->element_list, head)
                nftnl_set_elem_build(nlh, elem, ++i);