summaryrefslogtreecommitdiffstats
path: root/src/vnet/dhcp/dhcp4_proxy_node.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/dhcp/dhcp4_proxy_node.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/dhcp/dhcp4_proxy_node.c')
-rw-r--r--src/vnet/dhcp/dhcp4_proxy_node.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/vnet/dhcp/dhcp4_proxy_node.c b/src/vnet/dhcp/dhcp4_proxy_node.c
index 97ed3b5920a..99e5a739f74 100644
--- a/src/vnet/dhcp/dhcp4_proxy_node.c
+++ b/src/vnet/dhcp/dhcp4_proxy_node.c
@@ -736,14 +736,14 @@ VLIB_REGISTER_NODE (dhcp_proxy_to_client_node, static) = {
};
/* *INDENT-ON* */
-static clib_error_t *
-dhcp4_proxy_init (vlib_main_t * vm)
+void
+dhcp_maybe_register_udp_ports (void)
{
dhcp_proxy_main_t *dm = &dhcp_proxy_main;
- vlib_node_t *error_drop_node;
+ vlib_main_t *vm = dm->vlib_main;
- error_drop_node = vlib_get_node_by_name (vm, (u8 *) "error-drop");
- dm->error_drop_node_index = error_drop_node->index;
+ if (dm->udp_ports_registered)
+ return;
udp_register_dst_port (vm, UDP_DST_PORT_dhcp_to_client,
dhcp_proxy_to_client_node.index, 1 /* is_ip4 */ );
@@ -751,6 +751,19 @@ dhcp4_proxy_init (vlib_main_t * vm)
udp_register_dst_port (vm, UDP_DST_PORT_dhcp_to_server,
dhcp_proxy_to_server_node.index, 1 /* is_ip4 */ );
+ dm->udp_ports_registered = 1;
+}
+
+static clib_error_t *
+dhcp4_proxy_init (vlib_main_t * vm)
+{
+ dhcp_proxy_main_t *dm = &dhcp_proxy_main;
+ vlib_node_t *error_drop_node;
+
+ error_drop_node = vlib_get_node_by_name (vm, (u8 *) "error-drop");
+ dm->error_drop_node_index = error_drop_node->index;
+ dm->vlib_main = vm;
+
return 0;
}
@@ -777,6 +790,8 @@ dhcp4_proxy_set_server (ip46_address_t * addr,
if (ip46_address_is_zero (src_addr))
return VNET_API_ERROR_INVALID_SRC_ADDRESS;
+ dhcp_maybe_register_udp_ports ();
+
rx_fib_index = fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP4,
rx_table_id,
FIB_SOURCE_DHCP);