From 1f5705f0423adb21f63392848f488cfbf2e71900 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 May 2015 17:40:35 -0700 Subject: [PATCH] zebra: zebra-use-fixed-metric-cost.patch 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 | 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 11f6f0ab2f..4ab6b4bc15 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -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) { diff --git a/zebra/rt_netlink.h b/zebra/rt_netlink.h index 452b3974ea..2a4ce01615 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, int maxlen, int type, int data); -- 2.39.5