diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-08-30 16:15:46 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-08-30 16:15:55 +0200 |
commit | 37f71c93a3a8dff40f82cb2a8533a24e1cdf04f1 (patch) | |
tree | 827b392b7d1364854af818550ec77d68589ebc08 /src/expr/numgen.c | |
parent | aba8b360c344b87945959aaf31f672bf55040a85 (diff) |
expr: numgen: add missing nftnl_expr_ng_cmp()
This patch adds the missing comparator interface, most likely due to
race between the patchset that has added this and the introduction of
numgen.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expr/numgen.c')
-rw-r--r-- | src/expr/numgen.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/expr/numgen.c b/src/expr/numgen.c index e8fa9a1..0669eda 100644 --- a/src/expr/numgen.c +++ b/src/expr/numgen.c @@ -238,10 +238,28 @@ nftnl_expr_ng_snprintf(char *buf, size_t len, uint32_t type, return -1; } +static bool nftnl_expr_ng_cmp(const struct nftnl_expr *e1, + const struct nftnl_expr *e2) +{ + struct nftnl_expr_ng *n1 = nftnl_expr_data(e1); + struct nftnl_expr_ng *n2 = nftnl_expr_data(e2); + bool eq = true; + + if (e1->flags & (1 << NFTNL_EXPR_NG_DREG)) + eq &= (n1->dreg == n2->dreg); + if (e1->flags & (1 << NFTNL_EXPR_NG_UNTIL)) + eq &= (n1->until == n2->until); + if (e1->flags & (1 << NFTNL_EXPR_NG_TYPE)) + eq &= (n1->type == n2->type); + + return eq; +} + struct expr_ops expr_ops_ng = { .name = "numgen", .alloc_len = sizeof(struct nftnl_expr_ng), .max_attr = NFTA_NG_MAX, + .cmp = nftnl_expr_ng_cmp, .set = nftnl_expr_ng_set, .get = nftnl_expr_ng_get, .parse = nftnl_expr_ng_parse, |