]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Assign default protocol preference via proto_config_new().
authorOndrej Zajicek <santiago@crfreenet.org>
Tue, 24 Jan 2012 10:31:00 +0000 (11:31 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Tue, 24 Jan 2012 10:31:00 +0000 (11:31 +0100)
The patch from Alexander V. Chernikov.

14 files changed:
nest/config.Y
nest/proto.c
nest/protocol.h
nest/rt-dev.c
proto/bgp/bgp.c
proto/bgp/config.Y
proto/ospf/config.Y
proto/ospf/ospf.c
proto/pipe/config.Y
proto/pipe/pipe.c
proto/rip/rip.c
proto/static/static.c
sysdep/unix/krt.Y
sysdep/unix/krt.c

index a6baf4ead8dde6f1c9671a71870fd9fd6ede8fe3..3fcfa52815d8202a31a23fb8d1ab8c88750972e7 100644 (file)
@@ -219,7 +219,6 @@ CF_ADDTO(proto, dev_proto '}')
 
 dev_proto_start: proto_start DIRECT {
      this_proto = proto_config_new(&proto_device, sizeof(struct rt_dev_config), $1);
-     this_proto->preference = DEF_PREF_DIRECT;
      init_list(&DIRECT_CFG->iface_list);
    }
  ;
index d55c348d25bea5a2bd27ffd0367baee7267c8d26..0fc72ce16ed74729a4349938f8ddc9df3d70ec81 100644 (file)
@@ -200,6 +200,7 @@ proto_config_new(struct protocol *pr, unsigned size, int class)
   c->global = new_config;
   c->protocol = pr;
   c->name = pr->name;
+  c->preference = pr->preference;
   c->class = class;
   c->out_filter = FILTER_REJECT;
   c->table = c->global->master_rtc;
index 3766e15eea1c2819382f776cd4850104a801c380..a83c4ffc2003a20b6a413c3505a73b4dd5449a86 100644 (file)
@@ -39,6 +39,7 @@ struct protocol {
   char *template;                      /* Template for automatic generation of names */
   int name_counter;                    /* Counter for automatic name generation */
   int attr_class;                      /* Attribute class known to this protocol */
+  unsigned preference;                 /* Default protocol preference */
 
   void (*preconfig)(struct protocol *, struct config *);       /* Just before configuring */
   void (*postconfig)(struct proto_config *);                   /* After configuring each instance */
index 497ee8080e4ab76bda660a8e173e4cd80eff2fe7..54cb14ba09a9f51e80b8d916a0755b37930d6672 100644 (file)
@@ -109,6 +109,7 @@ dev_copy_config(struct proto_config *dest, struct proto_config *src)
 struct protocol proto_device = {
   name:                "Direct",
   template:    "direct%d",
+  preference:  DEF_PREF_DIRECT,
   init:                dev_init,
   reconfigure: dev_reconfigure,
   copy_config: dev_copy_config
index 66fdc603ea4a983c2fb3661276dd6f7f14f76cff..4d3c32fba61011de791f8857d0b7bc853cda67a1 100644 (file)
@@ -1178,6 +1178,7 @@ struct protocol proto_bgp = {
   name:                        "BGP",
   template:            "bgp%d",
   attr_class:          EAP_BGP,
+  preference:          DEF_PREF_BGP,
   init:                        bgp_init,
   start:               bgp_start,
   shutdown:            bgp_shutdown,
index 5fb609409924aa87260d173b8a18620709d40d10..78ca52de6ad426f98566837b2f95512ac66f9b5c 100644 (file)
@@ -33,7 +33,6 @@ CF_ADDTO(proto, bgp_proto '}' { bgp_check_config(BGP_CFG); } )
 
 bgp_proto_start: proto_start BGP {
      this_proto = proto_config_new(&proto_bgp, sizeof(struct bgp_config), $1);
-     this_proto->preference = DEF_PREF_BGP;
      BGP_CFG->hold_time = 240;
      BGP_CFG->connect_retry_time = 120;
      BGP_CFG->initial_hold_time = 240;
index 4ada41e842287bc61de9a9dfe7a155257daba974..24e125a7c419f6459811ee6e753bda9b5fee8453 100644 (file)
@@ -129,7 +129,6 @@ CF_ADDTO(proto, ospf_proto '}' { ospf_proto_finish(); } )
 
 ospf_proto_start: proto_start OSPF {
      this_proto = proto_config_new(&proto_ospf, sizeof(struct ospf_config), $1);
-     this_proto->preference = DEF_PREF_OSPF;
      init_list(&OSPF_CFG->area_list);
      init_list(&OSPF_CFG->vlink_list);
      OSPF_CFG->rfc1583 = DEFAULT_RFC1583;
index ce7ad37cb2a2bc871ba7b482e1c79428c4647824..73c06c27f241985c7b0321b0e05fd11e43536f84 100644 (file)
@@ -1542,6 +1542,7 @@ struct protocol proto_ospf = {
   name:                        "OSPF",
   template:            "ospf%d",
   attr_class:          EAP_OSPF,
+  preference:          DEF_PREF_OSPF,
   init:                        ospf_init,
   dump:                        ospf_dump,
   start:               ospf_start,
index 4478afe7ebe6076d3ceb3fcbd719c643d49905e8..40637558b4376b36ac0fc17fea37d1a789c0bbff 100644 (file)
@@ -24,7 +24,6 @@ CF_ADDTO(proto, pipe_proto '}')
 
 pipe_proto_start: proto_start PIPE {
      this_proto = proto_config_new(&proto_pipe, sizeof(struct pipe_config), $1);
-     this_proto->preference = DEF_PREF_PIPE;
      PIPE_CFG->mode = PIPE_TRANSPARENT;
   }
  ;
index 420c5a9d3705063438b80a6d04bf38d1c3609a4a..fe8618b6781d630b90f09a41e7aa7274e81442e3 100644 (file)
@@ -197,6 +197,7 @@ pipe_get_status(struct proto *P, byte *buf)
 struct protocol proto_pipe = {
   name:                "Pipe",
   template:    "pipe%d",
+  preference:  DEF_PREF_PIPE,
   postconfig:  pipe_postconfig,
   init:                pipe_init,
   start:       pipe_start,
index 543aa30695d9501a1d65d5da81602798a140e8f4..f0a4134775fd317fdc63706913d76dde18638397 100644 (file)
@@ -975,7 +975,6 @@ void
 rip_init_config(struct rip_proto_config *c)
 {
   init_list(&c->iface_list);
-  c->c.preference = DEF_PREF_RIP;
   c->infinity  = 16;
   c->port      = 520;
   c->period    = 30;
@@ -1032,6 +1031,7 @@ struct protocol proto_rip = {
   name: "RIP",
   template: "rip%d",
   attr_class: EAP_RIP,
+  preference: DEF_PREF_RIP,
   get_route_info: rip_get_route_info,
   get_attr: rip_get_attr,
 
index f6c2a33faa604426bef20bffbe4cccd4578e3cef..aaa9bfad76539d443ce771022a3721773dcbfed5 100644 (file)
@@ -353,7 +353,6 @@ static_if_notify(struct proto *p, unsigned flags, struct iface *i)
 void
 static_init_config(struct static_config *c)
 {
-  c->c.preference = DEF_PREF_STATIC;
   init_list(&c->iface_routes);
   init_list(&c->other_routes);
 }
@@ -523,6 +522,7 @@ static_copy_config(struct proto_config *dest, struct proto_config *src)
 struct protocol proto_static = {
   name:                "Static",
   template:    "static%d",
+  preference:  DEF_PREF_STATIC,
   init:                static_init,
   dump:                static_dump,
   start:       static_start,
index 86081966a21e888181713224a154ccb1fb676255..18e1e52ddd57a32631a64bca490ffbecb9945473 100644 (file)
@@ -31,7 +31,6 @@ kern_proto_start: proto_start KERNEL {
        cf_error("Kernel protocol already defined");
 #endif
      cf_krt = this_proto = proto_config_new(&proto_unix_kernel, sizeof(struct krt_config), $1);
-     this_proto->preference = DEF_PREF_INHERITED;
      THIS_KRT->scan_time = 60;
      THIS_KRT->learn = THIS_KRT->persist = 0;
      krt_scan_construct(THIS_KRT);
@@ -67,7 +66,6 @@ kif_proto_start: proto_start DEVICE {
      if (cf_kif)
        cf_error("Kernel device protocol already defined");
      cf_kif = this_proto = proto_config_new(&proto_unix_iface, sizeof(struct kif_config), $1);
-     this_proto->preference = DEF_PREF_DIRECT;
      THIS_KIF->scan_time = 60;
      init_list(&THIS_KIF->primary);
      krt_if_construct(THIS_KIF);
index ad8ea6b6d88e4324bf08a59e9c64b667596e360b..231c5fcf306aaa74a5beb7cde6422aa7b1401c35 100644 (file)
@@ -243,6 +243,7 @@ kif_copy_config(struct proto_config *dest, struct proto_config *src)
 struct protocol proto_unix_iface = {
   name:                "Device",
   template:    "device%d",
+  preference:  DEF_PREF_DIRECT,
   preconfig:   kif_preconfig,
   init:                kif_init,
   start:       kif_start,
@@ -968,6 +969,7 @@ struct protocol proto_unix_kernel = {
   name:                "Kernel",
   template:    "kernel%d",
   attr_class:  EAP_KRT,
+  preference:  DEF_PREF_INHERITED,
   preconfig:   krt_preconfig,
   postconfig:  krt_postconfig,
   init:                krt_init,