]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
MPLS: Handle compatibility with old configs
authorOndrej Zajicek <santiago@crfreenet.org>
Thu, 5 Oct 2023 15:54:43 +0000 (17:54 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Thu, 5 Oct 2023 15:54:43 +0000 (17:54 +0200)
Old configs do not define MPLS domains and may use a static protocol
to define static MPLS routes.

When MPLS channel is the only channel of static protocol, handle it
as a main channel. Also, define implicit MPLS domain if needed and
none is defined.

nest/mpls.Y
nest/protocol.h
proto/static/static.c

index 0e755fec84aa58a02fc5b1545ec84202f2d6e982..726a834a1b98d4ebd973149100ae4c2669fafd59 100644 (file)
@@ -99,7 +99,11 @@ mpls_channel_start: MPLS
   $$ = this_channel = channel_config_get(&channel_mpls, net_label[NET_MPLS], NET_MPLS, this_proto);
 
   if (EMPTY_LIST(new_config->mpls_domains))
-    cf_error("No MPLS domain defined");
+  {
+    int counter = 0;
+    mpls_domain_config_new(cf_default_name(new_config, "mpls%d", &counter));
+    cf_warn("No MPLS domain defined");
+  }
 
   /* Default values for new channel */
   if (!MPLS_CC->domain)
index af2a5d6876e984cd5d258d24799e0296fd331606..c87d38148005deaea1ced73545fb291540031335 100644 (file)
@@ -624,7 +624,7 @@ struct channel_config *proto_cf_find_channel(struct proto_config *p, uint net_ty
 static inline struct channel_config *proto_cf_main_channel(struct proto_config *pc)
 { return proto_cf_find_channel(pc, pc->net_type); }
 static inline struct channel_config *proto_cf_mpls_channel(struct proto_config *pc)
-{ return proto_cf_find_channel(pc, NET_MPLS); }
+{ return (pc->net_type != NET_MPLS) ? proto_cf_find_channel(pc, NET_MPLS) : NULL; }
 
 struct channel *proto_find_channel_by_table(struct proto *p, struct rtable *t);
 struct channel *proto_find_channel_by_name(struct proto *p, const char *n);
index 0e80ad6466eee9396b016c37067789126e3d0ff8..071803a81f5c1762b02e46ca68257a1c94b62008 100644 (file)
@@ -472,6 +472,10 @@ static_postconfig(struct proto_config *CF)
   struct static_config *cf = (void *) CF;
   struct static_route *r;
 
+  /* If there is just a MPLS channel, use it as a main channel */
+  if (!CF->net_type && proto_cf_mpls_channel(CF))
+    CF->net_type = NET_MPLS;
+
   if (! proto_cf_main_channel(CF))
     cf_error("Channel not specified");