diff options
author | Ole Troan <ot@cisco.com> | 2021-03-03 10:40:05 +0100 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2021-03-15 17:23:53 +0000 |
commit | 4376ab2a926b36c1131588069a8a9cdd2520073d (patch) | |
tree | c7315eeed5c134abef38a25d52ba0fb158a14f86 /src/vnet/bfd/bfd_api.c | |
parent | 387a08a8be413379618a633b140c58c35a1f6640 (diff) |
tests: use socket transport instead of shared memory
Type: improvement
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I9e65c94a5a05047a5104e9361ea36eac77b40442
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/vnet/bfd/bfd_api.c')
-rw-r--r-- | src/vnet/bfd/bfd_api.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/vnet/bfd/bfd_api.c b/src/vnet/bfd/bfd_api.c index ba7783fd54f..4760df2ac1b 100644 --- a/src/vnet/bfd/bfd_api.c +++ b/src/vnet/bfd/bfd_api.c @@ -175,6 +175,48 @@ send_bfd_udp_session_details (vl_api_registration_t * reg, u32 context, } void +send_bfd_udp_session_event (vl_api_registration_t *reg, u32 pid, + bfd_session_t *bs) +{ + if (bs->transport != BFD_TRANSPORT_UDP4 && + bs->transport != BFD_TRANSPORT_UDP6) + { + return; + } + + vl_api_bfd_udp_session_event_t *mp = vl_msg_api_alloc (sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); + mp->_vl_msg_id = ntohs (VL_API_BFD_UDP_SESSION_EVENT); + mp->pid = pid; + mp->state = clib_host_to_net_u32 (bs->local_state); + bfd_udp_session_t *bus = &bs->udp; + bfd_udp_key_t *key = &bus->key; + mp->sw_if_index = clib_host_to_net_u32 (key->sw_if_index); + if ((!bs->auth.is_delayed && bs->auth.curr_key) || + (bs->auth.is_delayed && bs->auth.next_key)) + { + mp->is_authenticated = true; + } + 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); + } + ip_address_encode (&key->local_addr, IP46_TYPE_ANY, &mp->local_addr); + ip_address_encode (&key->peer_addr, IP46_TYPE_ANY, &mp->peer_addr); + + mp->required_min_rx = clib_host_to_net_u32 (bs->config_required_min_rx_usec); + mp->desired_min_tx = clib_host_to_net_u32 (bs->config_desired_min_tx_usec); + mp->detect_mult = bs->local_detect_mult; + vl_api_send_msg (reg, (u8 *) mp); +} + +void bfd_event (bfd_main_t * bm, bfd_session_t * bs) { vpe_api_main_t *vam = &vpe_api_main; @@ -190,7 +232,7 @@ bfd_event (bfd_main_t * bm, bfd_session_t * bs) case BFD_TRANSPORT_UDP4: /* fallthrough */ case BFD_TRANSPORT_UDP6: - send_bfd_udp_session_details (vl_reg, 0, bs); + send_bfd_udp_session_event (vl_reg, 0, bs); } } } |