]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: Improve reconfiguration
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 5 Aug 2019 12:43:49 +0000 (14:43 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 5 Aug 2019 12:43:49 +0000 (14:43 +0200)
Several BGP channel options (including 'next hop self') could be
reconfigured without session reset, with just route refeed/refresh.
The patch improves reconfiguration code to do it that way.

nest/proto.c
nest/protocol.h
proto/bgp/bgp.c
proto/bgp/bgp.h

index 4aeec01e0bc08ee56929511f6ea4cffbe16cb4e1..0e82bf6908f36b80aa1394407851408c13d00051 100644 (file)
@@ -616,7 +616,7 @@ channel_reconfigure(struct channel *c, struct channel_config *cf)
   channel_verify_limits(c);
 
   /* Execute channel-specific reconfigure hook */
-  if (c->channel->reconfigure && !c->channel->reconfigure(c, cf))
+  if (c->channel->reconfigure && !c->channel->reconfigure(c, cf, &import_changed, &export_changed))
     return 0;
 
   /* If the channel is not open, it has no routes and we cannot reload it anyways */
index d67ba9e23c5494307f63a3f92982fd5ca06938e4..0132addf42f78d47484b835bbfe7ae6ac7354da4 100644 (file)
@@ -433,7 +433,7 @@ struct channel_class {
   uint config_size;                    /* Size of channel config data structure */
 
   void (*init)(struct channel *, struct channel_config *);     /* Create new instance */
-  int (*reconfigure)(struct channel *, struct channel_config *);       /* Try to reconfigure instance, returns success */
+  int (*reconfigure)(struct channel *, struct channel_config *, int *import_changed, int *export_changed);     /* Try to reconfigure instance, returns success */
   int (*start)(struct channel *);      /* Start the instance */
   void (*shutdown)(struct channel *);  /* Stop the instance */
   void (*cleanup)(struct channel *);   /* Channel finished flush */
index 6528723b0ab61b122387309ba708b2248bc42934..98fdd6d4bdac857c68065896b94f9011487faab2 100644 (file)
@@ -1830,23 +1830,30 @@ bgp_reconfigure(struct proto *P, struct proto_config *CF)
 #define IGP_TABLE(cf, sym) ((cf)->igp_table_##sym ? (cf)->igp_table_##sym ->table : NULL )
 
 static int
-bgp_channel_reconfigure(struct channel *C, struct channel_config *CC)
+bgp_channel_reconfigure(struct channel *C, struct channel_config *CC, int *import_changed, int *export_changed)
 {
   struct bgp_channel *c = (void *) C;
   struct bgp_channel_config *new = (void *) CC;
   struct bgp_channel_config *old = c->cf;
 
-  if (memcmp(((byte *) old) + sizeof(struct channel_config),
-            ((byte *) new) + sizeof(struct channel_config),
-            /* Remaining items must be checked separately */
-            OFFSETOF(struct bgp_channel_config, rest) - sizeof(struct channel_config)))
-    return 0;
-
-  /* Check change in IGP tables */
-  if ((IGP_TABLE(old, ip4) != IGP_TABLE(new, ip4)) ||
+  if ((new->secondary != old->secondary) ||
+      (new->gr_able != old->gr_able) ||
+      (new->ext_next_hop != old->ext_next_hop) ||
+      (new->add_path != old->add_path) ||
+      (new->import_table != old->import_table) ||
+      (IGP_TABLE(old, ip4) != IGP_TABLE(new, ip4)) ||
       (IGP_TABLE(old, ip6) != IGP_TABLE(new, ip6)))
     return 0;
 
+  if (new->gw_mode != old->gw_mode)
+    *import_changed = 1;
+
+  if (!ipa_equal(new->next_hop_addr, old->next_hop_addr) ||
+      (new->next_hop_self != old->next_hop_self) ||
+      (new->next_hop_keep != old->next_hop_keep) ||
+      (new->missing_lladdr != old->missing_lladdr))
+    *export_changed = 1;
+
   c->cf = new;
   return 1;
 }
index b1b9abedeedf343519c65f85a3f5e51ddf8b08b6..3f8ac90b61c6eb09becdcff5ba9707874542b660 100644 (file)
@@ -144,7 +144,6 @@ struct bgp_channel_config {
   u8 add_path;                         /* Use ADD-PATH extension [RFC 7911] */
   u8 import_table;                     /* Use c.in_table as Adj-RIB-In */
 
-  uint rest[0];                                /* Remaining items are reconfigured separately */
   struct rtable_config *igp_table_ip4; /* Table for recursive IPv4 next hop lookups */
   struct rtable_config *igp_table_ip6; /* Table for recursive IPv6 next hop lookups */
 };