Commit 415d6e29 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 7d67c21b
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;
@@ -561,7 +561,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" );

+1 −1
Original line number Diff line number Diff line
@@ -230,6 +230,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 */
@@ -446,7 +447,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
@@ -1099,7 +1099,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);
@@ -1115,8 +1114,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 &&
@@ -1206,7 +1204,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);

@@ -1225,7 +1222,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);
@@ -1264,8 +1260,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 −1
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad)

      rta a0 = {
	/* Use iface ID as local source ID */
	.src = rt_get_source(P, ad->iface->index),
	.pref = c->preference,
	.source = RTS_DEVICE,
	.scope = SCOPE_UNIVERSE,
@@ -85,6 +84,7 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad)
	.nh.iface = ad->iface,
      };
      rte e0 = {
	.src = rt_get_source(P, ad->iface->index),
	.attrs = &a0,
      };
      rte_update(c, net, &e0);
+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)
@@ -179,7 +179,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