]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: zebra-use-fixed-metric-cost.patch
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 20 May 2015 00:40:35 +0000 (17:40 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 20 May 2015 00:40:35 +0000 (17:40 -0700)
Zebra: Use a fixed route metric when populating kernel

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.

zebra/rt_netlink.c
zebra/rt_netlink.h

index 11f6f0ab2f43a7378a7739837b6c98fe2309b969..4ab6b4bc1537fa2ce4d27bea7f168f01354db3c0 100644 (file)
@@ -1706,7 +1706,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 (discard)
     {
index 452b3974ea2b9836f6b1472418732a760f8aa825..2a4ce016152ec783a5ec8391c5371324e7b28e68 100644 (file)
@@ -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, int maxlen, int type, int data);