summaryrefslogtreecommitdiffstats
path: root/ripngd/ripng_zebra.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-01-04 22:08:10 +0100
committerRenato Westphal <renato@opensourcerouting.org>2019-01-18 19:15:41 +0100
commitf9120f719ac2433dd9f168eed97e7b71ea38125e (patch)
tree63a1bfe594d65af6fdcfa3dbe16a7d3445b8b012 /ripngd/ripng_zebra.c
parentripd: fix unsetting of authentication password (diff)
downloadfrr-f9120f719ac2433dd9f168eed97e7b71ea38125e.tar.xz
frr-f9120f719ac2433dd9f168eed97e7b71ea38125e.zip
ripd, ripngd: change how we keep track of redistribution configuration
ripd and ripngd were leveraging the zclient code to keep track of the redistribute configuration, which is what most daemons do. The problem, however, is that the zclient code uses VRF IDs to identify VRFs, and VRF IDs are unknown until a VRF is enabled (information received from zebra). This means we can't configure a redistribute command on a RIP instance when the corresponding VRF is disabled (doing so leads to a null-dereference crash right now in both ripd and ripngd). To fix this, change the rip/ripng data structures so that they keep track of the full redistribute configuration and not only the route-map and metric associated to each command. This is similar to what bgpd and ospfd are doing to solve the same problem. In the future the zclient code and all daemons need to be refactored to consolidate the handling of redistribute configuration in a single place to reduce code duplication. One of the most important changes to do is to use VRF names and not VRF IDs to identify VRFs. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripngd/ripng_zebra.c')
-rw-r--r--ripngd/ripng_zebra.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c
index 913ac5191..e2dcc0238 100644
--- a/ripngd/ripng_zebra.c
+++ b/ripngd/ripng_zebra.c
@@ -165,24 +165,28 @@ void ripng_redistribute_conf_delete(struct ripng *ripng, int type)
int ripng_redistribute_check(struct ripng *ripng, int type)
{
- return vrf_bitmap_check(zclient->redist[AFI_IP6][type],
- ripng->vrf->vrf_id);
+ return ripng->redist[type].enabled;
}
-void ripng_redistribute_clean(struct ripng *ripng)
+void ripng_redistribute_enable(struct ripng *ripng)
{
for (int i = 0; i < ZEBRA_ROUTE_MAX; i++) {
- if (!vrf_bitmap_check(zclient->redist[AFI_IP6][i],
- ripng->vrf->vrf_id))
+ if (!ripng_redistribute_check(ripng, i))
continue;
- if (zclient->sock > 0)
- zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE,
- zclient, AFI_IP6, i, 0,
- ripng->vrf->vrf_id);
+ zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient,
+ AFI_IP6, i, 0, ripng->vrf->vrf_id);
+ }
+}
- vrf_bitmap_unset(zclient->redist[AFI_IP6][i],
- ripng->vrf->vrf_id);
+void ripng_redistribute_disable(struct ripng *ripng)
+{
+ for (int i = 0; i < ZEBRA_ROUTE_MAX; i++) {
+ if (!ripng_redistribute_check(ripng, i))
+ continue;
+
+ zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient,
+ AFI_IP6, i, 0, ripng->vrf->vrf_id);
}
}
@@ -192,8 +196,7 @@ void ripng_redistribute_write(struct vty *vty, struct ripng *ripng)
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
if (i == zclient->redist_default
- || !vrf_bitmap_check(zclient->redist[AFI_IP6][i],
- ripng->vrf->vrf_id))
+ || !ripng_redistribute_check(ripng, i))
continue;
vty_out(vty, " %s", zebra_route_string(i));