netfilter: bitwise: support variable RHS operands
Subsystems (2)
cover netfilter: bitwise: support variable RHS operands
Currently bitwise boolean operations can only have one variable operand because the mask and xor values have to be passed as immediate data. Support operations with two variable operands by allowing the mask and xor to be passed in registers.
There is a preliminary patch that renames a couple of variables.
Jeremy Sowden (2):
netfilter: bitwise: use more descriptive variable-names.
netfilter: bitwise: add support for passing mask and xor values in
registers.
include/uapi/linux/netfilter/nf_tables.h | 4 + net/netfilter/nft_bitwise.c | 120 +++++++++++++++++------ 2 files changed, 94 insertions(+), 30 deletions(-)
Signature · 1 line
2.25.0
PATCH 1/2 netfilter: bitwise: use more descriptive variable-names.
Name the mask and xor data variables, "mask" and "xor," instead of "d1" and "d2."
--- net/netfilter/nft_bitwise.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
net/netfilter/nft_bitwise.c +7 -7
@@ -93,7 +93,7 @@ static const struct nla_policy nft_bitwise_policy[NFTA_BITWISE_MAX + 1] = {static int nft_bitwise_init_bool (struct nft_bitwise *priv,const struct nlattr *const tb[]) { -struct nft_data_desc d1, d2; +struct nft_data_desc mask, xor;int err;if (tb[NFTA_BITWISE_DATA ])
@@ -103,29 +103,29 @@ static int nft_bitwise_init_bool(struct nft_bitwise *priv, !tb[NFTA_BITWISE_XOR])return -EINVAL ; - err =nft_data_init (NULL , &priv->mask,sizeof (priv->mask), &d1, + err =nft_data_init (NULL , &priv->mask,sizeof (priv->mask), &mask, tb[NFTA_BITWISE_MASK ]);if (err <0 )return err; -if (d1.type !=NFT_DATA_VALUE || d1.len != priv->len) { +if (mask.type !=NFT_DATA_VALUE || mask.len != priv->len) { err = -EINVAL ; goto err1; } - err =nft_data_init (NULL , &priv->xor,sizeof (priv->xor), &d2, + err =nft_data_init (NULL , &priv->xor,sizeof (priv->xor), &xor, tb[NFTA_BITWISE_XOR ]);if (err <0 ) goto err1; -if (d2.type !=NFT_DATA_VALUE || d2.len != priv->len) { +if (xor.type !=NFT_DATA_VALUE || xor.len != priv->len) { err = -EINVAL ; goto err2; }return 0 ; err2: -nft_data_release (&priv->xor, d2.type); +nft_data_release (&priv->xor, xor.type); err1: -nft_data_release (&priv->mask, d1.type); +nft_data_release (&priv->mask, mask.type);return err; }
Signature · 1 line
2.25.0
PATCH 2/2 netfilter: bitwise: add support for passing mask and xor values in registers.
In reply to Jeremy SowdenCurrently bitwise boolean operations can only have one variable operand because the mask and xor values have to be passed as immediate data. Support operations with two variable operands by allowing the mask and xor to be passed in registers.
--- include/uapi/linux/netfilter/nf_tables.h | 4 + net/netfilter/nft_bitwise.c | 118 +++++++++++++++++------ 2 files changed, 93 insertions(+), 29 deletions(-)
include/uapi/linux/netfilter/nf_tables.h +4 -0
@@ -526,6 +526,8 @@ 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_MREG: mask register (NLA_U32: nft_registers) +* @NFTA_BITWISE_XREG: xor register (NLA_U32: nft_registers) * * The bitwise expression supports boolean and shift operations. It implements * the boolean operations by performing the following operation:
@@ -549,6 +551,8 @@ enum nft_bitwise_attributes {NFTA_BITWISE_XOR ,NFTA_BITWISE_OP ,NFTA_BITWISE_DATA , +NFTA_BITWISE_MREG , +NFTA_BITWISE_XREG , __NFTA_BITWISE_MAX };#define NFTA_BITWISE_MAX (__NFTA_BITWISE_MAX - 1)
net/netfilter/nft_bitwise.c +89 -29
171 lines not on this page · raw message
Signature · 1 line
2.25.0
Pablo Neira Ayuso
maintainerQuoted 4 lines · Jeremy Sowden
Currently bitwise boolean operations can only have one variable operand because the mask and xor values have to be passed as immediate data. Support operations with two variable operands by allowing the mask and xor to be passed in registers.
Series applied, thanks.