Revision 600998fc

View differences:

nest/route.h
65 65
  fib_init_fn init;			/* Constructor */
66 66
};
67 67

  
68
static inline void * fib_node_to_user(struct fib *f, struct fib_node *e)
69
{ return e ? (void *) ((char *) e - f->node_offset) : NULL; }
70

  
71
static inline struct fib_node * fib_user_to_node(struct fib *f, void *e)
72
{ return e ? (void *) ((char *) e + f->node_offset) : NULL; }
73

  
68 74
void fib_init(struct fib *f, pool *p, uint addr_type, uint node_size, uint node_offset, uint hash_order, fib_init_fn init);
69 75
void *fib_find(struct fib *, const net_addr *);	/* Find or return NULL if doesn't exist */
70 76
void *fib_get(struct fib *, const net_addr *); 	/* Find or create new if nonexistent */
......
78 84
void fit_put(struct fib_iterator *, struct fib_node *);
79 85
void fit_put_next(struct fib *f, struct fib_iterator *i, struct fib_node *n, uint hpos);
80 86

  
81
/* XXXX: return user entries */
82
#define FIB_WALK(fib, z) do {					\
83
	struct fib_node *z, **ff = (fib)->hash_table;		\
84
	uint count = (fib)->hash_size;				\
85
	while (count--)						\
86
	  for(z = *ff++; z; z=z->next)
87

  
88
#define FIB_WALK(fib, type, z) do {				\
89
	struct fib_node *fn_, **ff_ = (fib)->hash_table;	\
90
	uint count_ = (fib)->hash_size;				\
91
	type *z;						\
92
	while (count_--)					\
93
	  for (fn_ = *ff_++; z = fib_node_to_user(fib, fn_); fn_=fn_->next)
87 94

  
88 95
#define FIB_WALK_END } while (0)
89 96

  
90 97
#define FIB_ITERATE_INIT(it, fib) fit_init(it, fib)
91 98

  
92
#define FIB_ITERATE_START(fib, it, z) do {			\
93
	struct fib_node *z = fit_get(fib, it);			\
94
	uint count = (fib)->hash_size;				\
95
	uint hpos = (it)->hash;					\
99
#define FIB_ITERATE_START(fib, it, type, z) do {		\
100
	struct fib_node *fn_ = fit_get(fib, it);		\
101
	uint count_ = (fib)->hash_size;				\
102
	uint hpos_ = (it)->hash;				\
103
	type *z;						\
96 104
	for(;;) {						\
97
	  if (!z)						\
105
	  if (!fn_)						\
98 106
            {							\
99
	       if (++hpos >= count)				\
107
	       if (++hpos_ >= count_)				\
100 108
		 break;						\
101
	       z = (fib)->hash_table[hpos];			\
109
	       fn_ = (fib)->hash_table[hpos_];			\
102 110
	       continue;					\
103
	    }
111
	    }							\
112
	  z = fib_node_to_user(fib, fn_);
104 113

  
105
#define FIB_ITERATE_END(z) z = z->next; } } while(0)
114
#define FIB_ITERATE_END fn_ = fn_->next; } } while(0)
106 115

  
107
#define FIB_ITERATE_PUT(it, z) fit_put(it, z)
116
#define FIB_ITERATE_PUT(it) fit_put(it, fn_)
108 117

  
109
#define FIB_ITERATE_PUT_NEXT(it, fib, z) fit_put_next(fib, it, z, hpos)
118
#define FIB_ITERATE_PUT_NEXT(it, fib) fit_put_next(fib, it, fn_, hpos_)
110 119

  
111 120
#define FIB_ITERATE_UNLINK(it, fib) fit_get(fib, it)
112 121

  
nest/rt-fib.c
49 49
#define HASH_LO_MIN 10
50 50

  
51 51

  
52
static inline void * fib_node_to_user(struct fib *f, struct fib_node *e)
53
{ return (void *) ((char *) e - f->node_offset); }
54

  
55
static inline struct fib_node * fib_user_to_node(struct fib *f, void *e)
56
{ return (void *) ((char *) e + f->node_offset); }
57

  
58 52
static void
59 53
fib_ht_alloc(struct fib *f)
60 54
{
......
168 162
    struct fib_node *e = f->hash_table[FIB_HASH(f, a, t)];		\
169 163
    while (e && !net_equal_##t(CAST(t) e->addr, CAST(t) a))		\
170 164
      e = e->next;							\
171
    e ? fib_node_to_user(f, e) : NULL;					\
165
    fib_node_to_user(f, e);						\
172 166
  })
173 167

  
174 168
#define FIB_INSERT(f,a,e,t)						\
nest/rt-table.c
1315 1315
void
1316 1316
rt_refresh_begin(rtable *t, struct announce_hook *ah)
1317 1317
{
1318
  net *n;
1319
  rte *e;
1320

  
1321
  FIB_WALK(&t->fib, fn)
1318
  FIB_WALK(&t->fib, net, n)
1322 1319
    {
1323
      n = (net *) fn;
1320
      rte *e;
1324 1321
      for (e = n->routes; e; e = e->next)
1325 1322
	if (e->sender == ah)
1326 1323
	  e->flags |= REF_STALE;
......
1340 1337
rt_refresh_end(rtable *t, struct announce_hook *ah)
1341 1338
{
1342 1339
  int prune = 0;
1343
  net *n;
1344
  rte *e;
1345 1340

  
1346
  FIB_WALK(&t->fib, fn)
1341
  FIB_WALK(&t->fib, net, n)
1347 1342
    {
1348
      n = (net *) fn;
1343
      rte *e;
1349 1344
      for (e = n->routes; e; e = e->next)
1350 1345
	if ((e->sender == ah) && (e->flags & REF_STALE))
1351 1346
	  {
......
1387 1382
void
1388 1383
rt_dump(rtable *t)
1389 1384
{
1390
  rte *e;
1391
  net *n;
1392
  struct announce_hook *a;
1393

  
1394 1385
  debug("Dump of routing table <%s>\n", t->name);
1395 1386
#ifdef DEBUGGING
1396 1387
  fib_check(&t->fib);
1397 1388
#endif
1398
  FIB_WALK(&t->fib, fn)
1389
  FIB_WALK(&t->fib, net, n)
1399 1390
    {
1400
      n = (net *) fn;
1391
      rte *e;
1401 1392
      for(e=n->routes; e; e=e->next)
1402 1393
	rte_dump(e);
1403 1394
    }
1404 1395
  FIB_WALK_END;
1396

  
1397
  struct announce_hook *a;
1405 1398
  WALK_LIST(a, t->hooks)
1406 1399
    debug("\tAnnounces routes to protocol %s\n", a->proto->name);
1407 1400
  debug("\n");
......
1471 1464

  
1472 1465
  FIB_ITERATE_INIT(&fit, &tab->fib);
1473 1466
again:
1474
  FIB_ITERATE_START(&tab->fib, &fit, f)
1467
  FIB_ITERATE_START(&tab->fib, &fit, net, n)
1475 1468
    {
1476
      net *n = (net *) f;
1477 1469
      ncnt++;
1478 1470
      if (!n->routes)		/* Orphaned FIB entry */
1479 1471
	{
1480
	  FIB_ITERATE_PUT(&fit, f);
1481
	  fib_delete(&tab->fib, f);
1472
	  FIB_ITERATE_PUT(&fit);
1473
	  fib_delete(&tab->fib, n);
1482 1474
	  ndel++;
1483 1475
	  goto again;
1484 1476
	}
1485 1477
    }
1486
  FIB_ITERATE_END(f);
1478
  FIB_ITERATE_END;
1487 1479
  DBG("Pruned %d of %d networks\n", ndel, ncnt);
1488 1480

  
1489 1481
  tab->gc_counter = 0;
......
1572 1564
    }
1573 1565

  
1574 1566
again:
1575
  FIB_ITERATE_START(&tab->fib, fit, fn)
1567
  FIB_ITERATE_START(&tab->fib, fit, net, n)
1576 1568
    {
1577
      net *n = (net *) fn;
1578 1569
      rte *e;
1579 1570

  
1580 1571
    rescan:
......
1583 1574
	  {
1584 1575
	    if (*limit <= 0)
1585 1576
	      {
1586
		FIB_ITERATE_PUT(fit, fn);
1577
		FIB_ITERATE_PUT(fit);
1587 1578
		return 0;
1588 1579
	      }
1589 1580

  
......
1594 1585
	  }
1595 1586
      if (!n->routes)		/* Orphaned FIB entry */
1596 1587
	{
1597
	  FIB_ITERATE_PUT(fit, fn);
1598
	  fib_delete(&tab->fib, fn);
1588
	  FIB_ITERATE_PUT(fit);
1589
	  fib_delete(&tab->fib, n);
1599 1590
	  goto again;
1600 1591
	}
1601 1592
    }
1602
  FIB_ITERATE_END(fn);
1593
  FIB_ITERATE_END;
1603 1594

  
1604 1595
#ifdef DEBUGGING
1605 1596
  fib_check(&tab->fib);
......
1791 1782
      tab->nhu_state = 2;
1792 1783
    }
1793 1784

  
1794
  FIB_ITERATE_START(&tab->fib, fit, fn)
1785
  FIB_ITERATE_START(&tab->fib, fit, net, n)
1795 1786
    {
1796 1787
      if (max_feed <= 0)
1797 1788
	{
1798
	  FIB_ITERATE_PUT(fit, fn);
1789
	  FIB_ITERATE_PUT(fit);
1799 1790
	  ev_schedule(tab->rt_event);
1800 1791
	  return;
1801 1792
	}
1802
      max_feed -= rt_next_hop_update_net(tab, (net *) fn);
1793
      max_feed -= rt_next_hop_update_net(tab, n);
1803 1794
    }
1804
  FIB_ITERATE_END(fn);
1795
  FIB_ITERATE_END;
1805 1796

  
1806 1797
  /* state change 2->0, 3->1 */
1807 1798
  tab->nhu_state &= 1;
......
1971 1962

  
1972 1963
again:
1973 1964
  h = p->feed_ahook;
1974
  FIB_ITERATE_START(&h->table->fib, fit, fn)
1965
  FIB_ITERATE_START(&h->table->fib, fit, net, n)
1975 1966
    {
1976
      net *n = (net *) fn;
1977 1967
      rte *e = n->routes;
1978 1968
      if (max_feed <= 0)
1979 1969
	{
1980
	  FIB_ITERATE_PUT(fit, fn);
1970
	  FIB_ITERATE_PUT(fit);
1981 1971
	  return 0;
1982 1972
	}
1983 1973

  
......
2008 1998
	    max_feed--;
2009 1999
	  }
2010 2000
    }
2011
  FIB_ITERATE_END(fn);
2001
  FIB_ITERATE_END;
2012 2002
  p->feed_ahook = h->next;
2013 2003
  if (!p->feed_ahook)
2014 2004
    {
......
2534 2524
  struct fib *fib = &d->table->fib;
2535 2525
  struct fib_iterator *it = &d->fit;
2536 2526

  
2537
  FIB_ITERATE_START(fib, it, f)
2527
  FIB_ITERATE_START(fib, it, net, n)
2538 2528
    {
2539
      net *n = (net *) f;
2540 2529
      if (d->running_on_config && d->running_on_config != config)
2541 2530
	{
2542 2531
	  cli_printf(c, 8004, "Stopped due to reconfiguration");
......
2549 2538
	}
2550 2539
      if (!max--)
2551 2540
	{
2552
	  FIB_ITERATE_PUT(it, f);
2541
	  FIB_ITERATE_PUT(it);
2553 2542
	  return;
2554 2543
	}
2555 2544
      rt_show_net(c, n, d);
2556 2545
    }
2557
  FIB_ITERATE_END(f);
2546
  FIB_ITERATE_END;
2558 2547
  if (d->stats)
2559 2548
    cli_printf(c, 14, "%d of %d routes for %d networks", d->show_counter, d->rt_counter, d->net_counter);
2560 2549
  else
proto/ospf/ospf.c
502 502
    ospf_iface_shutdown(ifa);
503 503

  
504 504
  /* Cleanup locked rta entries */
505
  FIB_WALK(&p->rtf, nftmp)
505
  FIB_WALK(&p->rtf, ort, nf)
506 506
  {
507
    rta_free(((ort *) nftmp)->old_rta);
507
    rta_free(nf->old_rta);
508 508
  }
509 509
  FIB_WALK_END;
510 510

  
......
745 745
  struct ospf_iface *ifa;
746 746
  struct ospf_neighbor *n;
747 747
  int ifano, nno, adjno, firstfib;
748
  struct area_net *anet;
749 748

  
750 749
  if (p->p.proto_state != PS_UP)
751 750
  {
......
794 793
    cli_msg(-1014, "\t\tNumber of adjacent neighbors:\t%u", adjno);
795 794

  
796 795
    firstfib = 1;
797
    FIB_WALK(&oa->net_fib, nftmp)
796
    FIB_WALK(&oa->net_fib, struct area_net, anet)
798 797
    {
799
      anet = (struct area_net *) nftmp;
800 798
      if(firstfib)
801 799
      {
802 800
	cli_msg(-1014, "\t\tArea networks:");
......
808 806
    FIB_WALK_END;
809 807

  
810 808
    firstfib = 1;
811
    FIB_WALK(&oa->enet_fib, nftmp)
809
    FIB_WALK(&oa->enet_fib, struct area_net, anet)
812 810
    {
813
      anet = (struct area_net *) nftmp;
814 811
      if(firstfib)
815 812
      {
816 813
	cli_msg(-1014, "\t\tArea external networks:");
proto/ospf/rt.c
1158 1158
ospf_rt_abr1(struct ospf_proto *p)
1159 1159
{
1160 1160
  struct area_net *anet;
1161
  ort *nf, *default_nf;
1161
  ort *default_nf;
1162 1162
  net_addr default_net;
1163 1163

  
1164 1164
  /* RFC 2328 G.3 - incomplete resolution of virtual next hops - routers */
1165
  FIB_WALK(&p->backbone->rtr, nftmp)
1165
  FIB_WALK(&p->backbone->rtr, ort, nf)
1166 1166
  {
1167
    nf = (ort *) nftmp;
1168

  
1169 1167
    if (nf->n.type && unresolved_vlink(nf))
1170 1168
      reset_ri(nf);
1171 1169
  }
1172 1170
  FIB_WALK_END;
1173 1171

  
1174 1172

  
1175
  FIB_WALK(&p->rtf, nftmp)
1173
  FIB_WALK(&p->rtf, ort, nf)
1176 1174
  {
1177
    nf = (ort *) nftmp;
1178

  
1179

  
1180 1175
    /* RFC 2328 G.3 - incomplete resolution of virtual next hops - networks */
1181 1176
    if (nf->n.type && unresolved_vlink(nf))
1182 1177
      reset_ri(nf);
......
1241 1236
    /* RFC 2328 16.4. (3) - precompute preferred ASBR entries */
1242 1237
    if (oa_is_ext(oa))
1243 1238
    {
1244
      FIB_WALK(&oa->rtr, nftmp)
1239
      FIB_WALK(&oa->rtr, ort, nf)
1245 1240
      {
1246
	nf = (ort *) nftmp;
1247 1241
	if (nf->n.options & ORTA_ASBR)
1248 1242
	  ri_install_asbr(p, rid_from_net(nf->fn.addr), &nf->n);
1249 1243
      }
......
1253 1247

  
1254 1248

  
1255 1249
  /* Originate or flush ASBR summary LSAs */
1256
  FIB_WALK(&p->backbone->rtr, nftmp)
1250
  FIB_WALK(&p->backbone->rtr, ort, nf)
1257 1251
  {
1258
    check_sum_rt_lsa(p, (ort *) nftmp);
1252
    check_sum_rt_lsa(p, nf);
1259 1253
  }
1260 1254
  FIB_WALK_END;
1261 1255

  
......
1282 1276
{
1283 1277
  struct ospf_area *oa;
1284 1278
  struct top_hash_entry *en;
1285
  ort *nf, *nf2;
1286

  
1287 1279

  
1288 1280
  /* RFC 3103 3.1 - type-7 translator election */
1289 1281
  struct ospf_area *bb = p->backbone;
......
1295 1287
      if (oa->ac->translator)
1296 1288
	goto decided;
1297 1289

  
1298
      FIB_WALK(&oa->rtr, nftmp)
1290
      FIB_WALK(&oa->rtr, ort, nf)
1299 1291
      {
1300
	nf = (ort *) nftmp;
1301 1292
	if (!nf->n.type || !(nf->n.options & ORTA_ABR))
1302 1293
	  continue;
1303 1294

  
1304
	nf2 = fib_find(&bb->rtr, nf->fn.addr);
1295
	ort *nf2 = fib_find(&bb->rtr, nf->fn.addr);
1305 1296
	if (!nf2 || !nf2->n.type || !(nf2->n.options & ORTA_ABR))
1306 1297
	  continue;
1307 1298

  
......
1341 1332

  
1342 1333

  
1343 1334
  /* Compute condensed external networks */
1344
  FIB_WALK(&p->rtf, nftmp)
1335
  FIB_WALK(&p->rtf, ort, nf)
1345 1336
  {
1346
    nf = (ort *) nftmp;
1347 1337
    if (rt_is_nssa(nf) && (nf->n.options & ORTA_PROP))
1348 1338
    {
1349
      struct area_net *anet = (struct area_net *)
1350
	fib_route(&nf->n.oa->enet_fib, nf->fn.addr);
1339
      struct area_net *anet = fib_route(&nf->n.oa->enet_fib, nf->fn.addr);
1351 1340

  
1352 1341
      if (anet)
1353 1342
      {
......
1356 1345
	  anet->active = 1;
1357 1346

  
1358 1347
	  /* Get a RT entry and mark it to know that it is an area network */
1359
	  nf2 = fib_get(&p->rtf, anet->fn.addr);
1348
	  ort *nf2 = fib_get(&p->rtf, anet->fn.addr);
1360 1349
	  nf2->area_net = 1;
1361 1350
	}
1362 1351

  
......
1371 1360
  FIB_WALK_END;
1372 1361

  
1373 1362

  
1374
  FIB_WALK(&p->rtf, nftmp)
1363
  FIB_WALK(&p->rtf, ort, nf)
1375 1364
  {
1376
    nf = (ort *) nftmp;
1377

  
1378 1365
    check_sum_net_lsa(p, nf);
1379 1366
    check_nssa_lsa(p, nf);
1380 1367
  }
......
1586 1573
{
1587 1574
  struct ospf_area *oa;
1588 1575
  struct top_hash_entry *en;
1589
  struct area_net *anet;
1590
  ort *ri;
1591 1576

  
1592 1577
  /* Reset old routing table */
1593
  FIB_WALK(&p->rtf, nftmp)
1578
  FIB_WALK(&p->rtf, ort, ri)
1594 1579
  {
1595
    ri = (ort *) nftmp;
1596 1580
    ri->area_net = 0;
1597 1581
    reset_ri(ri);
1598 1582
  }
......
1613 1597
  WALK_LIST(oa, p->area_list)
1614 1598
  {
1615 1599
    /* Reset ASBR routing tables */
1616
    FIB_WALK(&oa->rtr, nftmp)
1600
    FIB_WALK(&oa->rtr, ort, ri)
1617 1601
    {
1618
      ri = (ort *) nftmp;
1619 1602
      reset_ri(ri);
1620 1603
    }
1621 1604
    FIB_WALK_END;
......
1623 1606
    /* Reset condensed area networks */
1624 1607
    if (p->areano > 1)
1625 1608
    {
1626
      FIB_WALK(&oa->net_fib, nftmp)
1609
      FIB_WALK(&oa->net_fib, struct area_net, anet)
1627 1610
      {
1628
	anet = (struct area_net *) nftmp;
1629 1611
	anet->active = 0;
1630 1612
	anet->metric = 0;
1631 1613
      }
1632 1614
      FIB_WALK_END;
1633 1615

  
1634
      FIB_WALK(&oa->enet_fib, nftmp)
1616
      FIB_WALK(&oa->enet_fib, struct area_net, anet)
1635 1617
      {
1636
	anet = (struct area_net *) nftmp;
1637 1618
	anet->active = 0;
1638 1619
	anet->metric = 0;
1639 1620
      }
......
1935 1916
  struct top_hash_entry *en;
1936 1917
  struct fib_iterator fit;
1937 1918
  struct fib *fib = &p->rtf;
1938
  ort *nf;
1939 1919
  struct ospf_area *oa;
1940 1920

  
1941 1921
  /* This is used for forced reload of routes */
......
1946 1926
  DBG("Now syncing my rt table with nest's\n");
1947 1927
  FIB_ITERATE_INIT(&fit, fib);
1948 1928
again1:
1949
  FIB_ITERATE_START(fib, &fit, nftmp)
1929
  FIB_ITERATE_START(fib, &fit, ort, nf)
1950 1930
  {
1951
    nf = (ort *) nftmp;
1952

  
1953 1931
    /* Sanity check of next-hop addresses, failure should not happen */
1954 1932
    if (nf->n.type)
1955 1933
    {
......
2027 2005
    /* Remove unused rt entry, some special entries are persistent */
2028 2006
    if (!nf->n.type && !nf->external_rte && !nf->area_net)
2029 2007
    {
2030
      FIB_ITERATE_PUT(&fit, nftmp);
2031
      fib_delete(fib, nftmp);
2008
      FIB_ITERATE_PUT(&fit);
2009
      fib_delete(fib, nf);
2032 2010
      goto again1;
2033 2011
    }
2034 2012
  }
2035
  FIB_ITERATE_END(nftmp);
2013
  FIB_ITERATE_END;
2036 2014

  
2037 2015

  
2038 2016
  WALK_LIST(oa, p->area_list)
......
2040 2018
    /* Cleanup ASBR hash tables */
2041 2019
    FIB_ITERATE_INIT(&fit, &oa->rtr);
2042 2020
again2:
2043
    FIB_ITERATE_START(&oa->rtr, &fit, nftmp)
2021
    FIB_ITERATE_START(&oa->rtr, &fit, ort, nf)
2044 2022
    {
2045
      nf = (ort *) nftmp;
2046

  
2047 2023
      if (!nf->n.type)
2048 2024
      {
2049
	FIB_ITERATE_PUT(&fit, nftmp);
2050
	fib_delete(&oa->rtr, nftmp);
2025
	FIB_ITERATE_PUT(&fit);
2026
	fib_delete(&oa->rtr, nf);
2051 2027
	goto again2;
2052 2028
      }
2053 2029
    }
2054
    FIB_ITERATE_END(nftmp);
2030
    FIB_ITERATE_END;
2055 2031
  }
2056 2032

  
2057 2033
  /* Cleanup stale LSAs */
proto/rip/packets.c
417 417
  pkt->unused = 0;
418 418
  pos += rip_pkt_hdrlen(ifa);
419 419

  
420
  FIB_ITERATE_START(&p->rtable, &ifa->tx_fit, z)
420
  FIB_ITERATE_START(&p->rtable, &ifa->tx_fit, struct rip_entry, en)
421 421
  {
422
    struct rip_entry *en = (struct rip_entry *) z;
423

  
424 422
    /* Dummy entries */
425 423
    if (!en->valid)
426 424
      goto next_entry;
......
437 435
    /* Not enough space for current entry */
438 436
    if (pos > max)
439 437
    {
440
      FIB_ITERATE_PUT(&ifa->tx_fit, z);
438
      FIB_ITERATE_PUT(&ifa->tx_fit);
441 439
      goto break_loop;
442 440
    }
443 441

  
......
490 488

  
491 489
  next_entry: ;
492 490
  }
493
  FIB_ITERATE_END(z);
491
  FIB_ITERATE_END;
494 492
  ifa->tx_active = 0;
495 493

  
496 494
  /* Do not send empty packet */
proto/rip/rip.c
823 823
  FIB_ITERATE_INIT(&fit, &p->rtable);
824 824

  
825 825
  loop:
826
  FIB_ITERATE_START(&p->rtable, &fit, node)
826
  FIB_ITERATE_START(&p->rtable, &fit, struct rip_entry, en)
827 827
  {
828
    struct rip_entry *en = (struct rip_entry *) node;
829 828
    struct rip_rte *rt, **rp;
830 829
    int changed = 0;
831 830

  
......
852 851
       * rip_rt_notify() -> p->rtable change, invalidating hidden variables.
853 852
       */
854 853

  
855
      FIB_ITERATE_PUT_NEXT(&fit, &p->rtable, node);
854
      FIB_ITERATE_PUT_NEXT(&fit, &p->rtable);
856 855
      rip_announce_rte(p, en);
857 856
      goto loop;
858 857
    }
......
874 873
    /* Remove empty nodes */
875 874
    if (!en->valid && !en->routes)
876 875
    {
877
      FIB_ITERATE_PUT(&fit, node);
878
      fib_delete(&p->rtable, node);
876
      FIB_ITERATE_PUT(&fit);
877
      fib_delete(&p->rtable, en);
879 878
      goto loop;
880 879
    }
881 880
  }
882
  FIB_ITERATE_END(node);
881
  FIB_ITERATE_END;
883 882

  
884 883
  p->rt_reload = 0;
885 884

  
......
1248 1247
  int i;
1249 1248

  
1250 1249
  i = 0;
1251
  FIB_WALK(&p->rtable, e)
1250
  FIB_WALK(&p->rtable, struct rip_entry, en)
1252 1251
  {
1253
    struct rip_entry *en = (struct rip_entry *) e;
1254 1252
    debug("RIP: entry #%d: %N via %I dev %s valid %d metric %d age %d s\n",
1255 1253
	  i++, en->n.addr, en->next_hop, en->iface->name,
1256 1254
	  en->valid, en->metric, now - en->changed);
sysdep/unix/krt.c
412 412

  
413 413
  FIB_ITERATE_INIT(&fit, fib);
414 414
again:
415
  FIB_ITERATE_START(fib, &fit, f)
415
  FIB_ITERATE_START(fib, &fit, net, n)
416 416
    {
417
      net *n = (net *) f;
418 417
      rte *e, **ee, *best, **pbest, *old_best;
419 418

  
420 419
      old_best = n->routes;
......
445 444
	      krt_learn_announce_delete(p, n);
446 445
	      n->n.flags &= ~KRF_INSTALLED;
447 446
	    }
448
	  FIB_ITERATE_PUT(&fit, f);
449
	  fib_delete(fib, f);
447
	  FIB_ITERATE_PUT(&fit);
448
	  fib_delete(fib, n);
450 449
	  goto again;
451 450
	}
452 451
      *pbest = best->next;
......
461 460
      else
462 461
	DBG("%I/%d: uptodate (metric=%d)\n", n->n.prefix, n->n.pxlen, best->u.krt.metric);
463 462
    }
464
  FIB_ITERATE_END(f);
463
  FIB_ITERATE_END;
465 464

  
466 465
  p->reload = 0;
467 466
}
......
579 578
  struct rtable *t = p->p.table;
580 579

  
581 580
  KRT_TRACE(p, D_EVENTS, "Flushing kernel routes");
582
  FIB_WALK(&t->fib, f)
581
  FIB_WALK(&t->fib, net, n)
583 582
    {
584
      net *n = (net *) f;
585 583
      rte *e = n->routes;
586 584
      if (rte_is_valid(e) && (n->n.flags & KRF_INSTALLED))
587 585
	{
......
751 749
  struct rtable *t = p->p.table;
752 750

  
753 751
  KRT_TRACE(p, D_EVENTS, "Pruning table %s", t->name);
754
  FIB_WALK(&t->fib, f)
752
  FIB_WALK(&t->fib, net, n)
755 753
    {
756
      net *n = (net *) f;
757
      int verdict = f->flags & KRF_VERDICT_MASK;
754
      int verdict = n->n.flags & KRF_VERDICT_MASK;
758 755
      rte *new, *old, *rt_free = NULL;
759 756
      ea_list *tmpa = NULL;
760 757

  
......
783 780
      switch (verdict)
784 781
	{
785 782
	case KRF_CREATE:
786
	  if (new && (f->flags & KRF_INSTALLED))
783
	  if (new && (n->n.flags & KRF_INSTALLED))
787 784
	    {
788 785
	      krt_trace_in(p, new, "reinstalling");
789 786
	      krt_replace_rte(p, n, new, NULL, tmpa);
......
810 807
      if (rt_free)
811 808
	rte_free(rt_free);
812 809
      lp_flush(krt_filter_lp);
813
      f->flags &= ~KRF_VERDICT_MASK;
810
      n->n.flags &= ~KRF_VERDICT_MASK;
814 811
    }
815 812
  FIB_WALK_END;
816 813

  

Also available in: Unified diff