Revision fe9f1a6d nest/rt-table.c

View differences:

nest/rt-table.c
69 69
}
70 70

  
71 71
/* Like fib_route(), but skips empty net entries */
72
/*
72 73
static net *
73 74
net_route(rtable *tab, ip_addr a, int len)
74 75
{
......
85 86
    }
86 87
  return NULL;
87 88
}
88

  
89
static void
90
rte_init(struct fib_node *N)
91
{
92
  net *n = (net *) N;
93

  
94
  N->flags = 0;
95
  n->routes = NULL;
96
}
89
*/
97 90

  
98 91
/**
99 92
 * rte_find - find a route
......
230 223
  byte via[STD_ADDRESS_P_LENGTH+32];
231 224

  
232 225
  rt_format_via(e, via);
233
  log(L_TRACE "%s %c %s %I/%d %s", p->name, dir, msg, e->net->n.prefix, e->net->n.pxlen, via);
226
  log(L_TRACE "%s %c %s %N %s", p->name, dir, msg, e->net->n.addr, via);
234 227
}
235 228

  
236 229
static inline void
......
788 781
  int c;
789 782
  net *n = e->net;
790 783

  
791
  if ((n->n.pxlen > BITS_PER_IP_ADDRESS) || !ip_is_prefix(n->n.prefix,n->n.pxlen))
792
    {
793
      log(L_WARN "Ignoring bogus prefix %I/%d received via %s",
794
	  n->n.prefix, n->n.pxlen, e->sender->proto->name);
795
      return 0;
796
    }
784
  // (n->n.pxlen > BITS_PER_IP_ADDRESS) || !ip_is_prefix(n->n.prefix,n->n.pxlen))
785
  if (!net_validate(n->n.addr))
786
  {
787
    log(L_WARN "Ignoring bogus prefix %N received via %s",
788
	n->n.addr, e->sender->proto->name);
789
    return 0;
790
  }
797 791

  
798
  c = ipa_classify_net(n->n.prefix);
792
  c = net_classify(n->n.addr);
799 793
  if ((c < 0) || !(c & IADDR_HOST) || ((c & IADDR_SCOPE_MASK) <= SCOPE_LINK))
800
    {
801
      log(L_WARN "Ignoring bogus route %I/%d received via %s",
802
	  n->n.prefix, n->n.pxlen, e->sender->proto->name);
803
      return 0;
804
    }
794
  {
795
    log(L_WARN "Ignoring bogus route %N received via %s",
796
	n->n.addr, e->sender->proto->name);
797
    return 0;
798
  }
805 799

  
806 800
  return 1;
807 801
}
......
870 864
	    {
871 865
	      if (new)
872 866
		{
873
		  log_rl(&rl_pipe, L_ERR "Pipe collision detected when sending %I/%d to table %s",
874
		      net->n.prefix, net->n.pxlen, table->name);
867
		  log_rl(&rl_pipe, L_ERR "Pipe collision detected when sending %N to table %s",
868
		      net->n.addr, table->name);
875 869
		  rte_free_quick(new);
876 870
		}
877 871
	      return;
......
1278 1272

  
1279 1273
/* Check rtable for best route to given net whether it would be exported do p */
1280 1274
int
1281
rt_examine(rtable *t, ip_addr prefix, int pxlen, struct proto *p, struct filter *filter)
1275
rt_examine(rtable *t, net_addr *a, struct proto *p, struct filter *filter)
1282 1276
{
1283
  net *n = net_find(t, prefix, pxlen);
1277
  net *n = net_find(t, a);
1284 1278
  rte *rt = n ? n->routes : NULL;
1285 1279

  
1286 1280
  if (!rte_is_valid(rt))
......
1376 1370
rte_dump(rte *e)
1377 1371
{
1378 1372
  net *n = e->net;
1379
  debug("%-1I/%2d ", n->n.prefix, n->n.pxlen);
1373
  debug("%-1N ", n->n.addr);
1380 1374
  debug("KF=%02x PF=%02x pref=%d lm=%d ", n->n.flags, e->pflags, e->pref, now-e->lastmod);
1381 1375
  rta_dump(e->attrs);
1382 1376
  if (e->attrs->src->proto->proto->dump_attrs)
......
1527 1521
rt_setup(pool *p, rtable *t, char *name, struct rtable_config *cf)
1528 1522
{
1529 1523
  bzero(t, sizeof(*t));
1530
  fib_init(&t->fib, p, sizeof(net), 0, rte_init);
1531 1524
  t->name = name;
1532 1525
  t->config = cf;
1526
  t->addr_type = cf ? cf->addr_type : NET_IP4;
1527
  fib_init(&t->fib, p, t->addr_type, sizeof(net), OFFSETOF(net, n), 0, NULL);
1533 1528
  init_list(&t->hooks);
1534 1529
  if (cf)
1535 1530
    {
......
1660 1655
  struct symbol *s = cf_find_symbol("master");
1661 1656

  
1662 1657
  init_list(&c->tables);
1663
  c->master_rtc = rt_new_table(s);
1658
  c->master_rtc = rt_new_table(s, NET_IP4);
1664 1659
}
1665 1660

  
1666 1661

  
......
1817 1812

  
1818 1813

  
1819 1814
struct rtable_config *
1820
rt_new_table(struct symbol *s)
1815
rt_new_table(struct symbol *s, uint addr_type)
1821 1816
{
1822 1817
  /* Hack that allows to 'redefine' the master table */
1823 1818
  if ((s->class == SYM_TABLE) && (s->def == new_config->master_rtc))
......
1827 1822

  
1828 1823
  cf_define_symbol(s, SYM_TABLE, c);
1829 1824
  c->name = s->name;
1825
  c->addr_type = addr_type;
1830 1826
  add_tail(&new_config->tables, &c->n);
1831 1827
  c->gc_max_ops = 1000;
1832 1828
  c->gc_min_time = 5;
......
2196 2192
  if (tab->hcu_scheduled)
2197 2193
    return;
2198 2194

  
2199
  if (trie_match_prefix(hc->trie, net->n.prefix, net->n.pxlen))
2200
    rt_schedule_hcu(tab);
2195
  // XXXX
2196
  // if (trie_match_prefix(hc->trie, net->n.prefix, net->n.pxlen))
2197
  // rt_schedule_hcu(tab);
2201 2198
}
2202 2199

  
2203 2200
static int
......
2253 2250
  he->dest = RTD_UNREACHABLE;
2254 2251
  he->igp_metric = 0;
2255 2252

  
2256
  net *n = net_route(tab, he->addr, MAX_PREFIX_LENGTH);
2253
  // XXXX
2254
  // net *n = net_route(tab, he->addr, MAX_PREFIX_LENGTH);
2255
  net *n = NULL;
2257 2256
  if (n)
2258 2257
    {
2259 2258
      rte *e = n->routes;
2260 2259
      rta *a = e->attrs;
2261
      pxlen = n->n.pxlen;
2260
      pxlen = n->n.addr->pxlen;
2262 2261

  
2263 2262
      if (a->hostentry)
2264 2263
	{
2265 2264
	  /* Recursive route should not depend on another recursive route */
2266
	  log(L_WARN "Next hop address %I resolvable through recursive route for %I/%d",
2267
	      he->addr, n->n.prefix, pxlen);
2265
	  log(L_WARN "Next hop address %I resolvable through recursive route for %N",
2266
	      he->addr, n->n.addr);
2268 2267
	  goto done;
2269 2268
	}
2270 2269

  
......
2425 2424
  int first = 1;
2426 2425
  int pass = 0;
2427 2426

  
2428
  bsprintf(ia, "%I/%d", n->n.prefix, n->n.pxlen);
2427
  bsprintf(ia, "%N", n->n.addr);
2429 2428

  
2430 2429
  if (d->export_mode)
2431 2430
    {
......
2589 2588
    }
2590 2589
  else
2591 2590
    {
2591
      /* XXXX 
2592 2592
      if (d->show_for)
2593 2593
	n = net_route(d->table, d->prefix, d->pxlen);
2594 2594
      else
2595 2595
	n = net_find(d->table, d->prefix, d->pxlen);
2596
      */
2597
      n = NULL;
2596 2598

  
2597 2599
      if (n)
2598 2600
	rt_show_net(this_cli, n, d);
......
2613 2615
 * net_find - find a network entry
2614 2616
 * @tab: a routing table
2615 2617
 * @addr: address of the network
2616
 * @len: length of the network prefix
2617 2618
 *
2618 2619
 * net_find() looks up the given network in routing table @tab and
2619 2620
 * returns a pointer to its &net entry or %NULL if no such network
2620 2621
 * exists.
2621 2622
 */
2622
static inline net *net_find(rtable *tab, ip_addr addr, unsigned len)
2623
static inline net *net_find(rtable *tab, net_addr *addr)
2623 2624
{ DUMMY; }
2624 2625

  
2625 2626
/**
2626 2627
 * net_get - obtain a network entry
2627 2628
 * @tab: a routing table
2628 2629
 * @addr: address of the network
2629
 * @len: length of the network prefix
2630 2630
 *
2631 2631
 * net_get() looks up the given network in routing table @tab and
2632 2632
 * returns a pointer to its &net entry. If no such entry exists, it's
2633 2633
 * created.
2634 2634
 */
2635
static inline net *net_get(rtable *tab, ip_addr addr, unsigned len)
2635
static inline net *net_get(rtable *tab, net_addr *addr)
2636 2636
{ DUMMY; }
2637 2637

  
2638 2638
/**

Also available in: Unified diff