summaryrefslogtreecommitdiffstats
path: root/ripd
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2019-01-14 08:58:36 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2019-02-19 21:11:13 +0100
commit4b23867cad558a59e8d315400b82c0453510c9af (patch)
tree659eb4c089bfca4451921697caad11eaa5bc2d18 /ripd
parentMerge pull request #3823 from opensourcerouting/confd-build-fix (diff)
downloadfrr-4b23867cad558a59e8d315400b82c0453510c9af.tar.xz
frr-4b23867cad558a59e8d315400b82c0453510c9af.zip
lib, rip, ripng, eigrp: rework if_rmap context
so as to handle ri/ripng/eigrp multiple instances, the need is to encapsulate if_rmap hash table into a container context self to each instance. This work then reviews the if_rmap api, mainly by adding a if_rmap_ctx context, that is passed for each exchange between library and the daemon. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'ripd')
-rw-r--r--ripd/ripd.c36
-rw-r--r--ripd/ripd.h6
2 files changed, 32 insertions, 10 deletions
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 38b4aed5b..b95034e40 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -71,6 +71,9 @@ static int rip_update_jitter(unsigned long);
static void rip_distribute_update(struct distribute_ctx *ctx,
struct distribute *dist);
+static void rip_if_rmap_update(struct if_rmap_ctx *ctx,
+ struct if_rmap *if_rmap);
+
/* RIP output routes type. */
enum { rip_all_route, rip_changed_route };
@@ -2712,6 +2715,13 @@ int rip_create(int socket)
rip_distribute_update);
distribute_list_delete_hook(rip->distribute_ctx,
rip_distribute_update);
+
+ /* if rmap install. */
+ rip->if_rmap_ctx = if_rmap_ctx_create(
+ vrf_lookup_by_id(VRF_DEFAULT));
+ if_rmap_hook_add(rip->if_rmap_ctx, rip_if_rmap_update);
+ if_rmap_hook_delete(rip->if_rmap_ctx, rip_if_rmap_update);
+
return 0;
}
@@ -3228,7 +3238,7 @@ static int config_write_rip(struct vty *vty)
rip->distribute_ctx);
/* Interface routemap configuration */
- write += config_write_if_rmap(vty);
+ write += config_write_if_rmap(vty, rip->if_rmap_ctx);
}
return write;
}
@@ -3381,25 +3391,29 @@ void rip_clean(void)
route_table_finish(rip->neighbor);
distribute_list_delete(&rip->distribute_ctx);
+
+ if_rmap_ctx_delete(rip->if_rmap_ctx);
+
XFREE(MTYPE_RIP, rip);
rip = NULL;
}
-
rip_clean_network();
rip_passive_nondefault_clean();
rip_offset_clean();
rip_interfaces_clean();
rip_distance_reset();
rip_redistribute_clean();
+ if_rmap_terminate();
}
-static void rip_if_rmap_update(struct if_rmap *if_rmap)
+static void rip_if_rmap_update(struct if_rmap_ctx *ctx,
+ struct if_rmap *if_rmap)
{
struct interface *ifp;
struct rip_interface *ri;
struct route_map *rmap;
- ifp = if_lookup_by_name(if_rmap->ifname, VRF_DEFAULT);
+ ifp = if_lookup_by_name(if_rmap->ifname, ctx->vrf->vrf_id);
if (ifp == NULL)
return;
@@ -3426,10 +3440,18 @@ static void rip_if_rmap_update(struct if_rmap *if_rmap)
void rip_if_rmap_update_interface(struct interface *ifp)
{
struct if_rmap *if_rmap;
+ struct if_rmap_ctx *ctx;
- if_rmap = if_rmap_lookup(ifp->name);
+ if (!rip)
+ return;
+ if (ifp->vrf_id != VRF_DEFAULT)
+ return;
+ ctx = rip->if_rmap_ctx;
+ if (!ctx)
+ return;
+ if_rmap = if_rmap_lookup(ctx, ifp->name);
if (if_rmap)
- rip_if_rmap_update(if_rmap);
+ rip_if_rmap_update(ctx, if_rmap);
}
static void rip_routemap_update_redistribute(void)
@@ -3497,8 +3519,6 @@ void rip_init(void)
route_map_delete_hook(rip_routemap_update);
if_rmap_init(RIP_NODE);
- if_rmap_hook_add(rip_if_rmap_update);
- if_rmap_hook_delete(rip_if_rmap_update);
/* Distance control. */
rip_distance_table = route_table_init();
diff --git a/ripd/ripd.h b/ripd/ripd.h
index 7b8fe3a90..383df3707 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -154,6 +154,9 @@ struct rip {
/* For distribute-list container */
struct distribute_ctx *distribute_ctx;
+
+ /* For if_rmap container */
+ struct if_rmap_ctx *if_rmap_ctx;
};
/* RIP routing table entry which belong to rip_packet. */
@@ -419,8 +422,7 @@ extern void rip_zebra_ipv4_add(struct route_node *);
extern void rip_zebra_ipv4_delete(struct route_node *);
extern void rip_interface_multicast_set(int, struct connected *);
extern void rip_distribute_update_interface(struct interface *);
-extern void rip_if_rmap_update_interface(struct interface *);
-
+extern void rip_if_rmap_update_interface(struct interface *ifp);
extern int rip_show_network_config(struct vty *);
extern void rip_show_redistribute_config(struct vty *);