From 87a77ae542d8b29bb26432eb65ced254536c2895 Mon Sep 17 00:00:00 2001
From: Ondrej Zajicek <santiago@crfreenet.org>
Date: Tue, 3 Jun 2025 16:56:41 +0200
Subject: BGP: Do route refresh after preference change

Reconfiguration of preference is handled by nest code by asking for
reload, but in case of BGP with import table, that just reloaded routes
with the old preference. In BGP, we can handle that by triggering full
route refresh.

Although, it would be probably better to set preference in nest, when
a route is propagated from the import table.

diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index c8f90fadb..203715258 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -2830,12 +2830,16 @@ bgp_channel_reconfigure(struct channel *C, struct channel_config *CC, int *impor
   if ((new->gw_mode != old->gw_mode) ||
       (new->next_hop_prefer != old->next_hop_prefer) ||
       (new->aigp != old->aigp) ||
-      (new->cost != old->cost))
+      (new->cost != old->cost) ||
+      (new->c.preference != old->c.preference))
   {
     /* import_changed itself does not force ROUTE_REFRESH when import_table is active */
     if (c->c.in_table && (c->c.channel_state == CS_UP))
       bgp_schedule_packet(p->conn, c, PKT_ROUTE_REFRESH);
 
+    /* Note that preference is already handled in channel_reconfigure(),
+       but we need it handle again here for the ROUTE_REFRESH trigger */
+
     *import_changed = 1;
   }
 
