summaryrefslogtreecommitdiffstats
path: root/ripd
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2018-08-02 14:14:39 +0200
committerGitHub <noreply@github.com>2018-08-02 14:14:39 +0200
commita4bacbcfa536f2653e919440babe2da0bc264861 (patch)
treeca4c52a5678d1bf953bc4414a16135c7e3c73c8a /ripd
parentMerge pull request #2771 from qlyoung/fix-zserv-shutdown-crash-3 (diff)
parentripd: Use memory management for interface commands in RIP (diff)
downloadfrr-a4bacbcfa536f2653e919440babe2da0bc264861.tar.xz
frr-a4bacbcfa536f2653e919440babe2da0bc264861.zip
Merge pull request #2761 from donaldsharp/rip_memory
ripd: Use memory management for interface commands in RIP
Diffstat (limited to 'ripd')
-rw-r--r--ripd/rip_interface.c45
-rw-r--r--ripd/rip_memory.c1
-rw-r--r--ripd/rip_memory.h1
3 files changed, 23 insertions, 24 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 5a3f34120..58247f162 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -514,14 +514,12 @@ static void rip_interface_reset(struct rip_interface *ri)
ri->v2_broadcast = 0;
- if (ri->auth_str) {
- free(ri->auth_str);
- ri->auth_str = NULL;
- }
- if (ri->key_chain) {
- free(ri->key_chain);
- ri->key_chain = NULL;
- }
+ if (ri->auth_str)
+ XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
+
+ if (ri->key_chain)
+ XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
+
ri->list[RIP_FILTER_IN] = NULL;
ri->list[RIP_FILTER_OUT] = NULL;
@@ -825,7 +823,8 @@ static int rip_enable_if_add(const char *ifname)
if (ret >= 0)
return -1;
- vector_set(rip_enable_interface, strdup(ifname));
+ vector_set(rip_enable_interface,
+ XSTRDUP(MTYPE_RIP_INTERFACE_STRING, ifname));
rip_enable_apply_all(); /* TODOVJ */
@@ -843,7 +842,7 @@ static int rip_enable_if_delete(const char *ifname)
return -1;
str = vector_slot(rip_enable_interface, index);
- free(str);
+ XFREE(MTYPE_RIP_INTERFACE_STRING, str);
vector_unset(rip_enable_interface, index);
rip_enable_apply_all(); /* TODOVJ */
@@ -1062,7 +1061,7 @@ void rip_clean_network()
/* rip_enable_interface. */
for (i = 0; i < vector_active(rip_enable_interface); i++)
if ((str = vector_slot(rip_enable_interface, i)) != NULL) {
- free(str);
+ XFREE(MTYPE_RIP_INTERFACE_STRING, str);
vector_slot(rip_enable_interface, i) = NULL;
}
}
@@ -1110,7 +1109,8 @@ static int rip_passive_nondefault_set(struct vty *vty, const char *ifname)
if (rip_passive_nondefault_lookup(ifname) >= 0)
return CMD_WARNING_CONFIG_FAILED;
- vector_set(Vrip_passive_nondefault, strdup(ifname));
+ vector_set(Vrip_passive_nondefault,
+ XSTRDUP(MTYPE_RIP_INTERFACE_STRING, ifname));
rip_passive_interface_apply_all();
@@ -1127,7 +1127,7 @@ static int rip_passive_nondefault_unset(struct vty *vty, const char *ifname)
return CMD_WARNING_CONFIG_FAILED;
str = vector_slot(Vrip_passive_nondefault, i);
- free(str);
+ XFREE(MTYPE_RIP_INTERFACE_STRING, str);
vector_unset(Vrip_passive_nondefault, i);
rip_passive_interface_apply_all();
@@ -1143,7 +1143,7 @@ void rip_passive_nondefault_clean(void)
for (i = 0; i < vector_active(Vrip_passive_nondefault); i++)
if ((str = vector_slot(Vrip_passive_nondefault, i)) != NULL) {
- free(str);
+ XFREE(MTYPE_RIP_INTERFACE_STRING, str);
vector_slot(Vrip_passive_nondefault, i) = NULL;
}
rip_passive_interface_apply_all();
@@ -1529,9 +1529,9 @@ DEFUN (ip_rip_authentication_string,
}
if (ri->auth_str)
- free(ri->auth_str);
+ XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
- ri->auth_str = strdup(argv[idx_line]->arg);
+ ri->auth_str = XSTRDUP(MTYPE_RIP_INTERFACE_STRING, argv[idx_line]->arg);
return CMD_SUCCESS;
}
@@ -1552,9 +1552,7 @@ DEFUN (no_ip_rip_authentication_string,
ri = ifp->info;
if (ri->auth_str)
- free(ri->auth_str);
-
- ri->auth_str = NULL;
+ XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
return CMD_SUCCESS;
}
@@ -1581,9 +1579,10 @@ DEFUN (ip_rip_authentication_key_chain,
}
if (ri->key_chain)
- free(ri->key_chain);
+ XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
- ri->key_chain = strdup(argv[idx_line]->arg);
+ ri->key_chain =
+ XSTRDUP(MTYPE_RIP_INTERFACE_STRING, argv[idx_line]->arg);
return CMD_SUCCESS;
}
@@ -1604,9 +1603,7 @@ DEFUN (no_ip_rip_authentication_key_chain,
ri = ifp->info;
if (ri->key_chain)
- free(ri->key_chain);
-
- ri->key_chain = NULL;
+ XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
return CMD_SUCCESS;
}
diff --git a/ripd/rip_memory.c b/ripd/rip_memory.c
index 4cdd3df04..185241074 100644
--- a/ripd/rip_memory.c
+++ b/ripd/rip_memory.c
@@ -29,6 +29,7 @@ DEFINE_MGROUP(RIPD, "ripd")
DEFINE_MTYPE(RIPD, RIP, "RIP structure")
DEFINE_MTYPE(RIPD, RIP_INFO, "RIP route info")
DEFINE_MTYPE(RIPD, RIP_INTERFACE, "RIP interface")
+DEFINE_MTYPE(RIPD, RIP_INTERFACE_STRING, "RIP Interface String")
DEFINE_MTYPE(RIPD, RIP_PEER, "RIP peer")
DEFINE_MTYPE(RIPD, RIP_OFFSET_LIST, "RIP offset list")
DEFINE_MTYPE(RIPD, RIP_DISTANCE, "RIP distance")
diff --git a/ripd/rip_memory.h b/ripd/rip_memory.h
index 57abedd3a..29013ecec 100644
--- a/ripd/rip_memory.h
+++ b/ripd/rip_memory.h
@@ -28,6 +28,7 @@ DECLARE_MGROUP(RIPD)
DECLARE_MTYPE(RIP)
DECLARE_MTYPE(RIP_INFO)
DECLARE_MTYPE(RIP_INTERFACE)
+DECLARE_MTYPE(RIP_INTERFACE_STRING)
DECLARE_MTYPE(RIP_PEER)
DECLARE_MTYPE(RIP_OFFSET_LIST)
DECLARE_MTYPE(RIP_DISTANCE)