netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ana Rey <anarey@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: eric.dumazet@gmail.com, Ana Rey <anarey@gmail.com>
Subject: [PATCH] netfilter: nf_tables: Add cpu attribute support to meta expresion.
Date: Thu,  7 Aug 2014 09:00:56 +0200	[thread overview]
Message-ID: <1407394858-26841-2-git-send-email-anarey@gmail.com> (raw)
In-Reply-To: <1407394858-26841-1-git-send-email-anarey@gmail.com>

Add cpu support to meta expresion.

This allows you to match packets with cpu number.

Signed-off-by: Ana Rey <anarey@gmail.com>
---
 include/uapi/linux/netfilter/nf_tables.h |    2 ++
 net/netfilter/nft_meta.c                 |    5 +++++
 2 files changed, 7 insertions(+)

diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 72ad208..67218f3 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -572,6 +572,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,
@@ -594,6 +595,7 @@ enum nft_meta_keys {
 	NFT_META_BRI_IIFNAME,
 	NFT_META_BRI_OIFNAME,
 	NFT_META_PKTTYPE,
+	NFT_META_CPU,
 };
 
 /**
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index dbf7fe1..34a587e 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -17,6 +17,7 @@
 #include <linux/in.h>
 #include <linux/ip.h>
 #include <linux/ipv6.h>
+#include <linux/smp.h>
 #include <net/dst.h>
 #include <net/sock.h>
 #include <net/tcp_states.h> /* for TCP_TIME_WAIT */
@@ -150,6 +151,9 @@ void nft_meta_get_eval(const struct nft_expr *expr,
 			goto err;
 		}
 		break;
+	case NFT_META_CPU:
+		dest->data[0] = smp_processor_id();
+		break;
 	default:
 		WARN_ON(1);
 		goto err;
@@ -222,6 +226,7 @@ int nft_meta_get_init(const struct nft_ctx *ctx,
 	case NFT_META_SECMARK:
 #endif
 	case NFT_META_PKTTYPE:
+	case NFT_META_CPU:
 		break;
 	default:
 		return -EOPNOTSUPP;
-- 
1.7.10.4


  reply	other threads:[~2014-08-07  6:58 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 ` Ana Rey [this message]
2014-08-24 12:55   ` [PATCH] netfilter: nf_tables: Add cpu attribute support to " Pablo Neira Ayuso
2014-08-07  7:00 ` [PATCH] [nft] src: Add support for cpu in " Ana Rey
2014-08-24 12:55   ` 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-2-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).