From: Ana Rey <anarey@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: Ana Rey <anarey@gmail.com>
Subject: [libnftnl PATCH 3/6] src: chain: add set, unset, get, parse and build payload implementation for use value
Date: Thu, 26 Jun 2014 18:38:57 +0200 [thread overview]
Message-ID: <1403800740-10572-4-git-send-email-anarey@gmail.com> (raw)
In-Reply-To: <1403800740-10572-1-git-send-email-anarey@gmail.com>
Add some parts of the implemention of 'use' vualue in chain that miss it.
These changes are neeeded for a correct import/export of xml/json file
Signed-off-by: Ana Rey <anarey@gmail.com>
---
src/chain.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/chain.c b/src/chain.c
index 9e9f207..f01abb9 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -115,8 +115,7 @@ void nft_chain_attr_unset(struct nft_chain *c, uint16_t attr)
}
break;
case NFT_CHAIN_ATTR_USE:
- /* cannot be unset?, ignore it */
- return;
+ break;
case NFT_CHAIN_ATTR_TYPE:
if (c->type) {
xfree(c->type);
@@ -178,8 +177,8 @@ void nft_chain_attr_set_data(struct nft_chain *c, uint16_t attr,
c->policy = *((uint32_t *)data);
break;
case NFT_CHAIN_ATTR_USE:
- /* cannot be set, ignore it */
- return;
+ c->use = *((uint32_t *)data);
+ break;
case NFT_CHAIN_ATTR_BYTES:
c->bytes = *((uint64_t *)data);
break;
@@ -356,6 +355,8 @@ void nft_chain_nlmsg_build_payload(struct nlmsghdr *nlh, const struct nft_chain
}
if (c->flags & (1 << NFT_CHAIN_ATTR_POLICY))
mnl_attr_put_u32(nlh, NFTA_CHAIN_POLICY, htonl(c->policy));
+ if (c->flags & (1 << NFT_CHAIN_ATTR_USE))
+ mnl_attr_put_u32(nlh, NFTA_CHAIN_USE, htonl(c->use));
if ((c->flags & (1 << NFT_CHAIN_ATTR_PACKETS)) &&
(c->flags & (1 << NFT_CHAIN_ATTR_BYTES))) {
struct nlattr *nest;
@@ -566,7 +567,7 @@ int nft_jansson_parse_chain(struct nft_chain *c, json_t *tree,
json_t *root;
uint64_t uval64;
int policy;
- int32_t val32;
+ int32_t val32, use;
const char *valstr;
root = nft_jansson_get_node(tree, "chain", err);
@@ -609,6 +610,9 @@ int nft_jansson_parse_chain(struct nft_chain *c, json_t *tree,
nft_chain_attr_set_str(c, NFT_CHAIN_ATTR_TABLE, valstr);
+ if (nft_jansson_parse_val(root, "use", NFT_TYPE_U32, &use, err) == 0)
+ nft_chain_attr_set_u32(c, NFT_CHAIN_ATTR_USE, use);
+
if (nft_jansson_node_exist(root, "hooknum")) {
valstr = nft_jansson_parse_str(root, "type", err);
--
2.0.0
next prev parent reply other threads:[~2014-06-26 16:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-26 16:38 [libnftnl PATCH 0/6] src: chain: Do not print unset values in json and xml Ana Rey
2014-06-26 16:38 ` [libnftnl PATCH 1/6] src: chain: Free memory in the same function that is reserved Ana Rey
2014-06-30 10:42 ` Pablo Neira Ayuso
2014-06-26 16:38 ` [libnftnl PATCH 2/6] src: chain: Use nft_rule_expr_set_* in the xml parsing code Ana Rey
2014-06-30 10:42 ` Pablo Neira Ayuso
2014-06-26 16:38 ` Ana Rey [this message]
2014-06-30 10:42 ` [libnftnl PATCH 3/6] src: chain: add set, unset, get, parse and build payload implementation for use value Pablo Neira Ayuso
2014-06-26 16:38 ` [libnftnl PATCH 4/6] src: chain: Do not print unset values in xml Ana Rey
2014-06-26 16:38 ` [libnftnl PATCH 5/6] src: chain: Rename variables in nft_jansson_parse_chain functions Ana Rey
2014-06-26 16:39 ` [libnftnl PATCH 6/6] src: chain: Do not print unser values in json Ana Rey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403800740-10572-4-git-send-email-anarey@gmail.com \
--to=anarey@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).