-
Notifications
You must be signed in to change notification settings - Fork 539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Inband VLan #1555
Changes from 1 commit
9866901
6060060
ff48127
01552f9
d84e5ee
035c6cb
30b3cdf
798348c
2de8cd7
738e5f6
3efaf24
2c7508e
39b703f
9298c9e
8f587fc
c418c43
bfa4adb
3a6967d
cdf5f36
f3dc29d
0ddc5ab
f6d6440
9aff9c2
1d46612
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
#include "bufferorch.h" | ||
#include "directory.h" | ||
#include "vnetorch.h" | ||
#include "exec.h" | ||
|
||
extern sai_object_id_t gVirtualRouterId; | ||
extern Directory<Orch*> gDirectory; | ||
|
@@ -38,6 +39,8 @@ const int intfsorch_pri = 35; | |
#define RIF_FLEX_STAT_COUNTER_POLL_MSECS "1000" | ||
#define UPDATE_MAPS_SEC 1 | ||
|
||
#define INBAND_INTF_TIMER_SEC 1 | ||
|
||
#define LOOPBACK_PREFIX "Loopback" | ||
|
||
static const vector<sai_router_interface_stat_t> rifStatIds = | ||
|
@@ -96,6 +99,15 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch) : | |
{ | ||
SWSS_LOG_WARN("RIF flex counter group plugins was not set successfully: %s", e.what()); | ||
} | ||
|
||
if (gMySwitchType == "voq") | ||
{ | ||
auto intervT = timespec { .tv_sec = INBAND_INTF_TIMER_SEC , .tv_nsec = 0 }; | ||
m_inbandVlanTimer = new SelectableTimer(intervT); | ||
auto executorInbandVlan = new ExecutableTimer(m_inbandVlanTimer, this, | ||
"INBAND_VLAN_TIMER"); | ||
Orch::addExecutor(executorInbandVlan); | ||
} | ||
} | ||
|
||
sai_object_id_t IntfsOrch::getRouterIntfsId(const string &alias) | ||
|
@@ -1250,6 +1262,11 @@ void IntfsOrch::doTask(SelectableTimer &timer) | |
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
if (m_inbandVlanTimer == &timer) | ||
{ | ||
return processInbandVlanReady(); | ||
} | ||
|
||
SWSS_LOG_DEBUG("Registering %" PRId64 " new intfs", m_rifsToAdd.size()); | ||
string value; | ||
for (auto it = m_rifsToAdd.begin(); it != m_rifsToAdd.end(); ) | ||
|
@@ -1286,3 +1303,36 @@ void IntfsOrch::doTask(SelectableTimer &timer) | |
} | ||
} | ||
} | ||
|
||
void IntfsOrch::processInbandVlanReady() | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
Port inbandVlan; | ||
if (!gPortsOrch->getInbandPort(inbandVlan)) | ||
{ | ||
return; | ||
} | ||
|
||
string value; | ||
const auto id = sai_serialize_object_id(inbandVlan.m_rif_id); | ||
if (m_vidToRidTable->hget("", id, value)) | ||
{ | ||
stringstream cmd; | ||
cmd << "ifconfig " << inbandVlan.m_alias << " " << m_inbandAddress.to_string() << " up"; | ||
|
||
std::string res; | ||
int ret = swss::exec(cmd.str(), res); | ||
if (ret) | ||
{ | ||
SWSS_LOG_ERROR("Command '%s' failed with rc %d", cmd.str().c_str(), ret); | ||
} | ||
else | ||
{ | ||
SWSS_LOG_NOTICE("Configured Ip on the inband vlan"); | ||
|
||
} | ||
|
||
m_inbandVlanTimer->stop(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to stop the timer when there is failure in bringing up inband vlan in the kernel? Will it be a good idea to leave the timer running for re-tries? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you are right. Fixed. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -428,6 +428,35 @@ void NeighOrch::doTask(Consumer &consumer) | |
|
||
IpAddress ip_address(key.substr(found+1)); | ||
|
||
/* The following change is based on the following PR: | ||
* https://github.com/Azure/sonic-swss/pull/1431 | ||
* | ||
* For inband Vlan, a kernel neigh is added for every remote neighbor | ||
* and the interface that the neigh is attached is inband Vlan. | ||
* neighsyncd adds the kernel neigh to neigh table in APPL_DB again. | ||
* The following change is to skip adding these remote neighbor attached | ||
* to inband Vlan. | ||
* | ||
* The collection m_remoteNeigh is added to track remote neighbor. It's | ||
* updated in the following method introduced in the above PR: | ||
* | ||
* doVoqSystemNeighTask() | ||
*/ | ||
if (gPortsOrch->isInbandPort(alias)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the comments. Whole part of this change should be merged with existing Inband port type handling. PR 1431 is merged. Please rebase and adjust the changes accordingly so that the comments can be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I will rebase and remove comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
{ | ||
Port ibport; | ||
gPortsOrch->getInbandPort(ibport); | ||
if(ibport.m_type == Port::VLAN) | ||
{ | ||
/* Only create neighbor attached to inband Vlan */ | ||
if (m_remoteNeigh.find(ip_address) != m_remoteNeigh.end()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can Inband Vlan have neighbors other than remote neighbors? If not, we do not need to have collecting remote neigh. Just checking the interface of the neigh itself is enough to skip (as it is done for the Inband port type). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. iBGP peer can be resolved over inband Vlan. This kind of inband vlan neighbor needs to be created. But remote neighbors can be skipped. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vganesan-nokia why same cannot happen with Inband port ? iBGP neighbor can happen on inband port also ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only neighbors that would be available on the inband port are the static neigbors we add for the remote neighbors (which should be skipped here since these are already added to SAI as part of doVoqSystemNeighTask()). Unlike inband vlan, inband port will not have any other neighbors. So no need to collect or verify whether the neihbor is remote or not. Just check the interface of the neighbor and if the interface is inband interface, skip the neighbor. For inband port except the ip address of inband port of my asic, all the iBGP neighbors (which are ip address of inband port of other asics) are remote neighbors. These are already programmed in SAI by doVoqSystemNeighTask() so we skip here. But inband vlan will have both the iBGP neighbors (resolved via ARP) which should be programmed here and remote neighbors which are added statically to inband vlan and SAI prgrammed in doVoqSystemNeighTask(). Therefore for inband vlan case, we need to indentify the remote neighbors and skip. |
||
{ | ||
it = consumer.m_toSync.erase(it); | ||
continue; | ||
} | ||
} | ||
} | ||
|
||
NeighborEntry neighbor_entry = { ip_address, alias }; | ||
|
||
if (op == SET_COMMAND) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3326,7 +3326,14 @@ bool PortsOrch::addHostIntfs(Port &port, string alias, sai_object_id_t &host_int | |
attrs.push_back(attr); | ||
|
||
attr.id = SAI_HOSTIF_ATTR_OBJ_ID; | ||
attr.value.oid = port.m_port_id; | ||
if (port.m_type == Port::VLAN) | ||
{ | ||
attr.value.oid = port.m_vlan_info.vlan_oid; | ||
} | ||
else | ||
{ | ||
attr.value.oid = port.m_port_id; | ||
} | ||
attrs.push_back(attr); | ||
|
||
attr.id = SAI_HOSTIF_ATTR_NAME; | ||
|
@@ -3378,7 +3385,13 @@ bool PortsOrch::addBridgePort(Port &port) | |
sai_attribute_t attr; | ||
vector<sai_attribute_t> attrs; | ||
|
||
if (port.m_type == Port::PHY) | ||
/* | ||
* Local and remote CPU ports need to be added to inband Vlan. | ||
* Port type and oid setting for these CPU ports are similar to PHY ports. | ||
*/ | ||
if (port.m_type == Port::PHY || | ||
port.m_type == Port::CPU || | ||
port.m_type == Port::SYSTEM) | ||
{ | ||
attr.id = SAI_BRIDGE_PORT_ATTR_TYPE; | ||
attr.value.s32 = SAI_BRIDGE_PORT_TYPE_PORT; | ||
|
@@ -3420,22 +3433,28 @@ bool PortsOrch::addBridgePort(Port &port) | |
} | ||
|
||
/* Create a bridge port with admin status set to UP */ | ||
attr.id = SAI_BRIDGE_PORT_ATTR_ADMIN_STATE; | ||
attr.value.booldata = true; | ||
attrs.push_back(attr); | ||
|
||
/* And with hardware FDB learning mode set to HW (explicit default value) */ | ||
attr.id = SAI_BRIDGE_PORT_ATTR_FDB_LEARNING_MODE; | ||
auto found = learn_mode_map.find(port.m_learn_mode); | ||
if (found == learn_mode_map.end()) | ||
if (port.m_type != Port::SYSTEM) | ||
{ | ||
attr.value.s32 = SAI_BRIDGE_PORT_FDB_LEARNING_MODE_HW; | ||
attr.id = SAI_BRIDGE_PORT_ATTR_ADMIN_STATE; | ||
attr.value.booldata = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why we skip this for system port ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both local and remote cpu ports need to be added into inband vlan. The port type of remote cpu ports is system port, and thus we have to add the check here to skip the processing that's not required for system port. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michaelli10 Can you help. We can add system port as part of Bridge. Can we set SAI_BRIDGE_PORT_ATTR_ADMIN_STATE for Remote Systrem Port and what does it mean ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abdosi SAI_BRIDGE_PORT_ATTR_ADMIN_STATE is not currently supported for remote system port. |
||
attrs.push_back(attr); | ||
Comment on lines
+4020
to
+4022
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part of the code can be moved in the if block at line 3444. The check for the port.m_type != Port::SYSTEM is in two places unnecessarily. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Will fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
} | ||
else | ||
|
||
/* And with hardware FDB learning mode set to HW (explicit default value) */ | ||
if (port.m_type != Port::SYSTEM) | ||
{ | ||
attr.value.s32 = found->second; | ||
attr.id = SAI_BRIDGE_PORT_ATTR_FDB_LEARNING_MODE; | ||
auto found = learn_mode_map.find(port.m_learn_mode); | ||
if (found == learn_mode_map.end()) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also any reason to skip this for system port ? code here is generic for add systemport as bridge port. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both local and remote cpu ports need to be added into inband vlan. The port type of remote cpu ports is system port, and thus we have to add the check here to skip the processing that's not required for system port. |
||
attr.value.s32 = SAI_BRIDGE_PORT_FDB_LEARNING_MODE_HW; | ||
} | ||
else | ||
{ | ||
attr.value.s32 = found->second; | ||
} | ||
attrs.push_back(attr); | ||
} | ||
attrs.push_back(attr); | ||
|
||
sai_status_t status = sai_bridge_api->create_bridge_port(&port.m_bridge_port_id, gSwitchId, (uint32_t)attrs.size(), attrs.data()); | ||
if (status != SAI_STATUS_SUCCESS) | ||
|
@@ -3445,7 +3464,8 @@ bool PortsOrch::addBridgePort(Port &port) | |
return false; | ||
} | ||
|
||
if (!setHostIntfsStripTag(port, SAI_HOSTIF_VLAN_TAG_KEEP)) | ||
if (port.m_type != Port::SYSTEM && | ||
!setHostIntfsStripTag(port, SAI_HOSTIF_VLAN_TAG_KEEP)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to set %s for hostif of port %s", | ||
hostif_vlan_tag[SAI_HOSTIF_VLAN_TAG_KEEP], port.m_alias.c_str()); | ||
|
@@ -4631,3 +4651,97 @@ bool PortsOrch::initGearboxPort(Port &port) | |
return true; | ||
} | ||
|
||
/* | ||
* The following method is called from setVoqInbandIntf() introduced in the following PR: | ||
* https://github.com/Azure/sonic-swss/pull/1431 | ||
*/ | ||
bool PortsOrch::addInbandVlan(const string &alias, const string &type) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the comments. PR 1431 is merged. setVoqInbandIntf() can be modified to call this api if the inband type is "vlan". Please rebase and modify setVoqInbandIntf() to make this complete and the comments can be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I will rebase and remove the comment. |
||
{ | ||
if (m_inbandPortName == alias) | ||
{ | ||
/* Inband vlan already exists with this name */ | ||
SWSS_LOG_WARN("Interface %s is already configured as inband!", alias.c_str()); | ||
return true; | ||
} | ||
|
||
if (type != "vlan") | ||
{ | ||
SWSS_LOG_WARN("Inband type %s is not vlan.", type.c_str()); | ||
return false; | ||
} | ||
|
||
/* Create inband Vlan and also local and remote CPU ports to inband Vlan */ | ||
|
||
Port cpuPort; | ||
Port inbandVlan; | ||
string tagged_mode("tagged"); | ||
|
||
if (!addVlan(alias)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to add inband VLAN %s", alias.c_str()); | ||
return false; | ||
} | ||
|
||
if (!getPort(alias, inbandVlan)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to get port object of inband VLAN %s", alias.c_str()); | ||
return false; | ||
} | ||
Comment on lines
+5767
to
+5777
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we not do this vlan addition processing via vlan configuration by having entry in VLAN table in config_db? So that this will be similar to inband port type. For port type, the VOQ_INBAND_INTERFACE configuration is just to designate a port or vlan for interface for cpu-to-cpu communication. We actually do not configure the port or vlan itself. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We thought about this too. But inband VLAN is not exactly the same as regular SONiC VLANs. For example, the inband VLAN members are cpu ports, which do not have host intfs being created today. Therefore, inband VLAN processing is different from VLAN processing. |
||
|
||
getCpuPort(cpuPort); | ||
|
||
if (!addBridgePort(cpuPort)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to add CPU port %s as bridge port", cpuPort.m_alias.c_str()); | ||
return false; | ||
} | ||
|
||
if (!addVlanMember(inbandVlan, cpuPort, tagged_mode)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to add CPU port %s in inband VLAN", cpuPort.m_alias.c_str()); | ||
return false; | ||
} | ||
|
||
SWSS_LOG_NOTICE("add port %s to inbandVlan %s", cpuPort.m_alias.c_str(), inbandVlan.m_alias.c_str()); | ||
|
||
if (!addHostIntfs(inbandVlan, inbandVlan.m_alias, inbandVlan.m_hif_id)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to add host intf for inband VLAN"); | ||
return false; | ||
} | ||
|
||
if (!setHostIntfsOperStatus(inbandVlan, true)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to set host intf oper status for inband VLAN"); | ||
return false; | ||
} | ||
|
||
for (auto &it: m_portList) | ||
{ | ||
Port port = it.second; | ||
if (port.m_type != Port::SYSTEM || | ||
port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_LOCAL || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can local cpu port be covered in this same loop ? basically this will make code common w.r.t API addBridgePort() and addVlanMemeber() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good point. I will try to see if I can move local cpu port processing into the for loop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed as what you suggested. |
||
port.m_alias.find("Cpu") == string::npos) | ||
{ | ||
continue; | ||
} | ||
|
||
if (!addBridgePort(port)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to add port %s as bridge port", port.m_alias.c_str()); | ||
continue; | ||
} | ||
|
||
if (!addVlanMember(inbandVlan, port, tagged_mode)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to add port %s in inband VLAN", port.m_alias.c_str()); | ||
continue; | ||
} | ||
|
||
SWSS_LOG_NOTICE("add sysport %s to inbandVlan %s", port.m_alias.c_str(), inbandVlan.m_alias.c_str()); | ||
} | ||
|
||
m_inbandPortName = alias; | ||
|
||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need timer ? Can you point to design doc that cover this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since SAI create call is not synchronized, we cannot bring up inband vlan in kernel immediately after creating inband vlan with SAI call. We use this timer to periodically check if it's ready to bring up inband vlan in kernel or not. The timer is stopped once inband vlan is brought up in kernel successfully. I think this is implementation details, and thus is not covered in HLD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ysmanman how is this different w.r.t Regular VLAN IP Interface ? We don;t need timer there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abdosi There are few differences between regular Vlan and Inban Vlan: 0) The members of Inband Vlan are local and remote CPU ports, which don't have kernel devices created today. 1) Inband Vlan is a static configuration and imembership is unlikely user configurable. These are the main reasons that Inband Vlan was implemented different from regular Vlans and therefore we added the timer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sai call is synchronized now starting from 202012 release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lguohan thanks for the comment. I removed the inband vlan timer since sai call is synchronized now.