Skip to content

Commit

Permalink
netfilter: nft_meta: Add cpu attribute support
Browse files Browse the repository at this point in the history
Add cpu support to meta expresion.

This allows you to match packets with cpu number.

Signed-off-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Ana Rey authored and Pablo Neira Ayuso committed Aug 24, 2014
1 parent e2a093f commit afc5be3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/uapi/linux/netfilter/nf_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 (skb->pkt_type), special handling for loopback
* @NFT_META_CPU: cpu id through smp_processor_id()
*/
enum nft_meta_keys {
NFT_META_LEN,
Expand All @@ -594,6 +595,7 @@ enum nft_meta_keys {
NFT_META_BRI_IIFNAME,
NFT_META_BRI_OIFNAME,
NFT_META_PKTTYPE,
NFT_META_CPU,
};

/**
Expand Down
5 changes: 5 additions & 0 deletions net/netfilter/nft_meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -151,6 +152,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;
Expand Down Expand Up @@ -223,6 +227,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;
Expand Down

0 comments on commit afc5be3

Please sign in to comment.