From 2466f5068f044ddfcb1f300f1f20122030b52221 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Wed, 29 May 2019 13:46:35 -0400 Subject: Start the dns resolver process on demand Change-Id: Iab27b405fb3ca7aed94ae974d57c286c41298c3a Signed-off-by: Dave Barach --- src/vnet/dns/dns.c | 3 +++ src/vnet/dns/dns.h | 5 +++++ src/vnet/dns/resolver_process.c | 19 +++++++++++-------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/vnet/dns/dns.c b/src/vnet/dns/dns.c index 2951679eaa4..bae6cb4911e 100644 --- a/src/vnet/dns/dns.c +++ b/src/vnet/dns/dns.c @@ -74,6 +74,9 @@ dns_enable_disable (dns_main_t * dm, int is_enable) u32 n_vlib_mains = tm->n_vlib_mains; vlib_main_t *vm = dm->vlib_main; + /* Create the resolver process if not done already */ + vnet_dns_create_resolver_process (dm); + if (is_enable) { if (vec_len (dm->ip4_name_servers) == 0 diff --git a/src/vnet/dns/dns.h b/src/vnet/dns/dns.h index c747e2ecd38..b2e3e9b90cb 100644 --- a/src/vnet/dns/dns.h +++ b/src/vnet/dns/dns.h @@ -108,6 +108,9 @@ typedef struct ip4_address_t *ip4_name_servers; ip6_address_t *ip6_name_servers; + /** resolver process node index */ + u32 resolver_process_node_index; + /** config parameters */ u32 name_cache_size; u32 max_ttl_in_seconds; @@ -183,6 +186,8 @@ void vnet_send_dns6_reply (dns_main_t * dm, dns_pending_request_t * t, u8 *vnet_dns_labels_to_name (u8 * label, u8 * full_text, u8 ** parse_from_here); +void vnet_dns_create_resolver_process (dns_main_t * dm); + format_function_t format_dns_reply; static inline void diff --git a/src/vnet/dns/resolver_process.c b/src/vnet/dns/resolver_process.c index 5f43fada983..cba659266c9 100644 --- a/src/vnet/dns/resolver_process.c +++ b/src/vnet/dns/resolver_process.c @@ -322,15 +322,18 @@ dns_resolver_process (vlib_main_t * vm, return 0; /* or not */ } -/* *INDENT-OFF* */ -VLIB_REGISTER_NODE (dns_resolver_node) = +void +vnet_dns_create_resolver_process (dns_main_t * dm) { - .function = dns_resolver_process, - .type = VLIB_NODE_TYPE_PROCESS, - .name = "dns-resolver-process", -}; -/* *INDENT-ON* */ - + /* Already created the resolver process? */ + if (dm->resolver_process_node_index > 0) + return; + + /* No, create it now and make a note of the node index */ + dm->resolver_process_node_index = vlib_process_create + (dm->vlib_main, "dns-resolver-process", + dns_resolver_process, 16 /* log2_n_stack_bytes */ ); +} /* * fd.io coding-style-patch-verification: ON -- cgit 1.2.3-korg