-
Notifications
You must be signed in to change notification settings - Fork 520
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
[RouteOrch] Record ROUTE_TABLE entry programming status to APPL_STATE_DB #2512
Changes from 5 commits
99dd9e4
44d1c21
47a65eb
e9feb5e
74fd843
e50d5cd
2b80c52
0fa58de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,8 @@ RouteOrch::RouteOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames, | |
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
m_publisher.setBuffered(true); | ||
|
||
sai_attribute_t attr; | ||
attr.id = SAI_SWITCH_ATTR_NUMBER_OF_ECMP_GROUPS; | ||
|
||
|
@@ -499,7 +501,7 @@ void RouteOrch::doTask(Consumer& consumer) | |
|
||
auto rc = toBulk.emplace(std::piecewise_construct, | ||
std::forward_as_tuple(key, op), | ||
std::forward_as_tuple()); | ||
std::forward_as_tuple(key)); | ||
|
||
bool inserted = rc.second; | ||
auto& ctx = rc.first->second; | ||
|
@@ -630,6 +632,11 @@ void RouteOrch::doTask(Consumer& consumer) | |
|
||
if (fvField(i) == "seg_src") | ||
srv6_source = fvValue(i); | ||
|
||
if (fvField(i) == "protocol") | ||
{ | ||
ctx.protocol = fvValue(i); | ||
} | ||
} | ||
|
||
/* | ||
|
@@ -831,6 +838,10 @@ void RouteOrch::doTask(Consumer& consumer) | |
/* fullmask subnet route is same as ip2me route */ | ||
else if (ip_prefix.isFullMask() && m_intfsOrch->isPrefixSubnet(ip_prefix, alsv[0])) | ||
{ | ||
/* The prefix is full mask (/32 or /128) and it is an interface subnet route, so IntfOrch has already | ||
* created an IP2ME route for it and we skip programming such route here as it already exists. | ||
* However, to keep APPL_DB and APPL_STATE_DB consistent we have to publish it. */ | ||
publishRouteState(ctx, ReturnCode(SAI_STATUS_SUCCESS)); | ||
it = consumer.m_toSync.erase(it); | ||
} | ||
/* subnet route, vrf leaked route, etc */ | ||
|
@@ -2226,6 +2237,9 @@ bool RouteOrch::addRoutePost(const RouteBulkContext& ctx, const NextHopGroupKey | |
|
||
notifyNextHopChangeObservers(vrf_id, ipPrefix, nextHops, true); | ||
|
||
/* Publish and update APPL STATE DB route entry programming status */ | ||
publishRouteState(ctx, ReturnCode(SAI_STATUS_SUCCESS)); | ||
|
||
/* | ||
* If the route uses a temporary synced NHG owned by NhgOrch, return false | ||
* in order to keep trying to update the route in case the NHG is updated, | ||
|
@@ -2419,6 +2433,9 @@ bool RouteOrch::removeRoutePost(const RouteBulkContext& ctx) | |
|
||
SWSS_LOG_INFO("Remove route %s with next hop(s) %s", | ||
ipPrefix.to_string().c_str(), it_route->second.nhg_key.to_string().c_str()); | ||
|
||
/* Publish removal status, removes route entry from APPL STATE DB */ | ||
publishRouteState(ctx, ReturnCode(SAI_STATUS_SUCCESS)); | ||
|
||
if (ipPrefix.isDefaultRoute() && vrf_id == gVirtualRouterId) | ||
{ | ||
|
@@ -2574,3 +2591,22 @@ void RouteOrch::decNhgRefCount(const std::string &nhg_index) | |
gCbfNhgOrch->decNhgRefCount(nhg_index); | ||
} | ||
} | ||
|
||
void RouteOrch::publishRouteState(const RouteBulkContext& ctx, const ReturnCode& status) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
std::vector<FieldValueTuple> fvs; | ||
|
||
/* If the operation type is "DEL" then ctx.protocol is empty and fvs is left empty. | ||
* An empty fvs makes ResponsePublisher::publish() remove the state entry from APPL_STATE_DB | ||
*/ | ||
if (!ctx.protocol.empty()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why introduce this field for identifying operation? I'm not sure if i understand the logic here. Can you please explaing this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not the motivation for introducing this field. The context does not carry operation type, however, if the protocol is left empty that means it is a delete operation, since the delete update does not carry FVS (including protocol) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @prsunny Replaced with a flag saved in the context object, please check. |
||
{ | ||
fvs.emplace_back("protocol", ctx.protocol); | ||
} | ||
|
||
const bool replace = false; | ||
|
||
m_publisher.publish(APP_ROUTE_TABLE_NAME, ctx.key, fvs, status, replace); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,7 +165,7 @@ tests_intfmgrd_INCLUDES = $(tests_INCLUDES) -I$(top_srcdir)/cfgmgr -I$(top_srcdi | |
tests_intfmgrd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) | ||
tests_intfmgrd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) $(tests_intfmgrd_INCLUDES) | ||
tests_intfmgrd_LDADD = $(LDADD_GTEST) $(LDADD_SAI) -lnl-genl-3 -lhiredis -lhiredis \ | ||
-lswsscommon -lswsscommon -lgtest -lgtest_main -lzmq -lnl-3 -lnl-route-3 -lpthread | ||
-lswsscommon -lswsscommon -lgtest -lgtest_main -lzmq -lnl-3 -lnl-route-3 -lpthread -lgmock -lgmock_main | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need this change in intfmgrd? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @prsunny tests/mock_tests/fake_response_publisher.cpp tests_intfmgrd depends on is using google mock |
||
|
||
## fpmsyncd unit tests | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have to introduce this field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is required to construct RTM_NEWROUTE with correct proto number.
https://github.com/stepanblyschak/SONiC/blob/bgp-suppress-fib-pending/doc/BGP/BGP-supress-fib-pending.md#74-fpmsyncd