Revert "bgpd, ospfd: BGP ORR CI warning fixes"

This reverts commit d6b2761134.
This commit is contained in:
Donatas Abraitis 2023-01-17 18:10:04 +02:00
parent 3228977f58
commit 1ea57af264
6 changed files with 70 additions and 56 deletions

View File

@ -27,31 +27,32 @@
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) ||
@ -59,11 +60,33 @@ static inline bool is_orr_root_node(struct bgp_orr_group *orr_group, char *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)
@ -74,7 +97,7 @@ 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);
}
@ -119,7 +142,7 @@ static struct bgp_orr_group *bgp_orr_group_new(struct bgp *bgp, afi_t afi,
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);
}
@ -185,7 +208,7 @@ struct bgp_orr_group *bgp_orr_group_lookup_by_name(struct bgp *bgp, afi_t afi,
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__,
@ -206,7 +229,7 @@ static char *bgp_orr_group_rrclient_lookup(struct bgp_orr_group *orr_group,
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(
@ -297,7 +320,7 @@ int bgp_afi_safi_orr_group_set(struct bgp *bgp, afi_t afi, safi_t safi,
/* 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",
@ -313,21 +336,21 @@ int bgp_afi_safi_orr_group_set(struct bgp *bgp, afi_t afi, safi_t safi,
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;
@ -339,7 +362,7 @@ int bgp_afi_safi_orr_group_set(struct bgp *bgp, afi_t afi, safi_t safi,
/* 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",
@ -352,14 +375,14 @@ int bgp_afi_safi_orr_group_set(struct bgp *bgp, afi_t afi, safi_t safi,
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
@ -368,8 +391,8 @@ int bgp_afi_safi_orr_group_set(struct bgp *bgp, afi_t afi, safi_t safi,
} 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;
@ -381,7 +404,7 @@ int bgp_afi_safi_orr_group_set(struct bgp *bgp, afi_t afi, safi_t safi,
/* 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",
@ -397,8 +420,8 @@ int bgp_afi_safi_orr_group_set(struct bgp *bgp, afi_t afi, safi_t safi,
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;
@ -416,8 +439,8 @@ int bgp_afi_safi_orr_group_set(struct bgp *bgp, afi_t afi, safi_t safi,
} 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;
@ -485,7 +508,7 @@ static int peer_orr_group_set(struct peer *peer, afi_t afi, safi_t safi,
/* 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),
@ -522,7 +545,7 @@ static int peer_orr_group_unset(struct peer *peer, afi_t afi, safi_t safi,
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),
@ -762,11 +785,11 @@ bool peer_orr_rrclient_check(struct peer *peer, afi_t afi, safi_t safi)
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
@ -778,7 +801,7 @@ bool peer_orr_rrclient_check(struct peer *peer, afi_t afi, safi_t safi)
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;

View File

@ -58,8 +58,6 @@ enum bgp_orr_msg_type {
BGP_ORR_IMSG_MAX
};
extern struct zclient *zclient;
extern void bgp_config_write_orr(struct vty *vty, struct bgp *bgp, afi_t afi,
safi_t safi);

View File

@ -949,7 +949,7 @@ int bgp_vty_return(struct vty *vty, enum bgp_create_error_code ret)
str = "External roles can be set only on eBGP session";
break;
case BGP_ERR_PEER_ORR_CONFIGURED:
str = "Deconfigure optimal-route-reflection on this peer first";
str = "Deconfigure optimal-route-reflection on this peer first.";
break;
}
if (str) {

View File

@ -1609,17 +1609,13 @@ DEFPY (debug_ospf_orr,
OSPF_STR
"OSPF ORR information\n")
{
if (vty->node == CONFIG_NODE) {
if (no)
CONF_DEBUG_OFF(orr, ORR);
else
CONF_DEBUG_ON(orr, ORR);
} else {
if (no)
TERM_DEBUG_OFF(orr, ORR);
else
TERM_DEBUG_ON(orr, ORR);
}
if (vty->node == CONFIG_NODE)
CONF_DEBUG_ON(orr, ORR);
if (!no)
TERM_DEBUG_ON(orr, ORR);
else
TERM_DEBUG_OFF(orr, ORR);
return CMD_SUCCESS;
}

View File

@ -45,7 +45,7 @@
#include "ospf_te.h"
static void ospf_show_orr_root(struct orr_root *root);
static void ospf_show_orr(struct ospf *ospf, afi_t afi, safi_t safi);
void ospf_show_orr(struct ospf *ospf, afi_t afi, safi_t safi);
static struct orr_root *ospf_orr_root_new(struct ospf *ospf, afi_t afi,
safi_t safi, struct prefix *p)
{
@ -246,10 +246,7 @@ int ospf_orr_igp_metric_register(struct orr_igp_metric_reg msg)
ospf->orr_spf_request--;
}
if (IS_DEBUG_OSPF_ORR)
ospf_show_orr(ospf, afi, safi);
ospf_show_orr(ospf, afi, safi);
return 0;
}
@ -319,7 +316,7 @@ static void ospf_show_orr_root(struct orr_root *root)
&root->adv_router);
}
static void ospf_show_orr(struct ospf *ospf, afi_t afi, safi_t safi)
void ospf_show_orr(struct ospf *ospf, afi_t afi, safi_t safi)
{
struct listnode *node = NULL;
struct orr_root *orr_root = NULL;
@ -393,8 +390,7 @@ void ospf_orr_root_table_update(struct ospf_lsa *lsa, bool add)
if (root) {
IPV4_ADDR_COPY(&root->adv_router,
&lsa->data->adv_router);
if (IS_DEBUG_OSPF_ORR)
ospf_show_orr(ospf, afi, safi);
ospf_show_orr(ospf, afi, safi);
break;
}
}

View File

@ -11305,7 +11305,8 @@ static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf,
continue;
if (!json)
vty_out(vty,
"Calculated from location %pI4\n",
"Calculated from location"
" %pI4\n",
&root->router_id);
show_ip_ospf_route_network(
vty, ospf, root->new_table, json_vrf);