From 0b43cab60540d38e4f533cfb36cd2dbc81d8e23b Mon Sep 17 00:00:00 2001 From: Kamil Cudnik Date: Wed, 15 Apr 2020 15:56:04 +0200 Subject: [PATCH] [vs] Make default port admin state to false (#603) --- vslib/src/SwitchStateBaseHostif.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/vslib/src/SwitchStateBaseHostif.cpp b/vslib/src/SwitchStateBaseHostif.cpp index 8b18f52a2..f3fa2519b 100644 --- a/vslib/src/SwitchStateBaseHostif.cpp +++ b/vslib/src/SwitchStateBaseHostif.cpp @@ -479,15 +479,6 @@ bool SwitchStateBase::hostif_create_tap_veth_forwarding( SWSS_LOG_NOTICE("interface index = %d, %s\n", sock_address.sll_ifindex, vethname.c_str()); - if (ifup(vethname.c_str(), port_id, true, true)) - { - SWSS_LOG_ERROR("ifup failed on %s", vethname.c_str()); - - close(packet_socket); - - return false; - } - if (promisc(vethname.c_str())) { SWSS_LOG_ERROR("promisc failed on %s", vethname.c_str()); @@ -658,6 +649,25 @@ sai_status_t SwitchStateBase::vs_create_hostif_tap_interface( vs_set_dev_mtu(vname.c_str(), mtu); + attr.id = SAI_PORT_ATTR_ADMIN_STATE; + + status = get(SAI_OBJECT_TYPE_PORT, obj_id, 1, &attr); + + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("failed to get admin state for port %s", + sai_serialize_object_id(obj_id).c_str()); + + return false; + } + + if (ifup(vname.c_str(), obj_id, attr.value.booldata, false)) + { + SWSS_LOG_ERROR("ifup failed on %s", vname.c_str()); + + return false; + } + if (!hostif_create_tap_veth_forwarding(name, tapfd, obj_id)) { SWSS_LOG_ERROR("forwarding rule on %s was not added", name.c_str());