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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* @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,
NFT_META_BRI_IIFNAME,
NFT_META_BRI_OIFNAME,
NFT_META_PKTTYPE,
+ NFT_META_CPU,
};
/**
[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)
%token IBRIPORT "ibriport"
%token OBRIPORT "obriport"
%token PKTTYPE "pkttype"
+%token CPU "cpu"
%token CT "ct"
%token DIRECTION "direction"
| 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
"ibriport" { return IBRIPORT; }
"obriport" { return OBRIPORT; }
"pkttype" { return PKTTYPE; }
+"cpu" { return CPU; }
"ct" { return CT; }
"direction" { return DIRECTION; }