diff options
Diffstat (limited to 'src/vnet/bfd')
-rw-r--r-- | src/vnet/bfd/bfd.api | 21 | ||||
-rw-r--r-- | src/vnet/bfd/bfd_api.c | 44 | ||||
-rw-r--r-- | src/vnet/bfd/test/test_bfd.py | 30 |
3 files changed, 79 insertions, 16 deletions
diff --git a/src/vnet/bfd/bfd.api b/src/vnet/bfd/bfd.api index 9fdd5b728d4..f53cc7630fd 100644 --- a/src/vnet/bfd/bfd.api +++ b/src/vnet/bfd/bfd.api @@ -206,6 +206,11 @@ autoreply define bfd_udp_session_set_flags vl_api_if_status_flags_t flags; }; +service { + rpc want_bfd_events returns want_bfd_events_reply + events bfd_udp_session_event; +}; + /** \brief Register for BFD events @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -220,6 +225,22 @@ autoreply define want_bfd_events u32 pid; }; +define bfd_udp_session_event +{ + u32 client_index; + u32 pid; + vl_api_interface_index_t sw_if_index; + vl_api_address_t local_addr; + vl_api_address_t peer_addr; + vl_api_bfd_state_t state; + bool is_authenticated; + u8 bfd_key_id; + u32 conf_key_id; + u32 required_min_rx; + u32 desired_min_tx; + u8 detect_mult; +}; + /** \brief BFD UDP - add/replace key to configuration @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 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); } } } diff --git a/src/vnet/bfd/test/test_bfd.py b/src/vnet/bfd/test/test_bfd.py index 3e6453ccbc9..01b468c8e27 100644 --- a/src/vnet/bfd/test/test_bfd.py +++ b/src/vnet/bfd/test/test_bfd.py @@ -549,7 +549,7 @@ def bfd_session_up(test): test.test_session.inc_seq_num() test.test_session.send_packet() test.logger.info("BFD: Waiting for event") - e = test.vapi.wait_for_event(1, "bfd_udp_session_details") + e = test.vapi.wait_for_event(1, "bfd_udp_session_event") verify_event(test, e, expected_state=BFDState.up) test.logger.info("BFD: Session is Up") test.test_session.update(state=BFDState.up) @@ -569,7 +569,7 @@ def bfd_session_down(test): test.test_session.inc_seq_num() test.test_session.send_packet() test.logger.info("BFD: Waiting for event") - e = test.vapi.wait_for_event(1, "bfd_udp_session_details") + e = test.vapi.wait_for_event(1, "bfd_udp_session_event") verify_event(test, e, expected_state=BFDState.down) test.logger.info("BFD: Session is Down") test.assert_equal(test.vpp_session.state, BFDState.down, BFDState) @@ -750,12 +750,12 @@ class BFD4TestCase(VppTestCase): self.test_session.update(your_discriminator=p[BFD].my_discriminator, state=BFDState.up) self.logger.info("BFD: Waiting for event") - e = self.vapi.wait_for_event(1, "bfd_udp_session_details") + e = self.vapi.wait_for_event(1, "bfd_udp_session_event") verify_event(self, e, expected_state=BFDState.init) self.logger.info("BFD: Sending Up") self.test_session.send_packet() self.logger.info("BFD: Waiting for event") - e = self.vapi.wait_for_event(1, "bfd_udp_session_details") + e = self.vapi.wait_for_event(1, "bfd_udp_session_event") verify_event(self, e, expected_state=BFDState.up) self.logger.info("BFD: Session is Up") self.test_session.update(state=BFDState.up) @@ -820,7 +820,7 @@ class BFD4TestCase(VppTestCase): detection_time = self.test_session.detect_mult *\ self.vpp_session.required_min_rx / USEC_IN_SEC self.sleep(detection_time, "waiting for BFD session time-out") - e = self.vapi.wait_for_event(1, "bfd_udp_session_details") + e = self.vapi.wait_for_event(1, "bfd_udp_session_event") verify_event(self, e, expected_state=BFDState.down) def test_peer_discr_reset_sess_down(self): @@ -917,7 +917,7 @@ class BFD4TestCase(VppTestCase): self.vpp_session.required_min_rx) / USEC_IN_SEC self.test_session.send_packet(final) time_mark = time.time() - e = self.vapi.wait_for_event(2 * timeout, "bfd_udp_session_details") + e = self.vapi.wait_for_event(2 * timeout, "bfd_udp_session_event") verify_event(self, e, expected_state=BFDState.down) time_to_event = time.time() - time_mark self.assert_in_range(time_to_event, .9 * timeout, @@ -957,7 +957,7 @@ class BFD4TestCase(VppTestCase): self.vpp_session.required_min_rx / USEC_IN_SEC before = time.time() e = self.vapi.wait_for_event( - 2 * detection_time, "bfd_udp_session_details") + 2 * detection_time, "bfd_udp_session_event") after = time.time() self.assert_in_range(after - before, 0.9 * detection_time, @@ -1404,7 +1404,7 @@ class BFD4TestCase(VppTestCase): bfd_session_up(self) self.vpp_session.admin_down() self.pg0.enable_capture() - e = self.vapi.wait_for_event(1, "bfd_udp_session_details") + e = self.vapi.wait_for_event(1, "bfd_udp_session_event") verify_event(self, e, expected_state=BFDState.admin_down) for dummy in range(2): p = wait_for_bfd_packet(self) @@ -1417,7 +1417,7 @@ class BFD4TestCase(VppTestCase): self.assert_equal(p[BFD].state, BFDState.admin_down, BFDState) self.vpp_session.admin_up() self.test_session.update(state=BFDState.down) - e = self.vapi.wait_for_event(1, "bfd_udp_session_details") + e = self.vapi.wait_for_event(1, "bfd_udp_session_event") verify_event(self, e, expected_state=BFDState.down) p = wait_for_bfd_packet( self, pcap_time_min=time.time() - self.vpp_clock_offset) @@ -1426,14 +1426,14 @@ class BFD4TestCase(VppTestCase): p = wait_for_bfd_packet( self, pcap_time_min=time.time() - self.vpp_clock_offset) self.assert_equal(p[BFD].state, BFDState.init, BFDState) - e = self.vapi.wait_for_event(1, "bfd_udp_session_details") + e = self.vapi.wait_for_event(1, "bfd_udp_session_event") verify_event(self, e, expected_state=BFDState.init) self.test_session.update(state=BFDState.up) self.test_session.send_packet() p = wait_for_bfd_packet( self, pcap_time_min=time.time() - self.vpp_clock_offset) self.assert_equal(p[BFD].state, BFDState.up, BFDState) - e = self.vapi.wait_for_event(1, "bfd_udp_session_details") + e = self.vapi.wait_for_event(1, "bfd_udp_session_event") verify_event(self, e, expected_state=BFDState.up) def test_config_change_remote_demand(self): @@ -1483,7 +1483,7 @@ class BFD4TestCase(VppTestCase): vpp_session.add_vpp_config() vpp_session.admin_up() intf.remove_vpp_config() - e = self.vapi.wait_for_event(1, "bfd_udp_session_details") + e = self.vapi.wait_for_event(1, "bfd_udp_session_event") self.assert_equal(e.sw_if_index, sw_if_index, "sw_if_index") self.assertFalse(vpp_session.query_vpp_config()) @@ -1562,12 +1562,12 @@ class BFD6TestCase(VppTestCase): self.test_session.update(your_discriminator=p[BFD].my_discriminator, state=BFDState.up) self.logger.info("BFD: Waiting for event") - e = self.vapi.wait_for_event(1, "bfd_udp_session_details") + e = self.vapi.wait_for_event(1, "bfd_udp_session_event") verify_event(self, e, expected_state=BFDState.init) self.logger.info("BFD: Sending Up") self.test_session.send_packet() self.logger.info("BFD: Waiting for event") - e = self.vapi.wait_for_event(1, "bfd_udp_session_details") + e = self.vapi.wait_for_event(1, "bfd_udp_session_event") verify_event(self, e, expected_state=BFDState.up) self.logger.info("BFD: Session is Up") self.test_session.update(state=BFDState.up) @@ -1698,7 +1698,7 @@ class BFD6TestCase(VppTestCase): vpp_session.add_vpp_config() vpp_session.admin_up() intf.remove_vpp_config() - e = self.vapi.wait_for_event(1, "bfd_udp_session_details") + e = self.vapi.wait_for_event(1, "bfd_udp_session_event") self.assert_equal(e.sw_if_index, sw_if_index, "sw_if_index") self.assertFalse(vpp_session.query_vpp_config()) |