mirror of
				https://gitlab.labs.nic.cz/labs/bird.git
				synced 2024-05-11 16:54:54 +00:00 
			
		
		
		
	Merge commit '938742decc6e1d6d3a0375dd012b75172e747bbc' into haugesund
This commit is contained in:
		@@ -387,7 +387,7 @@ ospf_init(struct proto_config *CF)
 | 
			
		||||
static int
 | 
			
		||||
ospf_rte_better(struct rte *new, struct rte *old)
 | 
			
		||||
{
 | 
			
		||||
  u32 new_metric1 = ea_get_int(new->attrs->eattrs, &ea_ospf_metric1, LSINFINITY);
 | 
			
		||||
  u32 new_metric1 = ea_get_int(new->attrs, &ea_ospf_metric1, LSINFINITY);
 | 
			
		||||
 | 
			
		||||
  if (new_metric1 == LSINFINITY)
 | 
			
		||||
    return 0;
 | 
			
		||||
@@ -400,13 +400,13 @@ ospf_rte_better(struct rte *new, struct rte *old)
 | 
			
		||||
 | 
			
		||||
  if (ns == RTS_OSPF_EXT2)
 | 
			
		||||
  {
 | 
			
		||||
    u32 old_metric2 = ea_get_int(old->attrs->eattrs, &ea_ospf_metric2, LSINFINITY);
 | 
			
		||||
    u32 new_metric2 = ea_get_int(new->attrs->eattrs, &ea_ospf_metric2, LSINFINITY);
 | 
			
		||||
    u32 old_metric2 = ea_get_int(old->attrs, &ea_ospf_metric2, LSINFINITY);
 | 
			
		||||
    u32 new_metric2 = ea_get_int(new->attrs, &ea_ospf_metric2, LSINFINITY);
 | 
			
		||||
    if (new_metric2 < old_metric2) return 1;
 | 
			
		||||
    if (new_metric2 > old_metric2) return 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  u32 old_metric1 = ea_get_int(old->attrs->eattrs, &ea_ospf_metric1, LSINFINITY);
 | 
			
		||||
  u32 old_metric1 = ea_get_int(old->attrs, &ea_ospf_metric1, LSINFINITY);
 | 
			
		||||
  if (new_metric1 < old_metric1)
 | 
			
		||||
    return 1;
 | 
			
		||||
 | 
			
		||||
@@ -419,7 +419,7 @@ ospf_rte_igp_metric(const rte *rt)
 | 
			
		||||
  if (rt_get_source_attr(rt) == RTS_OSPF_EXT2)
 | 
			
		||||
    return IGP_METRIC_UNKNOWN;
 | 
			
		||||
 | 
			
		||||
  return ea_get_int(rt->attrs->eattrs, &ea_ospf_metric1, LSINFINITY);
 | 
			
		||||
  return ea_get_int(rt->attrs, &ea_ospf_metric1, LSINFINITY);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
@@ -535,7 +535,7 @@ ospf_shutdown(struct proto *P)
 | 
			
		||||
  /* Cleanup locked rta entries */
 | 
			
		||||
  FIB_WALK(&p->rtf, ort, nf)
 | 
			
		||||
  {
 | 
			
		||||
    rta_free(nf->old_rta);
 | 
			
		||||
    ea_free(nf->old_ea);
 | 
			
		||||
  }
 | 
			
		||||
  FIB_WALK_END;
 | 
			
		||||
 | 
			
		||||
@@ -592,18 +592,18 @@ ospf_get_route_info(rte * rte, byte * buf)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  buf += bsprintf(buf, " %s", type);
 | 
			
		||||
  buf += bsprintf(buf, " (%d/%d", rt_get_preference(rte), ea_get_int(rte->attrs->eattrs, &ea_ospf_metric1, LSINFINITY));
 | 
			
		||||
  buf += bsprintf(buf, " (%d/%d", rt_get_preference(rte), ea_get_int(rte->attrs, &ea_ospf_metric1, LSINFINITY));
 | 
			
		||||
  if (source == RTS_OSPF_EXT2)
 | 
			
		||||
    buf += bsprintf(buf, "/%d", ea_get_int(rte->attrs->eattrs, &ea_ospf_metric2, LSINFINITY));
 | 
			
		||||
    buf += bsprintf(buf, "/%d", ea_get_int(rte->attrs, &ea_ospf_metric2, LSINFINITY));
 | 
			
		||||
  buf += bsprintf(buf, ")");
 | 
			
		||||
  if (source == RTS_OSPF_EXT1 || source == RTS_OSPF_EXT2)
 | 
			
		||||
  {
 | 
			
		||||
    eattr *ea = ea_find(rte->attrs->eattrs, &ea_ospf_tag);
 | 
			
		||||
    eattr *ea = ea_find(rte->attrs, &ea_ospf_tag);
 | 
			
		||||
    if (ea && (ea->u.data > 0))
 | 
			
		||||
      buf += bsprintf(buf, " [%x]", ea->u.data);
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  eattr *ea = ea_find(rte->attrs->eattrs, &ea_ospf_router_id);
 | 
			
		||||
  eattr *ea = ea_find(rte->attrs, &ea_ospf_router_id);
 | 
			
		||||
  if (ea)
 | 
			
		||||
    buf += bsprintf(buf, " [%R]", ea->u.data);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1977,17 +1977,17 @@ add_cand(struct ospf_area *oa, struct top_hash_entry *en, struct top_hash_entry
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline int
 | 
			
		||||
ort_changed(ort *nf, rta *nr)
 | 
			
		||||
ort_changed(ort *nf, ea_list *nr)
 | 
			
		||||
{
 | 
			
		||||
  rta *or = nf->old_rta;
 | 
			
		||||
  ea_list *or = nf->old_ea;
 | 
			
		||||
 | 
			
		||||
  if (!or ||
 | 
			
		||||
    (nf->n.metric1 != nf->old_metric1) || (nf->n.metric2 != nf->old_metric2) ||
 | 
			
		||||
    (nf->n.tag != nf->old_tag) || (nf->n.rid != nf->old_rid))
 | 
			
		||||
    return 1;
 | 
			
		||||
 | 
			
		||||
  eattr *nhea_n = ea_find(nr->eattrs, &ea_gen_nexthop);
 | 
			
		||||
  eattr *nhea_o = ea_find(or->eattrs, &ea_gen_nexthop);
 | 
			
		||||
  eattr *nhea_n = ea_find(nr, &ea_gen_nexthop);
 | 
			
		||||
  eattr *nhea_o = ea_find(or, &ea_gen_nexthop);
 | 
			
		||||
  if (!nhea_n != !nhea_o)
 | 
			
		||||
    return 1;
 | 
			
		||||
 | 
			
		||||
@@ -2000,8 +2000,8 @@ ort_changed(ort *nf, rta *nr)
 | 
			
		||||
      return 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (	ea_get_int(nr->eattrs, &ea_gen_source, 0)
 | 
			
		||||
     != ea_get_int(or->eattrs, &ea_gen_source, 0))
 | 
			
		||||
  if (	ea_get_int(nr, &ea_gen_source, 0)
 | 
			
		||||
     != ea_get_int(or, &ea_gen_source, 0))
 | 
			
		||||
    return 1;
 | 
			
		||||
 | 
			
		||||
  return 0;
 | 
			
		||||
@@ -2047,9 +2047,6 @@ again1:
 | 
			
		||||
 | 
			
		||||
    if (nf->n.type) /* Add the route */
 | 
			
		||||
    {
 | 
			
		||||
      rta a0 = {
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      struct {
 | 
			
		||||
	ea_list l;
 | 
			
		||||
	eattr a[7];
 | 
			
		||||
@@ -2066,7 +2063,7 @@ again1:
 | 
			
		||||
      eattrs.a[eattrs.l.count++] =
 | 
			
		||||
	EA_LITERAL_DIRECT_ADATA(&ea_gen_nexthop, 0, &nf->n.nhs->ad);
 | 
			
		||||
 | 
			
		||||
      if (reload || ort_changed(nf, &a0))
 | 
			
		||||
      if (reload || ort_changed(nf, &eattrs.l))
 | 
			
		||||
      {
 | 
			
		||||
	nf->old_metric1 = nf->n.metric1;
 | 
			
		||||
	nf->old_metric2 = nf->n.metric2;
 | 
			
		||||
@@ -2088,27 +2085,29 @@ again1:
 | 
			
		||||
	  EA_LITERAL_EMBEDDED(&ea_ospf_router_id, 0, nf->n.rid);
 | 
			
		||||
 | 
			
		||||
	ASSERT_DIE(ARRAY_SIZE(eattrs.a) >= eattrs.l.count);
 | 
			
		||||
	a0.eattrs = &eattrs.l;
 | 
			
		||||
 | 
			
		||||
	rta_free(nf->old_rta);
 | 
			
		||||
	nf->old_rta = rta_lookup(&a0);
 | 
			
		||||
	ea_list *eal = ea_lookup(&eattrs.l);
 | 
			
		||||
	ea_free(nf->old_ea);
 | 
			
		||||
	nf->old_ea = eal;
 | 
			
		||||
 | 
			
		||||
	rte e0 = {
 | 
			
		||||
	  .attrs = nf->old_rta,
 | 
			
		||||
	  .attrs = eal,
 | 
			
		||||
	  .src = p->p.main_source,
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	DBG("Mod rte type %d - %N via %I on iface %s, met %d\n",
 | 
			
		||||
	    a0.source, nf->fn.addr, a0.gw, a0.iface ? a0.iface->name : "(none)", nf->n.metric1);
 | 
			
		||||
	    */
 | 
			
		||||
 | 
			
		||||
	rte_update(p->p.main_channel, nf->fn.addr, &e0, p->p.main_source);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    else if (nf->old_rta)
 | 
			
		||||
    else if (nf->old_ea)
 | 
			
		||||
    {
 | 
			
		||||
      /* Remove the route */
 | 
			
		||||
      rta_free(nf->old_rta);
 | 
			
		||||
      nf->old_rta = NULL;
 | 
			
		||||
      rta_free(nf->old_ea);
 | 
			
		||||
      nf->old_ea = NULL;
 | 
			
		||||
 | 
			
		||||
      rte_update(p->p.main_channel, nf->fn.addr, NULL, p->p.main_source);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -78,7 +78,7 @@ typedef struct ort
 | 
			
		||||
   */
 | 
			
		||||
  orta n;
 | 
			
		||||
  u32 old_metric1, old_metric2, old_tag, old_rid;
 | 
			
		||||
  rta *old_rta;
 | 
			
		||||
  ea_list *old_ea;
 | 
			
		||||
  u32 lsa_id;
 | 
			
		||||
  u8 external_rte;
 | 
			
		||||
  u8 area_net;
 | 
			
		||||
 
 | 
			
		||||
@@ -1337,9 +1337,9 @@ ospf_rt_notify(struct proto *P, struct channel *ch UNUSED, const net_addr *n, rt
 | 
			
		||||
  ASSERT(p->asbr);
 | 
			
		||||
 | 
			
		||||
  /* Get route attributes */
 | 
			
		||||
  rta *a = new->attrs;
 | 
			
		||||
  eattr *m1a = ea_find(a->eattrs, &ea_ospf_metric1);
 | 
			
		||||
  eattr *m2a = ea_find(a->eattrs, &ea_ospf_metric2);
 | 
			
		||||
  ea_list *a = new->attrs;
 | 
			
		||||
  eattr *m1a = ea_find(a, &ea_ospf_metric1);
 | 
			
		||||
  eattr *m2a = ea_find(a, &ea_ospf_metric2);
 | 
			
		||||
  uint m1 = m1a ? m1a->u.data : 0;
 | 
			
		||||
  uint m2 = m2a ? m2a->u.data : 10000;
 | 
			
		||||
 | 
			
		||||
@@ -1363,10 +1363,10 @@ ospf_rt_notify(struct proto *P, struct channel *ch UNUSED, const net_addr *n, rt
 | 
			
		||||
 | 
			
		||||
  uint ebit = m2a || !m1a;
 | 
			
		||||
  uint metric = ebit ? m2 : m1;
 | 
			
		||||
  uint tag = ea_get_int(a->eattrs, &ea_ospf_tag, 0);
 | 
			
		||||
  uint tag = ea_get_int(a, &ea_ospf_tag, 0);
 | 
			
		||||
 | 
			
		||||
  ip_addr fwd = IPA_NONE;
 | 
			
		||||
  eattr *nhea = ea_find(a->eattrs, &ea_gen_nexthop);
 | 
			
		||||
  eattr *nhea = ea_find(a, &ea_gen_nexthop);
 | 
			
		||||
  struct nexthop_adata *nhad = (struct nexthop_adata *) nhea->u.ptr;
 | 
			
		||||
  if (NEXTHOP_IS_REACHABLE(nhad))
 | 
			
		||||
    if (use_gw_for_fwaddr(p, nhad->nh.gw, nhad->nh.iface))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user