summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eigrpd/eigrpd.c2
-rw-r--r--lib/if_rmap.c10
-rw-r--r--lib/if_rmap.h6
-rw-r--r--ripd/ripd.c11
-rw-r--r--ripngd/ripngd.c11
5 files changed, 26 insertions, 14 deletions
diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c
index 4f0a5d1b0f..93f8b6f90e 100644
--- a/eigrpd/eigrpd.c
+++ b/eigrpd/eigrpd.c
@@ -209,7 +209,7 @@ static struct eigrp *eigrp_new(const char *AS)
/*
eigrp->if_rmap_ctx = if_rmap_ctx_create(
- vrf_lookup_by_id(VRF_DEFAULT));
+ VRF_DEFAULT_NAME);
if_rmap_hook_add (eigrp_if_rmap_update);
if_rmap_hook_delete (eigrp_if_rmap_update);
*/
diff --git a/lib/if_rmap.c b/lib/if_rmap.c
index 42d01c8731..8e58d23e28 100644
--- a/lib/if_rmap.c
+++ b/lib/if_rmap.c
@@ -27,6 +27,7 @@
#include "if_rmap.h"
DEFINE_MTYPE_STATIC(LIB, IF_RMAP_CTX, "Interface route map container")
+DEFINE_MTYPE_STATIC(LIB, IF_RMAP_CTX_NAME, "Interface route map container name")
DEFINE_MTYPE_STATIC(LIB, IF_RMAP, "Interface route map")
DEFINE_MTYPE_STATIC(LIB, IF_RMAP_NAME, "I.f. route map name")
@@ -300,15 +301,20 @@ int config_write_if_rmap(struct vty *vty,
void if_rmap_ctx_delete(struct if_rmap_ctx *ctx)
{
hash_clean(ctx->ifrmaphash, (void (*)(void *))if_rmap_free);
+ if (ctx->name)
+ XFREE(MTYPE_IF_RMAP_CTX_NAME, ctx);
XFREE(MTYPE_IF_RMAP_CTX, ctx);
}
-struct if_rmap_ctx *if_rmap_ctx_create(struct vrf *vrf)
+/* name is optional: either vrf name, or other */
+struct if_rmap_ctx *if_rmap_ctx_create(const char *name)
{
struct if_rmap_ctx *ctx;
ctx = XCALLOC(MTYPE_IF_RMAP_CTX, sizeof(struct if_rmap_ctx));
- ctx->vrf = vrf;
+
+ if (ctx->name)
+ ctx->name = XSTRDUP(MTYPE_IF_RMAP_CTX_NAME, name);
ctx->ifrmaphash = hash_create_size(4, if_rmap_hash_make, if_rmap_hash_cmp,
"Interface Route-Map Hash");
if (!if_rmap_ctx_list)
diff --git a/lib/if_rmap.h b/lib/if_rmap.h
index 21ac35fe1d..dfc7298823 100644
--- a/lib/if_rmap.h
+++ b/lib/if_rmap.h
@@ -44,11 +44,11 @@ struct if_rmap_ctx {
void (*if_rmap_delete_hook)(struct if_rmap_ctx *ctx,
struct if_rmap *ifrmap);
- /* vrf information */
- struct vrf *vrf;
+ /* naming information */
+ char *name;
};
-extern struct if_rmap_ctx *if_rmap_ctx_create(struct vrf *vrf);
+extern struct if_rmap_ctx *if_rmap_ctx_create(const char *name);
extern void if_rmap_ctx_delete(struct if_rmap_ctx *ctx);
extern void if_rmap_init(int node);
extern void if_rmap_terminate(void);
diff --git a/ripd/ripd.c b/ripd/ripd.c
index b95034e400..03f335dd41 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -2717,8 +2717,7 @@ int rip_create(int socket)
rip_distribute_update);
/* if rmap install. */
- rip->if_rmap_ctx = if_rmap_ctx_create(
- vrf_lookup_by_id(VRF_DEFAULT));
+ rip->if_rmap_ctx = if_rmap_ctx_create(VRF_DEFAULT_NAME);
if_rmap_hook_add(rip->if_rmap_ctx, rip_if_rmap_update);
if_rmap_hook_delete(rip->if_rmap_ctx, rip_if_rmap_update);
@@ -3409,11 +3408,15 @@ void rip_clean(void)
static void rip_if_rmap_update(struct if_rmap_ctx *ctx,
struct if_rmap *if_rmap)
{
- struct interface *ifp;
+ struct interface *ifp = NULL;
struct rip_interface *ri;
struct route_map *rmap;
+ struct vrf *vrf = NULL;
- ifp = if_lookup_by_name(if_rmap->ifname, ctx->vrf->vrf_id);
+ if (ctx->name)
+ vrf = vrf_lookup_by_name(ctx->name);
+ if (vrf)
+ ifp = if_lookup_by_name(if_rmap->ifname, vrf->vrf_id);
if (ifp == NULL)
return;
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index 3e0982e573..9faebcf0d0 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -1821,8 +1821,7 @@ int ripng_create(int socket)
ripng_distribute_update);
/* if rmap install. */
- ripng->if_rmap_ctx = if_rmap_ctx_create(
- vrf_lookup_by_id(VRF_DEFAULT));
+ ripng->if_rmap_ctx = if_rmap_ctx_create(VRF_DEFAULT_NAME);
if_rmap_hook_add(ripng->if_rmap_ctx, ripng_if_rmap_update);
if_rmap_hook_delete(ripng->if_rmap_ctx, ripng_if_rmap_update);
@@ -2490,11 +2489,15 @@ void ripng_clean(void)
static void ripng_if_rmap_update(struct if_rmap_ctx *ctx,
struct if_rmap *if_rmap)
{
- struct interface *ifp;
+ struct interface *ifp = NULL;
struct ripng_interface *ri;
struct route_map *rmap;
+ struct vrf *vrf = NULL;
- ifp = if_lookup_by_name(if_rmap->ifname, ctx->vrf->vrf_id);
+ if (ctx->name)
+ vrf = vrf_lookup_by_name(ctx->name);
+ if (vrf)
+ ifp = if_lookup_by_name(if_rmap->ifname, vrf->vrf_id);
if (ifp == NULL)
return;