diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/expr/cmp.c | 10 | ||||
-rw-r--r-- | src/jansson.c | 9 | ||||
-rw-r--r-- | src/mxml.c | 11 |
3 files changed, 8 insertions, 22 deletions
diff --git a/src/expr/cmp.c b/src/expr/cmp.c index 63250f3..2c334ab 100644 --- a/src/expr/cmp.c +++ b/src/expr/cmp.c @@ -258,7 +258,7 @@ nft_rule_expr_cmp_snprintf_json(char *buf, size_t size, struct nft_expr_cmp *cmp { int len = size, offset = 0, ret; - ret = snprintf(buf, len, "\"sreg\":%u,\"op\":\"%s\",\"cmpdata\":{", + ret = snprintf(buf, len, "\"sreg\":%u,\"op\":\"%s\",", cmp->sreg, expr_cmp_str[cmp->op]); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); @@ -266,9 +266,6 @@ nft_rule_expr_cmp_snprintf_json(char *buf, size_t size, struct nft_expr_cmp *cmp NFT_OUTPUT_JSON, 0, DATA_VALUE); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - ret = snprintf(buf+offset, len, "}"); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - return offset; } @@ -277,7 +274,7 @@ nft_rule_expr_cmp_snprintf_xml(char *buf, size_t size, struct nft_expr_cmp *cmp) { int len = size, offset = 0, ret; - ret = snprintf(buf, len, "<sreg>%u</sreg><op>%s</op><cmpdata>", + ret = snprintf(buf, len, "<sreg>%u</sreg><op>%s</op>", cmp->sreg, expr_cmp_str[cmp->op]); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); @@ -285,9 +282,6 @@ nft_rule_expr_cmp_snprintf_xml(char *buf, size_t size, struct nft_expr_cmp *cmp) NFT_OUTPUT_XML, 0, DATA_VALUE); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - ret = snprintf(buf+offset, len, "</cmpdata>"); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - return offset; } diff --git a/src/jansson.c b/src/jansson.c index 5107eb5..affe8fe 100644 --- a/src/jansson.c +++ b/src/jansson.c @@ -215,13 +215,10 @@ int nft_jansson_data_reg_parse(json_t *root, const char *node_name, json_t *data; int ret; + /* It is necessary for the compatibility with cmpdata label. */ data = json_object_get(root, node_name); - if (data == NULL) { - err->error = NFT_PARSE_EMISSINGNODE; - err->node_name = node_name; - errno = EINVAL; - return -1; - } + if (data == NULL) + data = root; data = json_object_get(data, "data_reg"); if (data == NULL) { @@ -140,15 +140,10 @@ int nft_mxml_data_reg_parse(mxml_node_t *tree, const char *node_name, node = mxmlFindElement(tree, tree, node_name, NULL, NULL, MXML_DESCEND_FIRST); - if (node == NULL || node->child == NULL) { - if (!(flags & NFT_XML_OPT)) { - err->error = NFT_PARSE_EMISSINGNODE; - err->node_name = node_name; - errno = EINVAL; - } - return DATA_NONE; - } + /* It is necessary for the compatibility with cmpdata label. */ + if (node == NULL || node->child == NULL) + node = tree; return nft_data_reg_xml_parse(data_reg, node, err); } |