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

Changes to read route tag value from Netlink Message and take appropriate action #3353

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
2 changes: 1 addition & 1 deletion fpmsyncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fpmsyncd_SOURCES = fpmsyncd.cpp fpmlink.cpp routesync.cpp $(top_srcdir)/warmrest

fpmsyncd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_ASAN)
fpmsyncd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_ASAN)
fpmsyncd_LDADD = $(LDFLAGS_ASAN) -lnl-3 -lnl-route-3 -lswsscommon
fpmsyncd_LDADD = $(LDFLAGS_ASAN) -lnl-3 -lnl-route-3 -lswsscommon -lyaml-cpp

if GCOV_ENABLED
fpmsyncd_SOURCES += ../gcovpreload/gcovpreload.cpp
Expand Down
30 changes: 30 additions & 0 deletions fpmsyncd/routesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "converter.h"
#include <string.h>
#include <arpa/inet.h>
#include <yaml-cpp/yaml.h>

using namespace std;
using namespace swss;
Expand Down Expand Up @@ -86,6 +87,20 @@ RouteSync::RouteSync(RedisPipeline *pipeline) :
m_nl_sock = nl_socket_alloc();
nl_connect(m_nl_sock, NETLINK_ROUTE);
rtnl_link_alloc_cache(m_nl_sock, AF_UNSPEC, &m_link_cache);

YAML::Node root;
try
{
root = YAML::LoadFile("/etc/sonic/constants.yml");
route_tag_not_to_appdb = root["constants"]["bgp"]["route_do_not_send_appdb_tag"].as<int>();
route_tag_fallback_to_default_route = root["constants"]["bgp"]["route_eligible_for_fallback_to_default_tag"].as<int>();
}
catch (const exception &e)
{
cout << "Exception \"" << e.what() << "\" had been thrown in daemon in loading constants.yml" << endl;
route_tag_not_to_appdb = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non T2 devices might always print the exception log?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only if fails to reads constants.yml which should not happen. this attribute are define in constants.yml (irrespective of the role)
https://github.com/sonic-net/sonic-buildimage/pull/20224/files#diff-e6f2fe13a6c276dc2f3b27a5bef79886f9c103194be4fcb28ce57375edf2c23c

route_tag_fallback_to_default_route = 0;
}
}

char *RouteSync::prefixMac2Str(char *mac, char *buf, int size)
Expand Down Expand Up @@ -667,6 +682,8 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf)
struct rtnl_route *route_obj = (struct rtnl_route *)obj;
struct nl_addr *dip;
char destipprefix[IFNAMSIZ + MAX_ADDR_SIZE + 2] = {0};
uint32_t tag = 0;
bool route_eligible_for_fallback_to_default_route = false;

if (vrf)
{
Expand All @@ -693,6 +710,13 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf)
destipprefix[strlen(vrf)] = ':';
}

tag = rtnl_route_get_priority(route_obj);

if (tag == route_tag_not_to_appdb)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand on pizza box, route_tag_not_to_appdb is zero. If for any route the priority is zero then route will not be added to app_db. So the route will always has non-zero priority?

Copy link
Contributor Author

@abdosi abdosi Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should not be zero. It always reads from constants.yml. Only time this will be zero in case of fail condition of loading/reading the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should not be zero. It always reads from constants.yml. Updated the fail case to be non-zero as 0xffffffff

return;
else if (tag == route_tag_fallback_to_default_route)
route_eligible_for_fallback_to_default_route = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indentation is wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.


dip = rtnl_route_get_dst(route_obj);
nl_addr2str(dip, destipprefix + strlen(destipprefix), MAX_ADDR_SIZE);

Expand Down Expand Up @@ -833,6 +857,12 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf)
fvVector.push_back(wt);
}

if (route_eligible_for_fallback_to_default_route)
{
FieldValueTuple tag("fallback_to_default_route", "true");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this field processed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fvVector.push_back(tag);
}

if (!warmRestartInProgress)
{
m_routeTable.set(destipprefix, fvVector);
Expand Down
2 changes: 2 additions & 0 deletions fpmsyncd/routesync.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class RouteSync : public NetMsg
ProducerStateTable m_vnet_tunnelTable;
struct nl_cache *m_link_cache;
struct nl_sock *m_nl_sock;
uint32_t route_tag_not_to_appdb;
uint32_t route_tag_fallback_to_default_route;

bool m_isSuppressionEnabled{false};
FpmInterface* m_fpmInterface {nullptr};
Expand Down
Loading