From 838915373efe11e388e57703e9733e42f42bd5da Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 18 Aug 2014 17:43:28 +0200 Subject: src: don't return error in netlink_linearize_rule() This function converts the rule from the list of statements to the netlink message format. The only two possible errors that can make this function to fail are memory exhaustion and malformed statements which inmediately stop the execution of nft. Signed-off-by: Pablo Neira Ayuso --- src/netlink.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/netlink.c') diff --git a/src/netlink.c b/src/netlink.c index dc7a7c4b..102f799a 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -354,16 +354,14 @@ int netlink_add_rule_batch(struct netlink_ctx *ctx, int err; nlr = alloc_nft_rule(&rule->handle); - err = netlink_linearize_rule(ctx, nlr, rule); - if (err == 0) { - err = mnl_nft_rule_batch_add(nlr, flags | NLM_F_EXCL, - ctx->seqnum); - if (err < 0) - netlink_io_error(ctx, &rule->location, - "Could not add rule to batch: %s", - strerror(errno)); - } + netlink_linearize_rule(ctx, nlr, rule); + err = mnl_nft_rule_batch_add(nlr, flags | NLM_F_EXCL, ctx->seqnum); nft_rule_free(nlr); + if (err < 0) { + netlink_io_error(ctx, &rule->location, + "Could not add rule to batch: %s", + strerror(errno)); + } return err; } -- cgit v1.2.3