]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
MRT load looks working, but has some minor things to finish. Reload works, somehow kk-mrt-load
authorKaterina Kubecova <katerina.kubecova@nic.cz>
Wed, 3 Sep 2025 13:48:45 +0000 (15:48 +0200)
committerKaterina Kubecova <katerina.kubecova@nic.cz>
Wed, 3 Sep 2025 13:48:45 +0000 (15:48 +0200)
doc/bird.sgml
nest/config.Y
proto/mrt/mrtload.Y
proto/mrt/mrtload.c

index b658d7ca5457c6ab1227d5b96bbbe9725d73befa..65c4c5c97784d11bc0a8604d87da0bd9d42aa861 100644 (file)
@@ -4628,7 +4628,7 @@ name="mrtdump"> options independently of MRT protocol, although that might
 change in the future.
 
 Saved MRT files can be loaded to BIRD. Unlike MRT save, MRT load uses channels
-and it loads to ipv4 or ipv6 table. All routes loaded from MRT files have
+and loads to ipv4 or ipv6 table. All routes loaded from MRT files have
 MRT as their source and they are unreachable. 
 
 BIRD implements the main MRT format specification as defined in <rfc id="6396">
@@ -4695,17 +4695,17 @@ protocol mrt {
 <label id="mrt-load-config">
 
 <p>MRT load configuration consists of name of the file to load and
-the table where the loaded routes will be stored. BGP messages are 
-loaded according to the time they arrived whith REPLAY ACCELERATE parameter.
+the table where the loaded routes will be stored. Speed of loading
+can be changed with REPLAY ACCELERATE parameter.
 
 <descrip>
-       <tag><label id="mrt-table">table <m/name/ | "<m/pattern/"</tag>
+       <tag><label id="mrt-table">table <m/name/</tag>
        Specify a routing table where the routes from loaded file should be stored.
 
        <tag><label id="mrt-filename">filename "<m/filename/"</tag>
        Specify a filename of the loaded MRT file. Mandatory, see example below.
 
-       <tag><label id="mrt-replay-accelerate">replay accelerate"<m/mrt-replay-accelerate/"</tag>
+       <tag><label id="mrt-replay-accelerate">replay accelerate <m/replay accelerate/</tag>
        MRT files with BGP messages will be loaded N-times quicker than they were arriving to BGP.
        However, it can be slower if there are too much of the messages. Without this parameter
        set, messages will be loaded regularly.
index 402ddb73ac93ffa50291f72cab5fdd37d28966ea..4a3b45b507c60dbdcfe868a358a768187f17ded1 100644 (file)
@@ -256,14 +256,10 @@ proto_name:
      s->class = this_proto->class;
      s->proto = this_proto;
      this_proto->name = s->name;
-     log("/* EMPTY */ , name %s, this %x next %x, prev %x", s->name, s, s->next, s->n.prev);
      }
  | symbol {
-     struct symbol *s = cf_define_symbol(new_config, $1, this_proto->class, proto, this_proto);
+     cf_define_symbol(new_config, $1, this_proto->class, proto, this_proto);
      this_proto->name = $1->name;
-     log("symbol , name %s, next = %x, prev %x", this_proto->name, s->next, s->n.prev);
-     if (s->n.prev)
-       log("s->n.prev->next %x", s->n.prev->next);
    }
  | FROM CF_SYM_KNOWN {
      if (($2->class != SYM_TEMPLATE) && ($2->class != SYM_PROTO)) cf_error("Template or protocol name expected");
@@ -272,12 +268,10 @@ proto_name:
      s->class = this_proto->class;
      s->proto = this_proto;
      this_proto->name = s->name;
-     log("CF_SYM_KNOWN , name %s", this_proto->name);
 
      proto_copy_config(this_proto, $2->proto);
    }
  | symbol FROM CF_SYM_KNOWN {
-     log("CF_SYM_KNOWN, %s", $1->name);
      if (($3->class != SYM_TEMPLATE) && ($3->class != SYM_PROTO)) cf_error("Template or protocol name expected");
 
      cf_define_symbol(new_config, $1, this_proto->class, proto, this_proto);
@@ -289,14 +283,14 @@ proto_name:
 
 proto_item:
    /* EMPTY */
- | DISABLED bool { this_proto->disabled = $2; log("proto item");}
- | DEBUG debug_mask { this_proto->debug = $2; log("proto item"); }
- | MRTDUMP mrtdump_mask { this_proto->mrtdump = $2; log("proto item"); }
- | ROUTER ID idval { this_proto->router_id = $3; log("proto item"); }
- | HOSTNAME text { this_proto->hostname = $2; log("proto item"); }
- | DESCRIPTION text { this_proto->dsc = $2; log("proto item"); }
- | VRF text { this_proto->vrf = if_get_by_name($2); this_proto->vrf_set = 1; log("proto item"); }
- | VRF DEFAULT { this_proto->vrf = NULL; this_proto->vrf_set = 1; log("proto item"); }
+ | DISABLED bool { this_proto->disabled = $2; }
+ | DEBUG debug_mask { this_proto->debug = $2; }
+ | MRTDUMP mrtdump_mask { this_proto->mrtdump = $2; }
+ | ROUTER ID idval { this_proto->router_id = $3; }
+ | HOSTNAME text { this_proto->hostname = $2; }
+ | DESCRIPTION text { this_proto->dsc = $2; }
+ | VRF text { this_proto->vrf = if_get_by_name($2); this_proto->vrf_set = 1; }
+ | VRF DEFAULT { this_proto->vrf = NULL; this_proto->vrf_set = 1; }
  ;
 
 
@@ -484,7 +478,7 @@ dev_proto:
  | dev_proto proto_item ';'
  | dev_proto proto_channel ';'
  | dev_proto dev_iface_patt ';'
- | dev_proto CHECK LINK bool ';' { DIRECT_CFG->check_link = $4; log("check link");}
+ | dev_proto CHECK LINK bool ';' { DIRECT_CFG->check_link = $4; }
  ;
 
 dev_iface_init:
index 58ba31f04d017b2dd54435e0548bf53163358786..7aff5731c28184fb26ed6e9d001932a70e23cf22 100644 (file)
@@ -28,39 +28,28 @@ mrtload_proto_start: proto_start MRTLOAD
 mrt_channel_start: bgp_afi
 {
   const struct bgp_af_desc *desc = bgp_get_af_desc($1);
-  log("hereee in afiiiii");
 
   if (!desc)
     cf_error("Unknown AFI/SAFI");
 
   this_channel = channel_config_get(&channel_mrtload, desc->name, desc->net, this_proto);
   MRTLOAD_CFG->channel_cf = MRTLOAD_BGP_CC;
-  log("this channel %x %x", this_channel, MRTLOAD_BGP_CC);
-
-  /* New channel */
-  if (!MRTLOAD_BGP_CC->desc)
-  {
-    MRTLOAD_BGP_CC->c.in_filter = FILTER_ACCEPT;
-    MRTLOAD_BGP_CC->c.out_filter = FILTER_REJECT;
-    MRTLOAD_BGP_CC->c.ra_mode = RA_UNDEF;
-    MRTLOAD_BGP_CC->afi = $1;
-    MRTLOAD_BGP_CC->desc = desc;
-    MRTLOAD_BGP_CC->next_hop_keep = 0xff; /* undefined */
-    MRTLOAD_BGP_CC->gr_able = 0xff;    /* undefined */
-    MRTLOAD_BGP_CC->llgr_able = 0xff;  /* undefined */
-    MRTLOAD_BGP_CC->llgr_time = ~0U;   /* undefined */
-    MRTLOAD_BGP_CC->min_llgr_time = ~0U; /* undefined */
-    MRTLOAD_BGP_CC->max_llgr_time = ~0U; /* undefined */
-    MRTLOAD_BGP_CC->aigp = 0xff;       /* undefined */
-  }
-};
 
-mrt_channel_item:
- /* empty */
- | channel_item ';'
- ;
+  MRTLOAD_BGP_CC->c.in_filter = FILTER_ACCEPT;
+  MRTLOAD_BGP_CC->c.out_filter = FILTER_REJECT;
+  MRTLOAD_BGP_CC->c.ra_mode = RA_UNDEF;
+  MRTLOAD_BGP_CC->afi = $1;
+  MRTLOAD_BGP_CC->desc = desc;
+  MRTLOAD_BGP_CC->next_hop_keep = 0xff; /* undefined */
+  MRTLOAD_BGP_CC->gr_able = 0xff;      /* undefined */
+  MRTLOAD_BGP_CC->llgr_able = 0xff;    /* undefined */
+  MRTLOAD_BGP_CC->llgr_time = ~0U;     /* undefined */
+  MRTLOAD_BGP_CC->min_llgr_time = ~0U; /* undefined */
+  MRTLOAD_BGP_CC->max_llgr_time = ~0U; /* undefined */
+  MRTLOAD_BGP_CC->aigp = 0xff; /* undefined */
+};
 
-mrt_proto_channel: mrt_channel_start //mrt_channel_item;
+mrt_proto_channel: mrt_channel_start;
 
 mrtload_proto_opts:
    /* empty */
@@ -69,17 +58,14 @@ mrtload_proto_opts:
 
  mrtload_proto_item:
    proto_item
- | FILENAME text       { MRTLOAD_CFG->filename = $2; log("file %s", $2);}
+ | FILENAME text { MRTLOAD_CFG->filename = $2; }
  | REPLAY ACCELERATE expr      { MRTLOAD_CFG->replay_accel = $3; }
  | TABLE rtable {
     MRTLOAD_CFG->table_cf = $2;
-    log("table_cf %x, MRTLOAD_BGP_CC %x", $2, MRTLOAD_BGP_CC);
-    if ($2->addr_type == NET_IP4){
+    if ($2->addr_type == NET_IP4)
       MRTLOAD_BGP_CC->igp_table_ip4 = $2;
-      log("MRTLOAD_BGP_CC->igp_table_ip4");}
-    else if ($2->addr_type == NET_IP6){
+    else if ($2->addr_type == NET_IP6)
       MRTLOAD_BGP_CC->igp_table_ip6 = $2;
-      log("MRTLOAD_BGP_CC->igp_table_ip6");}
     else
       cf_error("Mismatched IGP table type");
     }
index e5c4e1b7ed276ab7a8ce36e859b2098f0799e876..26ce2c9636e718799f9a8aabd0222883cbd7d35b 100644 (file)
@@ -632,7 +632,7 @@ mrtload_hook(timer *tm)
       return;
   }
 
-  tm_start(p->load_timer, 10000);
+  tm_start(p->load_timer, 10000); //TODO: this constant was found with a heuristic for my computer
 }
 
 static void
@@ -779,7 +779,9 @@ mrtload_shutdown(struct proto *P)
   {
     for (int i = 0; i < p->table_peers_count; i++)
       mb_free(p->table_peers[i].route_attrs);
+
     mb_free(p->table_peers);
+    p->table_peers = NULL;
   }
 
   return PS_DOWN;
@@ -788,7 +790,6 @@ mrtload_shutdown(struct proto *P)
 static int
 mrtload_reconfigure(struct proto *P, struct proto_config *CF UNUSED)
 {
-  log("mrtload_reconfigure");
   struct mrtload_proto *p = (void *) P;
 
   FIB_WALK(&p->channel->c.table->fib, net, n)
@@ -841,8 +842,8 @@ static int
 mrtload_channel_reconfigure(struct channel *C UNUSED, struct channel_config *CC UNUSED,
     int *import_changed UNUSED, int *export_changed UNUSED)
 {
-  log("mrtload_channel_reconfigure");
-  return 0; // Even if no variable was changed, the content of MRT file might be changed
+  /* Even if no variable was changed, the content of MRT file might be changed */
+  return 0;
 }
 
 const struct channel_class channel_mrtload = {