summaryrefslogtreecommitdiffstats
path: root/src/vnet/dns/dns.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-10-23 10:47:36 -0400
committerDamjan Marion <dmarion@me.com>2018-10-23 21:48:22 +0000
commit8a9566ebe0bb4644c0dbd118dc1292eca0b7d3e4 (patch)
tree2ddb6e1c5349ebf77423bc053e84ccb47b0c36f9 /src/vnet/dns/dns.c
parentbf4d5ce58435d3f424749ff69650ea67ce778f04 (diff)
dns, dhcp: on-demand udp port registration
Change-Id: I8bf411adc6c5f4caa349d161174b544d2de3ad1d Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vnet/dns/dns.c')
-rw-r--r--src/vnet/dns/dns.c29
1 files changed, 18 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;
}