diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index f4e901ef6ce5..1c902149711e 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -16974,7 +16974,8 @@ DEFUN (no_bgp_redistribute_ipv4_ospf, protocol = ZEBRA_ROUTE_TABLE; instance = strtoul(argv[idx_number]->arg, NULL, 10); - return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); + bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); + return CMD_SUCCESS; } ALIAS_HIDDEN( @@ -17010,7 +17011,8 @@ DEFUN (no_bgp_redistribute_ipv4, vty_out(vty, "%% Invalid route type\n"); return CMD_WARNING_CONFIG_FAILED; } - return bgp_redistribute_unset(bgp, AFI_IP, type, 0); + bgp_redistribute_unset(bgp, AFI_IP, type, 0); + return CMD_SUCCESS; } ALIAS_HIDDEN( @@ -17194,7 +17196,8 @@ DEFUN (no_bgp_redistribute_ipv6, return CMD_WARNING_CONFIG_FAILED; } - return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); + bgp_redistribute_unset(bgp, AFI_IP6, type, 0); + return CMD_SUCCESS; } /* Neighbor update tcp-mss. */ diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index d8204d0f311b..105c1080bc7f 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -2078,8 +2078,8 @@ int bgp_redistribute_unreg(struct bgp *bgp, afi_t afi, int type, } /* Unset redistribution. */ -int bgp_redistribute_unset(struct bgp *bgp, afi_t afi, int type, - unsigned short instance) +static void _bgp_redistribute_unset(struct bgp *bgp, afi_t afi, int type, + unsigned short instance) { struct bgp_redist *red; @@ -2096,7 +2096,7 @@ int bgp_redistribute_unset(struct bgp *bgp, afi_t afi, int type, red = bgp_redist_lookup(bgp, afi, type, instance); if (!red) - return CMD_SUCCESS; + return; bgp_redistribute_unreg(bgp, afi, type, instance); @@ -2110,8 +2110,23 @@ int bgp_redistribute_unset(struct bgp *bgp, afi_t afi, int type, red->redist_metric = 0; bgp_redist_del(bgp, afi, type, instance); +} - return CMD_SUCCESS; +void bgp_redistribute_unset(struct bgp *bgp, afi_t afi, int type, + unsigned short instance) +{ + struct listnode *node, *nnode; + struct bgp_redist *red; + + if (type != ZEBRA_ROUTE_TABLE || instance != 0) + return _bgp_redistribute_unset(bgp, afi, type, instance); + + /* walk over instance */ + if (!bgp->redist[afi][type]) + return; + + for (ALL_LIST_ELEMENTS(bgp->redist[afi][type], node, nnode, red)) + _bgp_redistribute_unset(bgp, afi, type, red->instance); } void bgp_redistribute_redo(struct bgp *bgp) diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h index ed2d5e669dca..0edae041d2f9 100644 --- a/bgpd/bgp_zebra.h +++ b/bgpd/bgp_zebra.h @@ -64,8 +64,8 @@ extern bool bgp_redistribute_rmap_set(struct bgp_redist *red, const char *name, struct route_map *route_map); extern bool bgp_redistribute_metric_set(struct bgp *bgp, struct bgp_redist *red, afi_t afi, int type, uint32_t metric); -extern int bgp_redistribute_unset(struct bgp *bgp, afi_t afi, int type, - unsigned short instance); +extern void bgp_redistribute_unset(struct bgp *bgp, afi_t afi, int type, + unsigned short instance); extern int bgp_redistribute_unreg(struct bgp *bgp, afi_t afi, int type, unsigned short instance);