mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 22:23:12 +00:00
ospfd: Coverity corrections
Following PR #6726, Coverity Scan detected some new errors in the OSPF Segment Routing code. This patch corrects them. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
This commit is contained in:
parent
0d174b6697
commit
83df36e845
@ -563,9 +563,9 @@ static void ospf_ext_link_update_adj_sid(struct ext_itf *exti)
|
||||
set_adj_sid(exti, true, bck_label, SID_LABEL);
|
||||
set_adj_sid(exti, false, label, SID_LABEL);
|
||||
} else {
|
||||
set_lan_adj_sid(exti, true, bck_label, SID_LABEL,
|
||||
set_lan_adj_sid(exti, true, bck_label, SID_LABEL,
|
||||
exti->lan_sid[0].neighbor_id);
|
||||
set_lan_adj_sid(exti, false, label, SID_LABEL,
|
||||
set_lan_adj_sid(exti, false, label, SID_LABEL,
|
||||
exti->lan_sid[1].neighbor_id);
|
||||
}
|
||||
|
||||
@ -590,8 +590,8 @@ static void ospf_ext_link_delete_adj_sid(struct ext_itf *exti)
|
||||
ospf_sr_local_block_release_label(exti->adj_sid[0].value);
|
||||
ospf_sr_local_block_release_label(exti->adj_sid[1].value);
|
||||
} else {
|
||||
ospf_sr_local_block_release_label(exti->adj_sid[0].value);
|
||||
ospf_sr_local_block_release_label(exti->adj_sid[1].value);
|
||||
ospf_sr_local_block_release_label(exti->lan_sid[0].value);
|
||||
ospf_sr_local_block_release_label(exti->lan_sid[1].value);
|
||||
}
|
||||
/* And reset corresponding TLV */
|
||||
unset_adjacency_sid(exti);
|
||||
|
@ -573,20 +573,23 @@ static void initialize_params(struct ospf_router_info *ori)
|
||||
return;
|
||||
}
|
||||
|
||||
static int is_mandated_params_set(struct ospf_router_info ori)
|
||||
static int is_mandated_params_set(struct ospf_router_info *ori)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (ntohs(ori.router_cap.header.type) == 0)
|
||||
if (ori == NULL)
|
||||
return rc;
|
||||
|
||||
if ((ntohs(ori.pce_info.pce_header.header.type) == RI_TLV_PCE)
|
||||
&& (ntohs(ori.pce_info.pce_address.header.type) == 0)
|
||||
&& (ntohs(ori.pce_info.pce_cap_flag.header.type) == 0))
|
||||
if (ntohs(ori->router_cap.header.type) == 0)
|
||||
return rc;
|
||||
|
||||
if ((ori.sr_info.enabled) && (ntohs(TLV_TYPE(ori.sr_info.algo)) == 0)
|
||||
&& (ntohs(TLV_TYPE(ori.sr_info.srgb)) == 0))
|
||||
if ((ntohs(ori->pce_info.pce_header.header.type) == RI_TLV_PCE)
|
||||
&& (ntohs(ori->pce_info.pce_address.header.type) == 0)
|
||||
&& (ntohs(ori->pce_info.pce_cap_flag.header.type) == 0))
|
||||
return rc;
|
||||
|
||||
if ((ori->sr_info.enabled) && (ntohs(TLV_TYPE(ori->sr_info.algo)) == 0)
|
||||
&& (ntohs(TLV_TYPE(ori->sr_info.srgb)) == 0))
|
||||
return rc;
|
||||
|
||||
rc = 1;
|
||||
@ -626,6 +629,10 @@ void ospf_router_info_update_sr(bool enable, struct sr_node *srn)
|
||||
initialize_params(&OspfRI);
|
||||
}
|
||||
|
||||
/* Check that SR node is valid */
|
||||
if (srn == NULL)
|
||||
return;
|
||||
|
||||
if (IS_DEBUG_OSPF_SR)
|
||||
zlog_debug("RI (%s): %s Routing Information for Segment Routing",
|
||||
__func__, enable ? "Enable" : "Disable");
|
||||
@ -986,7 +993,7 @@ static int ospf_router_info_lsa_originate(void *arg)
|
||||
}
|
||||
|
||||
/* Router Information is not yet Engaged, check parameters */
|
||||
if (!is_mandated_params_set(OspfRI))
|
||||
if (!is_mandated_params_set(&OspfRI))
|
||||
flog_warn(
|
||||
EC_OSPF_LSA,
|
||||
"RI (%s): lacks mandated ROUTER INFORMATION parameters",
|
||||
|
@ -2074,13 +2074,17 @@ static int update_srgb(uint32_t lower, uint32_t size)
|
||||
osr_debug("SR(%s): Got new SRGB [%u/%u]", __func__, OspfSR.srgb.start,
|
||||
OspfSR.srgb.start + OspfSR.srgb.size - 1);
|
||||
|
||||
/* SRGB is reserved, set Router Information parameters */
|
||||
ospf_router_info_update_sr(true, OspfSR.self);
|
||||
/* Update Self SR-Node */
|
||||
if (OspfSR.self != NULL) {
|
||||
/* SRGB is reserved, set Router Information parameters */
|
||||
ospf_router_info_update_sr(true, OspfSR.self);
|
||||
|
||||
/* and update NHLFE entries */
|
||||
hash_iterate(OspfSR.neighbors,
|
||||
(void (*)(struct hash_bucket *, void *))update_in_nhlfe,
|
||||
NULL);
|
||||
/* and update NHLFE entries */
|
||||
hash_iterate(
|
||||
OspfSR.neighbors,
|
||||
(void (*)(struct hash_bucket *, void *))update_in_nhlfe,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2198,9 +2202,11 @@ DEFUN (sr_local_label_range,
|
||||
}
|
||||
|
||||
/* SRLB is reserved, Update Self SR-Node and Router Information LSA */
|
||||
OspfSR.self->srlb.lower_bound = lower;
|
||||
OspfSR.self->srlb.range_size = upper - lower + 1;
|
||||
ospf_router_info_update_sr(true, OspfSR.self);
|
||||
if (OspfSR.self != NULL) {
|
||||
OspfSR.self->srlb.lower_bound = lower;
|
||||
OspfSR.self->srlb.range_size = upper - lower + 1;
|
||||
ospf_router_info_update_sr(true, OspfSR.self);
|
||||
}
|
||||
|
||||
/* and update (LAN)-Adjacency SID */
|
||||
ospf_ext_link_srlb_update();
|
||||
@ -2250,8 +2256,8 @@ DEFUN (no_sr_local_label_range,
|
||||
if (OspfSR.self != NULL) {
|
||||
OspfSR.self->srlb.lower_bound = DEFAULT_SRLB_LABEL;
|
||||
OspfSR.self->srlb.range_size = DEFAULT_SRLB_SIZE;
|
||||
ospf_router_info_update_sr(true, OspfSR.self);
|
||||
}
|
||||
ospf_router_info_update_sr(true, OspfSR.self);
|
||||
|
||||
/* and update (LAN)-Adjacency SID */
|
||||
ospf_ext_link_srlb_update();
|
||||
@ -2287,12 +2293,13 @@ DEFUN (sr_node_msd,
|
||||
|
||||
/* Set this router MSD */
|
||||
OspfSR.msd = msd;
|
||||
if (OspfSR.self != NULL)
|
||||
if (OspfSR.self != NULL) {
|
||||
OspfSR.self->msd = msd;
|
||||
|
||||
/* Set Router Information parameters if SR is UP */
|
||||
if (OspfSR.status == SR_UP)
|
||||
ospf_router_info_update_sr(true, OspfSR.self);
|
||||
/* Set Router Information parameters if SR is UP */
|
||||
if (OspfSR.status == SR_UP)
|
||||
ospf_router_info_update_sr(true, OspfSR.self);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@ -2311,12 +2318,13 @@ DEFUN (no_sr_node_msd,
|
||||
|
||||
/* unset this router MSD */
|
||||
OspfSR.msd = 0;
|
||||
if (OspfSR.self != NULL)
|
||||
if (OspfSR.self != NULL) {
|
||||
OspfSR.self->msd = 0;
|
||||
|
||||
/* Set Router Information parameters if SR is UP */
|
||||
if (OspfSR.status == SR_UP)
|
||||
ospf_router_info_update_sr(true, OspfSR.self);
|
||||
/* Set Router Information parameters if SR is UP */
|
||||
if (OspfSR.status == SR_UP)
|
||||
ospf_router_info_update_sr(true, OspfSR.self);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user