dhcp: api to enable client detect on interface 18/39718/3
authorOle Troan <otroan@employees.org>
Thu, 19 Oct 2023 07:05:38 +0000 (09:05 +0200)
committerDamjan Marion <dmarion@0xa5.net>
Thu, 16 Nov 2023 15:38:51 +0000 (15:38 +0000)
DHCPv4 aka BOOTP is somewhat awkward. A DHCP client
on an interface must receive DHCP packets to
the broadcast address or to a unicast address.
Apparently before it's been assigned to itself.

Add this new API to allow external DHCP clients
enable the DHCP client detect feature per interface.

Type: improvement
Change-Id: If55aac03f25a045496be483940e4f5e7e18885b9
Signed-off-by: Ole Troan <otroan@employees.org>
src/plugins/dhcp/dhcp.api
src/plugins/dhcp/dhcp_api.c
src/plugins/dhcp/dhcp_test.c

index 4611d5f..7f55912 100644 (file)
@@ -278,6 +278,15 @@ define dhcp_proxy_details
   vl_api_dhcp_server_t servers[count];
 };
 
+autoreply define dhcp_client_detect_enable_disable
+{
+  u32 client_index;
+  u32 context;
+
+  vl_api_interface_index_t sw_if_index;
+  bool enable;
+};
+
 /** \brief Set DHCPv6 DUID-LL
     @param client_index - opaque cookie to identify the sender
     @param context - sender context, to match reply w/ request
index 91ee0aa..19457a7 100644 (file)
@@ -645,6 +645,31 @@ call_dhcp6_reply_event_callbacks (void *data,
   return error;
 }
 
+static void
+vl_api_dhcp_client_detect_enable_disable_t_handler (
+  vl_api_dhcp_client_detect_enable_disable_t *mp)
+{
+  vl_api_dhcp_client_detect_enable_disable_reply_t *rmp;
+  int rv = 0;
+  VALIDATE_SW_IF_INDEX (mp);
+
+  if (mp->enable)
+    {
+      vnet_feature_enable_disable ("ip4-unicast", "ip4-dhcp-client-detect",
+                                  clib_net_to_host_u32 (mp->sw_if_index),
+                                  1 /* enable */, 0, 0);
+    }
+  else
+    {
+      vnet_feature_enable_disable ("ip4-unicast", "ip4-dhcp-client-detect",
+                                  clib_net_to_host_u32 (mp->sw_if_index),
+                                  0 /* disable */, 0, 0);
+    }
+
+  BAD_SW_IF_INDEX_LABEL;
+
+  REPLY_MACRO (VL_API_DHCP_CLIENT_DETECT_ENABLE_DISABLE_REPLY);
+}
 static uword
 dhcp6_reply_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
                     vlib_frame_t * f)
index d8288e6..7820f51 100644 (file)
@@ -421,6 +421,11 @@ api_dhcp_plugin_get_version (vat_main_t * vam)
 {
   return -1;
 }
+static int
+api_dhcp_client_detect_enable_disable (vat_main_t *vam)
+{
+  return -1;
+}
 
 static void
   vl_api_dhcp_plugin_get_version_reply_t_handler