]> git.ipfire.org Git - thirdparty/bird.git/blobdiff - proto/rip/rip.c
Minor cleanups and fixes
[thirdparty/bird.git] / proto / rip / rip.c
index d87a078cb390735edcdf663ab51a9652aaa730c2..55fb47c569a941bb025a512066bc468051d7f26f 100644 (file)
@@ -147,21 +147,16 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en)
       .src = p->p.main_source,
       .source = RTS_RIP,
       .scope = SCOPE_UNIVERSE,
-      .cast = RTC_UNICAST
+      .dest = RTD_UNICAST,
     };
 
     u8 rt_metric = rt->metric;
     u16 rt_tag = rt->tag;
-    struct rip_rte *rt2 = rt->next;
 
-    /* Find second valid rte */
-    while (rt2 && !rip_valid_rte(rt2))
-      rt2 = rt2->next;
-
-    if (p->ecmp && rt2)
+    if (p->ecmp)
     {
       /* ECMP route */
-      struct mpnh *nhs = NULL;
+      struct nexthop *nhs = NULL;
       int num = 0;
 
       for (rt = en->routes; rt && (num < p->ecmp); rt = rt->next)
@@ -169,33 +164,33 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en)
        if (!rip_valid_rte(rt))
            continue;
 
-       struct mpnh *nh = alloca(sizeof(struct mpnh));
+       struct nexthop *nh = allocz(sizeof(struct nexthop));
+
        nh->gw = rt->next_hop;
        nh->iface = rt->from->nbr->iface;
        nh->weight = rt->from->ifa->cf->ecmp_weight;
-       mpnh_insert(&nhs, nh);
+
+       nexthop_insert(&nhs, nh);
        num++;
 
        if (rt->tag != rt_tag)
          rt_tag = 0;
       }
 
-      a0.dest = RTD_MULTIPATH;
-      a0.nexthops = nhs;
+      a0.nh = *nhs;
     }
     else
     {
       /* Unipath route */
-      a0.dest = RTD_ROUTER;
-      a0.gw = rt->next_hop;
-      a0.iface = rt->from->nbr->iface;
       a0.from = rt->from->nbr->addr;
+      a0.nh.gw = rt->next_hop;
+      a0.nh.iface = rt->from->nbr->iface;
     }
 
     rta *a = rta_lookup(&a0);
     rte *e = rte_get_temp(a);
 
-    e->u.rip.from = a0.iface;
+    e->u.rip.from = a0.nh.iface;
     e->u.rip.metric = rt_metric;
     e->u.rip.tag = rt_tag;
 
@@ -345,8 +340,8 @@ rip_rt_notify(struct proto *P, struct channel *ch UNUSED, struct network *net, s
     en->metric = rt_metric;
     en->tag = rt_tag;
     en->from = (new->attrs->src->proto == P) ? new->u.rip.from : NULL;
-    en->iface = new->attrs->iface;
-    en->next_hop = new->attrs->gw;
+    en->iface = new->attrs->nh.iface;
+    en->next_hop = new->attrs->nh.gw;
   }
   else
   {
@@ -689,7 +684,7 @@ rip_reconfigure_iface(struct rip_proto *p, struct rip_iface *ifa, struct rip_ifa
 
   rip_iface_update_buffers(ifa);
 
-  if (ifa->next_regular > (now + new->update_time))
+  if (ifa->next_regular > (now + (bird_clock_t) new->update_time))
     ifa->next_regular = now + (random() % new->update_time) + 1;
 
   if (new->check_link != old->check_link)