diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index 1e996012ef56..eb176131ee5e 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -993,22 +993,23 @@ void subgroup_default_originate(struct update_subgroup *subgrp, bool withdraw) if (dest) { for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) { - if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) { - if (subgroup_announce_check( - dest, pi, subgrp, - bgp_dest_get_prefix(dest), - &attr, NULL)) { - struct attr *default_attr = - bgp_attr_intern(&attr); - - if (!bgp_adj_out_set_subgroup( - dest, subgrp, - default_attr, pi)) - bgp_attr_unintern( - &default_attr); - } else - bgp_attr_flush(&attr); - } + if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) + continue; + + if (subgroup_announce_check(dest, pi, subgrp, + bgp_dest_get_prefix( + dest), + &attr, NULL)) { + struct attr *default_attr = + bgp_attr_intern(&attr); + + if (!bgp_adj_out_set_subgroup(dest, + subgrp, + default_attr, + pi)) + bgp_attr_unintern(&default_attr); + } else + bgp_attr_flush(&attr); } bgp_dest_unlock_node(dest); }