Only call attrhash_cmp when necessary.
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
bgp_path_info_add(dest, tmp_pi);
} else {
tmp_pi = local_pi;
- if (attrhash_cmp(tmp_pi->attr, attr)
- && !CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED))
+ if (!CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED) && attrhash_cmp(tmp_pi->attr, attr))
route_change = 0;
else {
/*
pi = bgp_create_evpn_bgp_path_info(parent_pi, dest, &attr);
new_pi = true;
} else {
- if (attrhash_cmp(pi->attr, &attr)
- && !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
+ if (!CHECK_FLAG(pi->flags, BGP_PATH_REMOVED) && attrhash_cmp(pi->attr, &attr)) {
bgp_dest_unlock_node(dest);
return 0;
}
* install_evpn_route_entry_in_vni_mac() or
* install_evpn_route_entry_in_vni_ip()
*/
- if (attrhash_cmp(pi->attr, parent_pi->attr) &&
- !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED))
+ if (!CHECK_FLAG(pi->flags, BGP_PATH_REMOVED) &&
+ attrhash_cmp(pi->attr, parent_pi->attr))
return 0;
/* The attribute has changed. */
/* Add (or update) attribute to hash. */
bgp_dest_lock_node((struct bgp_dest *)parent_pi->net);
bgp_path_info_add(dest, pi);
} else {
- if (attrhash_cmp(pi->attr, parent_pi->attr)
- && !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
+ if (!CHECK_FLAG(pi->flags, BGP_PATH_REMOVED) &&
+ attrhash_cmp(pi->attr, parent_pi->attr)) {
bgp_dest_unlock_node(dest);
return 0;
}
bgp_path_info_add(dest, tmp_pi);
} else {
tmp_pi = local_pi;
- if (attrhash_cmp(tmp_pi->attr, attr)
- && !CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED))
+ if (!CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED) && attrhash_cmp(tmp_pi->attr, attr))
*route_changed = 0;
else {
/* The attribute has changed.
return NULL;
}
- if (attrhash_cmp(bpi->attr, new_attr) && labelssame &&
- !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED) &&
+ if (labelssame && !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED) &&
+ attrhash_cmp(bpi->attr, new_attr) &&
leak_update_nexthop_valid(to_bgp, bn, new_attr, afi, safi, source_bpi, bpi,
bgp_orig, p,
debug) == !!CHECK_FLAG(bpi->flags, BGP_PATH_VALID)) {
break;
if (pi) {
- if (attrhash_cmp(pi->attr, attr_new)
- && !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)
- && !CHECK_FLAG(bgp->flags, BGP_FLAG_FORCE_STATIC_PROCESS)) {
+ if (!CHECK_FLAG(pi->flags, BGP_PATH_REMOVED) &&
+ !CHECK_FLAG(bgp->flags, BGP_FLAG_FORCE_STATIC_PROCESS) &&
+ attrhash_cmp(pi->attr, attr_new)) {
bgp_dest_unlock_node(dest);
bgp_attr_unintern(&attr_new);
aspath_unintern(&attr.aspath);
if (bpi) {
/* Ensure the (source route) type is updated. */
bpi->type = type;
- if (attrhash_cmp(bpi->attr, new_attr)
- && !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) {
+ if (!CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED) &&
+ attrhash_cmp(bpi->attr, new_attr)) {
bgp_attr_unintern(&new_attr);
aspath_unintern(&attr.aspath);
bgp_dest_unlock_node(bn);
}
}
- if (attrhash_cmp(bpi->attr, new_attr)
- && !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) {
+ if (!CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED) && attrhash_cmp(bpi->attr, new_attr)) {
bgp_attr_unintern(&new_attr);
bgp_dest_unlock_node(bn);