You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libnftnl/SOURCES/0023-obj-Repurpose-struct-o...

235 lines
7.2 KiB

From 4a180882136a860773c86c507805ef01eb757dd8 Mon Sep 17 00:00:00 2001
From: Phil Sutter <psutter@redhat.com>
Date: Wed, 8 May 2024 22:39:41 +0200
Subject: [PATCH] obj: Repurpose struct obj_ops::max_attr field
JIRA: https://issues.redhat.com/browse/RHEL-28515
Upstream Status: libnftnl commit df4e259c0537fff58ecdc7b3ec1546fb2da93968
commit df4e259c0537fff58ecdc7b3ec1546fb2da93968
Author: Phil Sutter <phil@nwl.cc>
Date: Thu Mar 7 13:15:22 2024 +0100
obj: Repurpose struct obj_ops::max_attr field
Just like with struct expr_ops::max_attr, make it hold the maximum
object attribute (NFTNL_OBJ_*) value supported by this object type.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
include/libnftnl/object.h | 9 +++++++++
include/obj.h | 2 +-
src/obj/counter.c | 2 +-
src/obj/ct_expect.c | 2 +-
src/obj/ct_helper.c | 2 +-
src/obj/ct_timeout.c | 2 +-
src/obj/limit.c | 2 +-
src/obj/quota.c | 2 +-
src/obj/secmark.c | 2 +-
src/obj/synproxy.c | 2 +-
src/obj/tunnel.c | 2 +-
11 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/include/libnftnl/object.h b/include/libnftnl/object.h
index e235fdf..9930355 100644
--- a/include/libnftnl/object.h
+++ b/include/libnftnl/object.h
@@ -28,18 +28,21 @@ enum {
enum {
NFTNL_OBJ_CTR_PKTS = NFTNL_OBJ_BASE,
NFTNL_OBJ_CTR_BYTES,
+ __NFTNL_OBJ_CTR_MAX,
};
enum {
NFTNL_OBJ_QUOTA_BYTES = NFTNL_OBJ_BASE,
NFTNL_OBJ_QUOTA_CONSUMED,
NFTNL_OBJ_QUOTA_FLAGS,
+ __NFTNL_OBJ_QUOTA_MAX,
};
enum {
NFTNL_OBJ_CT_HELPER_NAME = NFTNL_OBJ_BASE,
NFTNL_OBJ_CT_HELPER_L3PROTO,
NFTNL_OBJ_CT_HELPER_L4PROTO,
+ __NFTNL_OBJ_CT_HELPER_MAX,
};
enum nftnl_cttimeout_array_tcp {
@@ -69,6 +72,7 @@ enum {
NFTNL_OBJ_CT_TIMEOUT_L3PROTO = NFTNL_OBJ_BASE,
NFTNL_OBJ_CT_TIMEOUT_L4PROTO,
NFTNL_OBJ_CT_TIMEOUT_ARRAY,
+ __NFTNL_OBJ_CT_TIMEOUT_MAX,
};
enum {
@@ -77,6 +81,7 @@ enum {
NFTNL_OBJ_CT_EXPECT_DPORT,
NFTNL_OBJ_CT_EXPECT_TIMEOUT,
NFTNL_OBJ_CT_EXPECT_SIZE,
+ __NFTNL_OBJ_CT_EXPECT_MAX,
};
enum {
@@ -85,12 +90,14 @@ enum {
NFTNL_OBJ_LIMIT_BURST,
NFTNL_OBJ_LIMIT_TYPE,
NFTNL_OBJ_LIMIT_FLAGS,
+ __NFTNL_OBJ_LIMIT_MAX,
};
enum {
NFTNL_OBJ_SYNPROXY_MSS = NFTNL_OBJ_BASE,
NFTNL_OBJ_SYNPROXY_WSCALE,
NFTNL_OBJ_SYNPROXY_FLAGS,
+ __NFTNL_OBJ_SYNPROXY_MAX,
};
enum {
@@ -110,10 +117,12 @@ enum {
NFTNL_OBJ_TUNNEL_ERSPAN_V1_INDEX,
NFTNL_OBJ_TUNNEL_ERSPAN_V2_HWID,
NFTNL_OBJ_TUNNEL_ERSPAN_V2_DIR,
+ __NFTNL_OBJ_TUNNEL_MAX,
};
enum {
NFTNL_OBJ_SECMARK_CTX = NFTNL_OBJ_BASE,
+ __NFTNL_OBJ_SECMARK_MAX,
};
struct nftnl_obj;
diff --git a/include/obj.h b/include/obj.h
index d848ac9..6d2af8d 100644
--- a/include/obj.h
+++ b/include/obj.h
@@ -104,7 +104,7 @@ struct obj_ops {
const char *name;
uint32_t type;
size_t alloc_len;
- int max_attr;
+ int nftnl_max_attr;
int (*set)(struct nftnl_obj *e, uint16_t type, const void *data, uint32_t data_len);
const void *(*get)(const struct nftnl_obj *e, uint16_t type, uint32_t *data_len);
int (*parse)(struct nftnl_obj *e, struct nlattr *attr);
diff --git a/src/obj/counter.c b/src/obj/counter.c
index ebf3e74..76a1b20 100644
--- a/src/obj/counter.c
+++ b/src/obj/counter.c
@@ -122,7 +122,7 @@ struct obj_ops obj_ops_counter = {
.name = "counter",
.type = NFT_OBJECT_COUNTER,
.alloc_len = sizeof(struct nftnl_obj_counter),
- .max_attr = NFTA_COUNTER_MAX,
+ .nftnl_max_attr = __NFTNL_OBJ_CTR_MAX - 1,
.set = nftnl_obj_counter_set,
.get = nftnl_obj_counter_get,
.parse = nftnl_obj_counter_parse,
diff --git a/src/obj/ct_expect.c b/src/obj/ct_expect.c
index 810ba9a..7e9c5e1 100644
--- a/src/obj/ct_expect.c
+++ b/src/obj/ct_expect.c
@@ -191,7 +191,7 @@ struct obj_ops obj_ops_ct_expect = {
.name = "ct_expect",
.type = NFT_OBJECT_CT_EXPECT,
.alloc_len = sizeof(struct nftnl_obj_ct_expect),
- .max_attr = NFTA_CT_EXPECT_MAX,
+ .nftnl_max_attr = __NFTNL_OBJ_CT_EXPECT_MAX - 1,
.set = nftnl_obj_ct_expect_set,
.get = nftnl_obj_ct_expect_get,
.parse = nftnl_obj_ct_expect_parse,
diff --git a/src/obj/ct_helper.c b/src/obj/ct_helper.c
index a31bd6f..f8aa734 100644
--- a/src/obj/ct_helper.c
+++ b/src/obj/ct_helper.c
@@ -145,7 +145,7 @@ struct obj_ops obj_ops_ct_helper = {
.name = "ct_helper",
.type = NFT_OBJECT_CT_HELPER,
.alloc_len = sizeof(struct nftnl_obj_ct_helper),
- .max_attr = NFTA_CT_HELPER_MAX,
+ .nftnl_max_attr = __NFTNL_OBJ_CT_HELPER_MAX - 1,
.set = nftnl_obj_ct_helper_set,
.get = nftnl_obj_ct_helper_get,
.parse = nftnl_obj_ct_helper_parse,
diff --git a/src/obj/ct_timeout.c b/src/obj/ct_timeout.c
index fedf9e3..ee86231 100644
--- a/src/obj/ct_timeout.c
+++ b/src/obj/ct_timeout.c
@@ -314,7 +314,7 @@ struct obj_ops obj_ops_ct_timeout = {
.name = "ct_timeout",
.type = NFT_OBJECT_CT_TIMEOUT,
.alloc_len = sizeof(struct nftnl_obj_ct_timeout),
- .max_attr = NFTA_CT_TIMEOUT_MAX,
+ .nftnl_max_attr = __NFTNL_OBJ_CT_TIMEOUT_MAX - 1,
.set = nftnl_obj_ct_timeout_set,
.get = nftnl_obj_ct_timeout_get,
.parse = nftnl_obj_ct_timeout_parse,
diff --git a/src/obj/limit.c b/src/obj/limit.c
index d7b1aed..1c54bbc 100644
--- a/src/obj/limit.c
+++ b/src/obj/limit.c
@@ -163,7 +163,7 @@ struct obj_ops obj_ops_limit = {
.name = "limit",
.type = NFT_OBJECT_LIMIT,
.alloc_len = sizeof(struct nftnl_obj_limit),
- .max_attr = NFTA_LIMIT_MAX,
+ .nftnl_max_attr = __NFTNL_OBJ_LIMIT_MAX - 1,
.set = nftnl_obj_limit_set,
.get = nftnl_obj_limit_get,
.parse = nftnl_obj_limit_parse,
diff --git a/src/obj/quota.c b/src/obj/quota.c
index 6c7559a..a39d552 100644
--- a/src/obj/quota.c
+++ b/src/obj/quota.c
@@ -139,7 +139,7 @@ struct obj_ops obj_ops_quota = {
.name = "quota",
.type = NFT_OBJECT_QUOTA,
.alloc_len = sizeof(struct nftnl_obj_quota),
- .max_attr = NFTA_QUOTA_MAX,
+ .nftnl_max_attr = __NFTNL_OBJ_QUOTA_MAX - 1,
.set = nftnl_obj_quota_set,
.get = nftnl_obj_quota_get,
.parse = nftnl_obj_quota_parse,
diff --git a/src/obj/secmark.c b/src/obj/secmark.c
index e5c24b3..c78e35f 100644
--- a/src/obj/secmark.c
+++ b/src/obj/secmark.c
@@ -111,7 +111,7 @@ struct obj_ops obj_ops_secmark = {
.name = "secmark",
.type = NFT_OBJECT_SECMARK,
.alloc_len = sizeof(struct nftnl_obj_secmark),
- .max_attr = NFTA_SECMARK_MAX,
+ .nftnl_max_attr = __NFTNL_OBJ_SECMARK_MAX - 1,
.set = nftnl_obj_secmark_set,
.get = nftnl_obj_secmark_get,
.parse = nftnl_obj_secmark_parse,
diff --git a/src/obj/synproxy.c b/src/obj/synproxy.c
index 4ef97ec..d259a51 100644
--- a/src/obj/synproxy.c
+++ b/src/obj/synproxy.c
@@ -138,7 +138,7 @@ struct obj_ops obj_ops_synproxy = {
.name = "synproxy",
.type = NFT_OBJECT_SYNPROXY,
.alloc_len = sizeof(struct nftnl_obj_synproxy),
- .max_attr = NFTA_SYNPROXY_MAX,
+ .nftnl_max_attr = __NFTNL_OBJ_SYNPROXY_MAX - 1,
.set = nftnl_obj_synproxy_set,
.get = nftnl_obj_synproxy_get,
.parse = nftnl_obj_synproxy_parse,
diff --git a/src/obj/tunnel.c b/src/obj/tunnel.c
index d2503dc..19a3639 100644
--- a/src/obj/tunnel.c
+++ b/src/obj/tunnel.c
@@ -542,7 +542,7 @@ struct obj_ops obj_ops_tunnel = {
.name = "tunnel",
.type = NFT_OBJECT_TUNNEL,
.alloc_len = sizeof(struct nftnl_obj_tunnel),
- .max_attr = NFTA_TUNNEL_KEY_MAX,
+ .nftnl_max_attr = __NFTNL_OBJ_TUNNEL_MAX - 1,
.set = nftnl_obj_tunnel_set,
.get = nftnl_obj_tunnel_get,
.parse = nftnl_obj_tunnel_parse,