Skip to content

Commit 37c197d

Browse files
author
Kumaresh Perumal
authored
[SRV6] Sonic-swss changes for SRV6 (sonic-net#1964)
*RouteOrch changes to trigger SRV6 nexthops and update route entries *SRV6Orch changes to create SRV6 nexthops, tunnel and SRV6 MY_SID_ENTRY objects
1 parent f502c32 commit 37c197d

18 files changed

+1357
-47
lines changed

doc/swss-schema.md

+17
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ and reflects the LAG ports into the redis under: `LAG_TABLE:<team0>:port`
167167
blackhole = BIT ; Set to 1 if this route is a blackhole (or null0)
168168
weight = weight_list ; List of weights.
169169
nexthop_group = string ; index within the NEXTHOP_GROUP_TABLE, used instead of nexthop and intf fields
170+
segment = string ; SRV6 segment name
171+
seg_src = string ; ipv6 address for SRV6 tunnel source
170172

171173
---------------------------------------------
172174

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

208+
---------------------------------------------
209+
### SRV6_SID_LIST_TABLE
210+
; Stores IPV6 prefixes for a SRV6 segment name
211+
key = ROUTE_TABLE:segment ; SRV6 segment name
212+
; field = value
213+
path = STRING ; Comma-separated list of IPV6 prefixes for a SRV6 segment
214+
215+
---------------------------------------------
216+
### SRV6_MY_SID_TABLE
217+
; Stores SRV6 MY_SID table entries and associated actions
218+
key = STRING ; SRV6 MY_SID prefix string
219+
; field = value
220+
action = STRING ; MY_SID actions like "end", "end.dt46"
221+
vrf = STRING ; VRF string for END.DT46 or END.DT4 or END.DT6
222+
206223
---------------------------------------------
207224
### FDB_TABLE
208225

orchagent/Makefile.am

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ orchagent_SOURCES = \
8282
muxorch.cpp \
8383
macsecorch.cpp \
8484
lagid.cpp \
85-
bfdorch.cpp
85+
bfdorch.cpp \
86+
srv6orch.cpp
8687

8788
orchagent_SOURCES += flex_counter/flex_counter_manager.cpp flex_counter/flex_counter_stat_manager.cpp
8889
orchagent_SOURCES += debug_counter/debug_counter.cpp debug_counter/drop_counter.cpp

orchagent/crmorch.cpp

+70
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ const map<CrmResourceType, string> crmResTypeNameMap =
4343
{ CrmResourceType::CRM_DNAT_ENTRY, "DNAT_ENTRY" },
4444
{ CrmResourceType::CRM_MPLS_INSEG, "MPLS_INSEG" },
4545
{ CrmResourceType::CRM_MPLS_NEXTHOP, "MPLS_NEXTHOP" },
46+
{ CrmResourceType::CRM_SRV6_MY_SID_ENTRY, "SRV6_MY_SID_ENTRY" },
47+
{ CrmResourceType::CRM_SRV6_NEXTHOP, "SRV6_NEXTHOP" },
4648
};
4749

4850
const map<CrmResourceType, uint32_t> crmResSaiAvailAttrMap =
@@ -65,6 +67,8 @@ const map<CrmResourceType, uint32_t> crmResSaiAvailAttrMap =
6567
{ CrmResourceType::CRM_DNAT_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_DNAT_ENTRY },
6668
{ CrmResourceType::CRM_MPLS_INSEG, SAI_OBJECT_TYPE_INSEG_ENTRY },
6769
{ CrmResourceType::CRM_MPLS_NEXTHOP, SAI_SWITCH_ATTR_AVAILABLE_IPV4_NEXTHOP_ENTRY },
70+
{ CrmResourceType::CRM_SRV6_MY_SID_ENTRY, SAI_OBJECT_TYPE_MY_SID_ENTRY },
71+
{ CrmResourceType::CRM_SRV6_NEXTHOP, SAI_SWITCH_ATTR_AVAILABLE_IPV6_NEXTHOP_ENTRY },
6872
};
6973

7074
const map<string, CrmResourceType> crmThreshTypeResMap =
@@ -87,6 +91,8 @@ const map<string, CrmResourceType> crmThreshTypeResMap =
8791
{ "dnat_entry_threshold_type", CrmResourceType::CRM_DNAT_ENTRY },
8892
{ "mpls_inseg_threshold_type", CrmResourceType::CRM_MPLS_INSEG },
8993
{ "mpls_nexthop_threshold_type", CrmResourceType::CRM_MPLS_NEXTHOP },
94+
{ "srv6_my_sid_entry_threshold_type", CrmResourceType::CRM_SRV6_MY_SID_ENTRY },
95+
{ "srv6_nexthop_threshold_type", CrmResourceType::CRM_SRV6_NEXTHOP },
9096
};
9197

9298
const map<string, CrmResourceType> crmThreshLowResMap =
@@ -109,6 +115,8 @@ const map<string, CrmResourceType> crmThreshLowResMap =
109115
{"dnat_entry_low_threshold", CrmResourceType::CRM_DNAT_ENTRY },
110116
{"mpls_inseg_low_threshold", CrmResourceType::CRM_MPLS_INSEG },
111117
{"mpls_nexthop_low_threshold", CrmResourceType::CRM_MPLS_NEXTHOP },
118+
{"srv6_my_sid_entry_low_threshold", CrmResourceType::CRM_SRV6_MY_SID_ENTRY },
119+
{"srv6_nexthop_low_threshold", CrmResourceType::CRM_SRV6_NEXTHOP },
112120
};
113121

114122
const map<string, CrmResourceType> crmThreshHighResMap =
@@ -131,6 +139,8 @@ const map<string, CrmResourceType> crmThreshHighResMap =
131139
{"dnat_entry_high_threshold", CrmResourceType::CRM_DNAT_ENTRY },
132140
{"mpls_inseg_high_threshold", CrmResourceType::CRM_MPLS_INSEG },
133141
{"mpls_nexthop_high_threshold", CrmResourceType::CRM_MPLS_NEXTHOP },
142+
{"srv6_my_sid_entry_high_threshold", CrmResourceType::CRM_SRV6_MY_SID_ENTRY },
143+
{"srv6_nexthop_high_threshold", CrmResourceType::CRM_SRV6_NEXTHOP },
134144
};
135145

136146
const map<string, CrmThresholdType> crmThreshTypeMap =
@@ -160,6 +170,8 @@ const map<string, CrmResourceType> crmAvailCntsTableMap =
160170
{ "crm_stats_dnat_entry_available", CrmResourceType::CRM_DNAT_ENTRY },
161171
{ "crm_stats_mpls_inseg_available", CrmResourceType::CRM_MPLS_INSEG },
162172
{ "crm_stats_mpls_nexthop_available", CrmResourceType::CRM_MPLS_NEXTHOP },
173+
{ "crm_stats_srv6_my_sid_entry_available", CrmResourceType::CRM_SRV6_MY_SID_ENTRY },
174+
{ "crm_stats_srv6_nexthop_available", CrmResourceType::CRM_SRV6_NEXTHOP },
163175
};
164176

165177
const map<string, CrmResourceType> crmUsedCntsTableMap =
@@ -182,6 +194,8 @@ const map<string, CrmResourceType> crmUsedCntsTableMap =
182194
{ "crm_stats_dnat_entry_used", CrmResourceType::CRM_DNAT_ENTRY },
183195
{ "crm_stats_mpls_inseg_used", CrmResourceType::CRM_MPLS_INSEG },
184196
{ "crm_stats_mpls_nexthop_used", CrmResourceType::CRM_MPLS_NEXTHOP },
197+
{ "crm_stats_srv6_my_sid_entry_used", CrmResourceType::CRM_SRV6_MY_SID_ENTRY },
198+
{ "crm_stats_srv6_nexthop_used", CrmResourceType::CRM_SRV6_NEXTHOP },
185199
};
186200

187201
CrmOrch::CrmOrch(DBConnector *db, string tableName):
@@ -614,6 +628,62 @@ void CrmOrch::getResAvailableCounters()
614628
break;
615629
}
616630

631+
case CrmResourceType::CRM_SRV6_MY_SID_ENTRY:
632+
{
633+
sai_object_type_t objType = static_cast<sai_object_type_t>(crmResSaiAvailAttrMap.at(res.first));
634+
uint64_t availCount = 0;
635+
sai_status_t status = sai_object_type_get_availability(gSwitchId, objType, 0, nullptr, &availCount);
636+
if (status != SAI_STATUS_SUCCESS)
637+
{
638+
if ((status == SAI_STATUS_NOT_SUPPORTED) ||
639+
(status == SAI_STATUS_NOT_IMPLEMENTED) ||
640+
SAI_STATUS_IS_ATTR_NOT_SUPPORTED(status) ||
641+
SAI_STATUS_IS_ATTR_NOT_IMPLEMENTED(status))
642+
{
643+
// mark unsupported resources
644+
res.second.resStatus = CrmResourceStatus::CRM_RES_NOT_SUPPORTED;
645+
SWSS_LOG_NOTICE("CRM Resource %s not supported", crmResTypeNameMap.at(res.first).c_str());
646+
break;
647+
}
648+
SWSS_LOG_ERROR("Failed to get availability for object_type %u , rv:%d", objType, status);
649+
break;
650+
}
651+
652+
res.second.countersMap[CRM_COUNTERS_TABLE_KEY].availableCounter = static_cast<uint32_t>(availCount);
653+
654+
break;
655+
}
656+
657+
case CrmResourceType::CRM_SRV6_NEXTHOP:
658+
{
659+
sai_object_type_t objType = static_cast<sai_object_type_t>(crmResSaiAvailAttrMap.at(res.first));
660+
sai_attribute_t attr;
661+
uint64_t availCount = 0;
662+
663+
attr.id = SAI_NEXT_HOP_ATTR_TYPE;
664+
attr.value.s32 = SAI_NEXT_HOP_TYPE_SRV6_SIDLIST;
665+
sai_status_t status = sai_object_type_get_availability(gSwitchId, objType, 1, &attr, &availCount);
666+
if (status != SAI_STATUS_SUCCESS)
667+
{
668+
if ((status == SAI_STATUS_NOT_SUPPORTED) ||
669+
(status == SAI_STATUS_NOT_IMPLEMENTED) ||
670+
SAI_STATUS_IS_ATTR_NOT_SUPPORTED(status) ||
671+
SAI_STATUS_IS_ATTR_NOT_IMPLEMENTED(status))
672+
{
673+
// mark unsupported resources
674+
res.second.resStatus = CrmResourceStatus::CRM_RES_NOT_SUPPORTED;
675+
SWSS_LOG_NOTICE("CRM Resource %s not supported", crmResTypeNameMap.at(res.first).c_str());
676+
break;
677+
}
678+
SWSS_LOG_ERROR("Failed to get availability for object_type %u , rv:%d", objType, status);
679+
break;
680+
}
681+
682+
res.second.countersMap[CRM_COUNTERS_TABLE_KEY].availableCounter = static_cast<uint32_t>(availCount);
683+
684+
break;
685+
}
686+
617687
default:
618688
SWSS_LOG_ERROR("Failed to get CRM resource type %u. Unknown resource type.\n", static_cast<uint32_t>(res.first));
619689
return;

orchagent/crmorch.h

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ enum class CrmResourceType
3030
CRM_DNAT_ENTRY,
3131
CRM_MPLS_INSEG,
3232
CRM_MPLS_NEXTHOP,
33+
CRM_SRV6_MY_SID_ENTRY,
34+
CRM_SRV6_NEXTHOP,
3335
};
3436

3537
enum class CrmThresholdType

orchagent/neighorch.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -1702,3 +1702,22 @@ bool NeighOrch::updateVoqNeighborEncapIndex(const NeighborEntry &neighborEntry,
17021702

17031703
return true;
17041704
}
1705+
1706+
void NeighOrch::updateSrv6Nexthop(const NextHopKey &nh, const sai_object_id_t &nh_id)
1707+
{
1708+
if (nh_id != SAI_NULL_OBJECT_ID)
1709+
{
1710+
NextHopEntry next_hop_entry;
1711+
next_hop_entry.next_hop_id = nh_id;
1712+
next_hop_entry.ref_count = 0;
1713+
next_hop_entry.nh_flags = 0;
1714+
m_syncdNextHops[nh] = next_hop_entry;
1715+
gCrmOrch->incCrmResUsedCounter(CrmResourceType::CRM_SRV6_NEXTHOP);
1716+
}
1717+
else
1718+
{
1719+
assert(m_syncdNextHops[nh].ref_count == 0);
1720+
gCrmOrch->decCrmResUsedCounter(CrmResourceType::CRM_SRV6_NEXTHOP);
1721+
m_syncdNextHops.erase(nh);
1722+
}
1723+
}

orchagent/neighorch.h

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class NeighOrch : public Orch, public Subject, public Observer
7979
bool delInbandNeighbor(string alias, IpAddress ip_address);
8080

8181
void resolveNeighbor(const NeighborEntry &);
82+
void updateSrv6Nexthop(const NextHopKey &, const sai_object_id_t &);
8283

8384
private:
8485
PortsOrch *m_portsOrch;

orchagent/nexthopgroupkey.h

+31-8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class NextHopGroupKey
1212
NextHopGroupKey(const std::string &nexthops)
1313
{
1414
m_overlay_nexthops = false;
15+
m_srv6_nexthops = false;
1516
auto nhv = tokenize(nexthops, NHG_DELIMITER);
1617
for (const auto &nh : nhv)
1718
{
@@ -20,20 +21,36 @@ class NextHopGroupKey
2021
}
2122

2223
/* ip_string|if_alias|vni|router_mac separated by ',' */
23-
NextHopGroupKey(const std::string &nexthops, bool overlay_nh)
24+
NextHopGroupKey(const std::string &nexthops, bool overlay_nh, bool srv6_nh)
2425
{
25-
m_overlay_nexthops = true;
26-
auto nhv = tokenize(nexthops, NHG_DELIMITER);
27-
for (const auto &nh_str : nhv)
26+
if (overlay_nh)
2827
{
29-
auto nh = NextHopKey(nh_str, overlay_nh);
30-
m_nexthops.insert(nh);
28+
m_overlay_nexthops = true;
29+
m_srv6_nexthops = false;
30+
auto nhv = tokenize(nexthops, NHG_DELIMITER);
31+
for (const auto &nh_str : nhv)
32+
{
33+
auto nh = NextHopKey(nh_str, overlay_nh, srv6_nh);
34+
m_nexthops.insert(nh);
35+
}
36+
}
37+
else if (srv6_nh)
38+
{
39+
m_overlay_nexthops = false;
40+
m_srv6_nexthops = true;
41+
auto nhv = tokenize(nexthops, NHG_DELIMITER);
42+
for (const auto &nh_str : nhv)
43+
{
44+
auto nh = NextHopKey(nh_str, overlay_nh, srv6_nh);
45+
m_nexthops.insert(nh);
46+
}
3147
}
3248
}
3349

3450
NextHopGroupKey(const std::string &nexthops, const std::string &weights)
3551
{
3652
m_overlay_nexthops = false;
53+
m_srv6_nexthops = false;
3754
std::vector<std::string> nhv = tokenize(nexthops, NHG_DELIMITER);
3855
std::vector<std::string> wtv = tokenize(weights, NHG_DELIMITER);
3956
bool set_weight = wtv.size() == nhv.size();
@@ -184,8 +201,8 @@ class NextHopGroupKey
184201
{
185202
nhs_str += NHG_DELIMITER;
186203
}
187-
if (m_overlay_nexthops) {
188-
nhs_str += it->to_string(m_overlay_nexthops);
204+
if (m_overlay_nexthops || m_srv6_nexthops) {
205+
nhs_str += it->to_string(m_overlay_nexthops, m_srv6_nexthops);
189206
} else {
190207
nhs_str += it->to_string();
191208
}
@@ -199,6 +216,11 @@ class NextHopGroupKey
199216
return m_overlay_nexthops;
200217
}
201218

219+
inline bool is_srv6_nexthop() const
220+
{
221+
return m_srv6_nexthops;
222+
}
223+
202224
void clear()
203225
{
204226
m_nexthops.clear();
@@ -207,6 +229,7 @@ class NextHopGroupKey
207229
private:
208230
std::set<NextHopKey> m_nexthops;
209231
bool m_overlay_nexthops;
232+
bool m_srv6_nexthops;
210233
};
211234

212235
#endif /* SWSS_NEXTHOPGROUPKEY_H */

0 commit comments

Comments
 (0)