path: root/src/set.c
diff options
authorPablo Neira Ayuso <>2013-07-26 15:56:37 +0200
committerPablo Neira Ayuso <>2013-07-26 16:15:51 +0200
commit2d16da839c46428c546d3ff372d919236920ead1 (patch)
treefd92c20dae6f07eb6f62493f15cda3dc5d44f899 /src/set.c
parent44928cd546f00a73797a570dcaee44f0bfe5bea7 (diff)
src: remove version from XML and JSON representations
This patch removes the version XML node and the version JSON field in all our existing objects. The current versioning approach consists of adding a version field to every object representation in XML and JSON. While listing my entire rule-set, one can notice that this approach is too bloated. Once the library enters stable stage, if we need to obsolete a XML node and a JSON field, we can follow this procedure: 1) Remove the XML node and the JSON field from the output, so fresh outputs will not contain the old ones anymore. 2) Do not remove the parsing of the old XML node and the JSON field inmediately. We have to keep supporting the parsing for a while to avoid breaking the interpretion of old XML/JSON files. We can spot a warning to warn about it, so users generate a fresh output again. Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'src/set.c')
1 files changed, 3 insertions, 12 deletions
diff --git a/src/set.c b/src/set.c
index 4b0ec6a..23a2ab1 100644
--- a/src/set.c
+++ b/src/set.c
@@ -311,7 +311,6 @@ static int nft_set_xml_parse(struct nft_set *s, char *xml)
struct nft_set_elem *elem;
char *name;
char *table;
- int version;
int family;
char *family_str;
@@ -324,13 +323,6 @@ static int nft_set_xml_parse(struct nft_set *s, char *xml)
if (strcmp(tree->value.opaque, "set") != 0)
goto err;
- if (nft_mxml_num_parse(tree, "set_xml_version", MXML_DESCEND_FIRST,
- BASE_DEC, &version, NFT_TYPE_S32) != 0)
- goto err;
- if (version != NFT_SET_XML_VERSION)
- goto err;
name = (char *)nft_mxml_str_parse(tree, "set_name",
if (name == NULL)
@@ -448,10 +440,10 @@ static int nft_set_snprintf_json(char *buf, size_t size, struct nft_set *s,
struct nft_set_elem *elem;
ret = snprintf(buf, size, "{ \"set\": { \"name\": \"%s\","
- "\"table\": \"%s\",\"version\": %d,"
+ "\"table\": \"%s\","
"\"flags\": %u,\"family\": \"%s\","
"\"key_type\": %u,\"key_len\": %u",
- s->name, s->table, NFT_SET_JSON_VERSION, s->set_flags,
+ s->name, s->table, s->set_flags,
nft_family2str(s->family), s->key_type, s->key_len);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
@@ -529,14 +521,13 @@ static int nft_set_snprintf_xml(char *buf, size_t size, struct nft_set *s,
ret = snprintf(buf, size, "<set><family>%s</family>"
- "<set_xml_version>%d</set_xml_version>"
nft_family2str(s->family), s->table, s->name,
- NFT_SET_XML_VERSION, s->set_flags, s->key_type,
+ s->set_flags, s->key_type,
s->key_len, s->data_type, s->data_len);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);