43 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 50 #define foreach_vpe_api_msg \ 51 _ (BFD_UDP_ADD, bfd_udp_add) \ 52 _ (BFD_UDP_MOD, bfd_udp_mod) \ 53 _ (BFD_UDP_DEL, bfd_udp_del) \ 54 _ (BFD_UDP_SESSION_DUMP, bfd_udp_session_dump) \ 55 _ (BFD_UDP_SESSION_SET_FLAGS, bfd_udp_session_set_flags) \ 56 _ (WANT_BFD_EVENTS, want_bfd_events) \ 57 _ (BFD_AUTH_SET_KEY, bfd_auth_set_key) \ 58 _ (BFD_AUTH_DEL_KEY, bfd_auth_del_key) \ 59 _ (BFD_AUTH_KEYS_DUMP, bfd_auth_keys_dump) \ 60 _ (BFD_UDP_AUTH_ACTIVATE, bfd_udp_auth_activate) \ 61 _ (BFD_UDP_AUTH_DEACTIVATE, bfd_udp_auth_deactivate) \ 62 _ (BFD_UDP_SET_ECHO_SOURCE, bfd_udp_set_echo_source) \ 63 _ (BFD_UDP_DEL_ECHO_SOURCE, bfd_udp_del_echo_source) \ 64 _ (BFD_UDP_GET_ECHO_SOURCE, bfd_udp_get_echo_source) 68 #define BFD_UDP_API_PARAM_COMMON_CODE \ 69 ip46_address_t local_addr; \ 70 clib_memset (&local_addr, 0, sizeof (local_addr)); \ 71 ip46_address_t peer_addr; \ 72 clib_memset (&peer_addr, 0, sizeof (peer_addr)); \ 75 clib_memcpy_fast (&local_addr.ip6, mp->local_addr, sizeof (local_addr.ip6)); \ 76 clib_memcpy_fast (&peer_addr.ip6, mp->peer_addr, sizeof (peer_addr.ip6)); \ 80 clib_memcpy_fast (&local_addr.ip4, mp->local_addr, sizeof (local_addr.ip4)); \ 81 clib_memcpy_fast (&peer_addr.ip4, mp->peer_addr, sizeof (peer_addr.ip4)); \ 84 #define BFD_UDP_API_PARAM_FROM_MP(mp) \ 85 clib_net_to_host_u32 (mp->sw_if_index), &local_addr, &peer_addr 90 vl_api_bfd_udp_add_reply_t *rmp;
111 vl_api_bfd_udp_mod_reply_t *rmp;
130 vl_api_bfd_udp_del_reply_t *rmp;
147 if (bs->
transport != BFD_TRANSPORT_UDP4 &&
155 mp->_vl_msg_id = ntohs (VL_API_BFD_UDP_SESSION_DETAILS);
159 bfd_udp_key_t *
key = &bus->
key;
160 mp->
sw_if_index = clib_host_to_net_u32 (key->sw_if_index);
180 sizeof (key->local_addr));
182 sizeof (key->peer_addr));
187 sizeof (key->local_addr.ip4.data));
189 sizeof (key->peer_addr.ip4.data));
207 vl_reg = vl_api_client_index_to_registration (reg->client_index);
210 switch (bs->transport)
212 case BFD_TRANSPORT_UDP4:
214 case BFD_TRANSPORT_UDP6:
215 send_bfd_udp_session_details (vl_reg, 0, bs);
234 if (bs->transport == BFD_TRANSPORT_UDP4 ||
235 bs->transport == BFD_TRANSPORT_UDP6)
236 send_bfd_udp_session_details (reg, mp->context, bs);
245 vl_api_bfd_udp_session_set_flags_reply_t *rmp;
253 REPLY_MACRO (VL_API_BFD_UDP_SESSION_SET_FLAGS_REPLY);
259 vl_api_bfd_auth_set_key_reply_t *rmp;
269 vl_api_bfd_auth_del_key_reply_t *rmp;
289 rmp = vl_msg_api_alloc (sizeof (*rmp));
290 clib_memset (rmp, 0, sizeof (*rmp));
291 rmp->_vl_msg_id = ntohs (VL_API_BFD_AUTH_KEYS_DETAILS);
292 rmp->context = mp->context;
293 rmp->conf_key_id = clib_host_to_net_u32 (key->conf_key_id);
294 rmp->auth_type = key->auth_type;
295 rmp->use_count = clib_host_to_net_u32 (key->use_count);
296 vl_api_send_msg (reg, (u8 *)rmp);
304 vl_api_bfd_udp_auth_activate_reply_t *rmp;
323 vl_api_bfd_udp_auth_deactivate_reply_t *rmp;
334 REPLY_MACRO (VL_API_BFD_UDP_AUTH_DEACTIVATE_REPLY);
341 vl_api_bfd_udp_set_echo_source_reply_t *rmp;
349 REPLY_MACRO (VL_API_BFD_UDP_SET_ECHO_SOURCE_REPLY);
356 vl_api_bfd_udp_del_echo_source_reply_t *rmp;
361 REPLY_MACRO (VL_API_BFD_UDP_DEL_ECHO_SOURCE_REPLY);
378 &have_usable_ip6, &ip6);
387 rmp->
sw_if_index = clib_host_to_net_u32 (sw_if_index);
424 #define vl_msg_name_crc_list 426 #undef vl_msg_name_crc_list 431 #define _(id, n, crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); 432 foreach_vl_msg_name_crc_bfd;
442 vl_msg_api_set_handlers (VL_API_##N, #n, vl_api_##n##_t_handler, \ 443 vl_noop_handler, vl_api_##n##_t_endian, \ 444 vl_api_##n##_t_print, sizeof (vl_api_##n##_t), 1); static void vl_api_bfd_auth_keys_dump_t_handler(vl_api_bfd_auth_keys_dump_t *mp)
VLIB_API_INIT_FUNCTION(bfd_api_hookup)
static void vl_api_bfd_udp_auth_activate_t_handler(vl_api_bfd_udp_auth_activate_t *mp)
u8 curr_bfd_key_id
current key ID sent out in bfd packet
Add UDP BFD session on interface.
Set flags of BFD UDP session.
static void vl_api_bfd_udp_auth_deactivate_t_handler(vl_api_bfd_udp_auth_deactivate_t *mp)
BFD UDP - add/replace key to configuration.
static void vl_api_bfd_auth_del_key_t_handler(vl_api_bfd_auth_del_key_t *mp)
#define foreach_vpe_api_msg
vnet_api_error_t bfd_udp_mod_session(u32 sw_if_index, const ip46_address_t *local_addr, const ip46_address_t *peer_addr, u32 desired_min_tx_usec, u32 required_min_rx_usec, u8 detect_mult)
modify existing session
#define clib_memcpy_fast(a, b, c)
BFD authentication key details.
#define REPLY_MACRO2(t, body)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
vnet_api_error_t bfd_udp_add_session(u32 sw_if_index, const ip46_address_t *local_addr, const ip46_address_t *peer_addr, u32 desired_min_tx_usec, u32 required_min_rx_usec, u8 detect_mult, u8 is_authenticated, u32 conf_key_id, u8 bfd_key_id)
create a new bfd session
vnet_api_error_t bfd_auth_del_key(u32 conf_key_id)
delete existing authentication key
#define BFD_UDP_API_PARAM_COMMON_CODE
pub_sub_handler(bfd_events, BFD_EVENTS)
void * vl_msg_api_alloc(int nbytes)
vnet_api_error_t bfd_udp_del_echo_source()
unset echo-source interface
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)
get echo source information - used by CLI
static clib_error_t * bfd_api_hookup(vlib_main_t *vm)
vnet_api_error_t bfd_udp_del_session(u32 sw_if_index, const ip46_address_t *local_addr, const ip46_address_t *peer_addr)
delete existing session
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
Get BFD echo source reply.
UDP transport specific data embedded in bfd_session's union.
void bfd_event(bfd_main_t *bm, bfd_session_t *bs)
#define BFD_UDP_API_PARAM_FROM_MP(mp)
vnet_api_error_t bfd_auth_set_key(u32 conf_key_id, u8 auth_type, u8 key_len, const u8 *key)
create or modify bfd authentication key
bfd_auth_key_t * next_key
set to next key to use if delayed switch is enabled - in that case the key is switched when first inc...
bfd_session_t * sessions
pool of bfd sessions context data
bfd_auth_key_t * auth_keys
pool of authentication keys
bfd_udp_key_t key
key identifying this session
bfd_transport_e transport
transport type for this session
BFD session details structure.
void send_bfd_udp_session_details(vl_api_registration_t *reg, u32 context, bfd_session_t *bs)
u8 local_detect_mult
configured detect multiplier
Get a list of configured authentication keys.
vnet_api_error_t bfd_udp_session_set_flags(u32 sw_if_index, const ip46_address_t *local_addr, const ip46_address_t *peer_addr, u8 admin_up_down)
set session admin down/up
API main structure, used by both vpp and binary API clients.
#define ip46_address_is_ip4(ip46)
An API client registration, only in vpp/vlib.
static void setup_message_id_table(api_main_t *am)
#define BAD_SW_IF_INDEX_LABEL
static void vl_api_bfd_auth_set_key_t_handler(vl_api_bfd_auth_set_key_t *mp)
struct bfd_session_s::@52 auth
authentication information
u32 config_desired_min_tx_usec
configured desired min tx interval (microseconds)
static void vl_api_bfd_udp_set_echo_source_t_handler(vl_api_bfd_udp_set_echo_source_t *mp)
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
static void vl_api_bfd_udp_session_dump_t_handler(vl_api_bfd_udp_session_dump_t *mp)
BFD UDP - deactivate authentication.
static void vl_api_bfd_udp_add_t_handler(vl_api_bfd_udp_add_t *mp)
vnet_api_error_t bfd_udp_auth_activate(u32 sw_if_index, const ip46_address_t *local_addr, const ip46_address_t *peer_addr, u32 conf_key_id, u8 bfd_key_id, u8 is_delayed)
activate authentication for existing session
u32 conf_key_id
global configuration key ID
bfd_state_e local_state
session state
static void vl_api_bfd_udp_mod_t_handler(vl_api_bfd_udp_mod_t *mp)
Delete UDP BFD session on interface.
vnet_api_error_t bfd_udp_set_echo_source(u32 loopback_sw_if_index)
set echo-source interface
u32 config_required_min_rx_usec
configured required min rx interval (microseconds)
static void vl_api_bfd_udp_del_t_handler(vl_api_bfd_udp_del_t *mp)
BFD UDP - activate/change authentication.
static void vl_api_bfd_udp_session_set_flags_t_handler(vl_api_bfd_udp_session_set_flags_t *mp)
u8 next_bfd_key_id
key ID to use when switched to next_key
static void vl_api_bfd_udp_get_echo_source_t_handler(vl_api_bfd_udp_get_echo_source_t *mp)
static void vl_api_bfd_udp_del_echo_source_t_handler(vl_api_bfd_udp_del_echo_source_t *mp)
vnet_api_error_t bfd_udp_auth_deactivate(u32 sw_if_index, const ip46_address_t *local_addr, const ip46_address_t *peer_addr, u8 is_delayed)
deactivate authentication for existing session
Modify UDP BFD session on interface.
bfd_auth_key_t * curr_key
current key in use
vpe_api_main_t vpe_api_main
BFD UDP - delete key from configuration.
u8 is_delayed
set to 1 if delayed action is pending, which might be activation of authentication, change of key or deactivation
#define VALIDATE_SW_IF_INDEX(mp)