DEFINE_MTYPE_STATIC(BGPD, ORR_IGP_INFO, "ORR IGP Metric info");
+extern struct zclient *zclient;
+
static inline bool is_orr_primary_root(struct bgp_orr_group *orr_group,
char *host)
{
- return orr_group->primary && strmatch(orr_group->primary->host, host);
+ return orr_group->primary && !strcmp(orr_group->primary->host, host);
}
static inline bool is_orr_secondary_root(struct bgp_orr_group *orr_group,
char *host)
{
return orr_group->secondary &&
- strmatch(orr_group->secondary->host, host);
+ !strcmp(orr_group->secondary->host, host);
}
static inline bool is_orr_tertiary_root(struct bgp_orr_group *orr_group,
char *host)
{
- return orr_group->tertiary && strmatch(orr_group->tertiary->host, host);
+ return orr_group->tertiary && !strcmp(orr_group->tertiary->host, host);
}
static inline bool is_orr_active_root(struct bgp_orr_group *orr_group,
char *host)
{
- return orr_group->active && strmatch(orr_group->active->host, host);
+ return orr_group->active && !strcmp(orr_group->active->host, host);
}
-
static inline bool is_orr_root_node(struct bgp_orr_group *orr_group, char *host)
{
return is_orr_primary_root(orr_group, host) ||
is_orr_tertiary_root(orr_group, host);
}
+static inline bool is_orr_primary_reachable(struct bgp_orr_group *orr_group)
+{
+ return orr_group->primary &&
+ orr_group->primary->afc_nego[orr_group->afi][orr_group->safi] &&
+ peer_established(orr_group->primary);
+}
+
+static inline bool is_orr_secondary_reachable(struct bgp_orr_group *orr_group)
+{
+ return orr_group->secondary &&
+ orr_group->secondary
+ ->afc_nego[orr_group->afi][orr_group->safi] &&
+ peer_established(orr_group->secondary);
+}
+
+static inline bool is_orr_tertiary_reachable(struct bgp_orr_group *orr_group)
+{
+ return orr_group->tertiary &&
+ orr_group->tertiary->afc_nego[orr_group->afi][orr_group->safi] &&
+ peer_established(orr_group->tertiary);
+}
+
static inline bool is_peer_orr_group_member(struct peer *peer, afi_t afi,
safi_t safi, const char *name)
{
return peer_af_flag_check(peer, afi, safi, PEER_FLAG_ORR_GROUP) &&
- strmatch(peer->orr_group_name[afi][safi], name);
+ !strcmp(peer->orr_group_name[afi][safi], name);
}
static inline bool is_peer_reachable(struct peer *peer, afi_t afi, safi_t safi)
static inline bool is_peer_active_eligible(struct peer *peer, afi_t afi,
safi_t safi, const char *name)
{
- return is_peer_reachable(peer, afi, safi) &&
+ return is_peer_reachable(peer, afi, afi) &&
is_peer_orr_group_member(peer, afi, safi, name);
}
if (!bgp->orr_group_count) {
ret = zclient_register_opaque(zclient, ORR_IGP_METRIC_UPDATE);
if (ret != ZCLIENT_SEND_SUCCESS)
- bgp_orr_debug(
+ zlog_debug(
"%s: zclient_register_opaque failed with ret = %d",
__func__, ret);
}
return NULL;
for (ALL_LIST_ELEMENTS_RO(orr_group_list, node, group))
- if (strmatch(group->name, name))
+ if (strcmp(group->name, name) == 0)
return group;
bgp_orr_debug("%s: For %s, ORR Group '%s' not found.", __func__,
return NULL;
for (ALL_LIST_ELEMENTS_RO(orr_group_rrclient_list, node, rrclient))
- if (strmatch(rrclient, rr_client_host))
+ if (strcmp(rrclient, rr_client_host) == 0)
return rrclient;
bgp_orr_debug(
/* Compare and update Primary Root Address */
if (primary) {
if (!orr_group->primary ||
- !strmatch(orr_group->primary->host, primary->host))
+ strcmp(orr_group->primary->host, primary->host))
orr_group->primary = primary;
else
bgp_orr_debug("%s: No change in Primary Root",
orr_group->active = primary;
bgp_orr_igp_metric_register(orr_group, true);
} else if (orr_group->primary &&
- !strmatch(orr_group->active->host,
- orr_group->primary->host)) {
+ strcmp(orr_group->active->host,
+ orr_group->primary->host)) {
bgp_orr_igp_metric_register(orr_group, false);
orr_group->active = primary;
bgp_orr_igp_metric_register(orr_group, true);
} else
- bgp_orr_debug("%s: %s", __func__,
+ bgp_orr_debug("%s: %pBP", __func__,
orr_group->primary
? "No change in Active Root"
: "Primary Root is NULL");
} else {
if (orr_group->primary) {
if (orr_group->active &&
- strmatch(orr_group->active->host,
- orr_group->primary->host)) {
+ !strcmp(orr_group->active->host,
+ orr_group->primary->host)) {
bgp_orr_igp_metric_register(orr_group, false);
orr_group->active = NULL;
/* Compare and update Secondary Root Address */
if (secondary) {
if (!orr_group->secondary ||
- !strmatch(orr_group->secondary->host, secondary->host))
+ strcmp(orr_group->secondary->host, secondary->host))
orr_group->secondary = secondary;
else
bgp_orr_debug("%s: No change in Secondary Root",
orr_group->active = secondary;
bgp_orr_igp_metric_register(orr_group, true);
} else if (!primary_eligible && orr_group->secondary &&
- !strmatch(orr_group->active->host,
- orr_group->secondary->host)) {
+ strcmp(orr_group->active->host,
+ orr_group->secondary->host)) {
bgp_orr_igp_metric_register(orr_group, false);
orr_group->active = secondary;
bgp_orr_igp_metric_register(orr_group, true);
} else
bgp_orr_debug(
- "%s: %s", __func__,
+ "%s: %pBP", __func__,
primary_eligible
? "Primary is Active Root"
: orr_group->secondary
} else {
if (orr_group->secondary) {
if (orr_group->active &&
- strmatch(orr_group->active->host,
- orr_group->secondary->host)) {
+ !strcmp(orr_group->active->host,
+ orr_group->secondary->host)) {
bgp_orr_igp_metric_register(orr_group, false);
orr_group->active = NULL;
/* Compare and update Tertiary Root Address */
if (tertiary) {
if (!orr_group->tertiary ||
- !strmatch(orr_group->tertiary->host, tertiary->host))
+ strcmp(orr_group->tertiary->host, tertiary->host))
orr_group->tertiary = tertiary;
else
bgp_orr_debug("%s: No change in Tertiay Root",
bgp_orr_igp_metric_register(orr_group, true);
} else if (!primary_eligible && !secondary_eligible &&
orr_group->tertiary &&
- !strmatch(orr_group->active->host,
- orr_group->tertiary->host)) {
+ strcmp(orr_group->active->host,
+ orr_group->tertiary->host)) {
bgp_orr_igp_metric_register(orr_group, false);
orr_group->active = tertiary;
} else {
if (orr_group->tertiary) {
if (orr_group->active &&
- strmatch(orr_group->active->host,
- orr_group->tertiary->host)) {
+ !strcmp(orr_group->active->host,
+ orr_group->tertiary->host)) {
bgp_orr_igp_metric_register(orr_group, false);
orr_group->active = NULL;
/* Skip processing if there is no change in ORR Group */
if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_ORR_GROUP)) {
- if (strmatch(peer->orr_group_name[afi][safi], orr_group_name)) {
+ if (!strcmp(peer->orr_group_name[afi][safi], orr_group_name)) {
bgp_orr_debug(
"%s: For %s, ORR Group '%s' is already configured on %pBP",
__func__, get_afi_safi_str(afi, safi, false),
assert(peer && peer->bgp && orr_group_name);
if (!peer_af_flag_check(peer, afi, safi, PEER_FLAG_ORR_GROUP) ||
- !strmatch(peer->orr_group_name[afi][safi], orr_group_name)) {
+ strcmp(peer->orr_group_name[afi][safi], orr_group_name)) {
bgp_orr_debug(
"%s: For %s, ORR Group '%s' is not configured on %pBP",
__func__, get_afi_safi_str(afi, safi, false),
for (ALL_LIST_ELEMENTS_RO(orr_group_list, node, orr_group)) {
/*Check if peer configured as primary/secondary/tertiary root */
if ((orr_group->primary &&
- strmatch(peer->host, orr_group->primary->host)) ||
+ !strcmp(peer->host, orr_group->primary->host)) ||
(orr_group->secondary &&
- strmatch(peer->host, orr_group->secondary->host)) ||
+ !strcmp(peer->host, orr_group->secondary->host)) ||
(orr_group->tertiary &&
- strmatch(peer->host, orr_group->tertiary->host)))
+ !strcmp(peer->host, orr_group->tertiary->host)))
return true;
/*
* Check if peer is mapped to any ORR Group in this
for (ALL_LIST_ELEMENTS_RO(orr_group_rrclient_list, node,
rrclient))
- if (strmatch(rrclient, peer->host))
+ if (!strcmp(rrclient, peer->host))
return true;
}
return false;