Skip to content

Commit

Permalink
Merge branch 'master' into multi-nexthop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndancejic authored Mar 7, 2023
2 parents 4c8c0ef + a2c9a61 commit 02f452f
Show file tree
Hide file tree
Showing 40 changed files with 1,314 additions and 174 deletions.
1 change: 1 addition & 0 deletions .azure-pipelines/build-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
clean: true
submodules: true
- script: |
sudo apt-get update
sudo apt-get install -y libhiredis0.14 libhiredis-dev
sudo apt-get install -y libzmq5 libzmq3-dev
sudo apt-get install -qq -y \
Expand Down
1 change: 1 addition & 0 deletions doc/swss-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ and reflects the LAG ports into the redis under: `LAG_TABLE:<team0>:port`
key = ROUTE_TABLE:segment ; SRV6 segment name
; field = value
path = STRING ; Comma-separated list of IPV6 prefixes for a SRV6 segment
type = STRING ; SRV6 segment list type like "insert", "encaps.red"; If not provided, default type will be "encaps.red"

---------------------------------------------
### SRV6_MY_SID_TABLE
Expand Down
1 change: 1 addition & 0 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3188,6 +3188,7 @@ void AclOrch::initDefaultTableTypes()
builder.withName(TABLE_TYPE_DROP)
.withBindPointType(SAI_ACL_BIND_POINT_TYPE_PORT)
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_TC))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_IN_PORTS))
.build()
);

Expand Down
1 change: 1 addition & 0 deletions orchagent/aclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@

#define MLNX_MAX_RANGES_COUNT 16
#define INGRESS_TABLE_DROP "IngressTableDrop"
#define EGRESS_TABLE_DROP "EgressTableDrop"
#define RULE_OPER_ADD 0
#define RULE_OPER_DELETE 1

Expand Down
11 changes: 11 additions & 0 deletions orchagent/bfdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ using namespace swss;
#define BFD_SESSION_DEFAULT_TX_INTERVAL 1000
#define BFD_SESSION_DEFAULT_RX_INTERVAL 1000
#define BFD_SESSION_DEFAULT_DETECT_MULTIPLIER 10
// TOS: default 6-bit DSCP value 48, default 2-bit ecn value 0. 48<<2 = 192
#define BFD_SESSION_DEFAULT_TOS 192
#define BFD_SESSION_MILLISECOND_TO_MICROSECOND 1000
#define BFD_SRCPORTINIT 49152
#define BFD_SRCPORTMAX 65536
Expand Down Expand Up @@ -243,6 +245,7 @@ bool BfdOrch::create_bfd_session(const string& key, const vector<FieldValueTuple
uint32_t tx_interval = BFD_SESSION_DEFAULT_TX_INTERVAL;
uint32_t rx_interval = BFD_SESSION_DEFAULT_RX_INTERVAL;
uint8_t multiplier = BFD_SESSION_DEFAULT_DETECT_MULTIPLIER;
uint8_t tos = BFD_SESSION_DEFAULT_TOS;
bool multihop = false;
MacAddress dst_mac;
bool dst_mac_provided = false;
Expand Down Expand Up @@ -291,6 +294,10 @@ bool BfdOrch::create_bfd_session(const string& key, const vector<FieldValueTuple
dst_mac = MacAddress(value);
dst_mac_provided = true;
}
else if (fvField(i) == "tos")
{
tos = to_uint<uint8_t>(value);
}
else
SWSS_LOG_ERROR("Unsupported BFD attribute %s\n", fvField(i).c_str());
}
Expand Down Expand Up @@ -352,6 +359,10 @@ bool BfdOrch::create_bfd_session(const string& key, const vector<FieldValueTuple
attrs.emplace_back(attr);
fvVector.emplace_back("multiplier", to_string(multiplier));

attr.id = SAI_BFD_SESSION_ATTR_TOS;
attr.value.u8 = tos;
attrs.emplace_back(attr);

if (multihop)
{
attr.id = SAI_BFD_SESSION_ATTR_MULTIHOP;
Expand Down
64 changes: 35 additions & 29 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ bool FdbOrch::storeFdbEntryState(const FdbUpdate& update)

fdbdata.bridge_port_id = update.port.m_bridge_port_id;
fdbdata.type = update.type;
fdbdata.sai_fdb_type = update.sai_fdb_type;
fdbdata.origin = FDB_ORIGIN_LEARN;
fdbdata.remote_ip = "";
fdbdata.esi = "";
Expand Down Expand Up @@ -206,20 +207,19 @@ Handles the SAI_FDB_EVENT_FLUSHED notification recieved from syncd
*/
void FdbOrch::handleSyncdFlushNotif(const sai_object_id_t& bv_id,
const sai_object_id_t& bridge_port_id,
const MacAddress& mac)
const MacAddress& mac,
const sai_fdb_entry_type_t& sai_fdb_type)
{
// Consolidated flush will have a zero mac
MacAddress flush_mac("00:00:00:00:00:00");

/* TODO: Read the SAI_FDB_FLUSH_ATTR_ENTRY_TYPE attr from the flush notif
and clear the entries accordingly, currently only non-static entries are flushed
*/
if (bridge_port_id == SAI_NULL_OBJECT_ID && bv_id == SAI_NULL_OBJECT_ID)
{
for (auto itr = m_entries.begin(); itr != m_entries.end();)
{
auto curr = itr++;
if (curr->second.type != "static" && (curr->first.mac == mac || mac == flush_mac) && curr->second.is_flush_pending)
if (curr->second.sai_fdb_type == sai_fdb_type &&
(curr->first.mac == mac || mac == flush_mac) && curr->second.is_flush_pending)
{
clearFdbEntry(curr->first);
}
Expand All @@ -233,7 +233,8 @@ void FdbOrch::handleSyncdFlushNotif(const sai_object_id_t& bv_id,
auto curr = itr++;
if (curr->second.bridge_port_id == bridge_port_id)
{
if (curr->second.type != "static" && (curr->first.mac == mac || mac == flush_mac) && curr->second.is_flush_pending)
if (curr->second.sai_fdb_type == sai_fdb_type &&
(curr->first.mac == mac || mac == flush_mac) && curr->second.is_flush_pending)
{
clearFdbEntry(curr->first);
}
Expand All @@ -248,7 +249,8 @@ void FdbOrch::handleSyncdFlushNotif(const sai_object_id_t& bv_id,
auto curr = itr++;
if (curr->first.bv_id == bv_id)
{
if (curr->second.type != "static" && (curr->first.mac == mac || mac == flush_mac) && curr->second.is_flush_pending)
if (curr->second.sai_fdb_type == sai_fdb_type &&
(curr->first.mac == mac || mac == flush_mac) && curr->second.is_flush_pending)
{
clearFdbEntry(curr->first);
}
Expand All @@ -263,7 +265,8 @@ void FdbOrch::handleSyncdFlushNotif(const sai_object_id_t& bv_id,
auto curr = itr++;
if (curr->first.bv_id == bv_id && curr->second.bridge_port_id == bridge_port_id)
{
if (curr->second.type != "static" && (curr->first.mac == mac || mac == flush_mac) && curr->second.is_flush_pending)
if (curr->second.sai_fdb_type == sai_fdb_type &&
(curr->first.mac == mac || mac == flush_mac) && curr->second.is_flush_pending)
{
clearFdbEntry(curr->first);
}
Expand All @@ -274,7 +277,8 @@ void FdbOrch::handleSyncdFlushNotif(const sai_object_id_t& bv_id,

void FdbOrch::update(sai_fdb_event_t type,
const sai_fdb_entry_t* entry,
sai_object_id_t bridge_port_id)
sai_object_id_t bridge_port_id,
const sai_fdb_entry_type_t &sai_fdb_type)
{
SWSS_LOG_ENTER();

Expand Down Expand Up @@ -365,6 +369,7 @@ void FdbOrch::update(sai_fdb_event_t type,

attr.id = SAI_FDB_ENTRY_ATTR_TYPE;
attr.value.s32 = SAI_FDB_ENTRY_TYPE_DYNAMIC;
update.sai_fdb_type = SAI_FDB_ENTRY_TYPE_DYNAMIC;
attrs.push_back(attr);

attr.id = SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID;
Expand Down Expand Up @@ -399,6 +404,7 @@ void FdbOrch::update(sai_fdb_event_t type,

update.add = true;
update.entry.port_name = update.port.m_alias;
update.sai_fdb_type = SAI_FDB_ENTRY_TYPE_DYNAMIC;
update.type = "dynamic";
update.port.m_fdb_count++;
m_portsOrch->setPort(update.port.m_alias, update.port);
Expand Down Expand Up @@ -569,6 +575,7 @@ void FdbOrch::update(sai_fdb_event_t type,
}
update.port.m_fdb_count++;
m_portsOrch->setPort(update.port.m_alias, update.port);
update.sai_fdb_type = SAI_FDB_ENTRY_TYPE_DYNAMIC;
storeFdbEntryState(update);

notify(SUBJECT_TYPE_FDB_CHANGE, &update);
Expand All @@ -592,7 +599,7 @@ void FdbOrch::update(sai_fdb_event_t type,
SWSS_LOG_INFO("FDB Flush: [ %s , %s ] = { port: %s }", update.entry.mac.to_string().c_str(),
vlanName.c_str(), update.port.m_alias.c_str());

handleSyncdFlushNotif(entry->bv_id, bridge_port_id, update.entry.mac);
handleSyncdFlushNotif(entry->bv_id, bridge_port_id, update.entry.mac, sai_fdb_type);

break;
}
Expand Down Expand Up @@ -636,29 +643,23 @@ bool FdbOrch::getPort(const MacAddress& mac, uint16_t vlan, Port& port)
return false;
}

sai_fdb_entry_t entry;
entry.switch_id = gSwitchId;
memcpy(entry.mac_address, mac.getMac(), sizeof(sai_mac_t));
FdbEntry entry;
entry.mac = mac;
entry.bv_id = port.m_vlan_info.vlan_oid;

sai_attribute_t attr;
attr.id = SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID;

sai_status_t status = sai_fdb_api->get_fdb_entry_attribute(&entry, 1, &attr);
if (status != SAI_STATUS_SUCCESS)
auto it = m_entries.find(entry);
if (it == m_entries.end())
{
SWSS_LOG_ERROR("Failed to get bridge port ID for FDB entry %s, rv:%d",
mac.to_string().c_str(), status);
task_process_status handle_status = handleSaiGetStatus(SAI_API_FDB, status);
if (handle_status != task_process_status::task_success)
{
return false;
}
// This message is now expected in many cases since orchagent will process events such as
// learning new neighbor entries prior to updating the m_entries FDB cache.
SWSS_LOG_INFO("Failed to get cached bridge port ID for FDB entry %s",
mac.to_string().c_str());
return false;
}

if (!m_portsOrch->getPortByBridgePortId(attr.value.oid, port))
if (!m_portsOrch->getPortByBridgePortId(it->second.bridge_port_id, port))
{
SWSS_LOG_ERROR("Failed to get port by bridge port ID 0x%" PRIx64, attr.value.oid);
SWSS_LOG_ERROR("Failed to get port by bridge port ID 0x%" PRIx64, it->second.bridge_port_id);
return false;
}

Expand Down Expand Up @@ -1002,6 +1003,7 @@ void FdbOrch::doTask(NotificationConsumer& consumer)
{
uint32_t count;
sai_fdb_event_notification_data_t *fdbevent = nullptr;
sai_fdb_entry_type_t sai_fdb_type = SAI_FDB_ENTRY_TYPE_DYNAMIC;

sai_deserialize_fdb_event_ntf(data, count, &fdbevent);

Expand All @@ -1014,11 +1016,14 @@ void FdbOrch::doTask(NotificationConsumer& consumer)
if (fdbevent[i].attr[j].id == SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID)
{
oid = fdbevent[i].attr[j].value.oid;
break;
}
else if (fdbevent[i].attr[j].id == SAI_FDB_ENTRY_ATTR_TYPE)
{
sai_fdb_type = (sai_fdb_entry_type_t)fdbevent[i].attr[j].value.s32;
}
}

this->update(fdbevent[i].event_type, &fdbevent[i].fdb_entry, oid);
this->update(fdbevent[i].event_type, &fdbevent[i].fdb_entry, oid, sai_fdb_type);
}

sai_deserialize_free_fdb_event_ntf(count, fdbevent);
Expand Down Expand Up @@ -1346,6 +1351,7 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
{
attr.value.s32 = (fdbData.type == "dynamic") ? SAI_FDB_ENTRY_TYPE_DYNAMIC : SAI_FDB_ENTRY_TYPE_STATIC;
}
fdbData.sai_fdb_type = (sai_fdb_entry_type_t)attr.value.s32;

attrs.push_back(attr);

Expand Down
7 changes: 5 additions & 2 deletions orchagent/fdborch.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct FdbUpdate
Port port;
string type;
bool add;
sai_fdb_entry_type_t sai_fdb_type;
};

struct FdbFlushUpdate
Expand Down Expand Up @@ -63,6 +64,7 @@ struct FdbData
string remote_ip;
string esi;
unsigned int vni;
sai_fdb_entry_type_t sai_fdb_type;
};

struct SavedFdbEntry
Expand Down Expand Up @@ -91,7 +93,7 @@ class FdbOrch: public Orch, public Subject, public Observer
}

bool bake() override;
void update(sai_fdb_event_t, const sai_fdb_entry_t *, sai_object_id_t);
void update(sai_fdb_event_t, const sai_fdb_entry_t *, sai_object_id_t, const sai_fdb_entry_type_t &);
void update(SubjectType type, void *cntx);
bool getPort(const MacAddress&, uint16_t, Port&);

Expand Down Expand Up @@ -125,7 +127,8 @@ class FdbOrch: public Orch, public Subject, public Observer
void notifyTunnelOrch(Port& port);

void clearFdbEntry(const FdbEntry&);
void handleSyncdFlushNotif(const sai_object_id_t&, const sai_object_id_t&, const MacAddress& );
void handleSyncdFlushNotif(const sai_object_id_t&, const sai_object_id_t&, const MacAddress&,
const sai_fdb_entry_type_t&);
};

#endif /* SWSS_FDBORCH_H */
7 changes: 7 additions & 0 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ bool IntfsOrch::setIntf(const string& alias, sai_object_id_t vrf_id, const IpPre
{
SWSS_LOG_ENTER();

if (m_removingIntfses.find(alias) != m_removingIntfses.end())
{
return false;
}

Port port;
gPortsOrch->getPort(alias, port);

Expand Down Expand Up @@ -1076,10 +1081,12 @@ void IntfsOrch::doTask(Consumer &consumer)
{
if (removeIntf(alias, port.m_vr_id, ip_prefix_in_key ? &ip_prefix : nullptr))
{
m_removingIntfses.erase(alias);
it = consumer.m_toSync.erase(it);
}
else
{
m_removingIntfses.insert(alias);
it++;
continue;
}
Expand Down
2 changes: 2 additions & 0 deletions orchagent/intfsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class IntfsOrch : public Orch
unique_ptr<ProducerTable> m_flexCounterTable;
unique_ptr<ProducerTable> m_flexCounterGroupTable;

std::set<std::string> m_removingIntfses;

std::string getRifFlexCounterTableKey(std::string s);

bool addRouterIntfs(sai_object_id_t vrf_id, Port &port, string loopbackAction);
Expand Down
Loading

0 comments on commit 02f452f

Please sign in to comment.