Commit 5cff1d5f authored by Maria Matejka's avatar Maria Matejka
Browse files

Route: moved rte_src pointer from rta to rte

It is an auxiliary key in the routing table, not a route attribute.
parent eb937358
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -526,7 +526,7 @@
      case SA_FROM:	RESULT(sa.f_type, ip, rta->from); break;
      case SA_GW:	RESULT(sa.f_type, ip, rta->nh.gw); break;
      case SA_NET:	RESULT(sa.f_type, net, (*fs->rte)->net->n.addr); break;
      case SA_PROTO:	RESULT(sa.f_type, s, rta->src->proto->name); break;
      case SA_PROTO:	RESULT(sa.f_type, s, (*fs->rte)->src->proto->name); break;
      case SA_SOURCE:	RESULT(sa.f_type, i, rta->source); break;
      case SA_SCOPE:	RESULT(sa.f_type, i, rta->scope); break;
      case SA_DEST:	RESULT(sa.f_type, i, rta->dest); break;
@@ -562,7 +562,7 @@
	{
	  ip_addr ip = v1.val.ip;
	  struct iface *ifa = ipa_is_link_local(ip) ? rta->nh.iface : NULL;
	  neighbor *n = neigh_find(rta->src->proto, ip, ifa, 0);
	  neighbor *n = neigh_find((*fs->rte)->src->proto, ip, ifa, 0);
	  if (!n || (n->scope == SCOPE_HOST))
	    runtime( "Invalid gw address" );

+2 −2
Original line number Diff line number Diff line
@@ -236,6 +236,7 @@ struct hostentry {
typedef struct rte {
  struct rte *next;
  net *net;				/* Network this RTE belongs to */
  struct rte_src *src;			/* Route source that created the route */
  struct channel *sender;		/* Channel used to send the route to the routing table */
  struct rta *attrs;			/* Attributes of this route */
  u32 id;				/* Table specific route id */
@@ -326,7 +327,7 @@ static inline net *net_get(rtable *tab, const net_addr *addr) { return (net *) f
void *net_route(rtable *tab, const net_addr *n);
int net_roa_check(rtable *tab, const net_addr *n, u32 asn);
rte *rte_find(net *net, struct rte_src *src);
rte *rte_get_temp(struct rta *);
rte *rte_get_temp(struct rta *, struct rte_src *src);
void rte_update2(struct channel *c, const net_addr *n, rte *new, struct rte_src *src);
/* rte_update() moved to protocol.h to avoid dependency conflicts */
int rt_examine(rtable *t, net_addr *a, struct proto *p, const struct filter *filter);
@@ -441,7 +442,6 @@ typedef struct rta {
  u32 uc;				/* Use count */
  u32 hash_key;				/* Hash over important fields */
  struct ea_list *eattrs;		/* Extended Attribute chain */
  struct rte_src *src;			/* Route source that created the route */
  struct hostentry *hostentry;		/* Hostentry for recursive next-hops */
  ip_addr from;				/* Advertising router */
  u32 igp_metric;			/* IGP metric to next hop (for iBGP routes) */
+3 −7
Original line number Diff line number Diff line
@@ -1105,7 +1105,6 @@ rta_hash(rta *a)
  mem_hash_init(&h);
#define MIX(f) mem_hash_mix(&h, &(a->f), sizeof(a->f));
#define BMIX(f) mem_hash_mix_num(&h, a->f);
  MIX(src);
  MIX(hostentry);
  MIX(from);
  MIX(igp_metric);
@@ -1121,8 +1120,7 @@ rta_hash(rta *a)
static inline int
rta_same(rta *x, rta *y)
{
  return (x->src == y->src &&
	  x->source == y->source &&
  return (x->source == y->source &&
	  x->scope == y->scope &&
	  x->dest == y->dest &&
	  x->igp_metric == y->igp_metric &&
@@ -1212,7 +1210,6 @@ rta_lookup(rta *o)
  r = rta_copy(o);
  r->hash_key = h;
  r->cached = 1;
  rt_lock_source(r->src);
  rt_lock_hostentry(r->hostentry);
  rta_insert(r);

@@ -1231,7 +1228,6 @@ rta__free(rta *a)
  if (a->next)
    a->next->pprev = a->pprev;
  rt_unlock_hostentry(a->hostentry);
  rt_unlock_source(a->src);
  if (a->nh.next)
    nexthop_free(a->nh.next);
  ea_free(a->eattrs);
@@ -1270,8 +1266,8 @@ rta_dump(rta *a)
			 "RTS_OSPF_EXT2", "RTS_BGP", "RTS_PIPE", "RTS_BABEL" };
  static char *rtd[] = { "", " DEV", " HOLE", " UNREACH", " PROHIBIT" };

  debug("p=%s pref=%d uc=%d %s %s%s h=%04x",
	a->src->proto->name, a->pref, a->uc, rts[a->source], ip_scope_text(a->scope),
  debug("pref=%d uc=%d %s %s%s h=%04x",
	a->pref, a->uc, rts[a->source], ip_scope_text(a->scope),
	rtd[a->dest], a->hash_key);
  if (!a->cached)
    debug(" !CACHED");
+1 −2
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad)
      struct rte_src *src = rt_get_source(P, ad->iface->index);

      rta a0 = {
	.src = src,
	.pref = c->preference,
	.source = RTS_DEVICE,
	.scope = SCOPE_UNIVERSE,
@@ -92,7 +91,7 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad)
      };

      a = rta_lookup(&a0);
      e = rte_get_temp(a);
      e = rte_get_temp(a, src);
      e->pflags = 0;
      rte_update2(c, net, e, src);
    }
+3 −3
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, int primary
  if (d->verbose && !rta_is_cached(a) && a->eattrs)
    ea_normalize(a->eattrs);

  get_route_info = a->src->proto->proto->get_route_info;
  get_route_info = e->src->proto->proto->get_route_info;
  if (get_route_info)
    get_route_info(e, info);
  else
@@ -66,7 +66,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, int primary
    rt_show_table(c, d);

  cli_printf(c, -1007, "%-20s %s [%s %s%s]%s%s", ia, rta_dest_name(a->dest),
	     a->src->proto->name, tm, from, primary ? (sync_error ? " !" : " *") : "", info);
	     e->src->proto->name, tm, from, primary ? (sync_error ? " !" : " *") : "", info);

  if (a->dest == RTD_UNICAST)
    for (nh = &(a->nh); nh; nh = nh->next)
@@ -180,7 +180,7 @@ rt_show_net(struct cli *c, net *n, struct rt_show_data *d)
	    }
	}

      if (d->show_protocol && (d->show_protocol != e->attrs->src->proto))
      if (d->show_protocol && (d->show_protocol != e->src->proto))
	goto skip;

      if (f_run(d->filter, &e, c->show_pool, 0) > F_ACCEPT)
Loading