From: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
To: netfilter-devel@vger.kernel.org
Cc: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Subject: [libnftables PATCH 6/7] expr: add support for expr list and capability to add it into a rule
Date: Tue, 14 May 2013 13:51:21 +0300 [thread overview]
Message-ID: <1368528682-10041-7-git-send-email-tomasz.bursztyka@linux.intel.com> (raw)
In-Reply-To: <1368528682-10041-1-git-send-email-tomasz.bursztyka@linux.intel.com>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
---
include/libnftables/expr.h | 7 +++++++
include/libnftables/rule.h | 3 +++
src/expr.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
src/internal.h | 4 ++++
src/libnftables.map | 5 +++++
src/rule.c | 12 ++++++++++++
6 files changed, 76 insertions(+)
diff --git a/include/libnftables/expr.h b/include/libnftables/expr.h
index d899e41..4d789b4 100644
--- a/include/libnftables/expr.h
+++ b/include/libnftables/expr.h
@@ -27,6 +27,13 @@ uint32_t nft_rule_expr_get_u32(struct nft_rule_expr *expr, uint16_t type);
uint64_t nft_rule_expr_get_u64(struct nft_rule_expr *expr, uint16_t type);
const char *nft_rule_expr_get_str(struct nft_rule_expr *expr, uint16_t type);
+struct nft_rule_expr_list;
+
+struct nft_rule_expr_list *nft_rule_expr_list_alloc(void);
+void nft_rule_expr_list_free(struct nft_rule_expr_list *list);
+void nft_rule_expr_list_add(struct nft_rule_expr *expr, struct nft_rule_expr_list *list);
+void nft_rule_expr_list_add_list(struct nft_rule_expr_list *to_add, struct nft_rule_expr_list *list);
+
void nft_rule_expr_build_payload(struct nlmsghdr *nlh, struct nft_rule_expr *expr);
enum {
diff --git a/include/libnftables/rule.h b/include/libnftables/rule.h
index e7396a4..5c713ce 100644
--- a/include/libnftables/rule.h
+++ b/include/libnftables/rule.h
@@ -36,6 +36,9 @@ uint64_t nft_rule_attr_get_u64(struct nft_rule *r, uint16_t attr);
void nft_rule_add_expr(struct nft_rule *r, struct nft_rule_expr *expr);
+struct nft_rule_expr_list;
+void nft_rule_add_expr_list(struct nft_rule *r, struct nft_rule_expr_list *list);
+
void nft_rule_nlmsg_build_payload(struct nlmsghdr *nlh, struct nft_rule *t);
enum {
diff --git a/src/expr.c b/src/expr.c
index 0b06aed..c73ac81 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -172,6 +172,51 @@ const char *nft_rule_expr_get_str(struct nft_rule_expr *expr, uint16_t type)
}
EXPORT_SYMBOL(nft_rule_expr_get_str);
+struct nft_rule_expr_list *nft_rule_expr_list_alloc(void)
+{
+ struct nft_rule_expr_list *list;
+
+ list = calloc(1, sizeof(struct nft_rule_expr_list));
+ if (list == NULL)
+ return NULL;
+
+ INIT_LIST_HEAD(&list->list);
+
+ return list;
+}
+EXPORT_SYMBOL(nft_rule_expr_list_alloc);
+
+void nft_rule_expr_list_free(struct nft_rule_expr_list *list)
+{
+ struct nft_rule_expr *e, *tmp;
+
+ list_for_each_entry_safe(e, tmp, &list->list, head) {
+ list_del(&e->head);
+ nft_rule_expr_free(e);
+ }
+ free(list);
+}
+EXPORT_SYMBOL(nft_rule_expr_list_free);
+
+void nft_rule_expr_list_add(struct nft_rule_expr *expr,
+ struct nft_rule_expr_list *list)
+{
+ list_add_tail(&expr->head, &list->list);
+}
+EXPORT_SYMBOL(nft_rule_expr_list_add);
+
+void nft_rule_expr_list_add_list(struct nft_rule_expr_list *to_add,
+ struct nft_rule_expr_list *list)
+{
+ struct nft_rule_expr *e, *tmp;
+
+ list_for_each_entry_safe(e, tmp, &to_add->list, head) {
+ list_del(&e->head);
+ list_add_tail(&e->head, &list->list);
+ }
+}
+EXPORT_SYMBOL(nft_rule_expr_list_add_list);
+
void
nft_rule_expr_build_payload(struct nlmsghdr *nlh, struct nft_rule_expr *expr)
{
diff --git a/src/internal.h b/src/internal.h
index f5717ed..a93667e 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -22,6 +22,10 @@ struct nft_rule_expr {
uint8_t data[];
};
+struct nft_rule_expr_list {
+ struct list_head list;
+};
+
struct nlattr;
struct nft_set {
diff --git a/src/libnftables.map b/src/libnftables.map
index 3f98287..3cffb74 100644
--- a/src/libnftables.map
+++ b/src/libnftables.map
@@ -56,6 +56,7 @@ global:
nft_rule_nlmsg_build_payload;
nft_rule_nlmsg_parse;
nft_rule_add_expr;
+ nft_rule_add_expr_list;
nft_rule_expr_iter_create;
nft_rule_expr_iter_next;
@@ -72,6 +73,10 @@ global:
nft_rule_expr_get_u32;
nft_rule_expr_get_u64;
nft_rule_expr_get_str;
+ nft_rule_expr_list_alloc;
+ nft_rule_expr_list_free;
+ nft_rule_expr_list_add;
+ nft_rule_expr_list_add_list;
nft_rule_expr_build_payload;
nft_rule_expr_free;
diff --git a/src/rule.c b/src/rule.c
index 501b4f6..afc22d3 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -258,6 +258,18 @@ void nft_rule_add_expr(struct nft_rule *r, struct nft_rule_expr *expr)
}
EXPORT_SYMBOL(nft_rule_add_expr);
+void nft_rule_add_expr_list(struct nft_rule *r,
+ struct nft_rule_expr_list *list)
+{
+ struct nft_rule_expr *e, *tmp;
+
+ list_for_each_entry_safe(e, tmp, &list->list, head) {
+ list_del(&e->head);
+ list_add_tail(&e->head, &r->expr_list);
+ }
+}
+EXPORT_SYMBOL(nft_rule_add_expr_list);
+
static int nft_rule_parse_attr_cb(const struct nlattr *attr, void *data)
{
const struct nlattr **tb = data;
--
1.8.2.1
next prev parent reply other threads:[~2013-05-14 10:51 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-14 10:49 [iptables-nftables/libnfables PATCHES] Target translation to nftables Tomasz Bursztyka
2013-05-14 10:51 ` [libnftables PATCH 0/7] Fixes and features Tomasz Bursztyka
2013-05-14 10:51 ` [libnftables PATCH 1/7] git: add a .gitignore file Tomasz Bursztyka
2013-05-14 22:17 ` Pablo Neira Ayuso
2013-05-15 6:51 ` Tomasz Bursztyka
2013-05-15 12:53 ` Pablo Neira Ayuso
2013-05-15 13:01 ` Tomasz Bursztyka
2013-05-14 10:51 ` [libnftables PATCH 2/7] build: add an autogen.sh script Tomasz Bursztyka
2013-05-14 10:51 ` [libnftables PATCH 3/7] rule: declare nft_rule_list structure at a proper place Tomasz Bursztyka
2013-05-14 10:51 ` [libnftables PATCH 4/7] expr: remove inconsistent and non implemented function Tomasz Bursztyka
2013-05-14 10:51 ` [libnftables PATCH 5/7] map: fix nft_rule_expr_build_payload export Tomasz Bursztyka
2013-05-14 10:51 ` Tomasz Bursztyka [this message]
2013-05-14 10:51 ` [libnftables PATCH 7/7] chain: handle attribute is relevant if only there is no name to use Tomasz Bursztyka
2013-05-14 22:20 ` Pablo Neira Ayuso
2013-05-15 6:08 ` Tomasz Bursztyka
2013-05-15 12:43 ` Pablo Neira Ayuso
2013-05-15 13:06 ` Tomasz Bursztyka
2013-05-15 13:40 ` Pablo Neira Ayuso
2013-05-15 13:54 ` Tomasz Bursztyka
2013-05-15 14:28 ` Pablo Neira Ayuso
2013-05-16 16:46 ` [libnftables PATCH 0/7] Fixes and features Pablo Neira Ayuso
2013-05-14 10:52 ` [iptables-nftables PATCH 0/6] " Tomasz Bursztyka
2013-05-14 10:52 ` [iptables-nftables PATCH 1/6] xtables: initialize xtables defaults even on listing rules Tomasz Bursztyka
2013-05-16 17:01 ` Pablo Neira Ayuso
2013-05-14 10:52 ` [iptables-nftables PATCH 2/6] xtables: destroy list iterator relevantly Tomasz Bursztyka
2013-05-16 17:02 ` Pablo Neira Ayuso
2013-05-14 10:52 ` [iptables-nftables PATCH 3/6] xtables: policy can be changed only on builtin chain Tomasz Bursztyka
2013-05-16 17:01 ` Pablo Neira Ayuso
2013-05-14 10:52 ` [iptables-nftables PATCH 4/6] xtables: Add support for translating xtables target into nft expressions Tomasz Bursztyka
2013-05-14 10:52 ` [iptables-nftables PATCH 5/6] xtables: add support for translating xtables matches " Tomasz Bursztyka
2013-05-14 10:52 ` [iptables-nftables PATCH 6/6] xtables: add suport for DNAT rule translation to nft extensions Tomasz Bursztyka
2013-05-14 22:30 ` Pablo Neira Ayuso
2013-05-15 6:48 ` Tomasz Bursztyka
2013-05-15 12:51 ` Pablo Neira Ayuso
2013-05-15 13:24 ` Tomasz Bursztyka
2013-05-15 13:49 ` Pablo Neira Ayuso
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=1368528682-10041-7-git-send-email-tomasz.bursztyka@linux.intel.com \
--to=tomasz.bursztyka@linux.intel.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).