It changes the parse functions to omit unset values. Now, It possible to use a xml file like this: [...] { "type": "nat", "nat_type": "snat", "family": "ip", "sreg_addr_min": 1, "sreg_addr_max": 1, } Signed-off-by: Ana Rey <anarey@xxxxxxxxx> --- src/expr/nat.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/expr/nat.c b/src/expr/nat.c index c10f0ff..0136fca 100644 --- a/src/expr/nat.c +++ b/src/expr/nat.c @@ -225,28 +225,20 @@ static int nft_rule_expr_nat_json_parse(struct nft_rule_expr *e, json_t *root, nft_rule_expr_set_u32(e, NFT_EXPR_NAT_FAMILY, val32); if (nft_jansson_parse_reg(root, "sreg_addr_min", NFT_TYPE_U32, - ®, err) < 0) - return -1; - - nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_ADDR_MIN, reg); + ®, err) == 0) + nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_ADDR_MIN, reg); if (nft_jansson_parse_reg(root, "sreg_addr_max", NFT_TYPE_U32, - ®, err) < 0) - return -1; - - nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_ADDR_MAX, reg); + ®, err) == 0) + nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_ADDR_MAX, reg); if (nft_jansson_parse_reg(root, "sreg_proto_min", NFT_TYPE_U32, - ®, err) < 0) - return -1; - - nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_PROTO_MIN, reg); + ®, err) == 0) + nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_PROTO_MIN, reg); if (nft_jansson_parse_reg(root, "sreg_proto_max", NFT_TYPE_U32, - ®, err) < 0) - return -1; - - nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_PROTO_MAX, reg); + ®, err) == 0) + nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_PROTO_MAX, reg); return 0; #else -- 2.0.0 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html