diff options
author | Daniel Béreš <daniel.beres@pantheon.tech> | 2021-11-03 08:55:04 +0000 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2021-11-09 09:54:34 +0000 |
commit | 90c397c505d35498b59756020e2d465f1b45e871 (patch) | |
tree | 54e39e758ed0e0764856806548e56aa9671d8cd0 | |
parent | f7b1f8a8911b51e01f7ecd79d25eb8d89da74884 (diff) |
memif: memif linkstate can't become up
Admin down implies Link down but nothing came with admin up.
Ticket: VPP-1959
Type: fix
Change-Id: I43725329ae7918659c73d703280c25de5f0b1d14
Signed-off-by: Daniel Béreš <daniel.beres@pantheon.tech>
-rw-r--r-- | src/plugins/memif/memif.c | 9 | ||||
-rw-r--r-- | test/test_memif.py | 40 |
2 files changed, 48 insertions, 1 deletions
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c index 886721aef75..4d662faae9e 100644 --- a/src/plugins/memif/memif.c +++ b/src/plugins/memif/memif.c @@ -1086,7 +1086,14 @@ memif_interface_admin_up_down (vnet_main_t *vnm, u32 hw_if_index, u32 flags) static clib_error_t *error = 0; if (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) - mif->flags |= MEMIF_IF_FLAG_ADMIN_UP; + { + if (mif->flags & MEMIF_IF_FLAG_CONNECTED) + { + vnet_hw_interface_set_flags (vnm, mif->hw_if_index, + VNET_HW_INTERFACE_FLAG_LINK_UP); + } + mif->flags |= MEMIF_IF_FLAG_ADMIN_UP; + } else mif->flags &= ~MEMIF_IF_FLAG_ADMIN_UP; diff --git a/test/test_memif.py b/test/test_memif.py index fc7cf9b2e7e..bf1c10a0a8a 100644 --- a/test/test_memif.py +++ b/test/test_memif.py @@ -303,6 +303,46 @@ class TestMemif(VppTestCase): route.remove_vpp_config() + def test_memif_admin_up_down_up(self): + """ Memif admin up/down/up """ + memif = VppMemif( + self, + VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE, + VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, + ring_size=1024, + buffer_size=2048, + secret="abc") + + remote_socket = VppSocketFilename(self.remote_test, 1, + "%s/memif.sock" % self.tempdir) + remote_socket.add_vpp_config() + + remote_memif = VppMemif( + self.remote_test, + VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER, + VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET, + socket_id=1, + ring_size=1024, + buffer_size=2048, + secret="abc") + + memif.add_vpp_config() + remote_memif.add_vpp_config() + + memif.admin_up() + remote_memif.admin_up() + memif.admin_down() + remote_memif.admin_down() + memif.admin_up() + remote_memif.admin_up() + + self._connect_test_one_interface(memif) + self._connect_test_one_interface(remote_memif) + + memif.remove_vpp_config() + remote_memif.remove_vpp_config() + remote_socket.remove_vpp_config() + if __name__ == '__main__': unittest.main(testRunner=VppTestRunner) |