summaryrefslogtreecommitdiff
path: root/zebra
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2025-04-11 11:12:52 +0200
committerLouis Scalbert <louis.scalbert@6wind.com>2025-04-11 15:52:30 +0200
commitcd451ff4efb533a682d2eec2026a2e5b081e7aaf (patch)
treeda16caff6a56540b3d8a9d82f91a15d3413f5810 /zebra
parentf163168c9521181326845b1d98e83f3325bf8508 (diff)
zebra: split up MTYPE_PBR_OBJ
Split up MTYPE_PBR_OBJ into dedicated MTYPE to clarify the memory allocation and free. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'zebra')
-rw-r--r--zebra/zapi_msg.c2
-rw-r--r--zebra/zebra_pbr.c32
-rw-r--r--zebra/zebra_pbr.h3
3 files changed, 21 insertions, 16 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index d4e65eb18c..7cd64b1edc 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -3872,7 +3872,7 @@ static inline void zebra_neigh_ip_del(ZAPI_HANDLER_ARGS)
static inline void zread_iptable(ZAPI_HANDLER_ARGS)
{
struct zebra_pbr_iptable *zpi =
- XCALLOC(MTYPE_PBR_OBJ, sizeof(struct zebra_pbr_iptable));
+ XCALLOC(MTYPE_PBR_IPTABLE, sizeof(struct zebra_pbr_iptable));
struct stream *s;
s = msg;
diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c
index 7f3635702f..c6abd78c0f 100644
--- a/zebra/zebra_pbr.c
+++ b/zebra/zebra_pbr.c
@@ -23,7 +23,11 @@
/* definitions */
DEFINE_MTYPE_STATIC(ZEBRA, PBR_IPTABLE_IFNAME, "PBR interface list");
-DEFINE_MTYPE(ZEBRA, PBR_OBJ, "PBR");
+DEFINE_MTYPE_STATIC(ZEBRA, PBR_RULE, "PBR rule");
+DEFINE_MTYPE_STATIC(ZEBRA, PBR_IPSET, "PBR ipset");
+DEFINE_MTYPE_STATIC(ZEBRA, PBR_IPSET_ENTRY, "PBR ipset entry");
+DEFINE_MTYPE(ZEBRA, PBR_IPTABLE, "PBR iptable");
+
/* definitions */
static const struct message ipset_type_msg[] = {
@@ -151,7 +155,7 @@ void zebra_pbr_rules_free(void *arg)
rule = (struct zebra_pbr_rule *)arg;
(void)dplane_pbr_rule_delete(rule);
- XFREE(MTYPE_PBR_OBJ, rule);
+ XFREE(MTYPE_PBR_RULE, rule);
}
uint32_t zebra_pbr_rules_hash_key(const void *arg)
@@ -274,7 +278,7 @@ void zebra_pbr_ipset_free(void *arg)
ipset = (struct zebra_pbr_ipset *)arg;
hook_call(zebra_pbr_ipset_update, 0, ipset);
- XFREE(MTYPE_PBR_OBJ, ipset);
+ XFREE(MTYPE_PBR_IPSET, ipset);
}
uint32_t zebra_pbr_ipset_hash_key(const void *arg)
@@ -318,7 +322,7 @@ void zebra_pbr_ipset_entry_free(void *arg)
hook_call(zebra_pbr_ipset_entry_update, 0, ipset);
- XFREE(MTYPE_PBR_OBJ, ipset);
+ XFREE(MTYPE_PBR_IPSET_ENTRY, ipset);
}
uint32_t zebra_pbr_ipset_entry_hash_key(const void *arg)
@@ -395,7 +399,7 @@ static void _zebra_pbr_iptable_free_all(void *arg, bool all)
}
list_delete(&iptable->interface_name_list);
}
- XFREE(MTYPE_PBR_OBJ, iptable);
+ XFREE(MTYPE_PBR_IPTABLE, iptable);
}
void zebra_pbr_iptable_free(void *arg)
@@ -477,7 +481,7 @@ static void *pbr_rule_alloc_intern(void *arg)
zpr = (struct zebra_pbr_rule *)arg;
- new = XCALLOC(MTYPE_PBR_OBJ, sizeof(*new));
+ new = XCALLOC(MTYPE_PBR_RULE, sizeof(*new));
memcpy(new, zpr, sizeof(*zpr));
@@ -491,7 +495,7 @@ static struct zebra_pbr_rule *pbr_rule_free(struct zebra_pbr_rule *hash_data,
zebra_neigh_deref(hash_data);
hash_release(zrouter.rules_hash, hash_data);
if (free_data) {
- XFREE(MTYPE_PBR_OBJ, hash_data);
+ XFREE(MTYPE_PBR_RULE, hash_data);
return NULL;
}
@@ -729,7 +733,7 @@ void zebra_pbr_add_rule(struct zebra_pbr_rule *rule)
(void)dplane_pbr_rule_update(found, new);
/* release the old hash data */
if (old)
- XFREE(MTYPE_PBR_OBJ, old);
+ XFREE(MTYPE_PBR_RULE, old);
} else {
if (IS_ZEBRA_DEBUG_PBR)
zlog_debug(
@@ -897,7 +901,7 @@ static void *pbr_ipset_alloc_intern(void *arg)
zpi = (struct zebra_pbr_ipset *)arg;
- new = XCALLOC(MTYPE_PBR_OBJ, sizeof(struct zebra_pbr_ipset));
+ new = XCALLOC(MTYPE_PBR_IPSET, sizeof(struct zebra_pbr_ipset));
memcpy(new, zpi, sizeof(*zpi));
@@ -918,7 +922,7 @@ void zebra_pbr_destroy_ipset(struct zebra_pbr_ipset *ipset)
(void)dplane_pbr_ipset_delete(ipset);
if (lookup) {
hash_release(zrouter.ipset_hash, lookup);
- XFREE(MTYPE_PBR_OBJ, lookup);
+ XFREE(MTYPE_PBR_IPSET, lookup);
} else
zlog_debug(
"%s: IPSet Entry being deleted we know nothing about",
@@ -971,7 +975,7 @@ static void *pbr_ipset_entry_alloc_intern(void *arg)
zpi = (struct zebra_pbr_ipset_entry *)arg;
- new = XCALLOC(MTYPE_PBR_OBJ, sizeof(struct zebra_pbr_ipset_entry));
+ new = XCALLOC(MTYPE_PBR_IPSET_ENTRY, sizeof(struct zebra_pbr_ipset_entry));
memcpy(new, zpi, sizeof(*zpi));
@@ -993,7 +997,7 @@ void zebra_pbr_del_ipset_entry(struct zebra_pbr_ipset_entry *ipset)
(void)dplane_pbr_ipset_entry_delete(ipset);
if (lookup) {
hash_release(zrouter.ipset_entry_hash, lookup);
- XFREE(MTYPE_PBR_OBJ, lookup);
+ XFREE(MTYPE_PBR_IPSET_ENTRY, lookup);
} else
zlog_debug("%s: IPSet being deleted we know nothing about",
__func__);
@@ -1008,7 +1012,7 @@ static void *pbr_iptable_alloc_intern(void *arg)
zpi = (struct zebra_pbr_iptable *)arg;
- new = XCALLOC(MTYPE_PBR_OBJ, sizeof(struct zebra_pbr_iptable));
+ new = XCALLOC(MTYPE_PBR_IPTABLE, sizeof(struct zebra_pbr_iptable));
/* Deep structure copy */
memcpy(new, zpi, sizeof(*zpi));
@@ -1050,7 +1054,7 @@ void zebra_pbr_del_iptable(struct zebra_pbr_iptable *iptable)
node);
}
list_delete(&iptable->interface_name_list);
- XFREE(MTYPE_PBR_OBJ, lookup);
+ XFREE(MTYPE_PBR_IPTABLE, lookup);
} else
zlog_debug("%s: IPTable being deleted we know nothing about",
__func__);
diff --git a/zebra/zebra_pbr.h b/zebra/zebra_pbr.h
index 1e4b5cd0f3..b4bfb7a726 100644
--- a/zebra/zebra_pbr.h
+++ b/zebra/zebra_pbr.h
@@ -21,7 +21,8 @@ extern "C" {
#endif
/* Memory type for PBR objects. */
-DECLARE_MTYPE(PBR_OBJ);
+DECLARE_MTYPE(PBR_IPTABLE);
+
struct zebra_pbr_action {
afi_t afi;