diff options
Diffstat (limited to 'src/vnet/dns')
-rw-r--r-- | src/vnet/dns/dns.c | 29 | ||||
-rw-r--r-- | src/vnet/dns/dns.h | 3 |
2 files changed, 21 insertions, 11 deletions
diff --git a/src/vnet/dns/dns.c b/src/vnet/dns/dns.c index 54b75aa1708..93b7fb8b9f4 100644 --- a/src/vnet/dns/dns.c +++ b/src/vnet/dns/dns.c @@ -72,6 +72,7 @@ dns_enable_disable (dns_main_t * dm, int is_enable) { vlib_thread_main_t *tm = &vlib_thread_main; u32 n_vlib_mains = tm->n_vlib_mains; + vlib_main_t *vm = dm->vlib_main; if (is_enable) { @@ -79,6 +80,23 @@ dns_enable_disable (dns_main_t * dm, int is_enable) && (vec_len (dm->ip6_name_servers) == 0)) return VNET_API_ERROR_NO_NAME_SERVERS; + if (dm->udp_ports_registered == 0) + { + udp_register_dst_port (vm, UDP_DST_PORT_dns_reply, + dns46_reply_node.index, 1 /* is_ip4 */ ); + + udp_register_dst_port (vm, UDP_DST_PORT_dns_reply6, + dns46_reply_node.index, 0 /* is_ip4 */ ); + + udp_register_dst_port (vm, UDP_DST_PORT_dns, + dns4_request_node.index, 1 /* is_ip4 */ ); + + udp_register_dst_port (vm, UDP_DST_PORT_dns6, + dns6_request_node.index, 0 /* is_ip4 */ ); + + dm->udp_ports_registered = 1; + } + if (dm->cache_entry_by_name == 0) { if (n_vlib_mains > 1) @@ -1597,17 +1615,6 @@ dns_init (vlib_main_t * vm) dm->max_ttl_in_seconds = 86400; dm->random_seed = 0xDEADDABE; - udp_register_dst_port (vm, UDP_DST_PORT_dns_reply, dns46_reply_node.index, - 1 /* is_ip4 */ ); - - udp_register_dst_port (vm, UDP_DST_PORT_dns_reply6, dns46_reply_node.index, - 0 /* is_ip4 */ ); - - udp_register_dst_port (vm, UDP_DST_PORT_dns, dns4_request_node.index, - 1 /* is_ip4 */ ); - - udp_register_dst_port (vm, UDP_DST_PORT_dns6, dns6_request_node.index, - 0 /* is_ip4 */ ); return 0; } diff --git a/src/vnet/dns/dns.h b/src/vnet/dns/dns.h index 59a61ed7687..c747e2ecd38 100644 --- a/src/vnet/dns/dns.h +++ b/src/vnet/dns/dns.h @@ -101,6 +101,9 @@ typedef struct /** enable / disable flag */ int is_enabled; + /** udp port registration complete */ + int udp_ports_registered; + /** upstream name servers, e.g. 8.8.8.8 */ ip4_address_t *ip4_name_servers; ip6_address_t *ip6_name_servers; |