9f623f
From 595b2e2e87f152c4ade7e2d66cb78915096f60c2 Mon Sep 17 00:00:00 2001
9f623f
From: Donald Sharp <donaldsharp72@gmail.com>
9f623f
Date: Mon, 2 Mar 2020 11:23:36 -0500
9f623f
Subject: [PATCH] Ignore routes in non-main tables
9f623f
9f623f
Route lookup in Linux is bounded by `ip rules` as well
9f623f
as the contents of specific routing tables.  With the
9f623f
advent of vrf's(l3mdev's) non-default tables are regularly being
9f623f
used for routing purposes.
9f623f
9f623f
dnsmasq listens to all route changes on the box and responds
9f623f
to each one with an event.  This is *expensive* when a full
9f623f
BGP routing table is placed into the linux kernel, moreso
9f623f
when dnsmasq is responding to events in tables that it will
9f623f
never actually need to respond to, since dnsmasq at this
9f623f
point in time has no concept of vrf's and would need
9f623f
to be programmed to understand them.  Help alleviate this load
9f623f
by reducing the set of data that dnsmasq pays attention to
9f623f
when we know there are events that are not useful at this
9f623f
point in time.
9f623f
9f623f
Signed-off-by: Donald Sharp <donaldsharp72@gmail.com>
9f623f
(cherry picked from commit b2ed691eb3ca6488a8878f5f3dd950a07b14a9db)
9f623f
---
9f623f
 src/netlink.c | 4 +++-
9f623f
 1 file changed, 3 insertions(+), 1 deletion(-)
9f623f
9f623f
diff --git a/src/netlink.c b/src/netlink.c
9f623f
index 8cd51af..0a3da3e 100644
9f623f
--- a/src/netlink.c
9f623f
+++ b/src/netlink.c
9f623f
@@ -363,7 +363,9 @@ static void nl_async(struct nlmsghdr *h)
9f623f
 	 failing. */ 
9f623f
       struct rtmsg *rtm = NLMSG_DATA(h);
9f623f
       
9f623f
-      if (rtm->rtm_type == RTN_UNICAST && rtm->rtm_scope == RT_SCOPE_LINK)
9f623f
+      if (rtm->rtm_type == RTN_UNICAST && rtm->rtm_scope == RT_SCOPE_LINK &&
9f623f
+	  (rtm->rtm_table == RT_TABLE_MAIN ||
9f623f
+	   rtm->rtm_table == RT_TABLE_LOCAL))
9f623f
 	queue_event(EVENT_NEWROUTE);
9f623f
     }
9f623f
   else if (h->nlmsg_type == RTM_NEWADDR || h->nlmsg_type == RTM_DELADDR) 
9f623f
-- 
9f623f
2.26.2
9f623f