Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
venkatmahalingam committed Apr 26, 2021
2 parents fce65a7 + d9f28b6 commit d106b4c
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 8 deletions.
17 changes: 13 additions & 4 deletions cfgmgr/sflowmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,26 @@ void SflowMgr::sflowUpdatePortInfo(Consumer &consumer)
port_info.admin = "";
m_sflowPortConfMap[key] = port_info;
}

bool speed_change = false;
string new_speed = SFLOW_ERROR_SPEED_STR;
for (auto i : values)
{
if (fvField(i) == "speed")
{
m_sflowPortConfMap[key].speed = fvValue(i);
new_speed = fvValue(i);
}
}
if (m_sflowPortConfMap[key].speed != new_speed)
{
m_sflowPortConfMap[key].speed = new_speed;
speed_change = true;
}

if (new_port)
if (m_gEnable && m_intfAllConf)
{
if (m_gEnable && m_intfAllConf)
// If the Local Conf is already present, dont't override it even though the speed is changed
if (new_port || (speed_change && !m_sflowPortConfMap[key].local_conf))
{
vector<FieldValueTuple> fvs;
sflowGetGlobalInfo(fvs, m_sflowPortConfMap[key].speed);
Expand Down Expand Up @@ -171,7 +180,7 @@ void SflowMgr::sflowGetGlobalInfo(vector<FieldValueTuple> &fvs, string speed)
FieldValueTuple fv1("admin_state", "up");
fvs.push_back(fv1);

if (speed != SFLOW_ERROR_SPEED_STR)
if (speed != SFLOW_ERROR_SPEED_STR && sflowSpeedRateInitMap.find(speed) != sflowSpeedRateInitMap.end())
{
rate = sflowSpeedRateInitMap[speed];
}
Expand Down
4 changes: 2 additions & 2 deletions cfgmgr/vlanmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ void VlanMgr::doVlanTask(Consumer &consumer)
mac = fvValue(i);
setHostVlanMac(vlan_id, mac);
}
else if (fvField(i) == "hostif_name")
else if (fvField(i) == "host_ifname")
{
hostif_name = fvValue(i);
}
Expand All @@ -381,7 +381,7 @@ void VlanMgr::doVlanTask(Consumer &consumer)
FieldValueTuple mc("mac", mac);
fvVector.push_back(mc);

FieldValueTuple hostif_name_fvt("hostif_name", hostif_name);
FieldValueTuple hostif_name_fvt("host_ifname", hostif_name);
fvVector.push_back(hostif_name_fvt);

m_appVlanTableProducer.set(key, fvVector);
Expand Down
10 changes: 10 additions & 0 deletions orchagent/macsecorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,11 @@ bool MACsecOrch::initMACsecObject(sai_object_id_t switch_id)
attr.id = SAI_MACSEC_ATTR_DIRECTION;
attr.value.s32 = SAI_MACSEC_DIRECTION_EGRESS;
attrs.push_back(attr);

attr.id = SAI_MACSEC_ATTR_PHYSICAL_BYPASS_ENABLE;
attr.value.booldata = true;
attrs.push_back(attr);

sai_status_t status = sai_macsec_api->create_macsec(
&macsec_obj.first->second.m_egress_id,
switch_id,
Expand All @@ -809,6 +814,11 @@ bool MACsecOrch::initMACsecObject(sai_object_id_t switch_id)
attr.id = SAI_MACSEC_ATTR_DIRECTION;
attr.value.s32 = SAI_MACSEC_DIRECTION_INGRESS;
attrs.push_back(attr);

attr.id = SAI_MACSEC_ATTR_PHYSICAL_BYPASS_ENABLE;
attr.value.booldata = true;
attrs.push_back(attr);

status = sai_macsec_api->create_macsec(
&macsec_obj.first->second.m_ingress_id,
switch_id,
Expand Down
2 changes: 1 addition & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2934,7 +2934,7 @@ void PortsOrch::doVlanTask(Consumer &consumer)
{
mac = MacAddress(fvValue(i));
}
if (fvField(i) == "hostif_name")
if (fvField(i) == "host_ifname")
{
hostif_name = fvValue(i);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/dvslib/dvs_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create_vlan(self, vlan):

def create_vlan_hostif(self, vlan, hostif_name):
vlan = "Vlan{}".format(vlan)
vlan_entry = {"vlanid": vlan, "hostif_name": hostif_name}
vlan_entry = {"vlanid": vlan, "host_ifname": hostif_name}
self.config_db.update_entry("VLAN", vlan, vlan_entry)

def remove_vlan(self, vlan):
Expand Down
44 changes: 44 additions & 0 deletions tests/test_sflow.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import time

class TestSflow:
speed_rate_table = {
"400000": "400000",
Expand Down Expand Up @@ -131,6 +133,48 @@ def test_ConfigDel(self, dvs, testlog):

expected_fields = {"SAI_SAMPLEPACKET_ATTR_SAMPLE_RATE": rate}
self.adb.wait_for_field_match("ASIC_STATE:SAI_OBJECT_TYPE_SAMPLEPACKET", sample_session, expected_fields)

def test_SamplingRatePortCfgUpdate(self, dvs, testlog):
'''
This test checks if the SflowMgr updates the sampling rate
1) When the Speed is Updated on the port and no local configuration has been given on the port
Eg:
config sflow enable
config interface speed Ethernet0 25000 (Let's suppose Original Speed for Ethernet0 is 100G)
show sflow interface | grep Ethernet0 (Should see a sampling rate of 25000 not 100000)
'''
self.setup_sflow(dvs)
appldb = dvs.get_app_db()
#dvs.runcmd("portconfig -p {} -s {}".format("Ethernet0", "25000"))
self.cdb.update_entry("PORT", "Ethernet0", {'speed' : "25000"})
expected_fields = {"sample_rate": self.speed_rate_table["25000"]}
appldb.wait_for_field_match("SFLOW_SESSION_TABLE", "Ethernet0", expected_fields)


def test_SamplingRateManualUpdate(self, dvs, testlog):
'''
This test checks if the SflowMgr updates the sampling rate
1) When the Cfg Sflow Table is updated with sampling rate by the user, this rate should not be impacted by Port Speed Changes
Eg:
config sflow enable
config sflow interface sample-rate Ethernet4 256
config interface Ethernet0 speed 25000 (Original Speed for Ethernet0 is 100G)
show sflow interface | grep Ethernet0 (Should see a sampling rate of 256 not 100000 or 25000
'''
self.setup_sflow(dvs)
appldb = dvs.get_app_db()

session_params = {"admin_state": "up", "sample_rate": "256"}
self.cdb.create_entry("SFLOW_SESSION", "Ethernet4", session_params)
self.cdb.wait_for_field_match("SFLOW_SESSION", "Ethernet4", session_params)
appldb.wait_for_field_match("SFLOW_SESSION_TABLE", "Ethernet4", {"sample_rate": "256"})

self.cdb.update_entry("PORT", "Ethernet4", {'speed' : "25000"})
# The Check here is about the original value not getting changed.
# If some bug was to appear, let's give it some time to get noticed
time.sleep(1)
appldb.wait_for_field_match("SFLOW_SESSION_TABLE", "Ethernet4", {"sample_rate": "256"})


def test_Teardown(self, dvs, testlog):
self.setup_sflow(dvs)
Expand Down

0 comments on commit d106b4c

Please sign in to comment.