Skip to content

Commit

Permalink
netfilter: nft_exthdr: Allow checking TCP option presence, too
Browse files Browse the repository at this point in the history
Honor NFT_EXTHDR_F_PRESENT flag so we check if the TCP option is
present.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Phil Sutter authored and ummakynes committed Mar 6, 2017
1 parent 8d70eeb commit 3c1fece
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions net/netfilter/nft_exthdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,21 @@ static void nft_exthdr_tcp_eval(const struct nft_expr *expr,
goto err;

offset = i + priv->offset;
dest[priv->len / NFT_REG32_SIZE] = 0;
memcpy(dest, opt + offset, priv->len);
if (priv->flags & NFT_EXTHDR_F_PRESENT) {
*dest = 1;
} else {
dest[priv->len / NFT_REG32_SIZE] = 0;
memcpy(dest, opt + offset, priv->len);
}

return;
}

err:
regs->verdict.code = NFT_BREAK;
if (priv->flags & NFT_EXTHDR_F_PRESENT)
*dest = 0;
else
regs->verdict.code = NFT_BREAK;
}

static const struct nla_policy nft_exthdr_policy[NFTA_EXTHDR_MAX + 1] = {
Expand Down

0 comments on commit 3c1fece

Please sign in to comment.