aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/memif/memif.c9
-rw-r--r--test/test_memif.py40
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)