Skip to contentSkip to conversation

set_elem: don't add NFTA_SET_ELEM_LIST_ELEMENTS attribute if set is empty

PATCH New Pablo Neira Ayuso 1 participant 1 message Oct 17, 2016 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 set_elem: don't add NFTA_SET_ELEM_LIST_ELEMENTS attribute if set is empty

If the set is empty, don't send an empty NFTA_SET_ELEM_LIST_ELEMENTS netlink attributes with no elements.

---
 src/set_elem.c | 3 +++
 1 file changed, 3 insertions(+)
src/set_elem.c +3 -0
index 46fb7c6e424b..4d2b4f6074b7 100644
@@ -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);
Signature · 1 line
2.1.4