diff options
author | Olivier Dugeon <olivier.dugeon@orange.com> | 2020-08-26 17:27:16 +0200 |
---|---|---|
committer | Olivier Dugeon <olivier.dugeon@orange.com> | 2020-08-26 17:27:16 +0200 |
commit | 83df36e845070aa18fa31344c0240c6552ffbc2a (patch) | |
tree | 3df6e8a4729d366641c6898560c9cc8e9364020a /ospfd/ospf_ri.c | |
parent | OSPFd: Correct Extended Prefix flooding for SR (diff) | |
download | frr-83df36e845070aa18fa31344c0240c6552ffbc2a.tar.xz frr-83df36e845070aa18fa31344c0240c6552ffbc2a.zip |
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>
Diffstat (limited to 'ospfd/ospf_ri.c')
-rw-r--r-- | ospfd/ospf_ri.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index 8eeaf7be3..fc9c8f6be 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -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", |