summaryrefslogtreecommitdiff
path: root/bgpd/rfapi/vnc_zebra.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2018-10-19 15:55:22 -0300
committerRenato Westphal <renato@opensourcerouting.org>2018-10-20 12:39:05 -0300
commit9f2337c913d0881701597edd419d1ba96b06f109 (patch)
tree4bb6dfbaba28aff6e294b363715bb46069a4370a /bgpd/rfapi/vnc_zebra.c
parent2eab13249cfea60f5788ac4393d2096e63d19e22 (diff)
bgpd: use the vrf_bitmap_*() helper functions when necessary
zclient->redist[afi][type] is a hash table and not an integer since a while ago when VRF support was introduced. As such, zclient->redist[][] should never be manipulated directly, the vrf_bitmap_*() helper functions should be used instead. This fixes a few crashes found by the CLI fuzzer. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'bgpd/rfapi/vnc_zebra.c')
-rw-r--r--bgpd/rfapi/vnc_zebra.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c
index 158c88da16..97d520eda7 100644
--- a/bgpd/rfapi/vnc_zebra.c
+++ b/bgpd/rfapi/vnc_zebra.c
@@ -578,7 +578,9 @@ static void vnc_zebra_add_del_prefix(struct bgp *bgp,
return;
}
- if (!zclient_vnc->redist[family2afi(rn->p.family)][ZEBRA_ROUTE_VNC])
+ if (!vrf_bitmap_check(zclient_vnc->redist[family2afi(rn->p.family)]
+ [ZEBRA_ROUTE_VNC],
+ VRF_DEFAULT))
return;
if (!bgp->rfapi_cfg) {
@@ -642,7 +644,8 @@ static void vnc_zebra_add_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd,
if (zclient_vnc->sock < 0)
return;
- if (!zclient_vnc->redist[afi][ZEBRA_ROUTE_VNC])
+ if (!vrf_bitmap_check(zclient_vnc->redist[afi][ZEBRA_ROUTE_VNC],
+ VRF_DEFAULT))
return;
if (afi != AFI_IP && afi != AFI_IP6) {
@@ -841,12 +844,12 @@ int vnc_redistribute_set(struct bgp *bgp, afi_t afi, int type)
// bgp->redist[afi][type] = 1;
/* Return if already redistribute flag is set. */
- if (zclient_vnc->redist[afi][type])
+ if (vrf_bitmap_check(zclient_vnc->redist[afi][type], VRF_DEFAULT))
return CMD_WARNING_CONFIG_FAILED;
vrf_bitmap_set(zclient_vnc->redist[afi][type], VRF_DEFAULT);
- // zclient_vnc->redist[afi][type] = 1;
+ // vrf_bitmap_set(zclient_vnc->redist[afi][type], VRF_DEFAULT);
/* Return if zebra connection is not established. */
if (zclient_vnc->sock < 0)
@@ -877,9 +880,9 @@ int vnc_redistribute_unset(struct bgp *bgp, afi_t afi, int type)
bgp->rfapi_cfg->redist[afi][type] = 0;
/* Return if zebra connection is disabled. */
- if (!zclient_vnc->redist[afi][type])
+ if (!vrf_bitmap_check(zclient_vnc->redist[afi][type], VRF_DEFAULT))
return CMD_WARNING_CONFIG_FAILED;
- zclient_vnc->redist[afi][type] = 0;
+ vrf_bitmap_unset(zclient_vnc->redist[afi][type], VRF_DEFAULT);
if (bgp->rfapi_cfg->redist[AFI_IP][type] == 0
&& bgp->rfapi_cfg->redist[AFI_IP6][type] == 0