diff --git a/src/vnet.am b/src/vnet.am
index 84930f0..d89d516 100644
--- a/src/vnet.am
+++ b/src/vnet.am
@@ -369,6 +369,7 @@
  vnet/bfd/bfd_udp.c				\
  vnet/bfd/bfd_main.c				\
  vnet/bfd/bfd_protocol.c			\
+ vnet/bfd/bfd_cli.c                             \
  vnet/bfd/bfd_api.c
 
 API_FILES += vnet/bfd/bfd.api
diff --git a/src/vnet/api_errno.h b/src/vnet/api_errno.h
index 861a576..a5bcb37 100644
--- a/src/vnet/api_errno.h
+++ b/src/vnet/api_errno.h
@@ -51,7 +51,6 @@
 _(ADDRESS_NOT_FOUND_FOR_INTERFACE, -60, "Address not found for interface") \
 _(ADDRESS_NOT_LINK_LOCAL, -61, "Address not link-local")                \
 _(IP6_NOT_ENABLED, -62, "ip6 not enabled")				\
-_(ADDRESS_MATCHES_INTERFACE_ADDRESS, -63, "Address matches interface address") \
 _(IN_PROGRESS, 10, "Operation in progress")				\
 _(NO_SUCH_NODE, -63, "No such graph node")				\
 _(NO_SUCH_NODE2, -64, "No such graph node #2")				\
diff --git a/src/vnet/bfd/bfd.api b/src/vnet/bfd/bfd.api
index 93bf0fb..2cdcfad 100644
--- a/src/vnet/bfd/bfd.api
+++ b/src/vnet/bfd/bfd.api
@@ -45,7 +45,7 @@
   u32 context;
 };
 
-/** \brief Delete BFD feature response
+/** \brief Delete BFD echo source response
     @param context - sender context, to match reply w/ request
     @param retval - return code for the request
 */
@@ -55,32 +55,6 @@
   i32 retval;
 };
 
-/** \brief Get BFD configuration
-*/
-define bfd_get_config
-{
-  u32 client_index;
-  u32 context;
-};
-
-/** \brief Get BFD configuration response
-    @param context - sender context, to match reply w/ request
-    @param retval - return code for the request
-    @param slow_timer - slow timer (seconds)
-    @param min_tx - desired min tx interval
-    @param min_rx - desired min rx interval
-    @param detect_mult - desired detection multiplier
-*/
-define bfd_get_config_reply
-{
-  u32 client_index;
-  u32 context;
-  u32 slow_timer;
-  u32 min_tx;
-  u32 min_rx;
-  u8 detect_mult;
-};
-
 /** \brief Add UDP BFD session on interface
     @param client_index - opaque cookie to identify the sender
     @param context - sender context, to match reply w/ request
diff --git a/src/vnet/bfd/bfd_api.c b/src/vnet/bfd/bfd_api.c
index 6632eae..e64df48 100644
--- a/src/vnet/bfd/bfd_api.c
+++ b/src/vnet/bfd/bfd_api.c
@@ -154,6 +154,21 @@
   bfd_udp_key_t *key = &bus->key;
   mp->sw_if_index = clib_host_to_net_u32 (key->sw_if_index);
   mp->is_ipv6 = !(ip46_address_is_ip4 (&key->local_addr));
+  if ((!bs->auth.is_delayed && bs->auth.curr_key) ||
+      (bs->auth.is_delayed && bs->auth.next_key))
+    {
+      mp->is_authenticated = 1;
+    }
+  if (bs->auth.is_delayed && bs->auth.next_key)
+    {
+      mp->bfd_key_id = bs->auth.next_bfd_key_id;
+      mp->conf_key_id = clib_host_to_net_u32 (bs->auth.next_key->conf_key_id);
+    }
+  else if (!bs->auth.is_delayed && bs->auth.curr_key)
+    {
+      mp->bfd_key_id = bs->auth.curr_bfd_key_id;
+      mp->conf_key_id = clib_host_to_net_u32 (bs->auth.curr_key->conf_key_id);
+    }
   if (mp->is_ipv6)
     {
       clib_memcpy (mp->local_addr, &key->local_addr,
@@ -289,10 +304,9 @@
 
   BFD_UDP_API_PARAM_COMMON_CODE;
 
-  rv =
-    bfd_udp_auth_activate (BFD_UDP_API_PARAM_FROM_MP (mp),
-			   clib_net_to_host_u32 (mp->conf_key_id),
-			   mp->bfd_key_id, mp->is_delayed);
+  rv = bfd_udp_auth_activate (BFD_UDP_API_PARAM_FROM_MP (mp),
+			      clib_net_to_host_u32 (mp->conf_key_id),
+			      mp->bfd_key_id, mp->is_delayed);
 
   BAD_SW_IF_INDEX_LABEL;
   REPLY_MACRO (VL_API_BFD_UDP_AUTH_ACTIVATE_REPLY);
diff --git a/src/vnet/bfd/bfd_api.h b/src/vnet/bfd/bfd_api.h
index 63d4a62..35ad3cd 100644
--- a/src/vnet/bfd/bfd_api.h
+++ b/src/vnet/bfd/bfd_api.h
@@ -22,7 +22,6 @@
 #include <vnet/api_errno.h>
 #include <vnet/vnet.h>
 #include <vnet/ip/ip6_packet.h>
-#include <vnet/bfd/bfd_udp.h>
 
 #define foreach_bfd_transport(F) \
   F (UDP4, "ip4-rewrite")        \
diff --git a/src/vnet/bfd/bfd_cli.c b/src/vnet/bfd/bfd_cli.c
new file mode 100644
index 0000000..a3736d9
--- /dev/null
+++ b/src/vnet/bfd/bfd_cli.c
@@ -0,0 +1,900 @@
+/*
+ * Copyright (c) 2011-2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file
+ * @brief BFD CLI implementation
+ */
+
+#include <vlib/vlib.h>
+#include <vlib/cli.h>
+#include <vppinfra/format.h>
+#include <vnet/api_errno.h>
+#include <vnet/ip/format.h>
+#include <vnet/bfd/bfd_api.h>
+#include <vnet/bfd/bfd_main.h>
+
+static u8 *
+format_bfd_session_cli (u8 * s, va_list * args)
+{
+  bfd_main_t *bm = va_arg (*args, bfd_main_t *);
+  bfd_session_t *bs = va_arg (*args, bfd_session_t *);
+  switch (bs->transport)
+    {
+    case BFD_TRANSPORT_UDP4:
+      s = format (s, "%=10u %-32s %20U %20U\n", bs->bs_idx, "IPv4 address",
+		  format_ip4_address, bs->udp.key.local_addr.ip4.as_u8,
+		  format_ip4_address, bs->udp.key.peer_addr.ip4.as_u8);
+      break;
+    case BFD_TRANSPORT_UDP6:
+      s = format (s, "%=10u %-32s %20U %20U\n", bs->bs_idx, "IPv6 address",
+		  format_ip6_address, &bs->udp.key.local_addr.ip6,
+		  format_ip6_address, &bs->udp.key.peer_addr.ip6);
+      break;
+    }
+  s = format (s, "%10s %-32s %20s %20s\n", "", "Session state",
+	      bfd_state_string (bs->local_state),
+	      bfd_state_string (bs->remote_state));
+  s = format (s, "%10s %-32s %20s %20s\n", "", "Diagnostic code",
+	      bfd_diag_code_string (bs->local_diag),
+	      bfd_diag_code_string (bs->remote_diag));
+  s = format (s, "%10s %-32s %20u %20u\n", "", "Detect multiplier",
+	      bs->local_detect_mult, bs->remote_detect_mult);
+  s = format (s, "%10s %-32s %20u %20u\n", "",
+	      "Required Min Rx Interval (usec)",
+	      bs->config_required_min_rx_usec, bs->remote_min_rx_usec);
+  s = format (s, "%10s %-32s %20u %20u\n", "",
+	      "Desired Min Tx Interval (usec)",
+	      bs->config_desired_min_tx_usec, bfd_clocks_to_usec (bm,
+								  bs->remote_desired_min_tx_clocks));
+  s =
+    format (s, "%10s %-32s %20u\n", "", "Transmit interval",
+	    bfd_clocks_to_usec (bm, bs->transmit_interval_clocks));
+  s =
+    format (s, "%10s %-32s %20s %20s\n", "", "Demand mode", "no",
+	    bs->remote_demand ? "yes" : "no");
+  s =
+    format (s, "%10s %-32s %20s\n", "", "Poll state",
+	    bfd_poll_state_string (bs->poll_state));
+  if (bs->auth.curr_key)
+    {
+      s = format (s, "%10s %-32s %20u\n", "", "Authentication config key ID",
+		  bs->auth.curr_key->conf_key_id);
+      s = format (s, "%10s %-32s %20u\n", "", "Authentication BFD key ID",
+		  bs->auth.curr_bfd_key_id);
+    }
+  return s;
+}
+
+static clib_error_t *
+show_bfd (vlib_main_t * vm, unformat_input_t * input,
+	  CLIB_UNUSED (vlib_cli_command_t * lmd))
+{
+  bfd_main_t *bm = &bfd_main;
+  bfd_session_t *bs = NULL;
+
+  if (unformat (input, "keys"))
+    {
+      bfd_auth_key_t *key = NULL;
+      u8 *s = format (NULL, "%=10s %=25s %=10s\n", "Configuration Key ID",
+		      "Type", "Use Count");
+      /* *INDENT-OFF* */
+      pool_foreach (key, bm->auth_keys, {
+        s = format (s, "%10u %-25s %10u\n", key->conf_key_id,
+                    bfd_auth_type_str (key->auth_type), key->use_count);
+      });
+      /* *INDENT-ON* */
+      vlib_cli_output (vm, "%v\n", s);
+      vlib_cli_output (vm, "Number of configured BFD keys: %lu\n",
+		       (u64) pool_elts (bm->auth_keys));
+    }
+  else if (unformat (input, "sessions"))
+    {
+      u8 *s = format (NULL, "%=10s %=32s %=20s %=20s\n", "Index", "Property",
+		      "Local value", "Remote value");
+      /* *INDENT-OFF* */
+      pool_foreach (bs, bm->sessions,
+                    { s = format (s, "%U", format_bfd_session_cli, bm, bs); });
+      /* *INDENT-ON* */
+      vlib_cli_output (vm, "%v", s);
+      vec_free (s);
+      vlib_cli_output (vm, "Number of configured BFD sessions: %lu\n",
+		       (u64) pool_elts (bm->sessions));
+    }
+  else if (unformat (input, "echo-source"))
+    {
+      int is_set;
+      u32 sw_if_index;
+      int have_usable_ip4;
+      ip4_address_t ip4;
+      int have_usable_ip6;
+      ip6_address_t ip6;
+      bfd_udp_get_echo_source (&is_set, &sw_if_index, &have_usable_ip4, &ip4,
+			       &have_usable_ip6, &ip6);
+      if (is_set)
+	{
+	  vnet_sw_interface_t *sw_if =
+	    vnet_get_sw_interface_safe (&vnet_main, sw_if_index);
+	  vnet_hw_interface_t *hw_if =
+	    vnet_get_hw_interface (&vnet_main, sw_if->hw_if_index);
+	  u8 *s = format (NULL, "UDP echo source is: %v\n", hw_if->name);
+	  s = format (s, "IPv4 address usable as echo source: ");
+	  if (have_usable_ip4)
+	    {
+	      s = format (s, "%U\n", format_ip4_address, &ip4);
+	    }
+	  else
+	    {
+	      s = format (s, "none\n");
+	    }
+	  s = format (s, "IPv6 address usable as echo source: ");
+	  if (have_usable_ip6)
+	    {
+	      s = format (s, "%U\n", format_ip6_address, &ip6);
+	    }
+	  else
+	    {
+	      s = format (s, "none\n");
+	    }
+	  vlib_cli_output (vm, "%v", s);
+	  vec_free (s);
+	}
+      else
+	{
+	  vlib_cli_output (vm, "UDP echo source is not set.\n");
+	}
+    }
+  else
+    {
+      vlib_cli_output (vm, "Number of configured BFD sessions: %lu\n",
+		       (u64) pool_elts (bm->sessions));
+      vlib_cli_output (vm, "Number of configured BFD keys: %lu\n",
+		       (u64) pool_elts (bm->auth_keys));
+    }
+  return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (show_bfd_command, static) = {
+  .path = "show bfd",
+  .short_help = "show bfd [keys|sessions|echo-source]",
+  .function = show_bfd,
+};
+/* *INDENT-ON* */
+
+static u8 *
+format_vnet_api_errno (u8 * s, va_list * args)
+{
+  vnet_api_error_t api_error = va_arg (*args, vnet_api_error_t);
+#define _(a, b, c)           \
+  case b:                    \
+    s = format (s, "%s", c); \
+    break;
+  switch (api_error)
+    {
+      foreach_vnet_api_error default:s = format (s, "UNKNOWN");
+      break;
+    }
+  return s;
+}
+
+static clib_error_t *
+bfd_cli_key_add (vlib_main_t * vm, unformat_input_t * input,
+		 CLIB_UNUSED (vlib_cli_command_t * lmd))
+{
+  clib_error_t *ret = NULL;
+  int have_key_id = 0;
+  u32 key_id = 0;
+  u8 *vec_auth_type = NULL;
+  bfd_auth_type_e auth_type = BFD_AUTH_TYPE_reserved;
+  u8 *secret = NULL;
+  static const u8 keyed_sha1[] = "keyed-sha1";
+  static const u8 meticulous_keyed_sha1[] = "meticulous-keyed-sha1";
+
+  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+    {
+      if (unformat (input, "conf-key-id %u", &key_id))
+	{
+	  have_key_id = 1;
+	}
+      else if (unformat (input, "type %U", unformat_token, "a-zA-Z0-9-",
+			 &vec_auth_type))
+	{
+	  if (vec_len (vec_auth_type) == sizeof (keyed_sha1) - 1 &&
+	      0 == memcmp (vec_auth_type, keyed_sha1,
+			   sizeof (keyed_sha1) - 1))
+	    {
+	      auth_type = BFD_AUTH_TYPE_keyed_sha1;
+	    }
+	  else if (vec_len (vec_auth_type) ==
+		   sizeof (meticulous_keyed_sha1) - 1 &&
+		   0 == memcmp (vec_auth_type, meticulous_keyed_sha1,
+				sizeof (meticulous_keyed_sha1) - 1))
+	    {
+	      auth_type = BFD_AUTH_TYPE_meticulous_keyed_sha1;
+	    }
+	  else
+	    {
+	      ret = clib_error_return (0, "invalid type `%v'", vec_auth_type);
+	      goto out;
+	    }
+	}
+      else if (unformat (input, "secret %U", unformat_hex_string, &secret))
+	{
+	  /* nothing to do here */
+	}
+      else
+	{
+	  ret = clib_error_return (0, "Unknown input `%U'",
+				   format_unformat_error, input);
+	  goto out;
+	}
+    }
+
+  if (!have_key_id)
+    {
+      ret =
+	clib_error_return (0, "required parameter missing: `conf-key-id'");
+      goto out;
+    }
+  if (!vec_auth_type)
+    {
+      ret = clib_error_return (0, "required parameter missing: `type'");
+      goto out;
+    }
+  if (!secret)
+    {
+      ret = clib_error_return (0, "required parameter missing: `secret'");
+      goto out;
+    }
+
+  vnet_api_error_t rv =
+    bfd_auth_set_key (key_id, auth_type, vec_len (secret), secret);
+  if (rv)
+    {
+      ret =
+	clib_error_return (0, "`bfd_auth_set_key' API call failed, rv=%d:%U",
+			   (int) rv, format_vnet_api_errno, rv);
+    }
+
+out:
+  vec_free (vec_auth_type);
+  return ret;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (bfd_cli_key_add_command, static) = {
+  .path = "bfd key set",
+  .short_help = "bfd key set"
+                " conf-key-id <id>"
+                " type <keyed-sha1|meticulous-keyed-sha1> "
+                " secret <secret>",
+  .function = bfd_cli_key_add,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+bfd_cli_key_del (vlib_main_t * vm, unformat_input_t * input,
+		 CLIB_UNUSED (vlib_cli_command_t * lmd))
+{
+  clib_error_t *ret = NULL;
+  u32 key_id = 0;
+
+  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+    {
+      if (!unformat (input, "conf-key-id %u", &key_id))
+	{
+	  ret = clib_error_return (0, "Unknown input `%U'",
+				   format_unformat_error, input);
+	  goto out;
+	}
+    }
+
+  vnet_api_error_t rv = bfd_auth_del_key (key_id);
+  if (rv)
+    {
+      ret =
+	clib_error_return (0, "`bfd_auth_del_key' API call failed, rv=%d:%U",
+			   (int) rv, format_vnet_api_errno, rv);
+    }
+
+out:
+  return ret;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (bfd_cli_key_del_command, static) = {
+  .path = "bfd key del",
+  .short_help = "bfd key del conf-key-id <id>",
+  .function = bfd_cli_key_del,
+};
+/* *INDENT-ON* */
+
+#define INTERFACE_STR "interface"
+#define LOCAL_ADDR_STR "local-addr"
+#define PEER_ADDR_STR "peer-addr"
+#define CONF_KEY_ID_STR "conf-key-id"
+#define BFD_KEY_ID_STR "bfd-key-id"
+#define DESIRED_MIN_TX_STR "desired-min-tx"
+#define REQUIRED_MIN_RX_STR "required-min-rx"
+#define DETECT_MULT_STR "detect-mult"
+#define ADMIN_STR "admin"
+#define DELAYED_STR "delayed"
+
+static const unsigned mandatory = 1;
+static const unsigned optional = 0;
+
+#define DECLARE(t, n, s, r, ...) \
+  int have_##n = 0;              \
+  t n;
+
+#define UNFORMAT(t, n, s, r, ...)              \
+  if (unformat (input, s " " __VA_ARGS__, &n)) \
+    {                                          \
+      something_parsed = 1;                    \
+      have_##n = 1;                            \
+    }
+
+#define CHECK_MANDATORY(t, n, s, r, ...)                                  \
+  if (mandatory == r && !have_##n)                                        \
+    {                                                                     \
+      ret = clib_error_return (0, "Required parameter `%s' missing.", n); \
+      goto out;                                                           \
+    }
+
+static clib_error_t *
+bfd_cli_udp_session_add (vlib_main_t * vm, unformat_input_t * input,
+			 CLIB_UNUSED (vlib_cli_command_t * lmd))
+{
+  clib_error_t *ret = NULL;
+#define foreach_bfd_cli_udp_session_add_cli_param(F)              \
+  F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U",            \
+     unformat_vnet_sw_interface, &vnet_main)                      \
+  F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
+     unformat_ip46_address)                                       \
+  F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U",   \
+     unformat_ip46_address)                                       \
+  F (u32, desired_min_tx, DESIRED_MIN_TX_STR, mandatory, "%u")    \
+  F (u32, required_min_rx, REQUIRED_MIN_RX_STR, mandatory, "%u")  \
+  F (u32, detect_mult, DETECT_MULT_STR, mandatory, "%u")          \
+  F (u32, conf_key_id, CONF_KEY_ID_STR, optional, "%u")           \
+  F (u32, bfd_key_id, BFD_KEY_ID_STR, optional, "%u")
+
+  foreach_bfd_cli_udp_session_add_cli_param (DECLARE);
+
+  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+    {
+      int something_parsed = 0;
+      foreach_bfd_cli_udp_session_add_cli_param (UNFORMAT);
+
+      if (!something_parsed)
+	{
+	  ret = clib_error_return (0, "Unknown input `%U'",
+				   format_unformat_error, input);
+	  goto out;
+	}
+    }
+
+  foreach_bfd_cli_udp_session_add_cli_param (CHECK_MANDATORY);
+
+  if (1 == have_conf_key_id + have_bfd_key_id)
+    {
+      ret = clib_error_return (0, "Incompatible parameter combination, `%s' "
+			       "and `%s' must be either both specified or none",
+			       CONF_KEY_ID_STR, BFD_KEY_ID_STR);
+      goto out;
+    }
+
+  if (detect_mult > 255)
+    {
+      ret = clib_error_return (0, "%s value `%u' out of range <1,255>",
+			       DETECT_MULT_STR, detect_mult);
+      goto out;
+    }
+
+  if (have_bfd_key_id && bfd_key_id > 255)
+    {
+      ret = clib_error_return (0, "%s value `%u' out of range <1,255>",
+			       BFD_KEY_ID_STR, bfd_key_id);
+      goto out;
+    }
+
+  vnet_api_error_t rv =
+    bfd_udp_add_session (sw_if_index, &local_addr, &peer_addr, desired_min_tx,
+			 required_min_rx,
+			 detect_mult, have_conf_key_id, conf_key_id,
+			 bfd_key_id);
+  if (rv)
+    {
+      ret =
+	clib_error_return (0,
+			   "`bfd_add_add_session' API call failed, rv=%d:%U",
+			   (int) rv, format_vnet_api_errno, rv);
+      goto out;
+    }
+
+out:
+  return ret;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (bfd_cli_udp_session_add_command, static) = {
+  .path = "bfd udp session add",
+  .short_help = "bfd udp session add"
+                " interface <interface>"
+                " local-addr <local-address>"
+                " peer-addr <peer-address>"
+                " desired-min-tx <desired min tx interval>"
+                " required-min-rx <required min rx interval>"
+                " detect-mult <detect multiplier> "
+                "["
+                " conf-key-id <config key ID>"
+                " bfd-key-id <BFD key ID>"
+                "]",
+  .function = bfd_cli_udp_session_add,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+bfd_cli_udp_session_mod (vlib_main_t * vm, unformat_input_t * input,
+			 CLIB_UNUSED (vlib_cli_command_t * lmd))
+{
+  clib_error_t *ret = NULL;
+#define foreach_bfd_cli_udp_session_mod_cli_param(F)              \
+  F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U",            \
+     unformat_vnet_sw_interface, &vnet_main)                      \
+  F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
+     unformat_ip46_address)                                       \
+  F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U",   \
+     unformat_ip46_address)                                       \
+  F (u32, desired_min_tx, DESIRED_MIN_TX_STR, mandatory, "%u")    \
+  F (u32, required_min_rx, REQUIRED_MIN_RX_STR, mandatory, "%u")  \
+  F (u32, detect_mult, DETECT_MULT_STR, mandatory, "%u")
+
+  foreach_bfd_cli_udp_session_mod_cli_param (DECLARE);
+
+  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+    {
+      int something_parsed = 0;
+      foreach_bfd_cli_udp_session_mod_cli_param (UNFORMAT);
+
+      if (!something_parsed)
+	{
+	  ret = clib_error_return (0, "Unknown input `%U'",
+				   format_unformat_error, input);
+	  goto out;
+	}
+    }
+
+  foreach_bfd_cli_udp_session_mod_cli_param (CHECK_MANDATORY);
+
+  if (detect_mult > 255)
+    {
+      ret = clib_error_return (0, "%s value `%u' out of range <1,255>",
+			       DETECT_MULT_STR, detect_mult);
+      goto out;
+    }
+
+  vnet_api_error_t rv =
+    bfd_udp_mod_session (sw_if_index, &local_addr, &peer_addr,
+			 desired_min_tx, required_min_rx, detect_mult);
+  if (rv)
+    {
+      ret =
+	clib_error_return (0,
+			   "`bfd_udp_mod_session' API call failed, rv=%d:%U",
+			   (int) rv, format_vnet_api_errno, rv);
+      goto out;
+    }
+
+out:
+  return ret;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (bfd_cli_udp_session_mod_command, static) = {
+  .path = "bfd udp session mod",
+  .short_help = "bfd udp session mod interface"
+                " <interface> local-addr"
+                " <local-address> peer-addr"
+                " <peer-address> desired-min-tx"
+                " <desired min tx interval> required-min-rx"
+                " <required min rx interval> detect-mult"
+                " <detect multiplier> ",
+  .function = bfd_cli_udp_session_mod,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+bfd_cli_udp_session_del (vlib_main_t * vm, unformat_input_t * input,
+			 CLIB_UNUSED (vlib_cli_command_t * lmd))
+{
+  clib_error_t *ret = NULL;
+#define foreach_bfd_cli_udp_session_del_cli_param(F)              \
+  F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U",            \
+     unformat_vnet_sw_interface, &vnet_main)                      \
+  F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
+     unformat_ip46_address)                                       \
+  F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U",   \
+     unformat_ip46_address)
+
+  foreach_bfd_cli_udp_session_del_cli_param (DECLARE);
+
+  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+    {
+      int something_parsed = 0;
+      foreach_bfd_cli_udp_session_del_cli_param (UNFORMAT);
+
+      if (!something_parsed)
+	{
+	  ret = clib_error_return (0, "Unknown input `%U'",
+				   format_unformat_error, input);
+	  goto out;
+	}
+    }
+
+  foreach_bfd_cli_udp_session_del_cli_param (CHECK_MANDATORY);
+
+  vnet_api_error_t rv =
+    bfd_udp_del_session (sw_if_index, &local_addr, &peer_addr);
+  if (rv)
+    {
+      ret =
+	clib_error_return (0,
+			   "`bfd_udp_del_session' API call failed, rv=%d:%U",
+			   (int) rv, format_vnet_api_errno, rv);
+      goto out;
+    }
+
+out:
+  return ret;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (bfd_cli_udp_session_del_command, static) = {
+  .path = "bfd udp session del",
+  .short_help = "bfd udp session del interface"
+                " <interface> local-addr"
+                " <local-address> peer-addr"
+                "<peer-address> ",
+  .function = bfd_cli_udp_session_del,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+bfd_cli_udp_session_set_flags (vlib_main_t * vm, unformat_input_t * input,
+			       CLIB_UNUSED (vlib_cli_command_t * lmd))
+{
+  clib_error_t *ret = NULL;
+#define foreach_bfd_cli_udp_session_set_flags_cli_param(F)        \
+  F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U",            \
+     unformat_vnet_sw_interface, &vnet_main)                      \
+  F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
+     unformat_ip46_address)                                       \
+  F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U",   \
+     unformat_ip46_address)                                       \
+  F (u8 *, admin_up_down_token, ADMIN_STR, mandatory, "%v",       \
+     &admin_up_down_token)
+
+  foreach_bfd_cli_udp_session_set_flags_cli_param (DECLARE);
+
+  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+    {
+      int something_parsed = 0;
+      foreach_bfd_cli_udp_session_set_flags_cli_param (UNFORMAT);
+
+      if (!something_parsed)
+	{
+	  ret = clib_error_return (0, "Unknown input `%U'",
+				   format_unformat_error, input);
+	  goto out;
+	}
+    }
+
+  foreach_bfd_cli_udp_session_set_flags_cli_param (CHECK_MANDATORY);
+
+  u8 admin_up_down;
+  static const char up[] = "up";
+  static const char down[] = "down";
+  if (!memcmp (admin_up_down_token, up, sizeof (up) - 1))
+    {
+      admin_up_down = 1;
+    }
+  else if (!memcmp (admin_up_down_token, down, sizeof (down) - 1))
+    {
+      admin_up_down = 0;
+    }
+  else
+    {
+      ret =
+	clib_error_return (0, "Unrecognized value for `%s' parameter: `%v'",
+			   ADMIN_STR, admin_up_down_token);
+      goto out;
+    }
+  vnet_api_error_t rv = bfd_udp_session_set_flags (sw_if_index, &local_addr,
+						   &peer_addr, admin_up_down);
+  if (rv)
+    {
+      ret =
+	clib_error_return (0,
+			   "`bfd_udp_session_set_flags' API call failed, rv=%d:%U",
+			   (int) rv, format_vnet_api_errno, rv);
+      goto out;
+    }
+
+out:
+  return ret;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (bfd_cli_udp_session_set_flags_command, static) = {
+  .path = "bfd udp session set-flags",
+  .short_help = "bfd udp session set-flags"
+                " interface <interface>"
+                " local-addr <local-address>"
+                " peer-addr <peer-address>"
+                " admin <up|down>",
+  .function = bfd_cli_udp_session_set_flags,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+bfd_cli_udp_session_auth_activate (vlib_main_t * vm, unformat_input_t * input,
+				   CLIB_UNUSED (vlib_cli_command_t * lmd))
+{
+  clib_error_t *ret = NULL;
+#define foreach_bfd_cli_udp_session_auth_activate_cli_param(F)    \
+  F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U",            \
+     unformat_vnet_sw_interface, &vnet_main)                      \
+  F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
+     unformat_ip46_address)                                       \
+  F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U",   \
+     unformat_ip46_address)                                       \
+  F (u8 *, delayed_token, DELAYED_STR, optional, "%v")            \
+  F (u32, conf_key_id, CONF_KEY_ID_STR, mandatory, "%u")          \
+  F (u32, bfd_key_id, BFD_KEY_ID_STR, mandatory, "%u")
+
+  foreach_bfd_cli_udp_session_auth_activate_cli_param (DECLARE);
+
+  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+    {
+      int something_parsed = 0;
+      foreach_bfd_cli_udp_session_auth_activate_cli_param (UNFORMAT);
+
+      if (!something_parsed)
+	{
+	  ret = clib_error_return (0, "Unknown input `%U'",
+				   format_unformat_error, input);
+	  goto out;
+	}
+    }
+
+  foreach_bfd_cli_udp_session_auth_activate_cli_param (CHECK_MANDATORY);
+
+  u8 is_delayed = 0;
+  if (have_delayed_token)
+    {
+      static const char yes[] = "yes";
+      static const char no[] = "no";
+      if (!memcmp (delayed_token, yes, sizeof (yes) - 1))
+	{
+	  is_delayed = 1;
+	}
+      else if (!memcmp (delayed_token, no, sizeof (no) - 1))
+	{
+	  is_delayed = 0;
+	}
+      else
+	{
+	  ret =
+	    clib_error_return (0,
+			       "Unrecognized value for `%s' parameter: `%v'",
+			       DELAYED_STR, delayed_token);
+	  goto out;
+	}
+    }
+
+  if (have_bfd_key_id && bfd_key_id > 255)
+    {
+      ret = clib_error_return (0, "%s value `%u' out of range <1,255>",
+			       BFD_KEY_ID_STR, bfd_key_id);
+      goto out;
+    }
+
+  vnet_api_error_t rv =
+    bfd_udp_auth_activate (sw_if_index, &local_addr, &peer_addr, conf_key_id,
+			   bfd_key_id, is_delayed);
+  if (rv)
+    {
+      ret =
+	clib_error_return (0,
+			   "`bfd_udp_auth_activate' API call failed, rv=%d:%U",
+			   (int) rv, format_vnet_api_errno, rv);
+      goto out;
+    }
+
+out:
+  return ret;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (bfd_cli_udp_session_auth_activate_command, static) = {
+  .path = "bfd udp session auth activate",
+  .short_help = "bfd udp session auth activate"
+                " interface <interface>"
+                " local-addr <local-address>"
+                " peer-addr <peer-address>"
+                " conf-key-id <config key ID>"
+                " bfd-key-id <BFD key ID>"
+                " [ delayed <yes|no>]",
+  .function = bfd_cli_udp_session_auth_activate,
+};
+
+static clib_error_t *
+bfd_cli_udp_session_auth_deactivate (vlib_main_t *vm, unformat_input_t *input,
+                                     CLIB_UNUSED (vlib_cli_command_t *lmd))
+{
+  clib_error_t *ret = NULL;
+#define foreach_bfd_cli_udp_session_auth_deactivate_cli_param(F)  \
+  F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U",            \
+     unformat_vnet_sw_interface, &vnet_main)                      \
+  F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
+     unformat_ip46_address)                                       \
+  F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U",   \
+     unformat_ip46_address)                                       \
+  F (u8 *, delayed_token, DELAYED_STR, optional, "%v")
+
+  foreach_bfd_cli_udp_session_auth_deactivate_cli_param (DECLARE);
+
+  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+    {
+      int something_parsed = 0;
+      foreach_bfd_cli_udp_session_auth_deactivate_cli_param (UNFORMAT);
+
+      if (!something_parsed)
+        {
+          ret = clib_error_return (0, "Unknown input `%U'",
+                                   format_unformat_error, input);
+          goto out;
+        }
+    }
+
+  foreach_bfd_cli_udp_session_auth_deactivate_cli_param (CHECK_MANDATORY);
+
+  u8 is_delayed = 0;
+  if (have_delayed_token)
+    {
+      static const char yes[] = "yes";
+      static const char no[] = "no";
+      if (!memcmp (delayed_token, yes, sizeof (yes) - 1))
+        {
+          is_delayed = 1;
+        }
+      else if (!memcmp (delayed_token, no, sizeof (no) - 1))
+        {
+          is_delayed = 0;
+        }
+      else
+        {
+          ret = clib_error_return (
+              0, "Unrecognized value for `%s' parameter: `%v'", DELAYED_STR,
+              delayed_token);
+          goto out;
+        }
+    }
+
+  vnet_api_error_t rv = bfd_udp_auth_deactivate (sw_if_index, &local_addr,
+                                                 &peer_addr, is_delayed);
+  if (rv)
+    {
+      ret = clib_error_return (
+          0, "`bfd_udp_auth_deactivate' API call failed, rv=%d:%U", (int)rv,
+          format_vnet_api_errno, rv);
+      goto out;
+    }
+
+out:
+  return ret;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (bfd_cli_udp_session_auth_deactivate_command, static) = {
+  .path = "bfd udp session auth deactivate",
+  .short_help = "bfd udp session auth deactivate"
+                " interface <interface>"
+                " local-addr <local-address>"
+                " peer-addr <peer-address>"
+                "[ delayed <yes|no>]",
+  .function = bfd_cli_udp_session_auth_deactivate,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+bfd_cli_udp_set_echo_source (vlib_main_t * vm, unformat_input_t * input,
+			     CLIB_UNUSED (vlib_cli_command_t * lmd))
+{
+  clib_error_t *ret = NULL;
+#define foreach_bfd_cli_udp_set_echo_source_cli_param(F) \
+  F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U",   \
+     unformat_vnet_sw_interface, &vnet_main)
+
+  foreach_bfd_cli_udp_set_echo_source_cli_param (DECLARE);
+
+  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+    {
+      int something_parsed = 0;
+      foreach_bfd_cli_udp_set_echo_source_cli_param (UNFORMAT);
+
+      if (!something_parsed)
+	{
+	  ret = clib_error_return (0, "Unknown input `%U'",
+				   format_unformat_error, input);
+	  goto out;
+	}
+    }
+
+  foreach_bfd_cli_udp_set_echo_source_cli_param (CHECK_MANDATORY);
+
+  vnet_api_error_t rv = bfd_udp_set_echo_source (sw_if_index);
+  if (rv)
+    {
+      ret =
+	clib_error_return (0,
+			   "`bfd_udp_set_echo_source' API call failed, rv=%d:%U",
+			   (int) rv, format_vnet_api_errno, rv);
+      goto out;
+    }
+
+out:
+  return ret;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (bfd_cli_udp_set_echo_source_cmd, static) = {
+  .path = "bfd udp echo-source set",
+  .short_help = "bfd udp echo-source set interface <interface>",
+  .function = bfd_cli_udp_set_echo_source,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+bfd_cli_udp_del_echo_source (vlib_main_t * vm, unformat_input_t * input,
+			     CLIB_UNUSED (vlib_cli_command_t * lmd))
+{
+  vnet_api_error_t rv = bfd_udp_del_echo_source ();
+  if (rv)
+    {
+      return clib_error_return (0,
+				"`bfd_udp_del_echo_source' API call failed, rv=%d:%U",
+				(int) rv, format_vnet_api_errno, rv);
+    }
+
+  return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (bfd_cli_udp_del_echo_source_cmd, static) = {
+  .path = "bfd udp echo-source del",
+  .short_help = "bfd udp echo-source del",
+  .function = bfd_cli_udp_del_echo_source,
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/bfd/bfd_main.c b/src/vnet/bfd/bfd_main.c
index 29c4045..01de637 100644
--- a/src/vnet/bfd/bfd_main.c
+++ b/src/vnet/bfd/bfd_main.c
@@ -55,7 +55,7 @@
   return bm->cpu_cps * ((f64) us / USEC_PER_SECOND);
 }
 
-static u32
+u32
 bfd_clocks_to_usec (const bfd_main_t * bm, u64 clocks)
 {
   return (clocks / bm->cpu_cps) * USEC_PER_SECOND;
@@ -70,7 +70,7 @@
 #undef F
 };
 
-static u8 *
+u8 *
 format_bfd_auth_key (u8 * s, va_list * args)
 {
   const bfd_auth_key_t *key = va_arg (*args, bfd_auth_key_t *);
@@ -147,7 +147,7 @@
     }
 }
 
-static const char *
+const char *
 bfd_poll_state_string (bfd_poll_state_e state)
 {
   switch (state)
@@ -265,12 +265,16 @@
 static void
 bfd_recalc_detection_time (bfd_main_t * bm, bfd_session_t * bs)
 {
-  bs->detection_time_clocks =
-    bs->remote_detect_mult * clib_max (bs->effective_required_min_rx_clocks,
-				       bs->remote_desired_min_tx_clocks);
-  BFD_DBG ("Recalculated detection time %lu clocks/%.2fs",
-	   bs->detection_time_clocks,
-	   bs->detection_time_clocks / bm->cpu_cps);
+  if (bs->local_state == BFD_STATE_init || bs->local_state == BFD_STATE_up)
+    {
+      bs->detection_time_clocks =
+	bs->remote_detect_mult *
+	clib_max (bs->effective_required_min_rx_clocks,
+		  bs->remote_desired_min_tx_clocks);
+      BFD_DBG ("Recalculated detection time %lu clocks/%.2fs",
+	       bs->detection_time_clocks,
+	       bs->detection_time_clocks / bm->cpu_cps);
+    }
 }
 
 static void
@@ -284,7 +288,8 @@
     {
       rx_timeout = bs->last_rx_clocks + bs->detection_time_clocks;
     }
-  if (BFD_STATE_up != bs->local_state || !bs->remote_demand ||
+  if (BFD_STATE_up != bs->local_state ||
+      (!bs->remote_demand && bs->remote_min_rx_usec) ||
       BFD_POLL_NOT_NEEDED != bs->poll_state)
     {
       tx_timeout = bs->tx_timeout_clocks;
@@ -348,7 +353,7 @@
 
 static void
 bfd_set_effective_required_min_rx (bfd_main_t * bm,
-				   bfd_session_t * bs, u64 now,
+				   bfd_session_t * bs,
 				   u64 required_min_rx_clocks)
 {
   bs->effective_required_min_rx_clocks = required_min_rx_clocks;
@@ -393,44 +398,33 @@
 bfd_session_start (bfd_main_t * bm, bfd_session_t * bs)
 {
   BFD_DBG ("\nStarting session: %U", format_bfd_session, bs);
+  bfd_set_effective_required_min_rx (bm, bs,
+				     bs->config_required_min_rx_clocks);
   bfd_recalc_tx_interval (bm, bs);
   vlib_process_signal_event (bm->vlib_main, bm->bfd_process_node_index,
 			     BFD_EVENT_NEW_SESSION, bs->bs_idx);
 }
 
-vnet_api_error_t
-bfd_del_session (uword bs_idx)
-{
-  const bfd_main_t *bm = &bfd_main;
-  if (!pool_is_free_index (bm->sessions, bs_idx))
-    {
-      bfd_session_t *bs = pool_elt_at_index (bm->sessions, bs_idx);
-      pool_put (bm->sessions, bs);
-      return 0;
-    }
-  else
-    {
-      BFD_ERR ("no such session");
-      return VNET_API_ERROR_BFD_ENOENT;
-    }
-  return 0;
-}
-
 void
 bfd_session_set_flags (bfd_session_t * bs, u8 admin_up_down)
 {
   bfd_main_t *bm = &bfd_main;
+  u64 now = clib_cpu_time_now ();
   if (admin_up_down)
     {
       BFD_DBG ("Session set admin-up, bs-idx=%u", bs->bs_idx);
       bfd_set_state (bm, bs, BFD_STATE_down, 0);
       bfd_set_diag (bs, BFD_DIAG_CODE_no_diag);
+      bfd_calc_next_tx (bm, bs, now);
+      bfd_set_timer (bm, bs, now, 0);
     }
   else
     {
       BFD_DBG ("Session set admin-down, bs-idx=%u", bs->bs_idx);
       bfd_set_diag (bs, BFD_DIAG_CODE_admin_down);
       bfd_set_state (bm, bs, BFD_STATE_admin_down, 0);
+      bfd_calc_next_tx (bm, bs, now);
+      bfd_set_timer (bm, bs, now, 0);
     }
 }
 
@@ -515,7 +509,7 @@
 					clib_max
 					(bs->config_desired_min_tx_clocks,
 					 bm->default_desired_min_tx_clocks));
-      bfd_set_effective_required_min_rx (bm, bs, now,
+      bfd_set_effective_required_min_rx (bm, bs,
 					 bs->config_required_min_rx_clocks);
       bfd_set_timer (bm, bs, now, handling_wakeup);
       break;
@@ -525,7 +519,7 @@
 					clib_max
 					(bs->config_desired_min_tx_clocks,
 					 bm->default_desired_min_tx_clocks));
-      bfd_set_effective_required_min_rx (bm, bs, now,
+      bfd_set_effective_required_min_rx (bm, bs,
 					 bs->config_required_min_rx_clocks);
       bfd_set_timer (bm, bs, now, handling_wakeup);
       break;
@@ -540,7 +534,7 @@
 					bs->config_desired_min_tx_clocks);
       if (BFD_POLL_NOT_NEEDED == bs->poll_state)
 	{
-	  bfd_set_effective_required_min_rx (bm, bs, now,
+	  bfd_set_effective_required_min_rx (bm, bs,
 					     bs->config_required_min_rx_clocks);
 	}
       bfd_set_timer (bm, bs, now, handling_wakeup);
@@ -932,7 +926,7 @@
 	  bs->echo = 1;
 	  bs->echo_last_rx_clocks = now;
 	  bs->echo_tx_timeout_clocks = now;
-	  bfd_set_effective_required_min_rx (bm, bs, now,
+	  bfd_set_effective_required_min_rx (bm, bs,
 					     clib_max
 					     (bm->min_required_min_rx_while_echo_clocks,
 					      bs->config_required_min_rx_clocks));
@@ -1569,6 +1563,7 @@
   bs->remote_discr = pkt->my_disc;
   bs->remote_state = bfd_pkt_get_state (pkt);
   bs->remote_demand = bfd_pkt_get_demand (pkt);
+  bs->remote_diag = bfd_pkt_get_diag_code (pkt);
   u64 now = clib_cpu_time_now ();
   bs->last_rx_clocks = now;
   if (bfd_pkt_get_auth_present (pkt))
@@ -1621,7 +1616,7 @@
 	  bfd_set_poll_state (bs, BFD_POLL_NOT_NEEDED);
 	  if (BFD_STATE_up == bs->local_state)
 	    {
-	      bfd_set_effective_required_min_rx (bm, bs, now,
+	      bfd_set_effective_required_min_rx (bm, bs,
 						 clib_max (bs->echo *
 							   bm->min_required_min_rx_while_echo_clocks,
 							   bs->config_required_min_rx_clocks));
@@ -1914,6 +1909,97 @@
   return 0;
 }
 
+vnet_api_error_t
+bfd_auth_set_key (u32 conf_key_id, u8 auth_type, u8 key_len,
+		  const u8 * key_data)
+{
+#if WITH_LIBSSL > 0
+  bfd_auth_key_t *auth_key = NULL;
+  if (!key_len || key_len > bfd_max_len_for_auth_type (auth_type))
+    {
+      clib_warning ("Invalid authentication key length for auth_type=%d:%s "
+		    "(key_len=%u, must be "
+		    "non-zero, expected max=%u)",
+		    auth_type, bfd_auth_type_str (auth_type), key_len,
+		    (u32) bfd_max_len_for_auth_type (auth_type));
+      return VNET_API_ERROR_INVALID_VALUE;
+    }
+  if (!bfd_auth_type_supported (auth_type))
+    {
+      clib_warning ("Unsupported auth type=%d:%s", auth_type,
+		    bfd_auth_type_str (auth_type));
+      return VNET_API_ERROR_BFD_NOTSUPP;
+    }
+  bfd_main_t *bm = &bfd_main;
+  uword *key_idx_p = hash_get (bm->auth_key_by_conf_key_id, conf_key_id);
+  if (key_idx_p)
+    {
+      /* modifying existing key - must not be used */
+      const uword key_idx = *key_idx_p;
+      auth_key = pool_elt_at_index (bm->auth_keys, key_idx);
+      if (auth_key->use_count > 0)
+	{
+	  clib_warning ("Authentication key with conf ID %u in use by %u BFD "
+			"session(s) - cannot modify",
+			conf_key_id, auth_key->use_count);
+	  return VNET_API_ERROR_BFD_EINUSE;
+	}
+    }
+  else
+    {
+      /* adding new key */
+      pool_get (bm->auth_keys, auth_key);
+      auth_key->conf_key_id = conf_key_id;
+      hash_set (bm->auth_key_by_conf_key_id, conf_key_id,
+		auth_key - bm->auth_keys);
+    }
+  auth_key->auth_type = auth_type;
+  memset (auth_key->key, 0, sizeof (auth_key->key));
+  clib_memcpy (auth_key->key, key_data, key_len);
+  return 0;
+#else
+  clib_warning ("SSL missing, cannot manipulate authentication keys");
+  return VNET_API_ERROR_BFD_NOTSUPP;
+#endif
+}
+
+vnet_api_error_t
+bfd_auth_del_key (u32 conf_key_id)
+{
+#if WITH_LIBSSL > 0
+  bfd_auth_key_t *auth_key = NULL;
+  bfd_main_t *bm = &bfd_main;
+  uword *key_idx_p = hash_get (bm->auth_key_by_conf_key_id, conf_key_id);
+  if (key_idx_p)
+    {
+      /* deleting existing key - must not be used */
+      const uword key_idx = *key_idx_p;
+      auth_key = pool_elt_at_index (bm->auth_keys, key_idx);
+      if (auth_key->use_count > 0)
+	{
+	  clib_warning ("Authentication key with conf ID %u in use by %u BFD "
+			"session(s) - cannot delete",
+			conf_key_id, auth_key->use_count);
+	  return VNET_API_ERROR_BFD_EINUSE;
+	}
+      hash_unset (bm->auth_key_by_conf_key_id, conf_key_id);
+      memset (auth_key, 0, sizeof (*auth_key));
+      pool_put (bm->auth_keys, auth_key);
+    }
+  else
+    {
+      /* no such key */
+      clib_warning ("Authentication key with conf ID %u does not exist",
+		    conf_key_id);
+      return VNET_API_ERROR_BFD_ENOENT;
+    }
+  return 0;
+#else
+  clib_warning ("SSL missing, cannot manipulate authentication keys");
+  return VNET_API_ERROR_BFD_NOTSUPP;
+#endif
+}
+
 bfd_main_t bfd_main;
 
 /*
diff --git a/src/vnet/bfd/bfd_main.h b/src/vnet/bfd/bfd_main.h
index d8063f9..3be3694 100644
--- a/src/vnet/bfd/bfd_main.h
+++ b/src/vnet/bfd/bfd_main.h
@@ -74,11 +74,14 @@
   /* session state */
   bfd_state_e local_state;
 
+  /* remote session state */
+  bfd_state_e remote_state;
+
   /* local diagnostics */
   bfd_diag_code_e local_diag;
 
-  /* remote session state */
-  bfd_state_e remote_state;
+  /* remote diagnostics */
+  bfd_diag_code_e remote_diag;
 
   /* local discriminator */
   u32 local_discr;
@@ -315,6 +318,7 @@
 void bfd_init_final_control_frame (vlib_main_t * vm, vlib_buffer_t * b,
 				   bfd_main_t * bm, bfd_session_t * bs);
 u8 *format_bfd_session (u8 * s, va_list * args);
+u8 *format_bfd_auth_key (u8 * s, va_list * args);
 void bfd_session_set_flags (bfd_session_t * bs, u8 admin_up_down);
 unsigned bfd_auth_type_supported (bfd_auth_type_e auth_type);
 vnet_api_error_t bfd_auth_activate (bfd_session_t * bs, u32 conf_key_id,
@@ -325,6 +329,9 @@
 					 u32 required_min_rx_usec,
 					 u8 detect_mult);
 
+u32 bfd_clocks_to_usec (const bfd_main_t * bm, u64 clocks);
+const char *bfd_poll_state_string (bfd_poll_state_e state);
+
 #define USEC_PER_MS 1000LL
 #define USEC_PER_SECOND (1000 * USEC_PER_MS)
 
diff --git a/src/vnet/bfd/bfd_protocol.c b/src/vnet/bfd/bfd_protocol.c
index 92b226b..5deb970 100644
--- a/src/vnet/bfd/bfd_protocol.c
+++ b/src/vnet/bfd/bfd_protocol.c
@@ -82,11 +82,13 @@
   return (pkt->head.sta_flags >> 3) & 1;
 }
 
+#if 0
 void
 bfd_pkt_set_control_plane_independent (bfd_pkt_t * pkt)
 {
   pkt->head.sta_flags |= 1 << 3;
 }
+#endif
 
 u8
 bfd_pkt_get_auth_present (const bfd_pkt_t * pkt)
@@ -106,11 +108,13 @@
   return (pkt->head.sta_flags >> 1) & 1;
 }
 
+#if 0
 void
 bfd_pkt_set_demand (bfd_pkt_t * pkt)
 {
   pkt->head.sta_flags |= 1 << 1;
 }
+#endif
 
 u8
 bfd_pkt_get_multipoint (const bfd_pkt_t * pkt)
@@ -118,11 +122,13 @@
   return (pkt->head.sta_flags >> 0) & 1;
 }
 
+#if 0
 void
 bfd_pkt_set_multipoint (bfd_pkt_t * pkt)
 {
   pkt->head.sta_flags |= 1 << 0;
 }
+#endif
 
 u32
 bfd_max_len_for_auth_type (bfd_auth_type_e auth_type)
diff --git a/src/vnet/bfd/bfd_udp.c b/src/vnet/bfd/bfd_udp.c
index cf05089..207f3b8 100644
--- a/src/vnet/bfd/bfd_udp.c
+++ b/src/vnet/bfd/bfd_udp.c
@@ -60,8 +60,7 @@
 bfd_udp_set_echo_source (u32 sw_if_index)
 {
   vnet_sw_interface_t *sw_if =
-    vnet_get_sw_interface_safe (bfd_udp_main.vnet_main,
-				bfd_udp_main.echo_source_sw_if_index);
+    vnet_get_sw_interface_safe (bfd_udp_main.vnet_main, sw_if_index);
   if (sw_if)
     {
       bfd_udp_main.echo_source_sw_if_index = sw_if_index;
@@ -84,6 +83,7 @@
 {
   if (!bfd_udp_main.echo_source_is_set)
     {
+      BFD_DBG ("UDP echo source not set - echo not available");
       return 0;
     }
   /*
@@ -127,6 +127,7 @@
           /* *INDENT-ON* */
 	}
     }
+  BFD_DBG ("No usable IP address for UDP echo - echo not available");
   return 0;
 }
 
@@ -144,11 +145,6 @@
   return 49152 + bs_idx % (65535 - 49152 + 1);
 }
 
-static void
-lol ()
-{
-}
-
 int
 bfd_udp_get_echo_src_ip4 (ip4_address_t * addr)
 {
@@ -204,7 +200,6 @@
           {
             *addr = *x;
             addr->as_u8[15] ^= 1; /* flip the last bit of the address */
-            lol ();
             return 1;
           }
       }));
@@ -213,6 +208,24 @@
   return 0;
 }
 
+void
+bfd_udp_get_echo_source (int *is_set, u32 * sw_if_index, int *have_usable_ip4,
+			 ip4_address_t * ip4, int *have_usable_ip6,
+			 ip6_address_t * ip6)
+{
+  if (bfd_udp_main.echo_source_is_set)
+    {
+      *is_set = 1;
+      *sw_if_index = bfd_udp_main.echo_source_sw_if_index;
+      *have_usable_ip4 = bfd_udp_get_echo_src_ip4 (ip4);
+      *have_usable_ip6 = bfd_udp_get_echo_src_ip6 (ip6);
+    }
+  else
+    {
+      *is_set = 0;
+    }
+}
+
 int
 bfd_add_udp4_transport (vlib_main_t * vm, vlib_buffer_t * b,
 			const bfd_session_t * bs, int is_echo)
@@ -661,97 +674,6 @@
 }
 
 vnet_api_error_t
-bfd_auth_set_key (u32 conf_key_id, u8 auth_type, u8 key_len,
-		  const u8 * key_data)
-{
-#if WITH_LIBSSL > 0
-  bfd_auth_key_t *auth_key = NULL;
-  if (!key_len || key_len > bfd_max_len_for_auth_type (auth_type))
-    {
-      clib_warning ("Invalid authentication key length for auth_type=%d:%s "
-		    "(key_len=%u, must be "
-		    "non-zero, expected max=%u)",
-		    auth_type, bfd_auth_type_str (auth_type), key_len,
-		    (u32) bfd_max_len_for_auth_type (auth_type));
-      return VNET_API_ERROR_INVALID_VALUE;
-    }
-  if (!bfd_auth_type_supported (auth_type))
-    {
-      clib_warning ("Unsupported auth type=%d:%s", auth_type,
-		    bfd_auth_type_str (auth_type));
-      return VNET_API_ERROR_BFD_NOTSUPP;
-    }
-  bfd_main_t *bm = bfd_udp_main.bfd_main;
-  uword *key_idx_p = hash_get (bm->auth_key_by_conf_key_id, conf_key_id);
-  if (key_idx_p)
-    {
-      /* modifying existing key - must not be used */
-      const uword key_idx = *key_idx_p;
-      auth_key = pool_elt_at_index (bm->auth_keys, key_idx);
-      if (auth_key->use_count > 0)
-	{
-	  clib_warning ("Authentication key with conf ID %u in use by %u BFD "
-			"sessions - cannot modify",
-			conf_key_id, auth_key->use_count);
-	  return VNET_API_ERROR_BFD_EINUSE;
-	}
-    }
-  else
-    {
-      /* adding new key */
-      pool_get (bm->auth_keys, auth_key);
-      auth_key->conf_key_id = conf_key_id;
-      hash_set (bm->auth_key_by_conf_key_id, conf_key_id,
-		auth_key - bm->auth_keys);
-    }
-  auth_key->auth_type = auth_type;
-  memset (auth_key->key, 0, sizeof (auth_key->key));
-  clib_memcpy (auth_key->key, key_data, key_len);
-  return 0;
-#else
-  clib_warning ("SSL missing, cannot manipulate authentication keys");
-  return VNET_API_ERROR_BFD_NOTSUPP;
-#endif
-}
-
-vnet_api_error_t
-bfd_auth_del_key (u32 conf_key_id)
-{
-#if WITH_LIBSSL > 0
-  bfd_auth_key_t *auth_key = NULL;
-  bfd_main_t *bm = bfd_udp_main.bfd_main;
-  uword *key_idx_p = hash_get (bm->auth_key_by_conf_key_id, conf_key_id);
-  if (key_idx_p)
-    {
-      /* deleting existing key - must not be used */
-      const uword key_idx = *key_idx_p;
-      auth_key = pool_elt_at_index (bm->auth_keys, key_idx);
-      if (auth_key->use_count > 0)
-	{
-	  clib_warning ("Authentication key with conf ID %u in use by %u BFD "
-			"sessions - cannot delete",
-			conf_key_id, auth_key->use_count);
-	  return VNET_API_ERROR_BFD_EINUSE;
-	}
-      hash_unset (bm->auth_key_by_conf_key_id, conf_key_id);
-      memset (auth_key, 0, sizeof (*auth_key));
-      pool_put (bm->auth_keys, auth_key);
-    }
-  else
-    {
-      /* no such key */
-      clib_warning ("Authentication key with conf ID %u does not exist",
-		    conf_key_id);
-      return VNET_API_ERROR_BFD_ENOENT;
-    }
-  return 0;
-#else
-  clib_warning ("SSL missing, cannot manipulate authentication keys");
-  return VNET_API_ERROR_BFD_NOTSUPP;
-#endif
-}
-
-vnet_api_error_t
 bfd_udp_auth_activate (u32 sw_if_index,
 		       const ip46_address_t * local_addr,
 		       const ip46_address_t * peer_addr,
diff --git a/src/vnet/bfd/bfd_udp.h b/src/vnet/bfd/bfd_udp.h
index ce2ee3c..e33b740 100644
--- a/src/vnet/bfd/bfd_udp.h
+++ b/src/vnet/bfd/bfd_udp.h
@@ -62,6 +62,11 @@
  */
 int bfd_udp_is_echo_available (bfd_transport_e transport);
 
+void
+bfd_udp_get_echo_source (int *is_set, u32 * sw_if_index, int *have_usable_ip4,
+			 ip4_address_t * ip4, int *have_usable_ip6,
+			 ip6_address_t * ip6);
+
 #endif /* __included_bfd_udp_h__ */
 
 /*
