]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
When rte_update is called for an identical route, don't announce anything.
authorMartin Mares <mj@ucw.cz>
Sat, 6 May 2000 21:21:19 +0000 (21:21 +0000)
committerMartin Mares <mj@ucw.cz>
Sat, 6 May 2000 21:21:19 +0000 (21:21 +0000)
Please implement the rte_same hook in your protocols. It should just
compare your metrics stored directly in rte, the rest is done by the core.

TODO
nest/protocol.h
nest/rt-table.c

diff --git a/TODO b/TODO
index 7f478f27c4f8137f9a6f5735861352ab4c474c89..ae0d53d909be8f4c8c96f0ce870e1db881d44f22 100644 (file)
--- a/TODO
+++ b/TODO
@@ -9,9 +9,6 @@ Core
 
 - tagging of external routes?
 
-- when an identical route is received, don't trigger updates
-
-- configure: --enable-ipv6
 - configure: IPv6 on glibc 2.0?
 
 - Makefile: install target?
index 2e64112f4eafc8c99ea7d752f2380d388652c86a..768792f234c2fe032e1bcdbefb42123e581e536b 100644 (file)
@@ -135,11 +135,13 @@ struct proto {
    *   Routing entry hooks (called only for rte's belonging to this protocol):
    *
    *      rte_better   Compare two rte's and decide which one is better (1=first, 0=second).
+   *       rte_same    Compare two rte's and decide whether they are identical (1=yes, 0=no).
    *      rte_insert   Called whenever a rte is inserted to a routing table.
    *      rte_remove   Called whenever a rte is removed from the routing table.
    */
 
   int (*rte_better)(struct rte *, struct rte *);
+  int (*rte_same)(struct rte *, struct rte *);
   void (*rte_insert)(struct network *, struct rte *);
   void (*rte_remove)(struct network *, struct rte *);
 
index 832e9ef4a722cb109fe2485b1117ea6aa5d29f98..4214d078ad1f0fec85389372105b7baa602d2bce 100644 (file)
@@ -272,6 +272,17 @@ rte_free_quick(rte *e)
   sl_free(rte_slab, e);
 }
 
+static int
+rte_same(rte *x, rte *y)
+{
+  return
+    x->attrs == y->attrs &&
+    x->flags == y->flags &&
+    x->pflags == y->pflags &&
+    x->pref == y->pref &&
+    (!x->attrs->proto->rte_same || x->attrs->proto->rte_same(x, y));
+}
+
 static void
 rte_recalculate(rtable *table, net *net, struct proto *p, rte *new, ea_list *tmpa)
 {
@@ -284,6 +295,14 @@ rte_recalculate(rtable *table, net *net, struct proto *p, rte *new, ea_list *tmp
     {
       if (old->attrs->proto == p)
        {
+         if (rte_same(old, new))
+           {
+             /* No changes, ignore the new route */
+             rte_trace_in(D_ROUTES, p, new, "ignored");
+             rte_free_quick(new);
+             old->lastmod = now;
+             return;
+           }
          *k = old->next;
          break;
        }