Blame SOURCES/dnsmasq-2.81-netlink-table.patch

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