Commit 4d57ca2b authored by Jeremy Sowden's avatar Jeremy Sowden Committed by Pablo Neira Ayuso

netfilter: bitwise: add helper for dumping boolean operations.

Split the code specific to dumping bitwise boolean operations out into a
separate function.  A similar function will be added later for shift
operations.
Signed-off-by: default avatarJeremy Sowden <jeremy@azazel.net>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 71d6ded3
...@@ -143,9 +143,24 @@ static int nft_bitwise_init(const struct nft_ctx *ctx, ...@@ -143,9 +143,24 @@ static int nft_bitwise_init(const struct nft_ctx *ctx,
return err; return err;
} }
static int nft_bitwise_dump_bool(struct sk_buff *skb,
const struct nft_bitwise *priv)
{
if (nft_data_dump(skb, NFTA_BITWISE_MASK, &priv->mask,
NFT_DATA_VALUE, priv->len) < 0)
return -1;
if (nft_data_dump(skb, NFTA_BITWISE_XOR, &priv->xor,
NFT_DATA_VALUE, priv->len) < 0)
return -1;
return 0;
}
static int nft_bitwise_dump(struct sk_buff *skb, const struct nft_expr *expr) static int nft_bitwise_dump(struct sk_buff *skb, const struct nft_expr *expr)
{ {
const struct nft_bitwise *priv = nft_expr_priv(expr); const struct nft_bitwise *priv = nft_expr_priv(expr);
int err = 0;
if (nft_dump_register(skb, NFTA_BITWISE_SREG, priv->sreg)) if (nft_dump_register(skb, NFTA_BITWISE_SREG, priv->sreg))
return -1; return -1;
...@@ -156,15 +171,13 @@ static int nft_bitwise_dump(struct sk_buff *skb, const struct nft_expr *expr) ...@@ -156,15 +171,13 @@ static int nft_bitwise_dump(struct sk_buff *skb, const struct nft_expr *expr)
if (nla_put_be32(skb, NFTA_BITWISE_OP, htonl(priv->op))) if (nla_put_be32(skb, NFTA_BITWISE_OP, htonl(priv->op)))
return -1; return -1;
if (nft_data_dump(skb, NFTA_BITWISE_MASK, &priv->mask, switch (priv->op) {
NFT_DATA_VALUE, priv->len) < 0) case NFT_BITWISE_BOOL:
return -1; err = nft_bitwise_dump_bool(skb, priv);
break;
if (nft_data_dump(skb, NFTA_BITWISE_XOR, &priv->xor, }
NFT_DATA_VALUE, priv->len) < 0)
return -1;
return 0; return err;
} }
static struct nft_data zero; static struct nft_data zero;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment