netfilter: bitwise: add support for doing AND, OR and XOR directly
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH v2 1/1 netfilter: bitwise: add support for doing AND, OR and XOR directly
From: Jeremy Sowden <[email protected]>
Hitherto, these operations have been converted in user space to mask-and-xor operations on one register and two immediate values, and it is the latter which have been evaluated by the kernel. We add support for evaluating these operations directly in kernel space on one register and either an immediate value or a second register.
Signed-off-by Jeremy Sowden <[email protected]>
Signed-off-by Pablo Neira Ayuso <[email protected]>
---
v2: - tigthen nft_bitwise_fast_init() to reject NFTA_BITWISE_SREG2
- relax nft_bitwise_init_bool() to allow _DATA to be != sizeof(u32)
include/uapi/linux/netfilter/nf_tables.h | 8 ++ net/netfilter/nft_bitwise.c | 132 +++++++++++++++++++++-- 2 files changed, 129 insertions(+), 11 deletions(-)
include/uapi/linux/netfilter/nf_tables.h +8 -0
@@ -568,11 +568,17 @@ enum nft_immediate_attributes {* and XOR boolean operations * @NFT_BITWISE_LSHIFT: left-shift operation * @NFT_BITWISE_RSHIFT: right-shift operation +* @NFT_BITWISE_AND: and operation +* @NFT_BITWISE_OR: or operation +* @NFT_BITWISE_XOR: xor operation */ enum nft_bitwise_ops {NFT_BITWISE_MASK_XOR ,NFT_BITWISE_LSHIFT ,NFT_BITWISE_RSHIFT , +NFT_BITWISE_AND , +NFT_BITWISE_OR , +NFT_BITWISE_XOR , };/* * Old name for NFT_BITWISE_MASK_XOR. Retained for backwards-compatibility.
@@ -590,6 +596,7 @@ enum nft_bitwise_ops {* @NFTA_BITWISE_OP: type of operation (NLA_U32: nft_bitwise_ops) * @NFTA_BITWISE_DATA: argument for non-boolean operations * (NLA_NESTED: nft_data_attributes) +* @NFTA_BITWISE_SREG2: second source register (NLA_U32: nft_registers) * * The bitwise expression supports boolean and shift operations. It implements * the boolean operations by performing the following operation:
@@ -613,6 +620,7 @@ enum nft_bitwise_attributes {NFTA_BITWISE_XOR ,NFTA_BITWISE_OP ,NFTA_BITWISE_DATA , +NFTA_BITWISE_SREG2 , __NFTA_BITWISE_MAX };#define NFTA_BITWISE_MAX (__NFTA_BITWISE_MAX - 1)
net/netfilter/nft_bitwise.c +121 -11
212 lines not on this page · raw message
Signature · 2 lines
2.30.2 :1