From: Dinesh Dutt <[email protected]>

The route metric is not used by the Linux kernel and is irrelevant to
the forwarding decision made by the kernel. Metric is a parameter used
only by a routing protocol to compute best path(s) and to communicate this
info to its peers. Consequently, there is no value in pushing the metric
provided by a protocol daemon to the kernel.

There is a significant advantage, at least on the Linux kernel, in pushing
a constant metric with a route populated by zebra. The metric is used as a
priority field in the kernel and modifying the metric due to say topology
changes causes multiple routes to be inserted into the kernel, with differing
priorities instead of replacing the existing one. This prevents us from
using replace semantic when a route changes.

So, this patch pushes a constant metric with a route populated by zebra.

Signed-off-by: Dinesh Dutt <[email protected]>
---
 zebra/rt_netlink.c | 6 +++++-
 zebra/rt_netlink.h | 3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index ffddeaa..2253cc1 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -1664,7 +1664,11 @@ netlink_route_multipath (int cmd, struct prefix *p, 
struct rib *rib,
   addattr_l (&req.n, sizeof req, RTA_DST, &p->u.prefix, bytelen);
 
   /* Metric. */
-  addattr32 (&req.n, sizeof req, RTA_PRIORITY, rib->metric);
+  /* Hardcode the metric for all routes coming from zebra. Metric isn't used
+   * either by the kernel or by zebra. Its purely for calculating best path(s)
+   * by the routing protocol and for communicating with protocol peers.
+   */
+  addattr32 (&req.n, sizeof req, RTA_PRIORITY, NL_DEFAULT_ROUTE_METRIC);
 
   if (rib->mtu || rib->nexthop_mtu)
     {
diff --git a/zebra/rt_netlink.h b/zebra/rt_netlink.h
index 40fa8eb..9e24060 100644
--- a/zebra/rt_netlink.h
+++ b/zebra/rt_netlink.h
@@ -24,7 +24,8 @@
 
 #ifdef HAVE_NETLINK
 
-#define NL_PKT_BUF_SIZE 8192
+#define NL_PKT_BUF_SIZE         8192
+#define NL_DEFAULT_ROUTE_METRIC 20
 
 extern int
 addattr32 (struct nlmsghdr *n, size_t maxlen, int type, int data);
-- 
1.9.1


_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to