Skip to content

Commit

Permalink
netfilter: nft_last: honor NFTA_LAST_SET on restoration
Browse files Browse the repository at this point in the history
NFTA_LAST_SET tells us if this expression has ever seen a packet, do not
ignore this attribute when restoring the ruleset.

Fixes: 836382d ("netfilter: nf_tables: add last expression")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Pablo Neira Ayuso committed Jul 6, 2021
1 parent cf4466e commit 6ac4bac
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions net/netfilter/nft_last.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,21 @@ static int nft_last_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
{
struct nft_last_priv *priv = nft_expr_priv(expr);
u64 last_jiffies;
u32 last_set = 0;
int err;

if (tb[NFTA_LAST_MSECS]) {
if (tb[NFTA_LAST_SET]) {
last_set = ntohl(nla_get_be32(tb[NFTA_LAST_SET]));
if (last_set == 1)
priv->last_set = 1;
}

if (last_set && tb[NFTA_LAST_MSECS]) {
err = nf_msecs_to_jiffies64(tb[NFTA_LAST_MSECS], &last_jiffies);
if (err < 0)
return err;

priv->last_jiffies = jiffies + (unsigned long)last_jiffies;
priv->last_set = 1;
}

return 0;
Expand Down

0 comments on commit 6ac4bac

Please sign in to comment.