Skip to content

Commit 6e6fb94

Browse files
Add changes to tunnel orch and address successful returns in pre-op
Signed-off-by: Prabhat Aravind <[email protected]>
1 parent 530635f commit 6e6fb94

File tree

7 files changed

+77
-19
lines changed

7 files changed

+77
-19
lines changed

orchagent/dash/dashorch.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,13 @@ void DashOrch::doTaskApplianceTable(ConsumerBase& consumer)
265265
SWSS_LOG_ENTER();
266266

267267
auto it = consumer.m_toSync.begin();
268+
uint32_t result;
268269
while (it != consumer.m_toSync.end())
269270
{
270271
KeyOpFieldsValuesTuple t = it->second;
271272
string appliance_id = kfvKey(t);
272273
string op = kfvOp(t);
273-
uint32_t result = DASH_RESULT_SUCCESS;
274+
result = DASH_RESULT_SUCCESS;
274275

275276
if (op == SET_COMMAND)
276277
{
@@ -351,13 +352,14 @@ void DashOrch::doTaskRoutingTypeTable(ConsumerBase& consumer)
351352
SWSS_LOG_ENTER();
352353

353354
auto it = consumer.m_toSync.begin();
355+
uint32_t result;
354356
while (it != consumer.m_toSync.end())
355357
{
356358
KeyOpFieldsValuesTuple t = it->second;
357359
string routing_type_str = kfvKey(t);
358360
string op = kfvOp(t);
359361
dash::route_type::RoutingType routing_type;
360-
uint32_t result = DASH_RESULT_SUCCESS;
362+
result = DASH_RESULT_SUCCESS;
361363

362364
std::transform(routing_type_str.begin(), routing_type_str.end(), routing_type_str.begin(), ::toupper);
363365
routing_type_str = "ROUTING_TYPE_" + routing_type_str;
@@ -691,12 +693,13 @@ void DashOrch::doTaskEniTable(ConsumerBase& consumer)
691693
SWSS_LOG_ENTER();
692694

693695
auto it = consumer.m_toSync.begin();
696+
uint32_t result;
694697
while (it != consumer.m_toSync.end())
695698
{
696699
auto t = it->second;
697700
string eni = kfvKey(t);
698701
string op = kfvOp(t);
699-
uint32_t result = DASH_RESULT_SUCCESS;
702+
result = DASH_RESULT_SUCCESS;
700703
if (op == SET_COMMAND)
701704
{
702705
EniEntry entry;
@@ -771,12 +774,13 @@ bool DashOrch::removeQosEntry(const string& qos_name)
771774
void DashOrch::doTaskQosTable(ConsumerBase& consumer)
772775
{
773776
auto it = consumer.m_toSync.begin();
777+
uint32_t result;
774778
while (it != consumer.m_toSync.end())
775779
{
776780
KeyOpFieldsValuesTuple t = it->second;
777781
string qos_name = kfvKey(t);
778782
string op = kfvOp(t);
779-
uint32_t result = DASH_RESULT_SUCCESS;
783+
result = DASH_RESULT_SUCCESS;
780784

781785
if (op == SET_COMMAND)
782786
{
@@ -923,12 +927,13 @@ bool DashOrch::removeEniRoute(const std::string& eni)
923927
void DashOrch::doTaskEniRouteTable(ConsumerBase& consumer)
924928
{
925929
auto it = consumer.m_toSync.begin();
930+
uint32_t result;
926931
while (it != consumer.m_toSync.end())
927932
{
928933
KeyOpFieldsValuesTuple t = it->second;
929934
string eni = kfvKey(t);
930935
string op = kfvOp(t);
931-
uint32_t result = DASH_RESULT_SUCCESS;
936+
result = DASH_RESULT_SUCCESS;
932937

933938
if (op == SET_COMMAND)
934939
{

orchagent/dash/dashrouteorch.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ void DashRouteOrch::doTaskRouteTable(ConsumerBase& consumer)
290290
SWSS_LOG_ENTER();
291291

292292
auto it = consumer.m_toSync.begin();
293-
293+
uint32_t result;
294294
while (it != consumer.m_toSync.end())
295295
{
296296
std::map<std::pair<std::string, std::string>,
@@ -306,6 +306,7 @@ void DashRouteOrch::doTaskRouteTable(ConsumerBase& consumer)
306306
std::forward_as_tuple());
307307
bool inserted = rc.second;
308308
auto &ctxt = rc.first->second;
309+
result = DASH_RESULT_SUCCESS;
309310

310311
if (!inserted)
311312
{
@@ -342,6 +343,11 @@ void DashRouteOrch::doTaskRouteTable(ConsumerBase& consumer)
342343
if (addOutboundRouting(key, ctxt))
343344
{
344345
it = consumer.m_toSync.erase(it);
346+
/*
347+
* Write result only when removing from consumer in pre-op
348+
* For other cases, this will be handled in post-op
349+
*/
350+
writeResultToDB(dash_route_result_table_, key, result);
345351
}
346352
else
347353
{
@@ -353,6 +359,7 @@ void DashRouteOrch::doTaskRouteTable(ConsumerBase& consumer)
353359
if (removeOutboundRouting(key, ctxt))
354360
{
355361
it = consumer.m_toSync.erase(it);
362+
removeResultFromDB(dash_route_result_table_, key);
356363
}
357364
else
358365
{
@@ -374,7 +381,7 @@ void DashRouteOrch::doTaskRouteTable(ConsumerBase& consumer)
374381
KeyOpFieldsValuesTuple t = it_prev->second;
375382
string key = kfvKey(t);
376383
string op = kfvOp(t);
377-
uint32_t result = DASH_RESULT_SUCCESS;
384+
result = DASH_RESULT_SUCCESS;
378385
auto found = toBulk.find(make_pair(key, op));
379386
if (found == toBulk.end())
380387
{
@@ -398,8 +405,8 @@ void DashRouteOrch::doTaskRouteTable(ConsumerBase& consumer)
398405
}
399406
else
400407
{
401-
result = DASH_RESULT_FAILURE;
402408
it_prev++;
409+
result = DASH_RESULT_FAILURE;
403410
}
404411
writeResultToDB(dash_route_result_table_, key, result);
405412
}
@@ -575,7 +582,7 @@ void DashRouteOrch::doTaskRouteRuleTable(ConsumerBase& consumer)
575582
SWSS_LOG_ENTER();
576583

577584
auto it = consumer.m_toSync.begin();
578-
585+
uint32_t result;
579586
while (it != consumer.m_toSync.end())
580587
{
581588
std::map<std::pair<std::string, std::string>,
@@ -591,6 +598,7 @@ void DashRouteOrch::doTaskRouteRuleTable(ConsumerBase& consumer)
591598
std::forward_as_tuple());
592599
bool inserted = rc.second;
593600
auto &ctxt = rc.first->second;
601+
result = DASH_RESULT_SUCCESS;
594602

595603
if (!inserted)
596604
{
@@ -625,6 +633,11 @@ void DashRouteOrch::doTaskRouteRuleTable(ConsumerBase& consumer)
625633
if (addInboundRouting(key, ctxt))
626634
{
627635
it = consumer.m_toSync.erase(it);
636+
/*
637+
* Write result only when removing from consumer in pre-op
638+
* For other cases, this will be handled in post-op
639+
*/
640+
writeResultToDB(dash_route_rule_result_table_, key, result);
628641
}
629642
else
630643
{
@@ -636,6 +649,7 @@ void DashRouteOrch::doTaskRouteRuleTable(ConsumerBase& consumer)
636649
if (removeInboundRouting(key, ctxt))
637650
{
638651
it = consumer.m_toSync.erase(it);
652+
removeResultFromDB(dash_route_rule_result_table_, key);
639653
}
640654
else
641655
{
@@ -657,7 +671,7 @@ void DashRouteOrch::doTaskRouteRuleTable(ConsumerBase& consumer)
657671
KeyOpFieldsValuesTuple t = it_prev->second;
658672
string key = kfvKey(t);
659673
string op = kfvOp(t);
660-
uint32_t result = DASH_RESULT_SUCCESS;
674+
result = DASH_RESULT_SUCCESS;
661675
auto found = toBulk.find(make_pair(key, op));
662676
if (found == toBulk.end())
663677
{
@@ -827,13 +841,13 @@ void DashRouteOrch::doTaskRouteGroupTable(ConsumerBase& consumer)
827841
SWSS_LOG_ENTER();
828842

829843
auto it = consumer.m_toSync.begin();
830-
844+
uint32_t result;
831845
while (it != consumer.m_toSync.end())
832846
{
833847
auto t = it->second;
834848
string route_group = kfvKey(t);
835849
string op = kfvOp(t);
836-
uint32_t result = DASH_RESULT_SUCCESS;
850+
result = DASH_RESULT_SUCCESS;
837851
if (op == SET_COMMAND)
838852
{
839853
dash::route_group::RouteGroup entry;

orchagent/dash/dashtunnelorch.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ bool ipAddrEq(const dash::types::IpAddress& lhs, const dash::types::IpAddress& r
5151
DashTunnelOrch::DashTunnelOrch(
5252
swss::DBConnector *db,
5353
std::vector<std::string> &tables,
54+
swss::DBConnector *app_state_db,
5455
swss::ZmqServer *zmqServer) :
5556
tunnel_bulker_(sai_dash_tunnel_api, gSwitchId, gMaxBulkSize, SAI_OBJECT_TYPE_DASH_TUNNEL),
5657
tunnel_member_bulker_(sai_dash_tunnel_api, gSwitchId, gMaxBulkSize, SAI_OBJECT_TYPE_DASH_TUNNEL_MEMBER),
5758
tunnel_nhop_bulker_(sai_dash_tunnel_api, gSwitchId, gMaxBulkSize, SAI_OBJECT_TYPE_DASH_TUNNEL_NEXT_HOP),
5859
ZmqOrch(db, tables, zmqServer)
5960
{
6061
SWSS_LOG_ENTER();
62+
dash_tunnel_result_table_ = std::make_unique<swss::Table>(app_state_db, APP_DASH_TUNNEL_TABLE_NAME);
6163
}
6264

6365
sai_object_id_t DashTunnelOrch::getTunnelOid(const std::string& tunnel_name)
@@ -90,6 +92,7 @@ void DashTunnelOrch::doTask(ConsumerBase &consumer)
9092
SWSS_LOG_ENTER();
9193

9294
const auto& tn = consumer.getTableName();
95+
uint32_t result;
9396
SWSS_LOG_INFO("doTask: %s", tn.c_str());
9497
if (tn != APP_DASH_TUNNEL_TABLE_NAME)
9598
{
@@ -102,6 +105,7 @@ void DashTunnelOrch::doTask(ConsumerBase &consumer)
102105
{
103106
std::map<std::pair<std::string, std::string>,
104107
DashTunnelBulkContext> toBulk;
108+
105109
while (it != consumer.m_toSync.end())
106110
{
107111
swss::KeyOpFieldsValuesTuple t = it->second;
@@ -112,6 +116,7 @@ void DashTunnelOrch::doTask(ConsumerBase &consumer)
112116
std::forward_as_tuple());
113117
bool inserted = rc.second;
114118
auto& ctxt = rc.first->second;
119+
result = DASH_RESULT_SUCCESS;
115120
if (!inserted)
116121
{
117122
ctxt.clear();
@@ -127,6 +132,11 @@ void DashTunnelOrch::doTask(ConsumerBase &consumer)
127132
if (addTunnel(tunnel_name, ctxt))
128133
{
129134
it = consumer.m_toSync.erase(it);
135+
/*
136+
* Write result only when removing from consumer in pre-op
137+
* For other cases, this will be handled in post-op
138+
*/
139+
writeResultToDB(dash_tunnel_result_table_, tunnel_name, result);
130140
}
131141
else
132142
{
@@ -137,6 +147,10 @@ void DashTunnelOrch::doTask(ConsumerBase &consumer)
137147
{
138148
if (removeTunnel(tunnel_name, ctxt))
139149
{
150+
/*
151+
* Postpone removal of result from result table until after
152+
* tunnel members are removed.
153+
*/
140154
it = consumer.m_toSync.erase(it);
141155
}
142156
else
@@ -145,7 +159,7 @@ void DashTunnelOrch::doTask(ConsumerBase &consumer)
145159
}
146160
}
147161
}
148-
162+
149163
tunnel_member_bulker_.flush();
150164
tunnel_bulker_.flush();
151165
tunnel_nhop_bulker_.flush();
@@ -156,6 +170,7 @@ void DashTunnelOrch::doTask(ConsumerBase &consumer)
156170
swss::KeyOpFieldsValuesTuple t = it_prev->second;
157171
std::string tunnel_name = kfvKey(t);
158172
std::string op = kfvOp(t);
173+
result = DASH_RESULT_SUCCESS;
159174
auto found = toBulk.find(std::make_pair(tunnel_name, op));
160175
if (found == toBulk.end())
161176
{
@@ -172,14 +187,17 @@ void DashTunnelOrch::doTask(ConsumerBase &consumer)
172187
}
173188
else
174189
{
190+
result = DASH_RESULT_FAILURE;
175191
it_prev++;
176192
}
193+
writeResultToDB(dash_tunnel_result_table_, tunnel_name, result);
177194
}
178195
else if (op == DEL_COMMAND)
179196
{
180197
if (removeTunnelPost(tunnel_name, ctxt))
181198
{
182199
it_prev = consumer.m_toSync.erase(it_prev);
200+
removeResultFromDB(dash_tunnel_result_table_, tunnel_name);
183201
}
184202
else
185203
{
@@ -196,6 +214,7 @@ void DashTunnelOrch::doTask(ConsumerBase &consumer)
196214
swss::KeyOpFieldsValuesTuple t = it_prev->second;
197215
std::string tunnel_name = kfvKey(t);
198216
std::string op = kfvOp(t);
217+
result = DASH_RESULT_SUCCESS;
199218
auto found = toBulk.find(std::make_pair(tunnel_name, op));
200219
if (found == toBulk.end())
201220
{
@@ -212,8 +231,10 @@ void DashTunnelOrch::doTask(ConsumerBase &consumer)
212231
}
213232
else
214233
{
234+
result = DASH_RESULT_FAILURE;
215235
it_prev++;
216236
}
237+
writeResultToDB(dash_tunnel_result_table_, tunnel_name, result);
217238
}
218239
else if (op == DEL_COMMAND)
219240
{

orchagent/dash/dashtunnelorch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class DashTunnelOrch : public ZmqOrch
5050
DashTunnelOrch(
5151
swss::DBConnector *db,
5252
std::vector<std::string> &tables,
53+
swss::DBConnector *app_state_db,
5354
swss::ZmqServer *zmqServer);
5455

5556
sai_object_id_t getTunnelOid(const std::string& tunnel_name);
@@ -59,6 +60,7 @@ class DashTunnelOrch : public ZmqOrch
5960
ObjectBulker<sai_dash_tunnel_api_t> tunnel_member_bulker_;
6061
ObjectBulker<sai_dash_tunnel_api_t> tunnel_nhop_bulker_;
6162
std::unordered_map<std::string, DashTunnelEntry> tunnel_table_;
63+
std::unique_ptr<swss::Table> dash_tunnel_result_table_;
6264

6365
void doTask(ConsumerBase &consumer);
6466
bool addTunnel(const std::string& tunnel_name, DashTunnelBulkContext& ctxt);

0 commit comments

Comments
 (0)