Revision 0cdbd397 nest/rt-table.c

View differences:

nest/rt-table.c
30 30
{
31 31
  bzero(t, sizeof(*t));
32 32
  fib_init(&t->fib, &root_pool, sizeof(rte), 0, rte_init);
33
  t->name = name;
33 34
}
34 35

  
35 36
net *
......
77 78
  rte *e = sl_alloc(rte_slab);
78 79

  
79 80
  e->attrs = a;
81
  e->flags = 0;
80 82
  e->pref = a->proto->preference;
81 83
  e->lastmod = 0;			/* FIXME */
82 84
  return e;
......
122 124
}
123 125

  
124 126
void
125
rte_update(net *net, rte *new)
127
rte_update(net *net, struct proto *p, rte *new)
126 128
{
127 129
  rte *old_best = net->routes;
128 130
  rte *old = NULL;
129 131
  rte **k, *r, *s;
130
  struct proto *p = new->attrs->proto;
131 132

  
132 133
  k = &net->routes;			/* Find and remove original route from the same protocol */
133 134
  while (old = *k)
......
140 141
      k = &old->next;
141 142
    }
142 143

  
143
  if (rte_better(new, old_best))	/* It's a new optimal route => announce and relink it */
144
  if (new && rte_better(new, old_best))	/* It's a new optimal route => announce and relink it */
144 145
    {
145 146
      rte_announce(new, old_best);
146 147
      new->next = net->routes;
......
181 182
}
182 183

  
183 184
void
184
rte_dump(rte *r)
185
rte_dump(net *n, rte *e)
185 186
{
187
  if (n)
188
    debug("%08x/%2d ", _I(n->n.prefix), n->n.pxlen);
189
  debug("PF=%02x pref=%d lm=%d ", e->pflags, e->pref, e->lastmod);
190
  rta_dump(e->attrs);
191
  if (e->flags & REF_CHOSEN)
192
    debug(" [*]");
193
  debug("\n");
186 194
}
187 195

  
188 196
void
189 197
rt_dump(rtable *t)
190 198
{
199
  rte *e;
200
  net *n;
201

  
202
  debug("Dump of routing table <%s>\n", t->name);
203
  while (t)
204
    {
205
      debug("Routes for TOS %02x:\n", t->tos);
206
      FIB_WALK(&t->fib, fn)
207
	{
208
	  n = (net *) fn;
209
	  for(e=n->routes; e; e=e->next)
210
	    rte_dump(n, e);
211
	}
212
      FIB_WALK_END;
213
      t = t->sibling;
214
    }
215
  debug("\n");
191 216
}
192 217

  
193 218
void
194 219
rt_dump_all(void)
195 220
{
221
  rt_dump(&master_table);
196 222
}
197 223

  
198 224
void

Also available in: Unified diff