Update PR #839 following review

* Remove enum status_t opcode in ospfd.h
 * Replace enum status_t opcode by bool enabled in ospf_te.[c,h] and ospf_ri.c
 * Add missign parenthesis '()' around 'if CHECK_FLAG' in ospf_te.c and ospf_ri.c

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
This commit is contained in:
Olivier Dugeon 2017-07-27 16:09:00 +02:00
parent 2a39170c6b
commit 32ab5cf4af
4 changed files with 83 additions and 105 deletions

View File

@ -60,7 +60,7 @@
/* Store Router Information PCE TLV and SubTLV in network byte order. */
struct ospf_pce_info {
status_t status;
bool enabled;
struct ri_tlv_pce pce_header;
struct ri_pce_subtlv_address pce_address;
struct ri_pce_subtlv_path_scope pce_scope;
@ -71,7 +71,7 @@ struct ospf_pce_info {
/* Following structure are internal use only. */
struct ospf_router_info {
status_t status;
bool enabled;
u_int8_t registered;
u_int8_t scope;
@ -119,13 +119,13 @@ int ospf_router_info_init(void)
{
memset(&OspfRI, 0, sizeof(struct ospf_router_info));
OspfRI.status = disable;
OspfRI.enabled = false;
OspfRI.registered = 0;
OspfRI.scope = OSPF_OPAQUE_AS_LSA;
OspfRI.flags = 0;
/* Initialize pce domain and neighbor list */
OspfRI.pce_info.status = disable;
OspfRI.pce_info.enabled = false;
OspfRI.pce_info.pce_domain = list_new();
OspfRI.pce_info.pce_domain->del = del_pce_info;
OspfRI.pce_info.pce_neighbor = list_new();
@ -193,7 +193,7 @@ void ospf_router_info_term(void)
OspfRI.pce_info.pce_domain = NULL;
OspfRI.pce_info.pce_neighbor = NULL;
OspfRI.status = disable;
OspfRI.enabled = false;
ospf_router_info_unregister();
@ -254,11 +254,11 @@ static int set_pce_header(struct ospf_pce_info *pce)
if (length != 0) {
pce->pce_header.header.type = htons(RI_TLV_PCE);
pce->pce_header.header.length = htons(length);
pce->status = enable;
pce->enabled = true;
} else {
pce->pce_header.header.type = 0;
pce->pce_header.header.length = 0;
pce->status = disable;
pce->enabled = false;
}
return length;
@ -525,7 +525,7 @@ static void ospf_router_info_lsa_body_set(struct stream *s)
set_pce_header (&OspfRI.pce_info);
/* Add RI PCE TLV if it is set */
if (OspfRI.pce_info.status == enable) {
if (OspfRI.pce_info.enabled) {
/* Build PCE TLV */
build_tlv_header(s, &OspfRI.pce_info.pce_header.header);
@ -686,7 +686,7 @@ static int ospf_router_info_lsa_originate(void *arg)
int rc = -1;
if (OspfRI.status == disable) {
if (!OspfRI.enabled) {
zlog_info(
"ospf_router_info_lsa_originate: ROUTER INFORMATION is disabled now.");
rc = 0; /* This is not an error case. */
@ -694,8 +694,8 @@ static int ospf_router_info_lsa_originate(void *arg)
}
/* Check if Router Information LSA is already engaged */
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED) {
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_FORCED_REFRESH) {
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)) {
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_FORCED_REFRESH)) {
UNSET_FLAG(OspfRI.flags, RIFLG_LSA_FORCED_REFRESH);
ospf_router_info_lsa_schedule(REFRESH_THIS_LSA);
}
@ -718,7 +718,7 @@ static struct ospf_lsa *ospf_router_info_lsa_refresh(struct ospf_lsa *lsa)
struct ospf_lsa *new = NULL;
struct ospf *top;
if (OspfRI.status == disable) {
if (!OspfRI.enabled) {
/*
* This LSA must have flushed before due to ROUTER INFORMATION
* status change.
@ -1044,14 +1044,14 @@ static void ospf_router_info_config_write_router(struct vty *vty)
struct ri_pce_subtlv_neighbor *neighbor;
struct in_addr tmp;
if (OspfRI.status == enable) {
if (OspfRI.enabled) {
if (OspfRI.scope == OSPF_OPAQUE_AS_LSA)
vty_out(vty, " router-info as\n");
else
vty_out(vty, " router-info area %s\n",
inet_ntoa(OspfRI.area_id));
if (OspfRI.pce_info.status == enable) {
if (OspfRI.pce_info.enabled) {
if (pce->pce_address.header.type != 0)
vty_out(vty, " pce address %s\n",
@ -1112,7 +1112,7 @@ DEFUN (router_info,
u_int8_t scope;
if (OspfRI.status == enable)
if (OspfRI.enabled)
return CMD_SUCCESS;
/* Check and get Area value if present */
@ -1135,7 +1135,7 @@ DEFUN (router_info,
return CMD_WARNING_CONFIG_FAILED;
}
OspfRI.status = enable;
OspfRI.enabled = true;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("RI-> Router Information (%s flooding): OFF -> ON",
@ -1154,7 +1154,7 @@ DEFUN (router_info,
initialize_params(&OspfRI);
/* Refresh RI LSA if already engaged */
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED) {
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)) {
zlog_debug ("RI-> Refresh LSA following configuration");
ospf_router_info_lsa_schedule (REFRESH_THIS_LSA);
} else {
@ -1172,26 +1172,26 @@ DEFUN (no_router_info,
"Disable the Router Information functionality\n")
{
if (OspfRI.status == disable)
if (!OspfRI.enabled)
return CMD_SUCCESS;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("RI-> Router Information: ON -> OFF");
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
ospf_router_info_lsa_schedule(FLUSH_THIS_LSA);
/* Unregister the callbacks */
ospf_router_info_unregister();
OspfRI.status = disable;
OspfRI.enabled = false;
return CMD_SUCCESS;
}
static int ospf_ri_enabled(struct vty *vty)
{
if (OspfRI.status == enable)
if (OspfRI.enabled)
return 1;
if (vty)
@ -1226,7 +1226,7 @@ DEFUN (pce_address,
set_pce_address(value, pi);
/* Refresh RI LSA if already engaged */
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
ospf_router_info_lsa_schedule(REFRESH_THIS_LSA);
}
@ -1245,7 +1245,7 @@ DEFUN (no_pce_address,
unset_param(&OspfRI.pce_info.pce_address.header);
/* Refresh RI LSA if already engaged */
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
ospf_router_info_lsa_schedule(REFRESH_THIS_LSA);
return CMD_SUCCESS;
@ -1276,7 +1276,7 @@ DEFUN (pce_path_scope,
set_pce_path_scope(scope, pi);
/* Refresh RI LSA if already engaged */
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
ospf_router_info_lsa_schedule(REFRESH_THIS_LSA);
}
@ -1295,7 +1295,7 @@ DEFUN (no_pce_path_scope,
unset_param(&OspfRI.pce_info.pce_address.header);
/* Refresh RI LSA if already engaged */
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
ospf_router_info_lsa_schedule(REFRESH_THIS_LSA);
return CMD_SUCCESS;
@ -1334,7 +1334,7 @@ DEFUN (pce_domain,
set_pce_domain(PCE_DOMAIN_TYPE_AS, as, pce);
/* Refresh RI LSA if already engaged */
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
ospf_router_info_lsa_schedule(REFRESH_THIS_LSA);
return CMD_SUCCESS;
@ -1364,7 +1364,7 @@ DEFUN (no_pce_domain,
unset_pce_domain(PCE_DOMAIN_TYPE_AS, as, pce);
/* Refresh RI LSA if already engaged */
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
ospf_router_info_lsa_schedule(REFRESH_THIS_LSA);
return CMD_SUCCESS;
@ -1404,7 +1404,7 @@ DEFUN (pce_neigbhor,
set_pce_neighbor(PCE_DOMAIN_TYPE_AS, as, pce);
/* Refresh RI LSA if already engaged */
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
ospf_router_info_lsa_schedule(REFRESH_THIS_LSA);
return CMD_SUCCESS;
@ -1434,7 +1434,7 @@ DEFUN (no_pce_neighbor,
unset_pce_neighbor(PCE_DOMAIN_TYPE_AS, as, pce);
/* Refresh RI LSA if already engaged */
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
ospf_router_info_lsa_schedule(REFRESH_THIS_LSA);
return CMD_SUCCESS;
@ -1466,7 +1466,7 @@ DEFUN (pce_cap_flag,
set_pce_cap_flag(cap, pce);
/* Refresh RI LSA if already engaged */
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
ospf_router_info_lsa_schedule(REFRESH_THIS_LSA);
}
@ -1484,7 +1484,7 @@ DEFUN (no_pce_cap_flag,
unset_param(&OspfRI.pce_info.pce_cap_flag.header);
/* Refresh RI LSA if already engaged */
if CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
ospf_router_info_lsa_schedule(REFRESH_THIS_LSA);
return CMD_SUCCESS;
@ -1499,7 +1499,7 @@ DEFUN (show_ip_ospf_router_info,
"Router Information\n")
{
if (OspfRI.status == enable) {
if (OspfRI.enabled) {
vty_out(vty, "--- Router Information parameters ---\n");
show_vty_router_cap(vty, &OspfRI.router_cap.header);
} else {
@ -1525,7 +1525,7 @@ DEFUN (show_ip_opsf_router_info_pce,
struct ri_pce_subtlv_domain *domain;
struct ri_pce_subtlv_neighbor *neighbor;
if (OspfRI.status == enable) {
if (OspfRI.enabled) {
vty_out(vty, "--- PCE parameters ---\n");
if (pce->pce_address.header.type != 0)

View File

@ -108,7 +108,7 @@ int ospf_mpls_te_init(void)
}
memset(&OspfMplsTE, 0, sizeof(struct ospf_mpls_te));
OspfMplsTE.status = disable;
OspfMplsTE.enabled = false;
OspfMplsTE.inter_as = Off;
OspfMplsTE.iflist = list_new();
OspfMplsTE.iflist->del = del_mpls_te_link;
@ -171,7 +171,7 @@ void ospf_mpls_te_term(void)
ospf_delete_opaque_functab(OSPF_OPAQUE_AREA_LSA,
OPAQUE_TYPE_TRAFFIC_ENGINEERING_LSA);
OspfMplsTE.status = disable;
OspfMplsTE.enabled = false;
ospf_mpls_te_unregister();
OspfMplsTE.inter_as = Off;
@ -243,8 +243,8 @@ static void ospf_mpls_te_foreach_area(void (*func)(struct mpls_te_link *lp,
continue;
if ((area = lp->area) == NULL)
continue;
if
CHECK_FLAG(lp->flags, LPFLG_LOOKUP_DONE) continue;
if (CHECK_FLAG(lp->flags, LPFLG_LOOKUP_DONE))
continue;
if (func != NULL)
(*func)(lp, sched_opcode);
@ -937,20 +937,18 @@ void ospf_mpls_te_update_if(struct interface *ifp)
/* Finally Re-Originate or Refresh Opaque LSA if MPLS_TE is
* enabled */
if (OspfMplsTE.status == enable)
if (OspfMplsTE.enabled)
if (lp->area != NULL) {
if
CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)
ospf_mpls_te_lsa_schedule(lp, REFRESH_THIS_LSA);
else ospf_mpls_te_lsa_schedule(
lp, REORIGINATE_THIS_LSA);
if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED))
ospf_mpls_te_lsa_schedule(lp, REFRESH_THIS_LSA);
else
ospf_mpls_te_lsa_schedule(lp, REORIGINATE_THIS_LSA);
}
} else {
/* If MPLS TE is disable on this interface, flush LSA if it is
* already engaged */
if
CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)
ospf_mpls_te_lsa_schedule(lp, FLUSH_THIS_LSA);
if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED))
ospf_mpls_te_lsa_schedule(lp, FLUSH_THIS_LSA);
else
/* Reset Activity flag */
lp->flags = LPFLG_LSA_INACTIVE;
@ -1028,20 +1026,18 @@ static void ospf_mpls_te_ism_change(struct ospf_interface *oi, int old_state)
!= ntohs(lp->link_id.header.type)
|| ntohl(old_id.value.s_addr)
!= ntohl(lp->link_id.value.s_addr))) {
if
CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)
ospf_mpls_te_lsa_schedule(lp, REFRESH_THIS_LSA);
else ospf_mpls_te_lsa_schedule(lp,
REORIGINATE_THIS_LSA);
if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED))
ospf_mpls_te_lsa_schedule(lp, REFRESH_THIS_LSA);
else
ospf_mpls_te_lsa_schedule(lp, REORIGINATE_THIS_LSA);
}
break;
default:
lp->link_type.header.type = htons(0);
lp->link_id.header.type = htons(0);
if
CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)
ospf_mpls_te_lsa_schedule(lp, FLUSH_THIS_LSA);
if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED))
ospf_mpls_te_lsa_schedule(lp, FLUSH_THIS_LSA);
break;
}
@ -1268,7 +1264,7 @@ static int ospf_mpls_te_lsa_originate_area(void *arg)
struct mpls_te_link *lp;
int rc = -1;
if (OspfMplsTE.status == disable) {
if (!OspfMplsTE.enabled) {
zlog_info(
"ospf_mpls_te_lsa_originate_area: MPLS-TE is disabled now.");
rc = 0; /* This is not an error case. */
@ -1287,23 +1283,16 @@ static int ospf_mpls_te_lsa_originate_area(void *arg)
if (!IPV4_ADDR_SAME(&lp->area->area_id, &area->area_id))
continue;
if
CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)
{
if
CHECK_FLAG(lp->flags,
LPFLG_LSA_FORCED_REFRESH)
{
UNSET_FLAG(
lp->flags,
LPFLG_LSA_FORCED_REFRESH);
zlog_warn(
"OSPF MPLS-TE (ospf_mpls_te_lsa_originate_area): Refresh instead of Originate");
ospf_mpls_te_lsa_schedule(
lp, REFRESH_THIS_LSA);
}
continue;
if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)) {
if (CHECK_FLAG(lp->flags, LPFLG_LSA_FORCED_REFRESH)) {
UNSET_FLAG(lp->flags, LPFLG_LSA_FORCED_REFRESH);
zlog_warn(
"OSPF MPLS-TE (ospf_mpls_te_lsa_originate_area): Refresh instead of Originate");
ospf_mpls_te_lsa_schedule(lp, REFRESH_THIS_LSA);
}
continue;
}
if (!is_mandated_params_set(lp)) {
zlog_warn(
"ospf_mpls_te_lsa_originate_area: Link(%s) lacks some mandated MPLS-TE parameters.",
@ -1372,7 +1361,7 @@ static int ospf_mpls_te_lsa_originate_as(void *arg)
struct mpls_te_link *lp;
int rc = -1;
if ((OspfMplsTE.status == disable)
if ((!OspfMplsTE.enabled)
|| (OspfMplsTE.inter_as == Off)) {
zlog_info(
"ospf_mpls_te_lsa_originate_as: MPLS-TE Inter-AS is disabled for now.");
@ -1386,21 +1375,14 @@ static int ospf_mpls_te_lsa_originate_as(void *arg)
|| !IS_INTER_AS(lp->type))
continue;
if
CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)
{
if
CHECK_FLAG(lp->flags,
LPFLG_LSA_FORCED_REFRESH)
{
UNSET_FLAG(
lp->flags,
LPFLG_LSA_FORCED_REFRESH);
ospf_mpls_te_lsa_schedule(
lp, REFRESH_THIS_LSA);
}
continue;
if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)) {
if (CHECK_FLAG(lp->flags, LPFLG_LSA_FORCED_REFRESH)) {
UNSET_FLAG(lp->flags,LPFLG_LSA_FORCED_REFRESH);
ospf_mpls_te_lsa_schedule(lp, REFRESH_THIS_LSA);
}
continue;
}
if (!is_mandated_params_set(lp)) {
zlog_warn(
"ospf_mpls_te_lsa_originate_as: Link(%s) lacks some mandated MPLS-TE parameters.",
@ -1436,7 +1418,7 @@ static struct ospf_lsa *ospf_mpls_te_lsa_refresh(struct ospf_lsa *lsa)
struct ospf *top;
struct ospf_lsa *new = NULL;
if (OspfMplsTE.status == disable) {
if (!OspfMplsTE.enabled) {
/*
* This LSA must have flushed before due to MPLS-TE status
* change.
@ -2172,7 +2154,7 @@ static void ospf_mpls_te_show_info(struct vty *vty, struct ospf_lsa *lsa)
static void ospf_mpls_te_config_write_router(struct vty *vty)
{
if (OspfMplsTE.status == enable) {
if (OspfMplsTE.enabled) {
vty_out(vty, " mpls-te on\n");
vty_out(vty, " mpls-te router-address %s\n",
inet_ntoa(OspfMplsTE.router_addr.value));
@ -2201,13 +2183,13 @@ DEFUN (ospf_mpls_te_on,
struct listnode *node;
struct mpls_te_link *lp;
if (OspfMplsTE.status == enable)
if (OspfMplsTE.enabled)
return CMD_SUCCESS;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("MPLS-TE: OFF -> ON");
OspfMplsTE.status = enable;
OspfMplsTE.enabled = true;
/* Reoriginate RFC3630 & RFC6827 Links */
ospf_mpls_te_foreach_area(ospf_mpls_te_lsa_schedule,
@ -2237,18 +2219,17 @@ DEFUN (no_ospf_mpls_te,
struct listnode *node, *nnode;
struct mpls_te_link *lp;
if (OspfMplsTE.status == disable)
if (!OspfMplsTE.enabled)
return CMD_SUCCESS;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("MPLS-TE: ON -> OFF");
OspfMplsTE.status = disable;
OspfMplsTE.enabled = false;
for (ALL_LIST_ELEMENTS(OspfMplsTE.iflist, node, nnode, lp))
if
CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)
ospf_mpls_te_lsa_schedule(lp, FLUSH_THIS_LSA);
if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED))
ospf_mpls_te_lsa_schedule(lp, FLUSH_THIS_LSA);
return CMD_SUCCESS;
}
@ -2279,7 +2260,7 @@ DEFUN (ospf_mpls_te_router_addr,
set_mpls_te_router_addr(value);
if (OspfMplsTE.status == disable)
if (!OspfMplsTE.enabled)
return CMD_SUCCESS;
for (ALL_LIST_ELEMENTS(OspfMplsTE.iflist, node, nnode, lp)) {
@ -2318,7 +2299,7 @@ static int set_inter_as_mode(struct vty *vty, const char *mode_name,
struct mpls_te_link *lp;
int format;
if (OspfMplsTE.status == enable) {
if (OspfMplsTE.enabled) {
/* Read and Check inter_as mode */
if (strcmp(mode_name, "as") == 0)
@ -2413,7 +2394,7 @@ DEFUN (no_ospf_mpls_te_inter_as,
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("MPLS-TE: Inter-AS support OFF");
if ((OspfMplsTE.status == enable)
if ((OspfMplsTE.enabled)
&& (OspfMplsTE.inter_as != Off)) {
OspfMplsTE.inter_as = Off;
/* Flush all Inter-AS LSA */
@ -2438,7 +2419,7 @@ DEFUN (show_ip_ospf_mpls_te_router,
"MPLS-TE information\n"
"MPLS-TE Router parameters\n")
{
if (OspfMplsTE.status == enable) {
if (OspfMplsTE.enabled) {
vty_out(vty, "--- MPLS-TE router parameters ---\n");
if (ntohs(OspfMplsTE.router_addr.header.type) != 0)
@ -2454,7 +2435,7 @@ static void show_mpls_te_link_sub(struct vty *vty, struct interface *ifp)
{
struct mpls_te_link *lp;
if ((OspfMplsTE.status == enable) && HAS_LINK_PARAMS(ifp)
if ((OspfMplsTE.enabled) && HAS_LINK_PARAMS(ifp)
&& !if_is_loopback(ifp) && if_is_up(ifp)
&& ((lp = lookup_linkparams_by_ifp(ifp)) != NULL)) {
/* Continue only if interface is not passive or support Inter-AS

View File

@ -337,7 +337,7 @@ struct te_link_subtlv {
/* Following structure are internal use only. */
struct ospf_mpls_te {
/* Status of MPLS-TE: enable or disbale */
status_t status;
bool enabled;
/* RFC5392 */
enum inter_as_mode inter_as;

View File

@ -84,9 +84,6 @@ struct ospf_external {
struct route_table *external_info;
};
/* Status of various sub function e.g. TE */
typedef enum _status_t {disable, enable} status_t;
/* OSPF master for system wide configuration and variables. */
struct ospf_master {
/* OSPF instance. */
@ -104,7 +101,7 @@ struct ospf_master {
/* Various OSPF global configuration. */
u_char options;
#define OSPF_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
#define OSPF_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
};
struct ospf_redist {