Skip to content

Commit cfacf2e

Browse files
authored
Merge branch 'master' into fpmMpls.azpInstall
2 parents 1887857 + 12f0ee7 commit cfacf2e

14 files changed

+213
-96
lines changed

.azure-pipelines/build-template.yml

+20-21
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
source: specific
7373
project: build
7474
pipeline: 9
75-
artifacts: ${{ parameters.swss_common_artifact_name }}
75+
artifact: ${{ parameters.swss_common_artifact_name }}
7676
runVersion: 'latestFromBranch'
7777
runBranch: 'refs/heads/master'
7878
displayName: "Download sonic swss common deb packages"
@@ -81,7 +81,7 @@ jobs:
8181
source: specific
8282
project: build
8383
pipeline: 12
84-
artifacts: ${{ parameters.sairedis_artifact_name }}
84+
artifact: ${{ parameters.sairedis_artifact_name }}
8585
runVersion: 'latestFromBranch'
8686
runBranch: 'refs/heads/master'
8787
displayName: "Download sonic sairedis deb packages"
@@ -90,29 +90,28 @@ jobs:
9090
source: specific
9191
project: build
9292
pipeline: ${{ parameters.buildimage_pipeline }}
93-
artifacts: ${{ parameters.buildimage_artifact_name }}
93+
artifact: ${{ parameters.buildimage_artifact_name }}
9494
runVersion: 'latestFromBranch'
9595
runBranch: 'refs/heads/master'
9696
displayName: "Download sonic buildimage deb packages"
9797
- script: |
98-
ls -l
99-
sudo dpkg -i ${{ parameters.buildimage_artifact_name }}/target/debs/buster/libnl-3-200_*.deb
100-
sudo dpkg -i ${{ parameters.buildimage_artifact_name }}/target/debs/buster/libnl-3-dev_*.deb
101-
sudo dpkg -i ${{ parameters.buildimage_artifact_name }}/target/debs/buster/libnl-genl-3-200_*.deb
102-
sudo dpkg -i ${{ parameters.buildimage_artifact_name }}/target/debs/buster/libnl-genl-3-dev_*.deb
103-
sudo dpkg -i ${{ parameters.buildimage_artifact_name }}/target/debs/buster/libnl-route-3-200_*.deb
104-
sudo dpkg -i ${{ parameters.buildimage_artifact_name }}/target/debs/buster/libnl-route-3-dev_*.deb
105-
sudo dpkg -i ${{ parameters.buildimage_artifact_name }}/target/debs/buster/libnl-nf-3-200_*.deb
106-
sudo dpkg -i ${{ parameters.buildimage_artifact_name }}/target/debs/buster/libnl-nf-3-dev_*.deb
107-
sudo dpkg -i ${{ parameters.swss_common_artifact_name }}/libswsscommon_1.0.0_${{ parameters.arch }}.deb
108-
sudo dpkg -i ${{ parameters.swss_common_artifact_name }}/libswsscommon-dev_1.0.0_${{ parameters.arch }}.deb
109-
sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/libsaivs_*.deb
110-
sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/libsaivs-dev_*.deb
111-
sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/libsairedis_*.deb
112-
sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/libsairedis-dev_*.deb
113-
sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/libsaimetadata_*.deb
114-
sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/libsaimetadata-dev_*.deb
115-
sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/syncd-vs_*.deb
98+
sudo dpkg -i target/debs/buster/libnl-3-200_*.deb
99+
sudo dpkg -i target/debs/buster/libnl-3-dev_*.deb
100+
sudo dpkg -i target/debs/buster/libnl-genl-3-200_*.deb
101+
sudo dpkg -i target/debs/buster/libnl-genl-3-dev_*.deb
102+
sudo dpkg -i target/debs/buster/libnl-route-3-200_*.deb
103+
sudo dpkg -i target/debs/buster/libnl-route-3-dev_*.deb
104+
sudo dpkg -i target/debs/buster/libnl-nf-3-200_*.deb
105+
sudo dpkg -i target/debs/buster/libnl-nf-3-dev_*.deb
106+
sudo dpkg -i libswsscommon_1.0.0_${{ parameters.arch }}.deb
107+
sudo dpkg -i libswsscommon-dev_1.0.0_${{ parameters.arch }}.deb
108+
sudo dpkg -i libsaivs_*.deb
109+
sudo dpkg -i libsaivs-dev_*.deb
110+
sudo dpkg -i libsairedis_*.deb
111+
sudo dpkg -i libsairedis-dev_*.deb
112+
sudo dpkg -i libsaimetadata_*.deb
113+
sudo dpkg -i libsaimetadata-dev_*.deb
114+
sudo dpkg -i syncd-vs_*.deb
116115
workingDirectory: $(Pipeline.Workspace)
117116
displayName: "Install libnl3, sonic swss common and sairedis"
118117
- checkout: self

cfgmgr/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ INCLUDES = -I$(top_srcdir)/lib -I $(top_srcdir) -I $(top_srcdir)/orchagent -I $(
22
CFLAGS_SAI = -I /usr/include/sai
33
LIBNL_CFLAGS = -I/usr/include/libnl3
44
LIBNL_LIBS = -lnl-genl-3 -lnl-route-3 -lnl-3
5-
SAIMETA_LIBS = -lsaimeta -lsaimetadata
5+
SAIMETA_LIBS = -lsaimeta -lsaimetadata -lzmq
66
COMMON_LIBS = -lswsscommon
77

88
bin_PROGRAMS = vlanmgrd teammgrd portmgrd intfmgrd buffermgrd vrfmgrd nbrmgrd vxlanmgrd sflowmgrd natmgrd coppmgrd tunnelmgrd macsecmgrd

cfgmgr/macsecmgr.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,32 @@ static void lexical_convert(const std::string &policy_str, MACsecMgr::MACsecProf
5252
}
5353
}
5454

55+
static void lexical_convert(const std::string &cipher_str, MACsecMgr::MACsecProfile::CipherSuite & cipher_suite)
56+
{
57+
SWSS_LOG_ENTER();
58+
59+
if (boost::iequals(cipher_str, "GCM-AES-128"))
60+
{
61+
cipher_suite = MACsecMgr::MACsecProfile::CipherSuite::GCM_AES_128;
62+
}
63+
else if (boost::iequals(cipher_str, "GCM-AES-256"))
64+
{
65+
cipher_suite = MACsecMgr::MACsecProfile::CipherSuite::GCM_AES_256;
66+
}
67+
else if (boost::iequals(cipher_str, "GCM-AES-XPN-128"))
68+
{
69+
cipher_suite = MACsecMgr::MACsecProfile::CipherSuite::GCM_AES_XPN_128;
70+
}
71+
else if (boost::iequals(cipher_str, "GCM-AES-XPN-256"))
72+
{
73+
cipher_suite = MACsecMgr::MACsecProfile::CipherSuite::GCM_AES_XPN_256;
74+
}
75+
else
76+
{
77+
throw std::invalid_argument("Invalid cipher_suite : " + cipher_str);
78+
}
79+
}
80+
5581
template<class T>
5682
static bool get_value(
5783
const MACsecMgr::TaskArgs & ta,
@@ -686,6 +712,20 @@ bool MACsecMgr::configureMACsec(
686712
"mka_priority",
687713
profile.priority);
688714

715+
wpa_cli_exec_and_check(
716+
session.sock,
717+
port_name,
718+
network_id,
719+
"macsec_ciphersuite",
720+
profile.cipher_suite);
721+
722+
wpa_cli_exec_and_check(
723+
session.sock,
724+
port_name,
725+
network_id,
726+
"macsec_include_sci",
727+
(profile.send_sci ? 1 : 0));
728+
689729
wpa_cli_exec_and_check(
690730
session.sock,
691731
port_name,

cfgmgr/macsecmgr.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ class MACsecMgr : public Orch
2828
struct MACsecProfile
2929
{
3030
std::uint32_t priority;
31-
std::string cipher_suite;
31+
enum CipherSuite
32+
{
33+
GCM_AES_128,
34+
GCM_AES_256,
35+
GCM_AES_XPN_128,
36+
GCM_AES_XPN_256,
37+
} cipher_suite;
3238
std::string primary_cak;
3339
std::string primary_ckn;
3440
std::string fallback_cak;

orchagent/aclorch.cpp

+47-13
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ extern CrmOrch *gCrmOrch;
3535
#define MIN_VLAN_ID 1 // 0 is a reserved VLAN ID
3636
#define MAX_VLAN_ID 4095 // 4096 is a reserved VLAN ID
3737

38+
const int TCP_PROTOCOL_NUM = 6; // TCP protocol number
39+
3840
acl_rule_attr_lookup_t aclMatchLookup =
3941
{
4042
{ MATCH_IN_PORTS, SAI_ACL_ENTRY_ATTR_FIELD_IN_PORTS },
@@ -645,7 +647,7 @@ void AclRule::updateInPorts()
645647
attr.id = SAI_ACL_ENTRY_ATTR_FIELD_IN_PORTS;
646648
attr.value = m_matches[SAI_ACL_ENTRY_ATTR_FIELD_IN_PORTS];
647649
attr.value.aclfield.enable = true;
648-
650+
649651
status = sai_acl_api->set_acl_entry_attribute(m_ruleOid, &attr);
650652
if (status != SAI_STATUS_SUCCESS)
651653
{
@@ -1378,14 +1380,14 @@ bool AclTable::create()
13781380
attr.id = SAI_ACL_TABLE_ATTR_ACL_STAGE;
13791381
attr.value.s32 = (stage == ACL_STAGE_INGRESS) ? SAI_ACL_STAGE_INGRESS : SAI_ACL_STAGE_EGRESS;
13801382
table_attrs.push_back(attr);
1381-
1383+
13821384
if (stage == ACL_STAGE_INGRESS)
13831385
{
13841386
attr.id = SAI_ACL_TABLE_ATTR_FIELD_IN_PORTS;
13851387
attr.value.booldata = true;
13861388
table_attrs.push_back(attr);
13871389
}
1388-
1390+
13891391
sai_status_t status = sai_acl_api->create_acl_table(&m_oid, gSwitchId, (uint32_t)table_attrs.size(), table_attrs.data());
13901392

13911393
if (status == SAI_STATUS_SUCCESS)
@@ -2985,11 +2987,11 @@ AclRule* AclOrch::getAclRule(string table_id, string rule_id)
29852987
bool AclOrch::updateAclRule(string table_id, string rule_id, string attr_name, void *data, bool oper)
29862988
{
29872989
SWSS_LOG_ENTER();
2988-
2990+
29892991
sai_object_id_t table_oid = getTableById(table_id);
29902992
string attr_value;
29912993

2992-
if (table_oid == SAI_NULL_OBJECT_ID)
2994+
if (table_oid == SAI_NULL_OBJECT_ID)
29932995
{
29942996
SWSS_LOG_ERROR("Failed to update ACL rule in ACL table %s. Table doesn't exist", table_id.c_str());
29952997
return false;
@@ -3002,29 +3004,29 @@ bool AclOrch::updateAclRule(string table_id, string rule_id, string attr_name, v
30023004
return false;
30033005
}
30043006

3005-
switch (aclMatchLookup[attr_name])
3007+
switch (aclMatchLookup[attr_name])
30063008
{
30073009
case SAI_ACL_ENTRY_ATTR_FIELD_IN_PORTS:
30083010
{
30093011
sai_object_id_t port_oid = *(sai_object_id_t *)data;
30103012
vector<sai_object_id_t> in_ports = rule_it->second->getInPorts();
30113013

3012-
if (oper == RULE_OPER_ADD)
3014+
if (oper == RULE_OPER_ADD)
30133015
{
30143016
in_ports.push_back(port_oid);
3015-
}
3016-
else
3017+
}
3018+
else
30173019
{
30183020
for (auto port_iter = in_ports.begin(); port_iter != in_ports.end(); port_iter++)
30193021
{
3020-
if (*port_iter == port_oid)
3022+
if (*port_iter == port_oid)
30213023
{
30223024
in_ports.erase(port_iter);
30233025
break;
30243026
}
30253027
}
30263028
}
3027-
3029+
30283030
for (const auto& port_iter: in_ports)
30293031
{
30303032
Port p;
@@ -3277,14 +3279,22 @@ void AclOrch::doAclRuleTask(Consumer &consumer)
32773279
it = consumer.m_toSync.erase(it);
32783280
return;
32793281
}
3280-
3282+
bool bHasTCPFlag = false;
3283+
bool bHasIPProtocol = false;
32813284
for (const auto& itr : kfvFieldsValues(t))
32823285
{
32833286
string attr_name = to_upper(fvField(itr));
32843287
string attr_value = fvValue(itr);
32853288

32863289
SWSS_LOG_INFO("ATTRIBUTE: %s %s", attr_name.c_str(), attr_value.c_str());
3287-
3290+
if (attr_name == MATCH_TCP_FLAGS)
3291+
{
3292+
bHasTCPFlag = true;
3293+
}
3294+
if (attr_name == MATCH_IP_PROTOCOL || attr_name == MATCH_NEXT_HEADER)
3295+
{
3296+
bHasIPProtocol = true;
3297+
}
32883298
if (newRule->validateAddPriority(attr_name, attr_value))
32893299
{
32903300
SWSS_LOG_INFO("Added priority attribute");
@@ -3304,6 +3314,30 @@ void AclOrch::doAclRuleTask(Consumer &consumer)
33043314
break;
33053315
}
33063316
}
3317+
// If acl rule is to match TCP_FLAGS, and IP_PROTOCOL(NEXT_HEADER) is not set
3318+
// we set IP_PROTOCOL(NEXT_HEADER) to 6 to match TCP explicitly
3319+
if (bHasTCPFlag && !bHasIPProtocol)
3320+
{
3321+
string attr_name;
3322+
if (type == ACL_TABLE_MIRRORV6 || type == ACL_TABLE_L3V6)
3323+
{
3324+
attr_name = MATCH_NEXT_HEADER;
3325+
}
3326+
else
3327+
{
3328+
attr_name = MATCH_IP_PROTOCOL;
3329+
3330+
}
3331+
string attr_value = std::to_string(TCP_PROTOCOL_NUM);
3332+
if (newRule->validateAddMatch(attr_name, attr_value))
3333+
{
3334+
SWSS_LOG_INFO("Automatically added match attribute '%s : %s'", attr_name.c_str(), attr_value.c_str());
3335+
}
3336+
else
3337+
{
3338+
SWSS_LOG_ERROR("Failed to add attribute '%s : %s'", attr_name.c_str(), attr_value.c_str());
3339+
}
3340+
}
33073341

33083342
// validate and create ACL rule
33093343
if (bAllAttributesOk && newRule->validate())

orchagent/fdborch.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1271,8 +1271,8 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
12711271

12721272
attrs.push_back(attr);
12731273

1274-
if ((fdbData.origin == FDB_ORIGIN_VXLAN_ADVERTIZED) || (fdbData.origin == FDB_ORIGIN_MCLAG_ADVERTIZED)
1275-
|| (fdbData.type == "dynamic"))
1274+
if (((fdbData.origin == FDB_ORIGIN_VXLAN_ADVERTIZED) || (fdbData.origin == FDB_ORIGIN_MCLAG_ADVERTIZED))
1275+
&& (fdbData.type == "dynamic"))
12761276
{
12771277
attr.id = SAI_FDB_ENTRY_ATTR_ALLOW_MAC_MOVE;
12781278
attr.value.booldata = true;

orchagent/macsecorch.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class MACsecOrchContext
219219

220220
sai_object_id_t *get_port_id()
221221
{
222-
if(m_port_id == nullptr)
222+
if (m_port_id == nullptr)
223223
{
224224
auto port = get_port();
225225
if (port == nullptr)
@@ -2231,7 +2231,9 @@ bool MACsecOrch::createMACsecACLDataEntry(
22312231
if (sci_in_sectag)
22322232
{
22332233
attr.id = SAI_ACL_ENTRY_ATTR_FIELD_MACSEC_SCI;
2234-
attr.value.u64 = sci;
2234+
attr.value.aclfield.enable = true;
2235+
attr.value.aclfield.mask.u64 = 0xFFFFFFFFFFFFFFFF;
2236+
attr.value.aclfield.data.u64 = sci;
22352237
attrs.push_back(attr);
22362238
}
22372239

orchagent/port_rates.lua

+12-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local function logit(msg)
1111
end
1212

1313
local counters_db = ARGV[1]
14-
local counters_table_name = ARGV[2]
14+
local counters_table_name = ARGV[2]
1515
local rates_table_name = "RATES"
1616

1717
-- Get configuration
@@ -51,7 +51,7 @@ for i = 1, n do
5151
local out_non_ucast_pkts_last = redis.call('HGET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS_last')
5252
local in_octets_last = redis.call('HGET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_IN_OCTETS_last')
5353
local out_octets_last = redis.call('HGET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_OUT_OCTETS_last')
54-
54+
5555
-- Calculate new rates values
5656
local rx_bps_new = (in_octets - in_octets_last)/delta
5757
local tx_bps_new = (out_octets - out_octets_last)/delta
@@ -69,25 +69,26 @@ for i = 1, n do
6969
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'RX_BPS', alpha*rx_bps_new + one_minus_alpha*rx_bps_old)
7070
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'RX_PPS', alpha*rx_pps_new + one_minus_alpha*rx_pps_old)
7171
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'TX_BPS', alpha*tx_bps_new + one_minus_alpha*tx_bps_old)
72-
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'TX_PPS', alpha*tx_pps_new + one_minus_alpha*tx_pps_old)
72+
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'TX_PPS', alpha*tx_pps_new + one_minus_alpha*tx_pps_old)
7373
else
7474
-- Store unsmoothed initial rates values in DB
7575
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'RX_BPS', rx_bps_new)
7676
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'RX_PPS', rx_pps_new)
7777
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'TX_BPS', tx_bps_new)
7878
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'TX_PPS', tx_pps_new)
7979
redis.call('HSET', state_table, 'INIT_DONE', 'DONE')
80-
end
80+
end
8181
else
82-
-- Set old COUNTERS values
83-
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_IN_UCAST_PKTS_last', in_ucast_pkts)
84-
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS_last', in_non_ucast_pkts)
85-
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_OUT_UCAST_PKTS_last', out_ucast_pkts)
86-
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS_last', out_non_ucast_pkts)
87-
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_IN_OCTETS_last', in_octets)
88-
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_OUT_OCTETS_last', out_octets)
8982
redis.call('HSET', state_table, 'INIT_DONE', 'COUNTERS_LAST')
9083
end
84+
85+
-- Set old COUNTERS values
86+
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_IN_UCAST_PKTS_last', in_ucast_pkts)
87+
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS_last', in_non_ucast_pkts)
88+
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_OUT_UCAST_PKTS_last', out_ucast_pkts)
89+
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS_last', out_non_ucast_pkts)
90+
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_IN_OCTETS_last', in_octets)
91+
redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_OUT_OCTETS_last', out_octets)
9192
end
9293

9394
return logtable

0 commit comments

Comments
 (0)