0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

BGP: explicitly sending route refresh from CLI

This commit is contained in:
Maria Matejka 2024-05-29 10:55:59 +02:00
parent e17824f5e5
commit ee7afdabc7
4 changed files with 42 additions and 32 deletions

View File

@ -1297,6 +1297,10 @@ This argument can be omitted if there exists only a single instance.
specified.
<!-- TODO: Move these protocol-specific remote control commands to the protocol sections -->
<tag><label id="cli-reload-bgp">reload bgp [in|out] [<m/name/]</tag>
Manually request (in) or send (out) route refresh (or both) on the
given BGP protocol(s).
<tag><label id="cli-show-ospf-iface">show ospf interface [<m/name/] ["<m/interface/"]</tag>
Show detailed information about OSPF interfaces.

View File

@ -1599,44 +1599,32 @@ bgp_update_bfd(struct bgp_proto *p, const struct bfd_options *bfd)
}
}
static int
bgp_reload_routes(struct channel *C, struct channel_import_request *cir)
void
bgp_reload_in(struct proto *P, uintptr_t _ UNUSED, int __ UNUSED)
{
struct bgp_proto *p = (void *) C->proto;
struct bgp_channel *c = (void *) C;
SKIP_BACK_DECLARE(struct bgp_proto, p, p, P);
/* For MPLS channel, reload all MPLS-aware channels */
if (C == p->p.mpls_channel)
if (P->proto_state == PS_UP)
{
struct bgp_channel *c;
BGP_WALK_CHANNELS(p, c)
if ((c->desc->mpls) && (p->route_refresh || c->cf->import_table))
channel_request_reload(&c->c);
/* Ignoring CIR, reloading always everything */
cir->done(cir);
return 1;
if (&c->c != P->mpls_channel)
{
cli_msg(-15, "%s.%s: reloading", P->name, c->c.name);
bgp_schedule_packet(p->conn, c, PKT_ROUTE_REFRESH);
}
}
/* Ignore non-BGP channels */
if (C->class != &channel_bgp)
{
cir->done(cir);
return 1;
}
if (cir->trie)
{
cir->done(cir);
return 0;
}
/* We do not need cir anymore and later we will not be able to detect when to free it. */
cir->done(cir);
ASSERT(p->conn && p->route_refresh);
bgp_schedule_packet(p->conn, c, PKT_ROUTE_REFRESH);
return 1;
else
cli_msg(-8006, "%s: not reloading, not up", P->name);
}
void
bgp_reload_out(struct proto *P, uintptr_t _ UNUSED, int __ UNUSED)
{
cli_msg(-8006, "%s: bgp reload out not implemented yet", P->name);
}
static void
bgp_feed_begin(struct channel *C)
{
@ -1948,7 +1936,6 @@ bgp_init(struct proto_config *CF)
P->rt_notify = bgp_rt_notify;
P->preexport = bgp_preexport;
P->iface_sub.neigh_notify = bgp_neigh_notify;
P->reload_routes = bgp_reload_routes;
P->feed_begin = bgp_feed_begin;
P->feed_end = bgp_feed_end;

View File

@ -589,6 +589,9 @@ void bgp_store_error(struct bgp_proto *p, struct bgp_conn *c, u8 class, u32 code
void bgp_stop(struct bgp_proto *p, int subcode, byte *data, uint len);
const char *bgp_format_role_name(u8 role);
void bgp_reload_in(struct proto *P, uintptr_t, int);
void bgp_reload_out(struct proto *P, uintptr_t, int);
static inline int
rte_resolvable(const rte *rt)
{

View File

@ -365,6 +365,22 @@ custom_attr: ATTRIBUTE BGP NUM type symbol ';' {
CF_ENUM(T_ENUM_BGP_ORIGIN, ORIGIN_, IGP, EGP, INCOMPLETE)
CF_CLI(RELOAD BGP, proto_patt, [<name>], [[Send and request route refresh to/from neighbor]])
{
proto_apply_cmd($3, bgp_reload_in, 1, 0);
proto_apply_cmd($3, bgp_reload_out, 1, 0);
};
CF_CLI(RELOAD BGP IN, proto_patt, [<name>], [[Request route refresh from neighbor]])
{
proto_apply_cmd($4, bgp_reload_in, 1, 0);
}
CF_CLI(RELOAD BGP OUT, proto_patt, [<name>], [[Refresh routes to neighbor]])
{
proto_apply_cmd($4, bgp_reload_out, 1, 0);
}
CF_CODE
CF_END