summaryrefslogtreecommitdiff
path: root/bgpd/bgp_route.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_route.c')
-rw-r--r--bgpd/bgp_route.c231
1 files changed, 124 insertions, 107 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index c2c034d164..1bd5780a20 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -146,7 +146,7 @@ struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi,
}
struct bgp_node *bgp_afi_node_lookup(struct bgp_table *table, afi_t afi,
- safi_t safi, struct prefix *p,
+ safi_t safi, const struct prefix *p,
struct prefix_rd *prd)
{
struct bgp_node *rn;
@@ -1241,7 +1241,8 @@ static enum filter_type bgp_input_filter(struct peer *peer, struct prefix *p,
#undef FILTER_EXIST_WARN
}
-static enum filter_type bgp_output_filter(struct peer *peer, struct prefix *p,
+static enum filter_type bgp_output_filter(struct peer *peer,
+ const struct prefix *p,
struct attr *attr, afi_t afi,
safi_t safi)
{
@@ -1282,30 +1283,30 @@ static enum filter_type bgp_output_filter(struct peer *peer, struct prefix *p,
}
/* If community attribute includes no_export then return 1. */
-static int bgp_community_filter(struct peer *peer, struct attr *attr)
+static bool bgp_community_filter(struct peer *peer, struct attr *attr)
{
if (attr->community) {
/* NO_ADVERTISE check. */
if (community_include(attr->community, COMMUNITY_NO_ADVERTISE))
- return 1;
+ return true;
/* NO_EXPORT check. */
if (peer->sort == BGP_PEER_EBGP
&& community_include(attr->community, COMMUNITY_NO_EXPORT))
- return 1;
+ return true;
/* NO_EXPORT_SUBCONFED check. */
if (peer->sort == BGP_PEER_EBGP
|| peer->sort == BGP_PEER_CONFED)
if (community_include(attr->community,
COMMUNITY_NO_EXPORT_SUBCONFED))
- return 1;
+ return true;
}
- return 0;
+ return false;
}
/* Route reflection loop check. */
-static int bgp_cluster_filter(struct peer *peer, struct attr *attr)
+static bool bgp_cluster_filter(struct peer *peer, struct attr *attr)
{
struct in_addr cluster_id;
@@ -1316,9 +1317,9 @@ static int bgp_cluster_filter(struct peer *peer, struct attr *attr)
cluster_id = peer->bgp->router_id;
if (cluster_loop_check(attr->cluster, cluster_id))
- return 1;
+ return true;
}
- return 0;
+ return false;
}
static int bgp_input_modifier(struct peer *peer, struct prefix *p,
@@ -1543,9 +1544,9 @@ static void subgroup_announce_reset_nhop(uint8_t family, struct attr *attr)
memset(&attr->mp_nexthop_global_in, 0, BGP_ATTR_NHLEN_IPV4);
}
-int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
- struct update_subgroup *subgrp, struct prefix *p,
- struct attr *attr)
+bool subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
+ struct update_subgroup *subgrp,
+ const struct prefix *p, struct attr *attr)
{
struct bgp_filter *filter;
struct peer *from;
@@ -1562,7 +1563,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
int samepeer_safe = 0; /* for synthetic mplsvpns routes */
if (DISABLE_BGP_ANNOUNCE)
- return 0;
+ return false;
afi = SUBGRP_AFI(subgrp);
safi = SUBGRP_SAFI(subgrp);
@@ -1609,7 +1610,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if (!CHECK_FLAG(pi->flags, BGP_PATH_VALID)
|| CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)
|| CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
- return 0;
+ return false;
}
/* If this is not the bestpath then check to see if there is an enabled
@@ -1617,14 +1618,14 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
* feature that requires us to advertise it */
if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
if (!bgp_addpath_tx_path(peer->addpath_type[afi][safi], pi)) {
- return 0;
+ return false;
}
}
/* Aggregate-address suppress check. */
if (pi->extra && pi->extra->suppress)
if (!UNSUPPRESS_MAP_NAME(filter)) {
- return 0;
+ return false;
}
/*
@@ -1635,7 +1636,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
*/
if (safi == SAFI_MPLS_VPN && pi->extra && pi->extra->num_labels
&& pi->extra->label[0] == BGP_PREVENT_VRF_2_VRF_LEAK)
- return 0;
+ return false;
/* If it's labeled safi, make sure the route has a valid label. */
if (safi == SAFI_LABELED_UNICAST) {
@@ -1648,13 +1649,13 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
inet_ntop(p->family, &p->u.prefix,
buf, SU_ADDRSTRLEN),
p->prefixlen, &label);
- return 0;
+ return false;
}
}
/* Do not send back route to sender. */
if (onlypeer && from == onlypeer) {
- return 0;
+ return false;
}
/* Do not send the default route in the BGP table if the neighbor is
@@ -1662,9 +1663,9 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if (CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_DEFAULT_ORIGINATE)) {
if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
- return 0;
+ return false;
else if (p->family == AF_INET6 && p->prefixlen == 0)
- return 0;
+ return false;
}
/* Transparency check. */
@@ -1679,7 +1680,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if (bgp_debug_update(NULL, p, subgrp->update_group, 0))
zlog_debug(
"subgrpannouncecheck: community filter check fail");
- return 0;
+ return false;
}
/* If the attribute has originator-id and it is same as remote
@@ -1692,7 +1693,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
"remote router-id",
onlypeer->host,
prefix2str(p, buf, sizeof(buf)));
- return 0;
+ return false;
}
/* ORF prefix-list filter check */
@@ -1710,7 +1711,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
peer->host,
prefix2str(p, buf,
sizeof(buf)));
- return 0;
+ return false;
}
}
@@ -1719,7 +1720,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if (bgp_debug_update(NULL, p, subgrp->update_group, 0))
zlog_debug("%s [Update:SEND] %s is filtered",
peer->host, prefix2str(p, buf, sizeof(buf)));
- return 0;
+ return false;
}
/* AS path loop check. */
@@ -1730,7 +1731,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
"%s [Update:SEND] suppress announcement to peer AS %u "
"that is part of AS path.",
onlypeer->host, onlypeer->as);
- return 0;
+ return false;
}
/* If we're a CONFED we need to loop check the CONFED ID too */
@@ -1741,7 +1742,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
"%s [Update:SEND] suppress announcement to peer AS %u"
" is AS path.",
peer->host, bgp->confed_id);
- return 0;
+ return false;
}
}
@@ -1765,13 +1766,13 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
BGP_FLAG_NO_CLIENT_TO_CLIENT))
if (CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_REFLECTOR_CLIENT))
- return 0;
+ return false;
} else {
/* A route from a Non-client peer. Reflect to all other
clients. */
if (!CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_REFLECTOR_CLIENT))
- return 0;
+ return false;
}
}
@@ -1875,16 +1876,9 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
struct bgp_path_info_extra dummy_rmap_path_extra = {0};
struct attr dummy_attr = {0};
- memset(&rmap_path, 0, sizeof(struct bgp_path_info));
- rmap_path.peer = peer;
- rmap_path.attr = attr;
- rmap_path.net = rn;
-
- if (pi->extra) {
- memcpy(&dummy_rmap_path_extra, pi->extra,
- sizeof(struct bgp_path_info_extra));
- rmap_path.extra = &dummy_rmap_path_extra;
- }
+ /* Fill temp path_info */
+ prep_for_rmap_apply(&rmap_path, &dummy_rmap_path_extra,
+ rn, pi, peer, attr);
/* don't confuse inbound and outbound setting */
RESET_FLAG(attr->rmap_change_flags);
@@ -1917,7 +1911,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
peer->host, prefix2str(p, buf, sizeof(buf)));
bgp_attr_flush(attr);
- return 0;
+ return false;
}
}
@@ -1933,7 +1927,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if (peer->bgp->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED)
if (!bgp_outbound_policy_exists(peer, filter))
- return 0;
+ return false;
/* draft-ietf-idr-deprecate-as-set-confed-set
* Filter routes having AS_SET or AS_CONFED_SET in the path.
@@ -1943,7 +1937,11 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
*/
if (peer->bgp->reject_as_sets == BGP_REJECT_AS_SETS_ENABLED)
if (aspath_check_as_sets(attr->aspath))
- return 0;
+ return false;
+
+ /* Codification of AS 0 Processing */
+ if (aspath_check_as_zero(attr->aspath))
+ return 0;
if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
if (peer->sort == BGP_PEER_IBGP
@@ -2002,7 +2000,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if ((p->family == AF_INET) &&
(!bgp_subgrp_multiaccess_check_v4(
piattr->nexthop,
- subgrp)))
+ subgrp, from)))
subgroup_announce_reset_nhop(
(peer_cap_enhe(peer, afi, safi)
? AF_INET6
@@ -2012,7 +2010,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if ((p->family == AF_INET6) &&
(!bgp_subgrp_multiaccess_check_v6(
piattr->mp_nexthop_global,
- subgrp)))
+ subgrp, from)))
subgroup_announce_reset_nhop(
(peer_cap_enhe(peer, afi, safi)
? AF_INET6
@@ -2051,7 +2049,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
subgroup_announce_reset_nhop(AF_INET6, attr);
}
- return 1;
+ return true;
}
static int bgp_route_select_timer_expire(struct thread *thread)
@@ -2103,6 +2101,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
if (debug)
prefix2str(&rn->p, pfx_buf, sizeof(pfx_buf));
+ rn->reason = bgp_path_selection_none;
/* bgp deterministic-med */
new_select = NULL;
if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) {
@@ -2182,6 +2181,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
new_select = NULL;
for (pi = bgp_node_get_bgp_path_info(rn);
(pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
+ enum bgp_path_selection_reason reason;
+
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
old_select = pi;
@@ -2222,8 +2223,12 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
bgp_path_info_unset_flag(rn, pi, BGP_PATH_DMED_CHECK);
+ reason = rn->reason;
if (bgp_path_info_cmp(bgp, pi, new_select, &paths_eq, mpath_cfg,
debug, pfx_buf, afi, safi, &rn->reason)) {
+ if (new_select == NULL &&
+ reason != bgp_path_selection_none)
+ rn->reason = reason;
new_select = pi;
}
}
@@ -2309,10 +2314,10 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
* A new route/change in bestpath of an existing route. Evaluate the path
* for advertisement to the subgroup.
*/
-int subgroup_process_announce_selected(struct update_subgroup *subgrp,
- struct bgp_path_info *selected,
- struct bgp_node *rn,
- uint32_t addpath_tx_id)
+void subgroup_process_announce_selected(struct update_subgroup *subgrp,
+ struct bgp_path_info *selected,
+ struct bgp_node *rn,
+ uint32_t addpath_tx_id)
{
struct prefix *p;
struct peer *onlypeer;
@@ -2336,7 +2341,7 @@ int subgroup_process_announce_selected(struct update_subgroup *subgrp,
/* First update is deferred until ORF or ROUTE-REFRESH is received */
if (onlypeer && CHECK_FLAG(onlypeer->af_sflags[afi][safi],
PEER_STATUS_ORF_WAIT_REFRESH))
- return 0;
+ return;
memset(&attr, 0, sizeof(struct attr));
/* It's initialized in bgp_announce_check() */
@@ -2355,8 +2360,6 @@ int subgroup_process_announce_selected(struct update_subgroup *subgrp,
else {
bgp_adj_out_unset_subgroup(rn, subgrp, 1, addpath_tx_id);
}
-
- return 0;
}
/*
@@ -2380,8 +2383,8 @@ void bgp_zebra_clear_route_change_flags(struct bgp_node *rn)
* if the route selection returns the same best route as earlier - to
* determine if we need to update zebra or not.
*/
-int bgp_zebra_has_route_changed(struct bgp_node *rn,
- struct bgp_path_info *selected)
+bool bgp_zebra_has_route_changed(struct bgp_node *rn,
+ struct bgp_path_info *selected)
{
struct bgp_path_info *mpinfo;
@@ -2393,7 +2396,7 @@ int bgp_zebra_has_route_changed(struct bgp_node *rn,
*/
if (CHECK_FLAG(selected->flags, BGP_PATH_IGP_CHANGED)
|| CHECK_FLAG(selected->flags, BGP_PATH_MULTIPATH_CHG))
- return 1;
+ return true;
/*
* If this is multipath, check all selected paths for any nexthop change
@@ -2402,11 +2405,11 @@ int bgp_zebra_has_route_changed(struct bgp_node *rn,
mpinfo = bgp_path_info_mpath_next(mpinfo)) {
if (CHECK_FLAG(mpinfo->flags, BGP_PATH_IGP_CHANGED)
|| CHECK_FLAG(mpinfo->flags, BGP_PATH_ATTR_CHANGED))
- return 1;
+ return true;
}
/* Nothing has changed from the RIB's perspective. */
- return 0;
+ return false;
}
struct bgp_process_queue {
@@ -2486,7 +2489,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
*/
if (CHECK_FLAG(rn->flags, BGP_NODE_SELECT_DEFER)) {
if (BGP_DEBUG(update, UPDATE_OUT))
- zlog_debug("SELECT_DEFER falg set for route %p", rn);
+ zlog_debug("SELECT_DEFER flag set for route %p", rn);
return;
}
@@ -2682,17 +2685,31 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
/* apply the route-map */
if (bgp->adv_cmd_rmap[afi][safi].map) {
route_map_result_t ret;
+ struct bgp_path_info rmap_path;
+ struct bgp_path_info_extra rmap_path_extra;
+ struct attr dummy_attr;
+
+ dummy_attr = *new_select->attr;
+
+ /* Fill temp path_info */
+ prep_for_rmap_apply(
+ &rmap_path, &rmap_path_extra,
+ rn, new_select, new_select->peer,
+ &dummy_attr);
+
+ RESET_FLAG(dummy_attr.rmap_change_flags);
ret = route_map_apply(
bgp->adv_cmd_rmap[afi][safi].map,
- &rn->p, RMAP_BGP, new_select);
- if (ret == RMAP_PERMITMATCH)
- bgp_evpn_advertise_type5_route(
- bgp, &rn->p, new_select->attr,
- afi, safi);
- else
+ &rn->p, RMAP_BGP, &rmap_path);
+ if (ret == RMAP_DENYMATCH) {
+ bgp_attr_flush(&dummy_attr);
bgp_evpn_withdraw_type5_route(
bgp, &rn->p, afi, safi);
+ } else
+ bgp_evpn_advertise_type5_route(
+ bgp, &rn->p, &dummy_attr,
+ afi, safi);
} else {
bgp_evpn_advertise_type5_route(bgp,
&rn->p,
@@ -2930,20 +2947,20 @@ static int bgp_maximum_prefix_restart_timer(struct thread *thread)
return 0;
}
-int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
- int always)
+bool bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
+ int always)
{
iana_afi_t pkt_afi;
iana_safi_t pkt_safi;
if (!CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
- return 0;
+ return false;
if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) {
if (CHECK_FLAG(peer->af_sflags[afi][safi],
PEER_STATUS_PREFIX_LIMIT)
&& !always)
- return 0;
+ return false;
zlog_info(
"%%MAXPFXEXCEED: No. of %s prefix received from %s %" PRIu32
@@ -2954,7 +2971,7 @@ int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
if (CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_MAX_PREFIX_WARNING))
- return 0;
+ return false;
/* Convert AFI, SAFI to values for packet. */
pkt_afi = afi_int2iana(afi);
@@ -2978,7 +2995,7 @@ int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
/* Dynamic peers will just close their connection. */
if (peer_dynamic_neighbor(peer))
- return 1;
+ return true;
/* restart timer start */
if (peer->pmax_restart[afi][safi]) {
@@ -2995,7 +3012,7 @@ int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
peer->v_pmax_restart);
}
- return 1;
+ return true;
} else
UNSET_FLAG(peer->af_sflags[afi][safi],
PEER_STATUS_PREFIX_LIMIT);
@@ -3005,7 +3022,7 @@ int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
if (CHECK_FLAG(peer->af_sflags[afi][safi],
PEER_STATUS_PREFIX_THRESHOLD)
&& !always)
- return 0;
+ return false;
zlog_info(
"%%MAXPFX: No. of %s prefix received from %s reaches %" PRIu32
@@ -3017,7 +3034,7 @@ int bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
} else
UNSET_FLAG(peer->af_sflags[afi][safi],
PEER_STATUS_PREFIX_THRESHOLD);
- return 0;
+ return false;
}
/* Unconditionally remove the route from the RIB, without taking
@@ -3186,23 +3203,23 @@ static bool overlay_index_equal(afi_t afi, struct bgp_path_info *path,
}
/* Check if received nexthop is valid or not. */
-static int bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
- uint8_t type, uint8_t stype,
- struct attr *attr, struct bgp_node *rn)
+static bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
+ uint8_t type, uint8_t stype,
+ struct attr *attr, struct bgp_node *rn)
{
- int ret = 0;
+ bool ret = 0;
/* Only validated for unicast and multicast currently. */
/* Also valid for EVPN where the nexthop is an IP address. */
if (safi != SAFI_UNICAST && safi != SAFI_MULTICAST && safi != SAFI_EVPN)
- return 0;
+ return false;
/* If NEXT_HOP is present, validate it. */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
if (attr->nexthop.s_addr == INADDR_ANY
|| IPV4_CLASS_DE(ntohl(attr->nexthop.s_addr))
|| bgp_nexthop_self(bgp, afi, type, stype, attr, rn))
- return 1;
+ return true;
}
/* If MP_NEXTHOP is present, validate it. */
@@ -3233,7 +3250,7 @@ static int bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
break;
default:
- ret = 1;
+ ret = true;
break;
}
}
@@ -4592,30 +4609,30 @@ void bgp_clear_stale_route(struct peer *peer, afi_t afi, safi_t safi)
}
}
-int bgp_outbound_policy_exists(struct peer *peer, struct bgp_filter *filter)
+bool bgp_outbound_policy_exists(struct peer *peer, struct bgp_filter *filter)
{
if (peer->sort == BGP_PEER_IBGP)
- return 1;
+ return true;
if (peer->sort == BGP_PEER_EBGP
&& (ROUTE_MAP_OUT_NAME(filter) || PREFIX_LIST_OUT_NAME(filter)
|| FILTER_LIST_OUT_NAME(filter)
|| DISTRIBUTE_OUT_NAME(filter)))
- return 1;
- return 0;
+ return true;
+ return false;
}
-int bgp_inbound_policy_exists(struct peer *peer, struct bgp_filter *filter)
+bool bgp_inbound_policy_exists(struct peer *peer, struct bgp_filter *filter)
{
if (peer->sort == BGP_PEER_IBGP)
- return 1;
+ return true;
if (peer->sort == BGP_PEER_EBGP
&& (ROUTE_MAP_IN_NAME(filter) || PREFIX_LIST_IN_NAME(filter)
|| FILTER_LIST_IN_NAME(filter)
|| DISTRIBUTE_IN_NAME(filter)))
- return 1;
- return 0;
+ return true;
+ return false;
}
static void bgp_cleanup_table(struct bgp *bgp, struct bgp_table *table,
@@ -6005,11 +6022,11 @@ static void bgp_aggregate_free(struct bgp_aggregate *aggregate)
XFREE(MTYPE_BGP_AGGREGATE, aggregate);
}
-static int bgp_aggregate_info_same(struct bgp_path_info *pi, uint8_t origin,
- struct aspath *aspath,
- struct community *comm,
- struct ecommunity *ecomm,
- struct lcommunity *lcomm)
+static bool bgp_aggregate_info_same(struct bgp_path_info *pi, uint8_t origin,
+ struct aspath *aspath,
+ struct community *comm,
+ struct ecommunity *ecomm,
+ struct lcommunity *lcomm)
{
static struct aspath *ae = NULL;
@@ -6017,27 +6034,27 @@ static int bgp_aggregate_info_same(struct bgp_path_info *pi, uint8_t origin,
ae = aspath_empty();
if (!pi)
- return 0;
+ return false;
if (origin != pi->attr->origin)
- return 0;
+ return false;
if (!aspath_cmp(pi->attr->aspath, (aspath) ? aspath : ae))
- return 0;
+ return false;
if (!community_cmp(pi->attr->community, comm))
- return 0;
+ return false;
if (!ecommunity_cmp(pi->attr->ecommunity, ecomm))
- return 0;
+ return false;
if (!lcommunity_cmp(pi->attr->lcommunity, lcomm))
- return 0;
+ return false;
if (!CHECK_FLAG(pi->flags, BGP_PATH_VALID))
- return 0;
+ return false;
- return 1;
+ return true;
}
static void bgp_aggregate_install(struct bgp *bgp, afi_t afi, safi_t safi,
@@ -7326,7 +7343,7 @@ void bgp_redistribute_withdraw(struct bgp *bgp, afi_t afi, int type,
}
/* Static function to display route. */
-static void route_vty_out_route(struct prefix *p, struct vty *vty,
+static void route_vty_out_route(const struct prefix *p, struct vty *vty,
json_object *json)
{
int len = 0;
@@ -7483,7 +7500,7 @@ static char *bgp_nexthop_hostname(struct peer *peer, struct attr *attr)
}
/* called from terminal list command */
-void route_vty_out(struct vty *vty, struct prefix *p,
+void route_vty_out(struct vty *vty, const struct prefix *p,
struct bgp_path_info *path, int display, safi_t safi,
json_object *json_paths)
{
@@ -8079,7 +8096,7 @@ void route_vty_out_tmp(struct vty *vty, struct prefix *p, struct attr *attr,
vty_out(vty, "\n");
}
-void route_vty_out_tag(struct vty *vty, struct prefix *p,
+void route_vty_out_tag(struct vty *vty, const struct prefix *p,
struct bgp_path_info *path, int display, safi_t safi,
json_object *json)
{
@@ -8172,7 +8189,7 @@ void route_vty_out_tag(struct vty *vty, struct prefix *p,
}
}
-void route_vty_out_overlay(struct vty *vty, struct prefix *p,
+void route_vty_out_overlay(struct vty *vty, const struct prefix *p,
struct bgp_path_info *path, int display,
json_object *json_paths)
{
@@ -12280,7 +12297,7 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str,
}
/* Apply BGP information to distance method. */
-uint8_t bgp_distance_apply(struct prefix *p, struct bgp_path_info *pinfo,
+uint8_t bgp_distance_apply(const struct prefix *p, struct bgp_path_info *pinfo,
afi_t afi, safi_t safi, struct bgp *bgp)
{
struct bgp_node *rn;