From: Ana Rey <anarey@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: eric.dumazet@gmail.com, Ana Rey <anarey@gmail.com>
Subject: [PATCH] [nft] src: Add support for cpu in meta expresion
Date: Thu, 7 Aug 2014 09:00:57 +0200 [thread overview]
Message-ID: <1407394858-26841-3-git-send-email-anarey@gmail.com> (raw)
In-Reply-To: <1407394858-26841-1-git-send-email-anarey@gmail.com>
This allows you to match cpu handling with a packet.
This is an example of the syntax for this new attribute:
nft add rule ip test input meta cpu 1 counter
nft add rule ip test input meta cpu 1-3 counter
nft add rule ip test input meta cpu { 1, 3} counter
Signed-off-by: Ana Rey <anarey@gmail.com>
---
include/linux/netfilter/nf_tables.h | 2 ++
src/meta.c | 3 +++
src/parser.y | 2 ++
src/scanner.l | 1 +
4 files changed, 8 insertions(+)
diff --git a/include/linux/netfilter/nf_tables.h b/include/linux/netfilter/nf_tables.h
index fbc7904..9e67c14 100644
--- a/include/linux/netfilter/nf_tables.h
+++ b/include/linux/netfilter/nf_tables.h
@@ -536,6 +536,7 @@ enum nft_exthdr_attributes {
* @NFT_META_BRI_IIFNAME: packet input bridge interface name
* @NFT_META_BRI_OIFNAME: packet output bridge interface name
* @NFT_META_PKTTYPE: packet type
+ * @NFT_META_CPU: packet cpu
*/
enum nft_meta_keys {
NFT_META_LEN,
@@ -558,6 +559,7 @@ enum nft_meta_keys {
NFT_META_BRI_IIFNAME,
NFT_META_BRI_OIFNAME,
NFT_META_PKTTYPE,
+ NFT_META_CPU,
};
/**
diff --git a/src/meta.c b/src/meta.c
index 2c61455..75a16ee 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -393,6 +393,9 @@ static const struct meta_template meta_templates[] = {
[NFT_META_PKTTYPE] = META_TEMPLATE("pkttype", &pkttype_type,
BITS_PER_BYTE,
BYTEORDER_HOST_ENDIAN),
+ [NFT_META_CPU] = META_TEMPLATE("cpu", &integer_type,
+ BITS_PER_BYTE,
+ BYTEORDER_HOST_ENDIAN),
};
static void meta_expr_print(const struct expr *expr)
diff --git a/src/parser.y b/src/parser.y
index 6da6e98..bf32c4e 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -325,6 +325,7 @@ static int monitor_lookup_event(const char *event)
%token IBRIPORT "ibriport"
%token OBRIPORT "obriport"
%token PKTTYPE "pkttype"
+%token CPU "cpu"
%token CT "ct"
%token DIRECTION "direction"
@@ -1786,6 +1787,7 @@ meta_key_unqualified : MARK { $$ = NFT_META_MARK; }
| IBRIPORT { $$ = NFT_META_BRI_IIFNAME; }
| OBRIPORT { $$ = NFT_META_BRI_OIFNAME; }
| PKTTYPE { $$ = NFT_META_PKTTYPE; }
+ | CPU { $$ = NFT_META_CPU; }
;
meta_stmt : META meta_key SET expr
diff --git a/src/scanner.l b/src/scanner.l
index 1d2be76..ad0b58d 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -407,6 +407,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
"ibriport" { return IBRIPORT; }
"obriport" { return OBRIPORT; }
"pkttype" { return PKTTYPE; }
+"cpu" { return CPU; }
"ct" { return CT; }
"direction" { return DIRECTION; }
--
1.7.10.4
next prev parent reply other threads:[~2014-08-07 6:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-07 7:00 [PATCH] [libnftnl] expr: meta: Add cpu support for meta expresion Ana Rey
2014-08-07 7:00 ` [PATCH] netfilter: nf_tables: Add cpu attribute support to " Ana Rey
2014-08-24 12:55 ` Pablo Neira Ayuso
2014-08-07 7:00 ` Ana Rey [this message]
2014-08-24 12:55 ` [PATCH] [nft] src: Add support for cpu in " Pablo Neira Ayuso
2014-08-07 7:00 ` [PATCH] [nft] tests: Add tests for cpu attribute of " Ana Rey
2014-08-24 12:56 ` [PATCH] [libnftnl] expr: meta: Add cpu support for " 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=1407394858-26841-3-git-send-email-anarey@gmail.com \
--to=anarey@gmail.com \
--cc=eric.dumazet@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).