Skip to content

Commit

Permalink
Merge pull request FRRouting#14282 from pguibert6WIND/fix_redistribut…
Browse files Browse the repository at this point in the history
…e_table_flush

bgpd: fix redistribute table command after bgp restarts
  • Loading branch information
ton31337 authored Aug 31, 2023
2 parents ef8cd78 + 82b11d8 commit c4f761d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
9 changes: 6 additions & 3 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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. */
Expand Down
23 changes: 19 additions & 4 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions bgpd/bgp_zebra.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit c4f761d

Please sign in to comment.