[quagga-dev 8917] Re: [PATCH] Zebra rib/fib to be in sinc with kernel routing table

"Igor Maravić" igorm at etf.rs
Sun Oct 23 13:36:51 BST 2011

> BTW, if you are going to hack route delete code in Q you need at least this patch:
>   http://lists.quagga.net/pipermail/quagga-dev/2009-January/007704.html
> People with route delete problems has found that this patch cure their problems.
>  Jocke
Why this patch wasn't excepted in upstream Quagga? It fixes a nasty Quagga bug.

I did some testing of my own and came up to another solution for problem with kernel routes.
It's quite simple really. It resembles to Stephen Hemminger patch for linux kernel(http://kerneltrap.org/mailarchive/linux-netdev/2008/6/2/2010564)
because if link detection is enabled, when carrier is lost, all routes from the kernel,linked to that interface, are deleted both in kernel and zebra.

1. when link detection is disabled and carrier was lost, only ipv4 routes that are linked to that interface will be deleted. They are deleted in kernel,
and after that Quagga receives RTM_DELROUTE message, and deletes them normally. All ipv6 routes, linked to that interface, are intact.
2. when link detection is enabled and carrier was lost, interface is declared as down. Then all routes that are linked to that interface are deleted
from zebra's fib. To be sure that zebra's fib is in sync with kernel routing table, if route is from kernel(RIB_KERNEL_ROUTE (fib))
and it wasn't previously marked for deletion(del == NULL), we call function rib_uninstall_kernel and after that we mark it to be deleted from rib (del=fib).
If route was previously deleted from kernel, rib_uninstall_kernel won't have any effect. But if the route still exists in kernel, it will be deleted.
3. when interface is manually set to down, all routes linked to that interface are deleted in kernel, and they are deleted from zebra's rib.

works perfectly with Joakim Tjernlund's patch.

Igor Maravić

Signed-off-by: Igor Maravic <igorm at etf.rs>
:100644 100644 12f3fa5... 7ee4801... M	zebra/zebra_rib.c
 zebra/zebra_rib.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 12f3fa5..7ee4801 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -758,6 +758,9 @@ rib_match_ipv6 (struct in6_addr *addr)
 #define RIB_SYSTEM_ROUTE(R) \
         ((R)->type == ZEBRA_ROUTE_KERNEL || (R)->type == ZEBRA_ROUTE_CONNECT)

+#define RIB_KERNEL_ROUTE(R) \
+         ((R)->type == ZEBRA_ROUTE_KERNEL)
 /* This function verifies reachability of one given nexthop, which can be
  * numbered or unnumbered, IPv4 or IPv6. The result is unconditionally stored
  * in nexthop->flags field. If the 4th parameter, 'set', is non-zero,
@@ -1128,6 +1131,10 @@ rib_process (struct route_node *rn)
       redistribute_delete (&rn->p, fib);
       if (! RIB_SYSTEM_ROUTE (fib))
 	rib_uninstall_kernel (rn, fib);
+      else if(RIB_KERNEL_ROUTE (fib) && del == NULL){
+	rib_uninstall_kernel (rn, fib);
+	del=fib;
+      }
       UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED);

       /* Set real nexthop. */

More information about the Quagga-dev mailing list