]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/if_rmap.c
mpls: add support for LDP LSPs
[mirror_frr.git] / lib / if_rmap.c
index e4a83de8bb85c1b281fde8a83332bbeec3d7d996..736f2e237d4803b6f3cea7bff35aad4705099229 100644 (file)
@@ -27,6 +27,9 @@
 #include "if.h"
 #include "if_rmap.h"
 
+DEFINE_MTYPE_STATIC(LIB, IF_RMAP,      "Interface route map")
+DEFINE_MTYPE_STATIC(LIB, IF_RMAP_NAME, "I.f. route map name")
+
 struct hash *ifrmaphash;
 
 /* Hook functions. */
@@ -64,10 +67,13 @@ if_rmap_lookup (const char *ifname)
   struct if_rmap *if_rmap;
 
   /* temporary copy */
-  key.ifname = (char *)ifname;
+  key.ifname = (ifname) ? XSTRDUP (MTYPE_IF_RMAP_NAME, ifname) : NULL;
 
   if_rmap = hash_lookup (ifrmaphash, &key);
   
+  if (key.ifname)
+    XFREE(MTYPE_IF_RMAP_NAME, key.ifname);
+
   return if_rmap;
 }
 
@@ -86,7 +92,7 @@ if_rmap_hook_delete (void (*func) (struct if_rmap *))
 static void *
 if_rmap_hash_alloc (void *arg)
 {
-  struct if_rmap *ifarg = arg;
+  struct if_rmap *ifarg = (struct if_rmap *)arg;
   struct if_rmap *if_rmap;
 
   if_rmap = if_rmap_new ();
@@ -99,11 +105,17 @@ static struct if_rmap *
 if_rmap_get (const char *ifname)
 {
   struct if_rmap key;
+  struct if_rmap *ret;
 
   /* temporary copy */
-  key.ifname = (char *)ifname;
+  key.ifname = (ifname) ? XSTRDUP (MTYPE_IF_RMAP_NAME, ifname) : NULL;
+
+  ret = hash_get (ifrmaphash, &key, if_rmap_hash_alloc);
+
+  if (key.ifname)
+    XFREE(MTYPE_IF_RMAP_NAME, key.ifname);
 
-  return (struct if_rmap *) hash_get (ifrmaphash, &key, if_rmap_hash_alloc);
+  return ret;
 }
 
 static unsigned int