Skip to content

Commit 95f24e2

Browse files
Revert "[RouteOrch] Record ROUTE_TABLE entry programming status to APPL_STATE_DB (sonic-net#2512)"
This reverts commit 35385ad.
1 parent 7e69134 commit 95f24e2

5 files changed

Lines changed: 7 additions & 132 deletions

File tree

orchagent/routeorch.cpp

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ RouteOrch::RouteOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames,
4848
{
4949
SWSS_LOG_ENTER();
5050

51-
m_publisher.setBuffered(true);
52-
5351
sai_attribute_t attr;
5452
attr.id = SAI_SWITCH_ATTR_NUMBER_OF_ECMP_GROUPS;
5553

@@ -502,7 +500,7 @@ void RouteOrch::doTask(Consumer& consumer)
502500

503501
auto rc = toBulk.emplace(std::piecewise_construct,
504502
std::forward_as_tuple(key, op),
505-
std::forward_as_tuple(key, (op == SET_COMMAND)));
503+
std::forward_as_tuple());
506504

507505
bool inserted = rc.second;
508506
auto& ctx = rc.first->second;
@@ -633,11 +631,6 @@ void RouteOrch::doTask(Consumer& consumer)
633631

634632
if (fvField(i) == "seg_src")
635633
srv6_source = fvValue(i);
636-
637-
if (fvField(i) == "protocol")
638-
{
639-
ctx.protocol = fvValue(i);
640-
}
641634
}
642635

643636
/*
@@ -858,10 +851,6 @@ void RouteOrch::doTask(Consumer& consumer)
858851
/* fullmask subnet route is same as ip2me route */
859852
else if (ip_prefix.isFullMask() && m_intfsOrch->isPrefixSubnet(ip_prefix, alsv[0]))
860853
{
861-
/* The prefix is full mask (/32 or /128) and it is an interface subnet route, so IntfOrch has already
862-
* created an IP2ME route for it and we skip programming such route here as it already exists.
863-
* However, to keep APPL_DB and APPL_STATE_DB consistent we have to publish it. */
864-
publishRouteState(ctx);
865854
it = consumer.m_toSync.erase(it);
866855
}
867856
/* subnet route, vrf leaked route, etc */
@@ -891,9 +880,7 @@ void RouteOrch::doTask(Consumer& consumer)
891880
}
892881
else
893882
{
894-
/* Duplicate entry. Publish route state anyway since there could be multiple DEL, SET operations
895-
* consolidated by ConsumerStateTable leading to orchagent receiving only the last SET update. */
896-
publishRouteState(ctx);
883+
/* Duplicate entry */
897884
it = consumer.m_toSync.erase(it);
898885
}
899886

@@ -2321,9 +2308,6 @@ bool RouteOrch::addRoutePost(const RouteBulkContext& ctx, const NextHopGroupKey
23212308

23222309
notifyNextHopChangeObservers(vrf_id, ipPrefix, nextHops, true);
23232310

2324-
/* Publish and update APPL STATE DB route entry programming status */
2325-
publishRouteState(ctx);
2326-
23272311
/*
23282312
* If the route uses a temporary synced NHG owned by NhgOrch, return false
23292313
* in order to keep trying to update the route in case the NHG is updated,
@@ -2538,9 +2522,6 @@ bool RouteOrch::removeRoutePost(const RouteBulkContext& ctx)
25382522

25392523
SWSS_LOG_INFO("Remove route %s with next hop(s) %s",
25402524
ipPrefix.to_string().c_str(), it_route->second.nhg_key.to_string().c_str());
2541-
2542-
/* Publish removal status, removes route entry from APPL STATE DB */
2543-
publishRouteState(ctx);
25442525

25452526
if (ipPrefix.isDefaultRoute() && vrf_id == gVirtualRouterId)
25462527
{
@@ -2697,22 +2678,3 @@ void RouteOrch::decNhgRefCount(const std::string &nhg_index)
26972678
gCbfNhgOrch->decNhgRefCount(nhg_index);
26982679
}
26992680
}
2700-
2701-
void RouteOrch::publishRouteState(const RouteBulkContext& ctx, const ReturnCode& status)
2702-
{
2703-
SWSS_LOG_ENTER();
2704-
2705-
std::vector<FieldValueTuple> fvs;
2706-
2707-
/* Leave the fvs empty if the operation type is "DEL".
2708-
* An empty fvs makes ResponsePublisher::publish() remove the state entry from APPL_STATE_DB
2709-
*/
2710-
if (ctx.is_set)
2711-
{
2712-
fvs.emplace_back("protocol", ctx.protocol);
2713-
}
2714-
2715-
const bool replace = false;
2716-
2717-
m_publisher.publish(APP_ROUTE_TABLE_NAME, ctx.key, fvs, status, replace);
2718-
}

orchagent/routeorch.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,8 @@ struct RouteBulkContext
122122
// using_temp_nhg will track if the NhgOrch's owned NHG is temporary or not
123123
bool using_temp_nhg;
124124

125-
std::string key; // Key in database table
126-
std::string protocol; // Protocol string
127-
bool is_set; // True if set operation
128-
129-
RouteBulkContext(const std::string& key, bool is_set)
130-
: key(key), excp_intfs_flag(false), using_temp_nhg(false), is_set(is_set)
125+
RouteBulkContext()
126+
: excp_intfs_flag(false), using_temp_nhg(false)
131127
{
132128
}
133129

@@ -143,8 +139,6 @@ struct RouteBulkContext
143139
excp_intfs_flag = false;
144140
vrf_id = SAI_NULL_OBJECT_ID;
145141
using_temp_nhg = false;
146-
key.clear();
147-
protocol.clear();
148142
}
149143
};
150144

@@ -276,8 +270,6 @@ class RouteOrch : public Orch, public Subject
276270
const NhgBase &getNhg(const std::string& nhg_index);
277271
void incNhgRefCount(const std::string& nhg_index);
278272
void decNhgRefCount(const std::string& nhg_index);
279-
280-
void publishRouteState(const RouteBulkContext& ctx, const ReturnCode& status = ReturnCode(SAI_STATUS_SUCCESS));
281273
};
282274

283275
#endif /* SWSS_ROUTEORCH_H */

tests/mock_tests/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ tests_intfmgrd_INCLUDES = $(tests_INCLUDES) -I$(top_srcdir)/cfgmgr -I$(top_srcdi
191191
tests_intfmgrd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI)
192192
tests_intfmgrd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) $(tests_intfmgrd_INCLUDES)
193193
tests_intfmgrd_LDADD = $(LDADD_GTEST) $(LDADD_SAI) -lnl-genl-3 -lhiredis -lhiredis \
194-
-lswsscommon -lswsscommon -lgtest -lgtest_main -lzmq -lnl-3 -lnl-route-3 -lpthread -lgmock -lgmock_main
194+
-lswsscommon -lswsscommon -lgtest -lgtest_main -lzmq -lnl-3 -lnl-route-3 -lpthread
195195

196196
## teammgrd unit tests
197197

tests/mock_tests/fake_response_publisher.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,19 @@
22
#include <vector>
33

44
#include "response_publisher.h"
5-
#include "mock_response_publisher.h"
6-
7-
/* This mock plugs into this fake response publisher implementation
8-
* when needed to test code that uses response publisher. */
9-
std::unique_ptr<MockResponsePublisher> gMockResponsePublisher;
105

116
ResponsePublisher::ResponsePublisher(bool buffered) : m_db(std::make_unique<swss::DBConnector>("APPL_STATE_DB", 0)), m_buffered(buffered) {}
127

138
void ResponsePublisher::publish(
149
const std::string& table, const std::string& key,
1510
const std::vector<swss::FieldValueTuple>& intent_attrs,
1611
const ReturnCode& status,
17-
const std::vector<swss::FieldValueTuple>& state_attrs, bool replace)
18-
{
19-
if (gMockResponsePublisher)
20-
{
21-
gMockResponsePublisher->publish(table, key, intent_attrs, status, state_attrs, replace);
22-
}
23-
}
12+
const std::vector<swss::FieldValueTuple>& state_attrs, bool replace) {}
2413

2514
void ResponsePublisher::publish(
2615
const std::string& table, const std::string& key,
2716
const std::vector<swss::FieldValueTuple>& intent_attrs,
28-
const ReturnCode& status, bool replace)
29-
{
30-
if (gMockResponsePublisher)
31-
{
32-
gMockResponsePublisher->publish(table, key, intent_attrs, status, replace);
33-
}
34-
}
17+
const ReturnCode& status, bool replace) {}
3518

3619
void ResponsePublisher::writeToDB(
3720
const std::string& table, const std::string& key,

tests/mock_tests/routeorch_ut.cpp

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,10 @@
77
#include "ut_helper.h"
88
#include "mock_orchagent_main.h"
99
#include "mock_table.h"
10-
#include "mock_response_publisher.h"
1110
#include "bulker.h"
1211

1312
extern string gMySwitchType;
1413

15-
extern std::unique_ptr<MockResponsePublisher> gMockResponsePublisher;
16-
17-
using ::testing::_;
1814

1915
namespace routeorch_test
2016
{
@@ -286,10 +282,6 @@ namespace routeorch_test
286282
{"mac_addr", "00:00:00:00:00:00" }});
287283
intfTable.set("Ethernet0:10.0.0.1/24", { { "scope", "global" },
288284
{ "family", "IPv4" }});
289-
intfTable.set("Ethernet4", { {"NULL", "NULL" },
290-
{"mac_addr", "00:00:00:00:00:00" }});
291-
intfTable.set("Ethernet4:11.0.0.1/32", { { "scope", "global" },
292-
{ "family", "IPv4" }});
293285
gIntfsOrch->addExistingData(&intfTable);
294286
static_cast<Orch *>(gIntfsOrch)->doTask();
295287

@@ -430,58 +422,4 @@ namespace routeorch_test
430422
ASSERT_EQ(current_set_count + 1, set_route_count);
431423
ASSERT_EQ(sai_fail_count, 0);
432424
}
433-
434-
TEST_F(RouteOrchTest, RouteOrchTestSetDelResponse)
435-
{
436-
gMockResponsePublisher = std::make_unique<MockResponsePublisher>();
437-
438-
std::deque<KeyOpFieldsValuesTuple> entries;
439-
std::string key = "2.2.2.0/24";
440-
std::vector<FieldValueTuple> fvs{{"ifname", "Ethernet0,Ethernet0"}, {"nexthop", "10.0.0.2,10.0.0.3"}, {"protocol", "bgp"}};
441-
entries.push_back({key, "SET", fvs});
442-
443-
auto consumer = dynamic_cast<Consumer *>(gRouteOrch->getExecutor(APP_ROUTE_TABLE_NAME));
444-
consumer->addToSync(entries);
445-
446-
EXPECT_CALL(*gMockResponsePublisher, publish(APP_ROUTE_TABLE_NAME, key, std::vector<FieldValueTuple>{{"protocol", "bgp"}}, ReturnCode(SAI_STATUS_SUCCESS), false)).Times(1);
447-
static_cast<Orch *>(gRouteOrch)->doTask();
448-
449-
// add entries again to the consumer queue (in case of rapid DEL/SET operations from fpmsyncd, routeorch just gets the last SET update)
450-
consumer->addToSync(entries);
451-
452-
EXPECT_CALL(*gMockResponsePublisher, publish(APP_ROUTE_TABLE_NAME, key, std::vector<FieldValueTuple>{{"protocol", "bgp"}}, ReturnCode(SAI_STATUS_SUCCESS), false)).Times(1);
453-
static_cast<Orch *>(gRouteOrch)->doTask();
454-
455-
entries.clear();
456-
457-
// Route deletion
458-
459-
entries.clear();
460-
entries.push_back({key, "DEL", {}});
461-
462-
consumer->addToSync(entries);
463-
464-
EXPECT_CALL(*gMockResponsePublisher, publish(APP_ROUTE_TABLE_NAME, key, std::vector<FieldValueTuple>{}, ReturnCode(SAI_STATUS_SUCCESS), false)).Times(1);
465-
static_cast<Orch *>(gRouteOrch)->doTask();
466-
467-
gMockResponsePublisher.reset();
468-
}
469-
470-
TEST_F(RouteOrchTest, RouteOrchSetFullMaskSubnetPrefix)
471-
{
472-
gMockResponsePublisher = std::make_unique<MockResponsePublisher>();
473-
474-
std::deque<KeyOpFieldsValuesTuple> entries;
475-
std::string key = "11.0.0.1/32";
476-
std::vector<FieldValueTuple> fvs{{"ifname", "Ethernet4"}, {"nexthop", "0.0.0.0"}, {"protocol", "bgp"}};
477-
entries.push_back({key, "SET", fvs});
478-
479-
auto consumer = dynamic_cast<Consumer *>(gRouteOrch->getExecutor(APP_ROUTE_TABLE_NAME));
480-
consumer->addToSync(entries);
481-
482-
EXPECT_CALL(*gMockResponsePublisher, publish(APP_ROUTE_TABLE_NAME, key, std::vector<FieldValueTuple>{{"protocol", "bgp"}}, ReturnCode(SAI_STATUS_SUCCESS), false)).Times(1);
483-
static_cast<Orch *>(gRouteOrch)->doTask();
484-
485-
gMockResponsePublisher.reset();
486-
}
487425
}

0 commit comments

Comments
 (0)