@@ -1700,8 +1700,6 @@ std::vector<route::tunnel_value_interface_t> route_t::MakeTunnelValueRequestInte
17001700{
17011701 std::vector<route::tunnel_value_interface_t > request_interface;
17021702
1703- tunnel_value_lookup[value_id].clear ();
1704-
17051703 const auto & visitor = utils::Visitor{
17061704 [&](const route::tunnel_destination_interface_t & nexthops) {
17071705 for (const auto & [nexthop, label, peer_id, origin_as, weight] : nexthops)
@@ -1790,6 +1788,8 @@ void route_t::tunnel_value_compile(common::idp::updateGlobalBase::request& globa
17901788 return ;
17911789 }
17921790
1791+ tunnel_value_lookup[value_id].clear ();
1792+
17931793 generation.for_each_socket ([this ,
17941794 &value_id,
17951795 &request_interface,
@@ -1803,64 +1803,47 @@ void route_t::tunnel_value_compile(common::idp::updateGlobalBase::request& globa
18031803 std::vector<uint32_t > weights;
18041804 uint64_t weight_total = 0 ;
18051805
1806- // / same numa
1807- for (const auto & item : request_interface)
1808- {
1809- const auto & [nexthop, egress_interface_id, label, egress_interface_name, peer_id, origin_as, weight, neighbor_address] = item;
1810- GCC_BUG_UNUSED (egress_interface_name);
1811-
1812- if (exist (interfaces, egress_interface_id))
1806+ auto collect = [&](auto filter) {
1807+ for (const auto & item : request_interface)
18131808 {
1814- const auto counter_id = tunnel_counter. get_id ({fallback. is_ipv4 (), peer_id, nexthop , origin_as}) ;
1809+ const auto & [nexthop, egress_interface_id, label, egress_interface_name, peer_id , origin_as, weight, neighbor_address] = item ;
18151810
1816- uint16_t flags = 0 ;
1817- if (neighbor_address.is_default ())
1811+ if (filter (item))
18181812 {
1819- flags |= YANET_NEXTHOP_FLAG_DIRECTLY;
1820- }
1813+ const auto counter_id = tunnel_counter.get_id ({fallback.is_ipv4 (), peer_id, nexthop, origin_as});
1814+
1815+ uint16_t flags = 0 ;
1816+ if (neighbor_address.is_default ())
1817+ {
1818+ flags |= YANET_NEXTHOP_FLAG_DIRECTLY;
1819+ }
18211820
1822- update_nexthops.emplace_back (egress_interface_id, counter_id, label, nexthop, neighbor_address, flags);
1823- weights.emplace_back (weight);
1821+ update_nexthops.emplace_back (egress_interface_id, counter_id, label, nexthop, neighbor_address, flags);
1822+ weights.emplace_back (weight);
18241823
1825- tunnel_value_lookup[value_id][socket_id].emplace_back (nexthop,
1826- egress_interface_name,
1827- label,
1828- peer_id,
1829- origin_as,
1830- weight);
1824+ tunnel_value_lookup[value_id][socket_id].emplace_back (nexthop,
1825+ egress_interface_name,
1826+ label,
1827+ peer_id,
1828+ origin_as,
1829+ weight);
18311830
1832- weight_total += weight;
1831+ weight_total += weight;
1832+ }
18331833 }
1834- }
1834+ };
1835+
1836+ // same numa
1837+ collect ([&](const route::tunnel_value_interface_t & e) {
1838+ return exist (interfaces, std::get<1 >(e));
1839+ });
18351840
18361841 // / all numa
18371842 if (update_nexthops.empty ())
18381843 {
1839- for (const auto & item : request_interface)
1840- {
1841- const auto & [nexthop, egress_interface_id, label, egress_interface_name, peer_id, origin_as, weight, neighbor_address] = item;
1842- GCC_BUG_UNUSED (egress_interface_name);
1843-
1844- const auto counter_id = tunnel_counter.get_id ({fallback.is_ipv4 (), peer_id, nexthop, origin_as});
1845-
1846- uint16_t flags = 0 ;
1847- if (neighbor_address.is_default ())
1848- {
1849- flags |= YANET_NEXTHOP_FLAG_DIRECTLY;
1850- }
1851-
1852- update_nexthops.emplace_back (egress_interface_id, counter_id, label, nexthop, neighbor_address, flags);
1853- weights.emplace_back (weight);
1854-
1855- tunnel_value_lookup[value_id][socket_id].emplace_back (nexthop,
1856- egress_interface_name,
1857- label,
1858- peer_id,
1859- origin_as,
1860- weight);
1861-
1862- weight_total += weight;
1863- }
1844+ collect ([](const route::tunnel_value_interface_t &) {
1845+ return true ;
1846+ });
18641847 }
18651848
18661849 const auto & [weight_start, weight_size, weight_is_fallback] = tunnel_weights.insert (weights);
@@ -1875,7 +1858,6 @@ void route_t::tunnel_value_compile(common::idp::updateGlobalBase::request& globa
18751858
18761859 for (auto & [nexthop, egress_interface_name, label, peer_id, origin_as, weight_percent] : tunnel_value_lookup[value_id][socket_id])
18771860 {
1878- GCC_BUG_UNUSED (socket_id);
18791861 GCC_BUG_UNUSED (nexthop);
18801862 GCC_BUG_UNUSED (egress_interface_name);
18811863 GCC_BUG_UNUSED (label);
0 commit comments