summaryrefslogtreecommitdiffstats
path: root/src/obj/ct_timeout.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2024-03-07 13:46:26 +0100
committerPhil Sutter <phil@nwl.cc>2024-04-11 01:27:07 +0200
commitf8348db87791bb8061b7f9ecf856e835ab74d006 (patch)
tree8989e13704203972383da57fa3507ba865702b7b /src/obj/ct_timeout.c
parent410c245e4811d7888daa456547af58d93d1c63b4 (diff)
obj: Introduce struct obj_ops::attr_policy
Just like with struct expr_ops::attr_policy, enable object types to inform about restrictions on attribute use. This way generic object code may perform sanity checks before dispatching to object ops. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src/obj/ct_timeout.c')
-rw-r--r--src/obj/ct_timeout.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/obj/ct_timeout.c b/src/obj/ct_timeout.c
index 011d928..88522d8 100644
--- a/src/obj/ct_timeout.c
+++ b/src/obj/ct_timeout.c
@@ -308,11 +308,18 @@ static int nftnl_obj_ct_timeout_snprintf(char *buf, size_t remain,
return offset;
}
+static struct attr_policy
+obj_ct_timeout_attr_policy[__NFTNL_OBJ_CT_TIMEOUT_MAX] = {
+ [NFTNL_OBJ_CT_TIMEOUT_L3PROTO] = { .maxlen = sizeof(uint16_t) },
+ [NFTNL_OBJ_CT_TIMEOUT_L4PROTO] = { .maxlen = sizeof(uint8_t) },
+};
+
struct obj_ops obj_ops_ct_timeout = {
.name = "ct_timeout",
.type = NFT_OBJECT_CT_TIMEOUT,
.alloc_len = sizeof(struct nftnl_obj_ct_timeout),
.nftnl_max_attr = __NFTNL_OBJ_CT_TIMEOUT_MAX - 1,
+ .attr_policy = obj_ct_timeout_attr_policy,
.set = nftnl_obj_ct_timeout_set,
.get = nftnl_obj_ct_timeout_get,
.parse = nftnl_obj_ct_timeout_parse,