From: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
To: netfilter-devel@vger.kernel.org
Cc: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Subject: [nftables-kernel PATCH 5/7] netfilter: nf_tables: Add a meta key to get the device address length
Date: Mon, 14 Oct 2013 15:46:54 +0300 [thread overview]
Message-ID: <1381754816-28472-6-git-send-email-tomasz.bursztyka@linux.intel.com> (raw)
In-Reply-To: <1381754816-28472-1-git-send-email-tomasz.bursztyka@linux.intel.com>
This will be useful to determine at runtime the position of some data in
the packet.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
---
include/uapi/linux/netfilter/nf_tables.h | 2 ++
net/netfilter/nft_meta.c | 12 +++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 81eec3b..65f41ff 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -526,6 +526,7 @@ enum nft_exthdr_attributes {
* @NFT_META_OIFNAME: packet output interface name (dev->name)
* @NFT_META_IIFTYPE: packet input interface type (dev->type)
* @NFT_META_OIFTYPE: packet output interface type (dev->type)
+ * @NFT_META_DEV_ADDRLEN: packet interface address length (dev->addr_len)
* @NFT_META_SKUID: originating socket UID (fsuid)
* @NFT_META_SKGID: originating socket GID (fsgid)
* @NFT_META_NFTRACE: packet nftrace bit
@@ -543,6 +544,7 @@ enum nft_meta_keys {
NFT_META_OIFNAME,
NFT_META_IIFTYPE,
NFT_META_OIFTYPE,
+ NFT_META_DEV_ADDRLEN,
NFT_META_SKUID,
NFT_META_SKGID,
NFT_META_NFTRACE,
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 8c28220..8116535 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -30,7 +30,7 @@ static void nft_meta_eval(const struct nft_expr *expr,
{
const struct nft_meta *priv = nft_expr_priv(expr);
const struct sk_buff *skb = pkt->skb;
- const struct net_device *in = pkt->in, *out = pkt->out;
+ const struct net_device *in = pkt->in, *out = pkt->out, *dev;
struct nft_data *dest = &data[priv->dreg];
switch (priv->key) {
@@ -76,6 +76,15 @@ static void nft_meta_eval(const struct nft_expr *expr,
goto err;
*(u16 *)dest->data = out->type;
break;
+ case NFT_META_DEV_ADDRLEN:
+ if (out != NULL)
+ dev = out;
+ else if (in != NULL)
+ dev = out;
+ else
+ goto err;
+ *(u8 *)dest->data = dev->addr_len;
+ break;
case NFT_META_SKUID:
if (skb->sk == NULL || skb->sk->sk_state == TCP_TIME_WAIT)
goto err;
@@ -159,6 +168,7 @@ static int nft_meta_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
case NFT_META_OIFNAME:
case NFT_META_IIFTYPE:
case NFT_META_OIFTYPE:
+ case NFT_META_DEV_ADDRLEN:
case NFT_META_SKUID:
case NFT_META_SKGID:
#ifdef CONFIG_NET_CLS_ROUTE
--
1.8.3.2
next prev parent reply other threads:[~2013-10-14 12:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-14 12:46 [nftables-kernel PATCH 0/7] API minor fixes and improvement proposals Tomasz Bursztyka
2013-10-14 12:46 ` [nftables-kernel PATCH 1/7] netfilter: nf_tables: Fix API documentation on a missing part Tomasz Bursztyka
2013-10-14 12:46 ` [nftables-kernel PATCH 2/7] netfilter: nf_tables: Use byteorder operands length relevantly Tomasz Bursztyka
2013-10-14 12:46 ` [nftables-kernel PATCH 3/7] netfilter: nf_tables: Expose the table's chain usage to the netlink API Tomasz Bursztyka
2013-10-14 12:46 ` [nftables-kernel PATCH 4/7] netfilter: nf_tables: Use a semantically relevant name on chain's refs Tomasz Bursztyka
2013-10-14 12:46 ` Tomasz Bursztyka [this message]
2013-10-14 12:46 ` [nftables-kernel PATCH 6/7] netfilter: nf_tables: Add left and right shifts to bitwise expression Tomasz Bursztyka
2013-10-14 12:46 ` [nftables-kernel PATCH 7/7] netfilter: nf_tables: Improve payload expression for an extra offset Tomasz Bursztyka
2013-10-14 12:58 ` [nftables-kernel PATCH 0/7] API minor fixes and improvement proposals Pablo Neira Ayuso
2013-10-14 13:50 ` Tomasz Bursztyka
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=1381754816-28472-6-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).