]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: explicitly sending route refresh from CLI
authorMaria Matejka <mq@ucw.cz>
Wed, 29 May 2024 08:55:59 +0000 (10:55 +0200)
committerMaria Matejka <mq@ucw.cz>
Wed, 29 May 2024 15:09:50 +0000 (17:09 +0200)
doc/bird.sgml
proto/bgp/bgp.c
proto/bgp/bgp.h
proto/bgp/config.Y

index c5a75e5448a9c35fac1fa669647358d8ae54e6b8..763ddfa3d3519f77942391be478b772e49bfbac1 100644 (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.
 
index 6739ac16c601c37fa55f026b93a8c39ea0ddb253..3c342cdd4cb90ac59ae39974bfa8b6137f757a46 100644 (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;
-  }
-
-  /* Ignore non-BGP channels */
-  if (C->class != &channel_bgp)
-  {
-    cir->done(cir);
-    return 1;
-  }
-
-  if (cir->trie)
-  {
-    cir->done(cir);
-    return 0;
+      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);
+      }
   }
-  /* We do not need cir anymore and later we will not be able to detect when to free it. */
-  cir->done(cir);
+  else
+    cli_msg(-8006, "%s: not reloading, not up", P->name);
+}
 
-  ASSERT(p->conn && p->route_refresh);
-  bgp_schedule_packet(p->conn, c, PKT_ROUTE_REFRESH);
-  return 1;
+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;
 
index 3d234fa276b8ed2d9804bd65b53cfd7c09c2ed88..fc739de1452a38c1a62220d37a8e9021843c7330 100644 (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)
 {
index 2ee26919cb54a950952168ff983431f64a3f481d..f2bce1df66c8adb8eacf1caeed54d740a5425244 100644 (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