]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixed unwanted reloads while reconfiguring protocols with import table on
authorMaria Matejka <mq@ucw.cz>
Wed, 8 Mar 2023 12:44:18 +0000 (13:44 +0100)
committerMaria Matejka <mq@ucw.cz>
Tue, 4 Apr 2023 15:00:58 +0000 (17:00 +0200)
nest/proto.c
nest/protocol.h
proto/bgp/bgp.c
proto/bgp/config.Y

index 6c6d4ed3d94d6b068267cf8941d10104e0fa94ee..3a8c938e5920cfec11faff0a132c3ca59678ab96 100644 (file)
@@ -690,7 +690,7 @@ channel_reload_dump_req(struct rt_export_request *req)
 void channel_reload_export_bulk(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe, rte **feed, uint count);
 
 /* Called by protocol to activate in_table */
-void
+static void
 channel_setup_in_table(struct channel *c)
 {
   c->reload_req = (struct rt_export_request) {
@@ -701,8 +701,6 @@ channel_setup_in_table(struct channel *c)
     .dump_req = channel_reload_dump_req,
     .log_state_change = channel_reload_log_state_change,
   };
-
-  c->in_keep |= RIK_PREFILTER;
 }
 
 
@@ -711,6 +709,9 @@ channel_do_start(struct channel *c)
 {
   c->proto->active_channels++;
 
+  if ((c->in_keep & RIK_PREFILTER) == RIK_PREFILTER)
+    channel_setup_in_table(c);
+
   CALL(c->channel->start, c);
 
   channel_start_import(c);
@@ -882,7 +883,7 @@ channel_request_reload(struct channel *c)
 
   CD(c, "Reload requested");
 
-  if (c->in_keep & RIK_PREFILTER)
+  if ((c->in_keep & RIK_PREFILTER) == RIK_PREFILTER)
     channel_schedule_reload(c);
   else
     c->proto->reload_routes(c);
index f9f89c06a0b1fe2bc7fd5c544723976e52c50163..fe987d1793e9502dfc500114baba4aac92a1793e 100644 (file)
@@ -642,7 +642,6 @@ struct channel *proto_add_channel(struct proto *p, struct channel_config *cf);
 int proto_configure_channel(struct proto *p, struct channel **c, struct channel_config *cf);
 
 void channel_set_state(struct channel *c, uint state);
-void channel_setup_in_table(struct channel *c);
 void channel_schedule_reload(struct channel *c);
 
 static inline void channel_init(struct channel *c) { channel_set_state(c, CS_START); }
index 26fccdc3160da8c7c39a15b23ecf28288a58cbae..851167b66fd9720f124bb9b095e54c2a91d66537 100644 (file)
@@ -651,7 +651,7 @@ bgp_conn_enter_established_state(struct bgp_conn *conn)
 
     int active = loc->ready && rem->ready;
     c->c.disabled = !active;
-    c->c.reloadable = p->route_refresh || c->cf->import_table;
+    c->c.reloadable = p->route_refresh || ((c->c.in_keep & RIK_PREFILTER) == RIK_PREFILTER);
 
     c->index = active ? num++ : 0;
 
@@ -1868,9 +1868,6 @@ bgp_channel_start(struct channel *C)
 
   c->pool = p->p.pool; // XXXX
 
-  if (c->cf->import_table)
-    channel_setup_in_table(C);
-
   if (c->cf->export_table)
     bgp_setup_out_table(c);
 
@@ -2283,7 +2280,6 @@ bgp_channel_reconfigure(struct channel *C, struct channel_config *CC, int *impor
       (new->llgr_time != old->llgr_time) ||
       (new->ext_next_hop != old->ext_next_hop) ||
       (new->add_path != old->add_path) ||
-      (new->import_table != old->import_table) ||
       (new->export_table != old->export_table) ||
       (TABLE(new, igp_table_ip4) != TABLE(old, igp_table_ip4)) ||
       (TABLE(new, igp_table_ip6) != TABLE(old, igp_table_ip6)) ||
@@ -2298,11 +2294,13 @@ bgp_channel_reconfigure(struct channel *C, struct channel_config *CC, int *impor
       (new->aigp != old->aigp) ||
       (new->cost != old->cost))
   {
-    /* import_changed itself does not force ROUTE_REFRESH when import_table is active */
-    if ((c->c.in_keep & RIK_PREFILTER) && (c->c.channel_state == CS_UP))
+    /* If import table is active and route refresh is possible, we just ask for route refresh */
+    if ((c->c.in_keep & RIK_PREFILTER) && (c->c.channel_state == CS_UP) && p->route_refresh)
       bgp_schedule_packet(p->conn, c, PKT_ROUTE_REFRESH);
 
-    *import_changed = 1;
+    /* Otherwise we do complete reload */
+    else
+      *import_changed = 1;
   }
 
   if (!ipa_equal(new->next_hop_addr, old->next_hop_addr) ||
index 66d97e3bb1f80cc3055182b18e77f3909f764115..a51c82bd431c873ebd2a5fac2ecdfd64ef995551 100644 (file)
@@ -329,6 +329,9 @@ bgp_channel_end:
   if (!this_channel->table)
     cf_error("Routing table not specified");
 
+  if (BGP_CC->import_table)
+    this_channel->in_keep |= RIK_PREFILTER;
+
   this_channel = NULL;
 };