]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Removed TOS support. This simplifies many things a lot.
authorMartin Mares <mj@ucw.cz>
Mon, 12 Apr 1999 18:01:07 +0000 (18:01 +0000)
committerMartin Mares <mj@ucw.cz>
Mon, 12 Apr 1999 18:01:07 +0000 (18:01 +0000)
15 files changed:
TODO
nest/route.h
nest/rt-attr.c
nest/rt-dev.c
nest/rt-table.c
proto/rip/rip.c
proto/static/static.c
sysdep/cf/README
sysdep/cf/linux-20.h
sysdep/cf/linux-21.h
sysdep/cf/linux-22.h
sysdep/linux/krt-scan.c
sysdep/linux/netlink/netlink.c
sysdep/unix/krt-set.c
sysdep/unix/krt.c

diff --git a/TODO b/TODO
index e39678e050197415c89ef7ca96677ee240a79a0e..87eb4cbc10685d1369724ad2845c51956d18cfcd 100644 (file)
--- 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
 ~~~~~~~
index ebe10f1f4a759d56fd3a58ed10cc06dad265dc19..10628cdb937e457e9e6c4ba5dd642eb522ad7f29 100644 (file)
@@ -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 */
index 2cb2bc50e3fba8a15eac8482c2a6e19998616503..2a369cedd6cc7732ec0ed38594297f3dc70ae999 100644 (file)
@@ -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)
index a92fe6f9bc47b99261b9bdc2a4bd082c3901365f..d6035f566d8a2b591905e6856febe7366545e6ae 100644 (file)
@@ -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;
index 47b4bb72eb312aed21d1b5c4b95a084577c07ed8..2b60bb839c59ce03a8457afa7289d5da305839b6 100644 (file)
@@ -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);
 }
index e345de6cf74dda3aec74b02917dd857614450d47..c2285a7b102420d3d65bc4a96e5b309683e457c9 100644 (file)
@@ -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;
index 3a485bf3f20a5d4f4ac393a35017e82b63a7a9cf..871438a6e44252150741f81509e435c813077a88 100644 (file)
@@ -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);
 }
index eb8ac340649aafc9ced160df1c5ee7d497776bb6..1f8d99969c336d2d4b3729f16e678d70f2033343 100644 (file)
@@ -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
index c816f942dfcc180f1600e7ffcced5bc84442622a..9d513e2e4e69520d81d228650581575a94763a82 100644 (file)
@@ -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
index 3a46f87541e8d5604886e1579e530b225f282796..f9ad830dc7d6c9fac7c7c0bfa19f65bf8698c40a 100644 (file)
@@ -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
index a76cb1bbb26672e4fb6554a6fcebab6b979b4571..53ce67cf46d4031e06bef0da2e33592561297b71 100644 (file)
@@ -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
index 85e092d780b187bc5e20bb83451aaccc3685488e..7ee80f27972a90cf6c9c6d1471a2ecf54c342684 100644 (file)
@@ -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;
index 326c1746d3163a3d0b59c28ffb280dc45a0181fb..31dd608de0638d3040bbc413dbc8c916534041be 100644 (file)
@@ -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;
index 435587beedae47263a18df9d061a76a811a67348..e1f69db2a32e91742e4565e873427d53db05417c 100644 (file)
@@ -38,8 +38,7 @@ krt_capable(rte *e)
 #ifdef RTF_REJECT
      || a->dest == RTD_UNREACHABLE
 #endif
-     ) &&
-    !a->tos;
+     );
 }
 
 static void
index 5d694f65f72acd06fde0f3cbaebff98f499347dd..69d535bccc392f929027e9102370ce706beb3cfc 100644 (file)
@@ -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;