Skip to contentSkip to conversation

examples: nft-rule-parse-add: fix wrong buffer usage when building rule header

PATCH In review Arturo Borrero Gonzalez 2 participants 2 messages Nov 17, 2014 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples: nft-rule-parse-add: fix wrong buffer usage when building rule header

The libmnl helper returns a pointer where to start putting the rule data.

---
 examples/nft-rule-parse-add.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
examples/nft-rule-parse-add.c +2 -1
index 4160435..75f5268 100644
@@ -122,7 +122,8 @@ int main(int argc, char *argv[])
 
 	rule_seq = seq;
 	family = nft_rule_attr_get_u32(r, NFT_RULE_ATTR_FAMILY);
-	nlh = nft_rule_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, family,
+	nlh = nft_rule_nlmsg_build_hdr(mnl_nlmsg_batch_current(batch),
+				       NFT_MSG_NEWRULE, family,
 				       NLM_F_CREATE|NLM_F_APPEND|NLM_F_ACK,
 				       seq++);
 	nft_rule_nlmsg_build_payload(nlh, r);
#1 lore raw
Quoted 1 line · Arturo Borrero Gonzalez

The libmnl helper returns a pointer where to start putting the rule data.

Thanks Arturo.

I think it would be good to get rid of the -parse-* examples and replace them by one using the ruleset API.