Skip to content
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

[SRV6] Sonic-swss changes for SRV6 #1964

Merged
merged 38 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9b041ce
SRV6 orchagent initial commit
Oct 4, 2021
3e9efcb
Add SRV6 orchagent files
Oct 4, 2021
03cd02c
Fix indentations
Oct 4, 2021
abb3459
Fix nexthop strings
Oct 5, 2021
5205c85
Remove temp code
Oct 5, 2021
3cc2ee0
Nexthop type check and few indentations
Oct 5, 2021
b35c82d
Add CRM for SRV6 nexthop and my_sid
Oct 6, 2021
7953b27
Update CRM for my_sid_entry
Oct 14, 2021
a31e6ea
Update code comments
Oct 15, 2021
97b7bef
Merge branch 'master' into swss_srv6
Oct 15, 2021
adef2d2
Merge SRV6 nexthop after nghOrch changes
Oct 19, 2021
e093fe5
Add new APP_DB tables
Oct 21, 2021
e1a89a7
Merge branch 'master' into swss_srv6
Oct 26, 2021
4425eb1
Address review comments
Oct 26, 2021
487e806
add srv6 mysid and sidlist test cases
hzheng5 Oct 25, 2021
1edefba
Merge branch 'master' into swss_srv6
Oct 27, 2021
2926edf
Remove SRV6 nexthops after route update
Oct 29, 2021
3f80b12
Fix type
Nov 3, 2021
a3ad299
Update log statement
Nov 3, 2021
1ae973e
Update log
Nov 3, 2021
84f63e8
Merge branch 'master' into swss_srv6
Nov 5, 2021
25145a6
Address review comments
Nov 5, 2021
3b7d14d
Merge branch 'swss_srv6' of github.com:kperumalbfn/sonic-swss into sw…
Nov 5, 2021
fdecd12
Initialize weight to 0 in nhkey
Nov 5, 2021
1da2a13
Merge branch 'swss_srv6' of github.com:kperumalbfn/sonic-swss into sw…
Nov 5, 2021
63be845
Initialize weight to 0 in nhkey
Nov 5, 2021
c62e1e4
Address review comment for NHGKey
Nov 8, 2021
31e9618
Merge branch 'swss_srv6' of github.com:kperumalbfn/sonic-swss into sw…
Nov 9, 2021
69167c3
Address review comments
Nov 9, 2021
db915f9
Merge branch 'master' into swss_srv6
Nov 9, 2021
eca248a
Merge branch 'swss_srv6' of github.com:kperumalbfn/sonic-swss into sw…
Nov 9, 2021
924248a
Change LOG NOTICE to LOG INFO
Nov 9, 2021
dc72650
Merge branch 'swss_srv6' of github.com:kperumalbfn/sonic-swss into sw…
Nov 9, 2021
9a50756
Merge branch 'swss_srv6' of github.com:kperumalbfn/sonic-swss into sw…
Nov 9, 2021
e0c1bde
Remove extra line
Nov 10, 2021
a9f2ac2
Remove extra line
Nov 10, 2021
d4c52b8
Merge branch 'master' into swss_srv6
Nov 10, 2021
b32617d
review comments and resolve merge conflicts
Nov 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions doc/swss-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ and reflects the LAG ports into the redis under: `LAG_TABLE:<team0>:port`
blackhole = BIT ; Set to 1 if this route is a blackhole (or null0)
weight = weight_list ; List of weights.
nexthop_group = string ; index within the NEXTHOP_GROUP_TABLE, used instead of nexthop and intf fields
segment = string ; SRV6 segment name
seg_src = string ; ipv6 address for SRV6 tunnel source

---------------------------------------------

Expand Down Expand Up @@ -203,6 +205,21 @@ and reflects the LAG ports into the redis under: `LAG_TABLE:<team0>:port`
neigh = 12HEXDIG ; mac address of the neighbor
family = "IPv4" / "IPv6" ; address family

---------------------------------------------
### SRV6_SID_LIST_TABLE
; Stores IPV6 prefixes for a SRV6 segment name
key = ROUTE_TABLE:segment ; SRV6 segment name
; field = value
path = STRING ; Comma-separated list of IPV6 prefixes for a SRV6 segment

---------------------------------------------
### SRV6_MY_SID_TABLE
; Stores SRV6 MY_SID table entries and associated actions
key = STRING ; SRV6 MY_SID prefix string
; field = value
action = STRING ; MY_SID actions like "end", "end.dt46"
vrf = STRING ; VRF string for END.DT46 or END.DT4 or END.DT6

---------------------------------------------
### FDB_TABLE

Expand Down
3 changes: 2 additions & 1 deletion orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ orchagent_SOURCES = \
muxorch.cpp \
macsecorch.cpp \
lagid.cpp \
bfdorch.cpp
bfdorch.cpp \
srv6orch.cpp

orchagent_SOURCES += flex_counter/flex_counter_manager.cpp flex_counter/flex_counter_stat_manager.cpp
orchagent_SOURCES += debug_counter/debug_counter.cpp debug_counter/drop_counter.cpp
Expand Down
70 changes: 70 additions & 0 deletions orchagent/crmorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const map<CrmResourceType, string> crmResTypeNameMap =
{ CrmResourceType::CRM_DNAT_ENTRY, "DNAT_ENTRY" },
{ CrmResourceType::CRM_MPLS_INSEG, "MPLS_INSEG" },
{ CrmResourceType::CRM_MPLS_NEXTHOP, "MPLS_NEXTHOP" },
{ CrmResourceType::CRM_SRV6_MY_SID_ENTRY, "SRV6_MY_SID_ENTRY" },
{ CrmResourceType::CRM_SRV6_NEXTHOP, "SRV6_NEXTHOP" },
};

const map<CrmResourceType, uint32_t> crmResSaiAvailAttrMap =
Expand All @@ -65,6 +67,8 @@ const map<CrmResourceType, uint32_t> crmResSaiAvailAttrMap =
{ CrmResourceType::CRM_DNAT_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_DNAT_ENTRY },
{ CrmResourceType::CRM_MPLS_INSEG, SAI_OBJECT_TYPE_INSEG_ENTRY },
{ CrmResourceType::CRM_MPLS_NEXTHOP, SAI_SWITCH_ATTR_AVAILABLE_IPV4_NEXTHOP_ENTRY },
{ CrmResourceType::CRM_SRV6_MY_SID_ENTRY, SAI_OBJECT_TYPE_MY_SID_ENTRY },
{ CrmResourceType::CRM_SRV6_NEXTHOP, SAI_SWITCH_ATTR_AVAILABLE_IPV6_NEXTHOP_ENTRY },
};

const map<string, CrmResourceType> crmThreshTypeResMap =
Expand All @@ -87,6 +91,8 @@ const map<string, CrmResourceType> crmThreshTypeResMap =
{ "dnat_entry_threshold_type", CrmResourceType::CRM_DNAT_ENTRY },
{ "mpls_inseg_threshold_type", CrmResourceType::CRM_MPLS_INSEG },
{ "mpls_nexthop_threshold_type", CrmResourceType::CRM_MPLS_NEXTHOP },
{ "srv6_my_sid_entry_threshold_type", CrmResourceType::CRM_SRV6_MY_SID_ENTRY },
{ "srv6_nexthop_threshold_type", CrmResourceType::CRM_SRV6_NEXTHOP },
};

const map<string, CrmResourceType> crmThreshLowResMap =
Expand All @@ -109,6 +115,8 @@ const map<string, CrmResourceType> crmThreshLowResMap =
{"dnat_entry_low_threshold", CrmResourceType::CRM_DNAT_ENTRY },
{"mpls_inseg_low_threshold", CrmResourceType::CRM_MPLS_INSEG },
{"mpls_nexthop_low_threshold", CrmResourceType::CRM_MPLS_NEXTHOP },
{"srv6_my_sid_entry_low_threshold", CrmResourceType::CRM_SRV6_MY_SID_ENTRY },
{"srv6_nexthop_low_threshold", CrmResourceType::CRM_SRV6_NEXTHOP },
};

const map<string, CrmResourceType> crmThreshHighResMap =
Expand All @@ -131,6 +139,8 @@ const map<string, CrmResourceType> crmThreshHighResMap =
{"dnat_entry_high_threshold", CrmResourceType::CRM_DNAT_ENTRY },
{"mpls_inseg_high_threshold", CrmResourceType::CRM_MPLS_INSEG },
{"mpls_nexthop_high_threshold", CrmResourceType::CRM_MPLS_NEXTHOP },
{"srv6_my_sid_entry_high_threshold", CrmResourceType::CRM_SRV6_MY_SID_ENTRY },
{"srv6_nexthop_high_threshold", CrmResourceType::CRM_SRV6_NEXTHOP },
};

const map<string, CrmThresholdType> crmThreshTypeMap =
Expand Down Expand Up @@ -160,6 +170,8 @@ const map<string, CrmResourceType> crmAvailCntsTableMap =
{ "crm_stats_dnat_entry_available", CrmResourceType::CRM_DNAT_ENTRY },
{ "crm_stats_mpls_inseg_available", CrmResourceType::CRM_MPLS_INSEG },
{ "crm_stats_mpls_nexthop_available", CrmResourceType::CRM_MPLS_NEXTHOP },
{ "crm_stats_srv6_my_sid_entry_available", CrmResourceType::CRM_SRV6_MY_SID_ENTRY },
{ "crm_stats_srv6_nexthop_available", CrmResourceType::CRM_SRV6_NEXTHOP },
};

const map<string, CrmResourceType> crmUsedCntsTableMap =
Expand All @@ -182,6 +194,8 @@ const map<string, CrmResourceType> crmUsedCntsTableMap =
{ "crm_stats_dnat_entry_used", CrmResourceType::CRM_DNAT_ENTRY },
{ "crm_stats_mpls_inseg_used", CrmResourceType::CRM_MPLS_INSEG },
{ "crm_stats_mpls_nexthop_used", CrmResourceType::CRM_MPLS_NEXTHOP },
{ "crm_stats_srv6_my_sid_entry_used", CrmResourceType::CRM_SRV6_MY_SID_ENTRY },
{ "crm_stats_srv6_nexthop_used", CrmResourceType::CRM_SRV6_NEXTHOP },
};

CrmOrch::CrmOrch(DBConnector *db, string tableName):
Expand Down Expand Up @@ -614,6 +628,62 @@ void CrmOrch::getResAvailableCounters()
break;
}

case CrmResourceType::CRM_SRV6_MY_SID_ENTRY:
{
sai_object_type_t objType = static_cast<sai_object_type_t>(crmResSaiAvailAttrMap.at(res.first));
uint64_t availCount = 0;
sai_status_t status = sai_object_type_get_availability(gSwitchId, objType, 0, nullptr, &availCount);
if (status != SAI_STATUS_SUCCESS)
{
if ((status == SAI_STATUS_NOT_SUPPORTED) ||
(status == SAI_STATUS_NOT_IMPLEMENTED) ||
SAI_STATUS_IS_ATTR_NOT_SUPPORTED(status) ||
SAI_STATUS_IS_ATTR_NOT_IMPLEMENTED(status))
{
// mark unsupported resources
res.second.resStatus = CrmResourceStatus::CRM_RES_NOT_SUPPORTED;
SWSS_LOG_NOTICE("CRM Resource %s not supported", crmResTypeNameMap.at(res.first).c_str());
break;
}
SWSS_LOG_ERROR("Failed to get availability for object_type %u , rv:%d", objType, status);
break;
}

res.second.countersMap[CRM_COUNTERS_TABLE_KEY].availableCounter = static_cast<uint32_t>(availCount);

break;
}

case CrmResourceType::CRM_SRV6_NEXTHOP:
{
sai_object_type_t objType = static_cast<sai_object_type_t>(crmResSaiAvailAttrMap.at(res.first));
sai_attribute_t attr;
uint64_t availCount = 0;

attr.id = SAI_NEXT_HOP_ATTR_TYPE;
attr.value.s32 = SAI_NEXT_HOP_TYPE_SRV6_SIDLIST;
sai_status_t status = sai_object_type_get_availability(gSwitchId, objType, 1, &attr, &availCount);
if (status != SAI_STATUS_SUCCESS)
{
if ((status == SAI_STATUS_NOT_SUPPORTED) ||
(status == SAI_STATUS_NOT_IMPLEMENTED) ||
SAI_STATUS_IS_ATTR_NOT_SUPPORTED(status) ||
SAI_STATUS_IS_ATTR_NOT_IMPLEMENTED(status))
{
// mark unsupported resources
res.second.resStatus = CrmResourceStatus::CRM_RES_NOT_SUPPORTED;
SWSS_LOG_NOTICE("CRM Resource %s not supported", crmResTypeNameMap.at(res.first).c_str());
break;
}
SWSS_LOG_ERROR("Failed to get availability for object_type %u , rv:%d", objType, status);
break;
}

res.second.countersMap[CRM_COUNTERS_TABLE_KEY].availableCounter = static_cast<uint32_t>(availCount);

break;
}

default:
SWSS_LOG_ERROR("Failed to get CRM resource type %u. Unknown resource type.\n", static_cast<uint32_t>(res.first));
return;
Expand Down
2 changes: 2 additions & 0 deletions orchagent/crmorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ enum class CrmResourceType
CRM_DNAT_ENTRY,
CRM_MPLS_INSEG,
CRM_MPLS_NEXTHOP,
CRM_SRV6_MY_SID_ENTRY,
CRM_SRV6_NEXTHOP,
};

enum class CrmThresholdType
Expand Down
19 changes: 19 additions & 0 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1702,3 +1702,22 @@ bool NeighOrch::updateVoqNeighborEncapIndex(const NeighborEntry &neighborEntry,

return true;
}

void NeighOrch::updateSrv6Nexthop(const NextHopKey &nh, const sai_object_id_t &nh_id)
kperumalbfn marked this conversation as resolved.
Show resolved Hide resolved
{
if (nh_id != SAI_NULL_OBJECT_ID)
{
NextHopEntry next_hop_entry;
next_hop_entry.next_hop_id = nh_id;
next_hop_entry.ref_count = 0;
next_hop_entry.nh_flags = 0;
m_syncdNextHops[nh] = next_hop_entry;
gCrmOrch->incCrmResUsedCounter(CrmResourceType::CRM_SRV6_NEXTHOP);
}
else
{
assert(m_syncdNextHops[nh].ref_count == 0);
gCrmOrch->decCrmResUsedCounter(CrmResourceType::CRM_SRV6_NEXTHOP);
m_syncdNextHops.erase(nh);
}
}
1 change: 1 addition & 0 deletions orchagent/neighorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class NeighOrch : public Orch, public Subject, public Observer
bool delInbandNeighbor(string alias, IpAddress ip_address);

void resolveNeighbor(const NeighborEntry &);
void updateSrv6Nexthop(const NextHopKey &, const sai_object_id_t &);

private:
PortsOrch *m_portsOrch;
Expand Down
39 changes: 31 additions & 8 deletions orchagent/nexthopgroupkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class NextHopGroupKey
NextHopGroupKey(const std::string &nexthops)
{
m_overlay_nexthops = false;
m_srv6_nexthops = false;
auto nhv = tokenize(nexthops, NHG_DELIMITER);
for (const auto &nh : nhv)
{
Expand All @@ -20,20 +21,36 @@ class NextHopGroupKey
}

/* ip_string|if_alias|vni|router_mac separated by ',' */
NextHopGroupKey(const std::string &nexthops, bool overlay_nh)
NextHopGroupKey(const std::string &nexthops, bool overlay_nh, bool srv6_nh)
{
m_overlay_nexthops = true;
auto nhv = tokenize(nexthops, NHG_DELIMITER);
for (const auto &nh_str : nhv)
if (overlay_nh)
{
auto nh = NextHopKey(nh_str, overlay_nh);
m_nexthops.insert(nh);
m_overlay_nexthops = true;
m_srv6_nexthops = false;
auto nhv = tokenize(nexthops, NHG_DELIMITER);
for (const auto &nh_str : nhv)
{
auto nh = NextHopKey(nh_str, overlay_nh, srv6_nh);
m_nexthops.insert(nh);
}
}
else if (srv6_nh)
{
m_overlay_nexthops = false;
m_srv6_nexthops = true;
auto nhv = tokenize(nexthops, NHG_DELIMITER);
for (const auto &nh_str : nhv)
{
auto nh = NextHopKey(nh_str, overlay_nh, srv6_nh);
m_nexthops.insert(nh);
}
}
}

NextHopGroupKey(const std::string &nexthops, const std::string &weights)
{
m_overlay_nexthops = false;
m_srv6_nexthops = false;
std::vector<std::string> nhv = tokenize(nexthops, NHG_DELIMITER);
std::vector<std::string> wtv = tokenize(weights, NHG_DELIMITER);
bool set_weight = wtv.size() == nhv.size();
Expand Down Expand Up @@ -184,8 +201,8 @@ class NextHopGroupKey
{
nhs_str += NHG_DELIMITER;
}
if (m_overlay_nexthops) {
nhs_str += it->to_string(m_overlay_nexthops);
if (m_overlay_nexthops || m_srv6_nexthops) {
nhs_str += it->to_string(m_overlay_nexthops, m_srv6_nexthops);
} else {
nhs_str += it->to_string();
}
Expand All @@ -199,6 +216,11 @@ class NextHopGroupKey
return m_overlay_nexthops;
}

inline bool is_srv6_nexthop() const
{
return m_srv6_nexthops;
}

void clear()
{
m_nexthops.clear();
Expand All @@ -207,6 +229,7 @@ class NextHopGroupKey
private:
std::set<NextHopKey> m_nexthops;
bool m_overlay_nexthops;
bool m_srv6_nexthops;
};

#endif /* SWSS_NEXTHOPGROUPKEY_H */
Loading