13
13
#include " converter.h"
14
14
#include < string.h>
15
15
#include < arpa/inet.h>
16
+ #include < yaml-cpp/yaml.h>
16
17
17
18
using namespace std ;
18
19
using namespace swss ;
@@ -86,6 +87,20 @@ RouteSync::RouteSync(RedisPipeline *pipeline) :
86
87
m_nl_sock = nl_socket_alloc ();
87
88
nl_connect (m_nl_sock, NETLINK_ROUTE);
88
89
rtnl_link_alloc_cache (m_nl_sock, AF_UNSPEC, &m_link_cache);
90
+
91
+ YAML::Node root;
92
+ try
93
+ {
94
+ root = YAML::LoadFile (" /etc/sonic/constants.yml" );
95
+ route_tag_not_to_appdb = root[" constants" ][" bgp" ][" route_do_not_send_appdb_tag" ].as <int >();
96
+ route_tag_fallback_to_default_route = root[" constants" ][" bgp" ][" route_eligible_for_fallback_to_default_tag" ].as <int >();
97
+ }
98
+ catch (const exception &e)
99
+ {
100
+ cout << " Exception \" " << e.what () << " \" had been thrown in daemon in loading constants.yml" << endl;
101
+ route_tag_not_to_appdb = 0xffffffff ;
102
+ route_tag_fallback_to_default_route = 0xffffffff ;
103
+ }
89
104
}
90
105
91
106
char *RouteSync::prefixMac2Str (char *mac, char *buf, int size)
@@ -667,6 +682,8 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf)
667
682
struct rtnl_route *route_obj = (struct rtnl_route *)obj;
668
683
struct nl_addr *dip;
669
684
char destipprefix[IFNAMSIZ + MAX_ADDR_SIZE + 2 ] = {0 };
685
+ uint32_t tag = 0 ;
686
+ bool route_eligible_for_fallback_to_default_route = false ;
670
687
671
688
if (vrf)
672
689
{
@@ -693,6 +710,13 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf)
693
710
destipprefix[strlen (vrf)] = ' :' ;
694
711
}
695
712
713
+ tag = rtnl_route_get_priority (route_obj);
714
+
715
+ if (tag == route_tag_not_to_appdb)
716
+ return ;
717
+ else if (tag == route_tag_fallback_to_default_route)
718
+ route_eligible_for_fallback_to_default_route = true ;
719
+
696
720
dip = rtnl_route_get_dst (route_obj);
697
721
nl_addr2str (dip, destipprefix + strlen (destipprefix), MAX_ADDR_SIZE);
698
722
@@ -833,6 +857,12 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf)
833
857
fvVector.push_back (wt);
834
858
}
835
859
860
+ if (route_eligible_for_fallback_to_default_route)
861
+ {
862
+ FieldValueTuple tag (" fallback_to_default_route" , " true" );
863
+ fvVector.push_back (tag);
864
+ }
865
+
836
866
if (!warmRestartInProgress)
837
867
{
838
868
m_routeTable.set (destipprefix, fvVector);
0 commit comments