summaryrefslogtreecommitdiffstats
path: root/src/expr/last.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/expr/last.c')
-rw-r--r--src/expr/last.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/expr/last.c b/src/expr/last.c
index e2a60c4..8e5b88e 100644
--- a/src/expr/last.c
+++ b/src/expr/last.c
@@ -32,13 +32,11 @@ static int nftnl_expr_last_set(struct nftnl_expr *e, uint16_t type,
switch (type) {
case NFTNL_EXPR_LAST_MSECS:
- memcpy(&last->msecs, data, sizeof(last->msecs));
+ memcpy(&last->msecs, data, data_len);
break;
case NFTNL_EXPR_LAST_SET:
- memcpy(&last->set, data, sizeof(last->set));
+ memcpy(&last->set, data, data_len);
break;
- default:
- return -1;
}
return 0;
}
@@ -126,13 +124,19 @@ static int nftnl_expr_last_snprintf(char *buf, size_t len,
return snprintf(buf, len, "%"PRIu64" ", last->msecs);
}
+static struct attr_policy last_attr_policy[__NFTNL_EXPR_LAST_MAX] = {
+ [NFTNL_EXPR_LAST_MSECS] = { .maxlen = sizeof(uint64_t) },
+ [NFTNL_EXPR_LAST_SET] = { .maxlen = sizeof(uint32_t) },
+};
+
struct expr_ops expr_ops_last = {
.name = "last",
.alloc_len = sizeof(struct nftnl_expr_last),
- .max_attr = NFTA_LAST_MAX,
+ .nftnl_max_attr = __NFTNL_EXPR_LAST_MAX - 1,
+ .attr_policy = last_attr_policy,
.set = nftnl_expr_last_set,
.get = nftnl_expr_last_get,
.parse = nftnl_expr_last_parse,
.build = nftnl_expr_last_build,
- .snprintf = nftnl_expr_last_snprintf,
+ .output = nftnl_expr_last_snprintf,
};