]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixes issues with static protocol reconfiguration.
authorOndrej Zajicek <santiago@crfreenet.org>
Wed, 26 Feb 2014 12:25:39 +0000 (13:25 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Wed, 26 Feb 2014 15:01:20 +0000 (16:01 +0100)
The old static route was not removed when the nexthop changed and the
new one was not viable (no neighbor).

Thanks to Pierluigi Rolando for the original patch.

proto/static/static.c
proto/static/static.h

index 9b115acd2c2f6b54adafade975e47157f9930649..d3a595d35fc0b7f5ebc656415a3dbceddcfb9e8f 100644 (file)
@@ -62,7 +62,7 @@ static_install(struct proto *p, struct static_route *r, struct iface *ifa)
   rta a, *aa;
   rte *e;
 
-  if (r->installed)
+  if (r->installed > 0)
     return;
 
   DBG("Installing static route %I/%d, rtd=%d\n", r->net, r->masklen, r->dest);
@@ -125,7 +125,7 @@ static_remove(struct proto *p, struct static_route *r)
   if (!r->installed)
     return;
 
-  DBG("Removing static route %I/%d\n", r->net, r->masklen);
+  DBG("Removing static route %I/%d via %I\n", r->net, r->masklen, r->via);
   n = net_find(p->table, r->net, r->masklen);
   rte_update(p, n, NULL);
   r->installed = 0;
@@ -420,19 +420,24 @@ static_match(struct proto *p, struct static_route *r, struct static_config *n)
 
   if (r->neigh)
     r->neigh->data = NULL;
+
   WALK_LIST(t, n->iface_routes)
     if (static_same_net(r, t))
-      {
-       t->installed = r->installed && static_same_dest(r, t);
-       return;
-      }
+      goto found;
+
   WALK_LIST(t, n->other_routes)
     if (static_same_net(r, t))
-      {
-       t->installed = r->installed && static_same_dest(r, t);
-       return;
-      }
+      goto found;
+
   static_remove(p, r);
+  return;
+
+ found:
+  /* If destination is different, force reinstall */
+  if ((r->installed > 0) && !static_same_dest(r, t))
+    t->installed = -1;
+  else
+    t->installed = r->installed;
 }
 
 static inline rtable *
index eb87ddec7dadfe77d9e38054c1ebc83cb32ac486..99a0e68b252af9d47b794397cbce083af6c1b7c0 100644 (file)
@@ -31,7 +31,7 @@ struct static_route {
   struct neighbor *neigh;
   byte *if_name;                       /* Name for RTD_DEVICE routes */
   struct static_route *mp_next;                /* Nexthops for RTD_MULTIPATH routes */
-  int installed;                       /* Installed in master table */
+  int installed;                       /* Installed in rt table, -1 for reinstall */
 };
 
 /* Dummy nodes (parts of multipath route) abuses masklen field for weight