summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-04-12 20:01:07 +0200
committerMartin Mares <mj@ucw.cz>1999-04-12 20:01:07 +0200
commit08e2d6259a71c5e43ac0083ea6d81357678f99eb (patch)
treeb8c1cfaf6196d54c506ed025a9d29697bda087b6
parent170c984a9ef1bde00711f405b03d24a2e151501c (diff)
downloadbird-08e2d6259a71c5e43ac0083ea6d81357678f99eb.tar
bird-08e2d6259a71c5e43ac0083ea6d81357678f99eb.zip
Removed TOS support. This simplifies many things a lot.
-rw-r--r--TODO8
-rw-r--r--nest/route.h19
-rw-r--r--nest/rt-attr.c5
-rw-r--r--nest/rt-dev.c6
-rw-r--r--nest/rt-table.c114
-rw-r--r--proto/rip/rip.c3
-rw-r--r--proto/static/static.c5
-rw-r--r--sysdep/cf/README1
-rw-r--r--sysdep/cf/linux-20.h1
-rw-r--r--sysdep/cf/linux-21.h1
-rw-r--r--sysdep/cf/linux-22.h1
-rw-r--r--sysdep/linux/krt-scan.c4
-rw-r--r--sysdep/linux/netlink/netlink.c8
-rw-r--r--sysdep/unix/krt-set.c3
-rw-r--r--sysdep/unix/krt.c16
15 files changed, 67 insertions, 128 deletions
diff --git a/TODO b/TODO
index e39678e..87eb4cb 100644
--- a/TODO
+++ b/TODO
@@ -1,9 +1,9 @@
Core
~~~~
-- Remove TOS support?
-
* protocols: implement dumping of protocol-dependent rte attributes
+- prefer loopback addresses as router IDs (dummy interface?)
+
- config: executable config files
- do we really need preconfig?
@@ -19,13 +19,11 @@ Core
- adding of route: check whether all bits not covered by masklen are zero
-- incoming packets: interface the packet came from? (esp. for multicasts)
-- broadcast/multicast echoing suppresion
-
- netlink: import Linux route attributes to our rta's, so that they can be filtered?
- iface: when seen an invalid broadcast, fix it up or at least report
- iface: we always need ifindex at least for PtP links (OSPF)
+- iface: interface filters should support filtering by IP address as well
Cleanup
~~~~~~~
diff --git a/nest/route.h b/nest/route.h
index ebe10f1..10628cd 100644
--- a/nest/route.h
+++ b/nest/route.h
@@ -94,17 +94,17 @@ void fit_put(struct fib_iterator *, struct fib_node *);
#define FIB_ITERATE_PUT(it, z) fit_put(it, z)
/*
- * Master Routing Tables. Generally speaking, each of them is a list
- * of FIB (one per TOS) with each entry pointing to a list of route entries
- * representing routes to given network.
+ * Master Routing Tables. Generally speaking, each of them contains a FIB
+ * with each entry pointing to a list of route entries representing routes
+ * to given network (with the selected one at the head).
+ *
* Each of the RTE's contains variable data (the preference and protocol-dependent
* metrics) and a pointer to a route attribute block common for many routes).
- * It's guaranteed that there is at most one RTE for every (prefix,proto,source) triplet.
+ *
+ * It's guaranteed that there is at most one RTE for every (prefix,proto) pair.
*/
typedef struct rtable {
- struct rtable *sibling; /* Our sibling for different TOS */
- byte tos; /* TOS for this table */
struct fib fib;
char *name; /* Name of this table */
} rtable;
@@ -156,8 +156,8 @@ extern rtable master_table;
void rt_init(void);
void rt_setup(pool *, rtable *, char *);
-net *net_find(rtable *tab, unsigned tos, ip_addr addr, unsigned len);
-net *net_get(rtable *tab, unsigned tos, ip_addr addr, unsigned len);
+static inline net *net_find(rtable *tab, ip_addr addr, unsigned len) { return (net *) fib_find(&tab->fib, &addr, len); }
+static inline net *net_get(rtable *tab, ip_addr addr, unsigned len) { return (net *) fib_get(&tab->fib, &addr, len); }
rte *rte_find(net *net, struct proto *p);
rte *rte_get_temp(struct rta *);
void rte_update(net *net, struct proto *p, rte *new);
@@ -188,10 +188,9 @@ typedef struct rta {
byte scope; /* Route scope (SCOPE_... -- see ip.h) */
byte cast; /* Casting type (RTC_...) */
byte dest; /* Route destination type (RTD_...) */
- byte tos; /* TOS of this route */
byte flags; /* Route flags (RTF_...) */
byte aflags; /* Attribute cache flags (RTAF_...) */
- byte rfu; /* Padding */
+ byte rfu, rfu2; /* Padding */
ip_addr gw; /* Next hop */
ip_addr from; /* Advertising router */
struct iface *iface; /* Outgoing interface */
diff --git a/nest/rt-attr.c b/nest/rt-attr.c
index 2cb2bc5..2a369ce 100644
--- a/nest/rt-attr.c
+++ b/nest/rt-attr.c
@@ -271,7 +271,6 @@ rta_same(rta *x, rta *y)
x->scope == y->scope &&
x->cast == y->cast &&
x->dest == y->dest &&
- x->tos == y->tos &&
x->flags == y->flags &&
ipa_equal(x->gw, y->gw) &&
ipa_equal(x->from, y->from) &&
@@ -334,9 +333,9 @@ rta_dump(rta *a)
static char *rtc[] = { "", " BC", " MC", " AC" };
static char *rtd[] = { "", " DEV", " HOLE", " UNREACH", " PROHIBIT" };
- debug("p=%s uc=%d %s %s%s%s TOS=%d",
+ debug("p=%s uc=%d %s %s%s%s",
a->proto->name, a->uc, rts[a->source], sco[a->scope], rtc[a->cast],
- rtd[a->dest], a->tos);
+ rtd[a->dest]);
if (a->flags & RTF_EXTERIOR)
debug(" EXT");
if (a->flags & RTF_TAGGED)
diff --git a/nest/rt-dev.c b/nest/rt-dev.c
index a92fe6f..d6035f5 100644
--- a/nest/rt-dev.c
+++ b/nest/rt-dev.c
@@ -31,7 +31,7 @@ dev_if_notify(struct proto *p, unsigned c, struct iface *new, struct iface *old)
net *n;
debug("dev_if_notify: %s going down\n", old->name);
- n = net_find(p->table, 0, old->prefix, old->pxlen);
+ n = net_find(p->table, old->prefix, old->pxlen);
if (!n)
{
debug("dev_if_notify: device shutdown: prefix not found\n");
@@ -56,9 +56,9 @@ dev_if_notify(struct proto *p, unsigned c, struct iface *new, struct iface *old)
A.attrs = NULL;
a = rta_lookup(&A);
if (new->flags & IF_UNNUMBERED)
- n = net_get(p->table, 0, new->opposite, new->pxlen);
+ n = net_get(p->table, new->opposite, new->pxlen);
else
- n = net_get(p->table, 0, new->prefix, new->pxlen);
+ n = net_get(p->table, new->prefix, new->pxlen);
e = rte_get_temp(a);
e->net = n;
e->pflags = 0;
diff --git a/nest/rt-table.c b/nest/rt-table.c
index 47b4bb7..2b60bb8 100644
--- a/nest/rt-table.c
+++ b/nest/rt-table.c
@@ -46,35 +46,6 @@ rt_setup(pool *p, rtable *t, char *name)
t->name = name;
}
-net *
-net_find(rtable *tab, unsigned tos, ip_addr mask, unsigned len)
-{
- while (tab && tab->tos != tos)
- tab = tab->sibling;
- if (!tab)
- return NULL;
- return (net *) fib_find(&tab->fib, &mask, len);
-}
-
-net *
-net_get(rtable *tab, unsigned tos, ip_addr mask, unsigned len)
-{
- rtable *t = tab;
-
- while (t && t->tos != tos)
- t = t->sibling;
- if (!t)
- {
- while (tab->sibling)
- tab = tab->sibling;
- t = mb_alloc(&root_pool, sizeof(rtable));
- rt_setup(&root_pool, t, NULL); /* FIXME: Either delete all the TOS logic or use the right pool */
- tab->sibling = t;
- t->tos = tos;
- }
- return (net *) fib_get(&t->fib, &mask, len);
-}
-
rte *
rte_find(net *net, struct proto *p)
{
@@ -181,23 +152,19 @@ rt_feed_baby(struct proto *p)
if (!p->rt_notify)
return;
debug("Announcing routes to new protocol %s\n", p->name);
- while (t)
+ FIB_WALK(&t->fib, fn)
{
- FIB_WALK(&t->fib, fn)
+ net *n = (net *) fn;
+ rte *e;
+ for(e=n->routes; e; e=e->next)
{
- net *n = (net *) fn;
- rte *e;
- for(e=n->routes; e; e=e->next)
- {
- struct proto *q = e->attrs->proto;
- ea_list *tmpa = q->make_tmp_attrs ? q->make_tmp_attrs(e, rte_update_pool) : NULL;
- do_rte_announce(p, n, e, NULL, tmpa);
- lp_flush(rte_update_pool);
- }
+ struct proto *q = e->attrs->proto;
+ ea_list *tmpa = q->make_tmp_attrs ? q->make_tmp_attrs(e, rte_update_pool) : NULL;
+ do_rte_announce(p, n, e, NULL, tmpa);
+ lp_flush(rte_update_pool);
}
- FIB_WALK_END;
- t = t->sibling;
}
+ FIB_WALK_END;
}
static inline int
@@ -396,21 +363,16 @@ rt_dump(rtable *t)
net *n;
debug("Dump of routing table <%s>\n", t->name);
- while (t)
- {
- debug("Routes for TOS %02x:\n", t->tos);
#ifdef DEBUGGING
- fib_check(&t->fib);
+ fib_check(&t->fib);
#endif
- FIB_WALK(&t->fib, fn)
- {
- n = (net *) fn;
- for(e=n->routes; e; e=e->next)
- rte_dump(e);
- }
- FIB_WALK_END;
- t = t->sibling;
+ FIB_WALK(&t->fib, fn)
+ {
+ n = (net *) fn;
+ for(e=n->routes; e; e=e->next)
+ rte_dump(e);
}
+ FIB_WALK_END;
debug("\n");
}
@@ -449,33 +411,29 @@ rt_prune(rtable *tab)
int rcnt = 0, rdel = 0, ncnt = 0, ndel = 0;
DBG("Pruning route table %s\n", tab->name);
- while (tab)
+ FIB_ITERATE_INIT(&fit, &tab->fib);
+again:
+ FIB_ITERATE_START(&tab->fib, &fit, f)
{
- FIB_ITERATE_INIT(&fit, &tab->fib);
- again:
- FIB_ITERATE_START(&tab->fib, &fit, f)
+ net *n = (net *) f;
+ rte *e;
+ ncnt++;
+ rescan:
+ for (e=n->routes; e; e=e->next, rcnt++)
+ if (e->attrs->proto->core_state != FS_HAPPY)
+ {
+ rte_discard(e);
+ rdel++;
+ goto rescan;
+ }
+ if (!n->routes) /* Orphaned FIB entry? */
{
- net *n = (net *) f;
- rte *e;
- ncnt++;
- rescan:
- for (e=n->routes; e; e=e->next, rcnt++)
- if (e->attrs->proto->core_state != FS_HAPPY)
- {
- rte_discard(e);
- rdel++;
- goto rescan;
- }
- if (!n->routes) /* Orphaned FIB entry? */
- {
- FIB_ITERATE_PUT(&fit, f);
- fib_delete(&tab->fib, f);
- ndel++;
- goto again;
- }
+ FIB_ITERATE_PUT(&fit, f);
+ fib_delete(&tab->fib, f);
+ ndel++;
+ goto again;
}
- FIB_ITERATE_END(f);
- tab = tab->sibling;
}
+ FIB_ITERATE_END(f);
DBG("Pruned %d of %d routes and %d of %d networks\n", rcnt, rdel, ncnt, ndel);
}
diff --git a/proto/rip/rip.c b/proto/rip/rip.c
index e345de6..c2285a7 100644
--- a/proto/rip/rip.c
+++ b/proto/rip/rip.c
@@ -198,7 +198,6 @@ advertise_entry( struct proto *p, struct rip_block *b, ip_addr whotoldme )
A.scope = SCOPE_UNIVERSE;
A.cast = RTC_UNICAST;
A.dest = RTD_ROUTER;
- A.tos = 0;
A.flags = 0;
A.gw = ipa_nonzero(b->nexthop) ? b->nexthop : whotoldme;
A.from = whotoldme;
@@ -226,7 +225,7 @@ advertise_entry( struct proto *p, struct rip_block *b, ip_addr whotoldme )
log( L_ERR "%I asked me to route %I/%I, but that is not valid netmask.", A.from, b->network, b->netmask );
return;
}
- n = net_get( p->table, 0, b->network, ipa_mklen( b->netmask ));
+ n = net_get( p->table, b->network, ipa_mklen( b->netmask ));
r = rte_get_temp(a);
r->u.rip.metric = ntohl(b->metric) + rif->metric;
if (r->u.rip.metric > P_CF->infinity) r->u.rip.metric = P_CF->infinity;
diff --git a/proto/static/static.c b/proto/static/static.c
index 3a485bf..871438a 100644
--- a/proto/static/static.c
+++ b/proto/static/static.c
@@ -32,12 +32,11 @@ static_install(struct proto *p, struct static_route *r, struct iface *ifa)
a.scope = SCOPE_UNIVERSE;
a.cast = RTC_UNICAST;
a.dest = r->dest;
- a.tos = 0;
a.gw = r->via;
a.iface = ifa;
aa = rta_lookup(&a);
- n = net_get(p->table, a.tos, r->net, r->masklen);
+ n = net_get(p->table, r->net, r->masklen);
e = rte_get_temp(aa);
e->net = n;
e->pflags = 0;
@@ -50,7 +49,7 @@ static_remove(struct proto *p, struct static_route *r)
net *n;
DBG("Removing static route %I/%d\n", r->net, r->masklen);
- n = net_find(p->table, 0, r->net, r->masklen);
+ n = net_find(p->table, r->net, r->masklen);
if (n)
rte_update(n, p, NULL);
}
diff --git a/sysdep/cf/README b/sysdep/cf/README
index eb8ac34..1f8d999 100644
--- a/sysdep/cf/README
+++ b/sysdep/cf/README
@@ -1,7 +1,6 @@
Available configuration variables:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-CONFIG_TOS Routing by TOS supported
CONFIG_AUTO_ROUTES Device routes are added automagically by the kernel
CONFIG_ALL_MULTICAST All devices support multicasting (i.e., ignore IFF_MULTICAST)
CONFIG_SELF_CONSCIOUS We're able to recognize whether route was installed by us
diff --git a/sysdep/cf/linux-20.h b/sysdep/cf/linux-20.h
index c816f94..9d513e2 100644
--- a/sysdep/cf/linux-20.h
+++ b/sysdep/cf/linux-20.h
@@ -6,7 +6,6 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
-#undef CONFIG_TOS
#undef CONFIG_AUTO_ROUTES
#define CONFIG_ALL_MULTICAST
#undef CONFIG_SELF_CONSCIOUS
diff --git a/sysdep/cf/linux-21.h b/sysdep/cf/linux-21.h
index 3a46f87..f9ad830 100644
--- a/sysdep/cf/linux-21.h
+++ b/sysdep/cf/linux-21.h
@@ -6,7 +6,6 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
-#undef CONFIG_TOS
#define CONFIG_AUTO_ROUTES
#define CONFIG_ALL_MULTICAST
#undef CONFIG_SELF_CONSCIOUS
diff --git a/sysdep/cf/linux-22.h b/sysdep/cf/linux-22.h
index a76cb1b..53ce67c 100644
--- a/sysdep/cf/linux-22.h
+++ b/sysdep/cf/linux-22.h
@@ -6,7 +6,6 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
-#define CONFIG_TOS
#define CONFIG_AUTO_ROUTES
#define CONFIG_ALL_MULTICAST
#define CONFIG_SELF_CONSCIOUS
diff --git a/sysdep/linux/krt-scan.c b/sysdep/linux/krt-scan.c
index 85e092d..7ee80f2 100644
--- a/sysdep/linux/krt-scan.c
+++ b/sysdep/linux/krt-scan.c
@@ -86,13 +86,13 @@ krt_parse_entry(byte *ent, struct krt_proto *p)
return;
}
- net = net_get(&master_table, 0, dest, masklen);
+ net = net_get(&master_table, dest, masklen);
a.proto = &p->p;
a.source = RTS_INHERIT;
a.scope = SCOPE_UNIVERSE;
a.cast = RTC_UNICAST;
- a.tos = a.flags = a.aflags = 0;
+ a.flags = a.aflags = 0;
a.from = IPA_NONE;
a.iface = NULL;
a.attrs = NULL;
diff --git a/sysdep/linux/netlink/netlink.c b/sysdep/linux/netlink/netlink.c
index 326c174..31dd608 100644
--- a/sysdep/linux/netlink/netlink.c
+++ b/sysdep/linux/netlink/netlink.c
@@ -487,9 +487,9 @@ nl_send_route(rte *e, int new)
void
krt_set_notify(struct krt_proto *p, net *n, rte *new, rte *old)
{
- if (old && new && old->attrs->tos == new->attrs->tos)
+ if (old && new)
{
- /* FIXME: Priorities should be identical as well, but we don't use them yet. */
+ /* FIXME: Priorities and TOS should be identical as well, but we don't use them yet. */
nl_send_route(new, 1);
}
else
@@ -594,12 +594,12 @@ nl_parse_route(struct krt_proto *p, struct nlmsghdr *h, int scan)
src = KRT_SRC_ALIEN;
}
- net = net_get(&master_table, 0, dst, i->rtm_dst_len);
+ net = net_get(&master_table, dst, i->rtm_dst_len);
ra.proto = &p->p;
ra.source = RTS_INHERIT;
ra.scope = SCOPE_UNIVERSE; /* FIXME: Use kernel scope? */
ra.cast = RTC_UNICAST;
- ra.tos = ra.flags = ra.aflags = 0;
+ ra.flags = ra.aflags = 0;
ra.from = IPA_NONE;
ra.gw = IPA_NONE;
ra.iface = NULL;
diff --git a/sysdep/unix/krt-set.c b/sysdep/unix/krt-set.c
index 435587b..e1f69db 100644
--- a/sysdep/unix/krt-set.c
+++ b/sysdep/unix/krt-set.c
@@ -38,8 +38,7 @@ krt_capable(rte *e)
#ifdef RTF_REJECT
|| a->dest == RTD_UNREACHABLE
#endif
- ) &&
- !a->tos;
+ );
}
static void
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c
index 5d694f6..69d535b 100644
--- a/sysdep/unix/krt.c
+++ b/sysdep/unix/krt.c
@@ -128,7 +128,7 @@ krt_learn_announce_update(struct krt_proto *p, rte *e)
net *n = e->net;
rta *aa = rta_clone(e->attrs);
rte *ee = rte_get_temp(aa);
- net *nn = net_get(p->p.table, 0, n->n.prefix, n->n.pxlen); /* FIXME: TOS */
+ net *nn = net_get(p->p.table, n->n.prefix, n->n.pxlen);
ee->net = nn;
ee->pflags = 0;
ee->u.krt = e->u.krt;
@@ -138,7 +138,7 @@ krt_learn_announce_update(struct krt_proto *p, rte *e)
static void
krt_learn_announce_delete(struct krt_proto *p, net *n)
{
- n = net_find(p->p.table, 0, n->n.prefix, n->n.pxlen); /* FIXME: TOS */
+ n = net_find(p->p.table, n->n.prefix, n->n.pxlen);
if (n)
rte_update(n, &p->p, NULL);
}
@@ -147,7 +147,7 @@ static void
krt_learn_scan(struct krt_proto *p, rte *e)
{
net *n0 = e->net;
- net *n = net_get(&p->krt_table, 0, n0->n.prefix, n0->n.pxlen); /* FIXME: TOS */
+ net *n = net_get(&p->krt_table, n0->n.prefix, n0->n.pxlen);
rte *m, **mm;
e->attrs->source = RTS_INHERIT;
@@ -250,7 +250,7 @@ static void
krt_learn_async(struct krt_proto *p, rte *e, int new)
{
net *n0 = e->net;
- net *n = net_get(&p->krt_table, 0, n0->n.prefix, n0->n.pxlen); /* FIXME: TOS */
+ net *n = net_get(&p->krt_table, n0->n.prefix, n0->n.pxlen);
rte *g, **gg, *best, **bestp, *old_best;
e->attrs->source = RTS_INHERIT;
@@ -359,10 +359,6 @@ krt_flush_routes(struct krt_proto *p)
struct rtable *t = &master_table;
DBG("Flushing kernel routes...\n");
- while (t && t->tos)
- t = t->sibling;
- if (!t)
- return;
FIB_WALK(&t->fib, f)
{
net *n = (net *) f;
@@ -474,10 +470,6 @@ krt_prune(struct krt_proto *p)
struct fib_node *f;
DBG("Pruning routes...\n");
- while (t && t->tos)
- t = t->sibling;
- if (!t)
- return;
FIB_WALK(&t->fib, f)
{
net *n = (net *) f;