@@ -1672,7 +1672,7 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf)
16721672 const auto itg = m_nh_groups.find (nhg_id);
16731673 if (itg == m_nh_groups.end ())
16741674 {
1675- SWSS_LOG_DEBUG (" NextHop group id %d not found. Dropping the route %s" , nhg_id, destipprefix);
1675+ SWSS_LOG_ERROR (" NextHop group id %d not found. Dropping the route %s" , nhg_id, destipprefix);
16761676 return ;
16771677 }
16781678 NextHopGroup& nhg = itg->second ;
@@ -1866,10 +1866,11 @@ void RouteSync::onNextHopMsg(struct nlmsghdr *h, int len)
18661866 SWSS_LOG_INFO (" New nexthop group message!" );
18671867 struct nexthop_grp *nha_grp = (struct nexthop_grp *)RTA_DATA (tb[NHA_GROUP]);
18681868 grp_count = (int )(RTA_PAYLOAD (tb[NHA_GROUP]) / sizeof (*nha_grp));
1869-
1870- if (grp_count > MAX_MULTIPATH_NUM)
1869+ if (grp_count > MAX_MULTIPATH_NUM)
1870+ {
1871+ SWSS_LOG_ERROR (" Nexthop group count (%d) exceeds the maximum allowed (%d). Clamping to maximum." , grp_count, MAX_MULTIPATH_NUM);
18711872 grp_count = MAX_MULTIPATH_NUM;
1872-
1873+ }
18731874 for (int i = 0 ; i < grp_count; i++) {
18741875 grp[i].id = nha_grp[i].id ;
18751876 /*
@@ -1917,19 +1918,20 @@ void RouteSync::onNextHopMsg(struct nlmsghdr *h, int len)
19171918 }
19181919 }
19191920 }
1920- if (grp_count)
1921+ if (grp_count > 0 )
19211922 {
1922- vector<pair<uint32_t ,uint8_t >> group;
1923- for (int i = 0 ; i < grp_count; i++)
1923+ vector<pair<uint32_t , uint8_t >> group (grp_count) ;
1924+ for (int i = 0 ; i < grp_count; i++)
19241925 {
1925- group. push_back ( std::make_pair (grp[i].id , grp[i].weight ) );
1926+ group[i] = std::make_pair (grp[i].id , grp[i].weight );
19261927 }
1928+
19271929 auto it = m_nh_groups.find (id);
1928- if (it != m_nh_groups.end ())
1930+ if (it != m_nh_groups.end ())
19291931 {
19301932 NextHopGroup &nhg = it->second ;
19311933 nhg.group = group;
1932- if (nhg.installed )
1934+ if (nhg.installed )
19331935 {
19341936 updateNextHopGroupDb (nhg);
19351937 }
@@ -2630,7 +2632,7 @@ void RouteSync::onWarmStartEnd(DBConnector& applStateDb)
26302632 */
26312633const string RouteSync::getNextHopGroupKeyAsString (uint32_t id) const
26322634{
2633- return string ( " ID " ) + to_string (id);
2635+ return to_string (id);
26342636}
26352637
26362638/*
0 commit comments