-
Notifications
You must be signed in to change notification settings - Fork 537
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
base: master
Are you sure you want to change the base?
Changes from all commits
f21f91a
553363b
26a6212
f609c8d
a608553
adff6c4
4ef4277
1465f05
1a2f986
3b456ae
bcc259b
42164d4
6aead84
9ca5ba6
a39fd1b
dae2b55
918ad05
11da94d
54de7d9
2796581
1d65e52
13e2d4f
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 |
---|---|---|
|
@@ -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; | ||
|
@@ -149,6 +150,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 = 0xffffffff; | ||
route_tag_fallback_to_default_route = 0xffffffff; | ||
} | ||
} | ||
|
||
char *RouteSync::prefixMac2Str(char *mac, char *buf, int size) | ||
|
@@ -1548,6 +1563,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) | ||
{ | ||
|
@@ -1574,6 +1591,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) | ||
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. As I understand on pizza box, 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 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. 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.
|
||
return; | ||
else if (tag == route_tag_fallback_to_default_route) | ||
route_eligible_for_fallback_to_default_route = true; | ||
|
||
dip = rtnl_route_get_dst(route_obj); | ||
nl_addr2str(dip, destipprefix + strlen(destipprefix), MAX_ADDR_SIZE); | ||
|
||
|
@@ -1714,6 +1738,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"); | ||
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. Where is this field processed? 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. @dgsudharsan : Here #3389 |
||
fvVector.push_back(tag); | ||
} | ||
|
||
if (!warmRestartInProgress) | ||
{ | ||
m_routeTable.set(destipprefix, fvVector); | ||
|
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.
Can you please explain motivation for this change?
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.
@dgsudharsan : To resolve
lyaml-cpp
dependency of swss debian package. Asapt install
take care of resolve all dependency