]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Nest: Clean up main channel handling
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Thu, 17 Jun 2021 14:56:51 +0000 (16:56 +0200)
committerMaria Matejka <mq@ucw.cz>
Fri, 10 Sep 2021 15:32:05 +0000 (17:32 +0200)
Remove assumption that main channel is the only channel.

nest/protocol.h
proto/ospf/config.Y
proto/radv/config.Y
proto/radv/radv.c
proto/rip/rip.c
proto/rpki/rpki.c
proto/static/static.c
sysdep/unix/krt.c

index 48eb01d251f08f2f1255d73d3d0612d33e2d16ea..abcc505d4ce320ec4287a73561c23ab7ec25f8e5 100644 (file)
@@ -616,7 +616,7 @@ struct channel {
 
 struct channel_config *proto_cf_find_channel(struct proto_config *p, uint net_type);
 static inline struct channel_config *proto_cf_main_channel(struct proto_config *pc)
-{ struct channel_config *cc = HEAD(pc->channels); return NODE_VALID(cc) ? cc : NULL; }
+{ return proto_cf_find_channel(pc, pc->net_type); }
 
 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 fd2cfe8ae1757eb765fd6474b7c7fbbc27efeec6..4b7d5a361196612e176ebbca499d48dd4f7eb53e 100644 (file)
@@ -85,7 +85,7 @@ ospf_proto_finish(void)
   struct ospf_iface_patt *ic;
 
   /* Define default channel */
-  if (EMPTY_LIST(this_proto->channels))
+  if (! proto_cf_main_channel(this_proto))
   {
     uint net_type = this_proto->net_type = ospf_cfg_is_v2() ? NET_IP4 : NET_IP6;
     channel_config_new(NULL, net_label[net_type], net_type, this_proto);
@@ -248,8 +248,7 @@ ospf_channel_start: net_type ospf_af_mc
   $$ = this_channel = channel_config_get(NULL, net_label[$1], $1, this_proto);
 
   /* Save the multicast flag */
-  if (this_channel == proto_cf_main_channel(this_proto))
-    OSPF_CFG->af_mc = $2;
+  OSPF_CFG->af_mc = $2;
 };
 
 ospf_channel: ospf_channel_start channel_opt_list channel_end;
index dda9cfcd678be5f7f076c3eaa090db6c47e8d36a..8d4a3ab94221bbbe0b760a0f3b479d00d0111982 100644 (file)
@@ -46,6 +46,7 @@ proto: radv_proto ;
 radv_proto_start: proto_start RADV
 {
   this_proto = proto_config_new(&proto_radv, $1);
+  this_proto->net_type = NET_IP6;
 
   init_list(&RADV_CFG->patt_list);
   init_list(&RADV_CFG->pref_list);
index b4235917053365b80b116ef4742002502df3610c..66e8eb4bbde24af361dc909ea9f5627baebfe140 100644 (file)
@@ -564,7 +564,7 @@ radv_postconfig(struct proto_config *CF)
   // struct radv_config *cf = (void *) CF;
 
   /* Define default channel */
-  if (EMPTY_LIST(CF->channels))
+  if (! proto_cf_main_channel(CF))
     channel_config_new(NULL, net_label[NET_IP6], NET_IP6, CF);
 }
 
index 8b4719f73ff995849c74cf3a21207cca5d0943f7..e1a235a08e86e0ecd89a9ef49457b37ea302db0b 100644 (file)
@@ -1105,7 +1105,7 @@ rip_postconfig(struct proto_config *CF)
   // struct rip_config *cf = (void *) CF;
 
   /* Define default channel */
-  if (EMPTY_LIST(CF->channels))
+  if (! proto_cf_main_channel(CF))
     channel_config_new(NULL, net_label[CF->net_type], CF->net_type, CF);
 }
 
index 799cb8773b2587542eb7599769347ba6f6a6b933..ab0837f30abe76e4f7d7acd6a5f8a94bcdb498f4 100644 (file)
@@ -923,7 +923,7 @@ rpki_postconfig(struct proto_config *CF)
 {
   /* Define default channel */
   if (EMPTY_LIST(CF->channels))
-    channel_config_new(NULL, net_label[CF->net_type], CF->net_type, CF);
+    cf_error("Channel not specified");
 }
 
 static void
index 661f1aac96e94e3db34f5f9b948553393277a725..2789c1bb454b55c6cccff4f76bb3d1a6bd4cf1ed 100644 (file)
@@ -434,7 +434,7 @@ static_postconfig(struct proto_config *CF)
   struct static_config *cf = (void *) CF;
   struct static_route *r;
 
-  if (EMPTY_LIST(CF->channels))
+  if (! proto_cf_main_channel(CF))
     cf_error("Channel not specified");
 
   struct channel_config *cc = proto_cf_main_channel(CF);
index ceb88563f6cfa62cdeac1daaa85f2d2cdfcbd1f4..7c2614b101047c96bb7645a928e749e62942d2fd 100644 (file)
@@ -1013,7 +1013,7 @@ krt_postconfig(struct proto_config *CF)
   if (cf->c.class == SYM_TEMPLATE)
     return;
 
-  if (EMPTY_LIST(CF->channels))
+  if (! proto_cf_main_channel(CF))
     cf_error("Channel not specified");
 
 #ifdef CONFIG_ALL_TABLES_AT_ONCE