diff options
author | Olivier Dugeon <olivier.dugeon@orange.com> | 2018-02-01 14:30:34 +0100 |
---|---|---|
committer | Olivier Dugeon <olivier.dugeon@orange.com> | 2018-02-01 14:30:34 +0100 |
commit | db28a51f7e3b7ada03994e1fb4eb027fc9b37f11 (patch) | |
tree | 3ca34024e94af3e91d17a5142258e1e978775613 /ospfd/ospf_ext.c | |
parent | OSPFd: Clean up Segment Routing patch (diff) | |
download | frr-db28a51f7e3b7ada03994e1fb4eb027fc9b37f11.tar.xz frr-db28a51f7e3b7ada03994e1fb4eb027fc9b37f11.zip |
OSPFd: Correct Extended Prefix LSA refresh
- When Extended Prefix LSA need to be refresh, paramaters may be
taken from the wrong interface i.e. Extended Link instead of Prefix
resulting in producing an empty LSA body. Then, ospfd crash due to the
assert on LSA length in ospf_lsa_different() function: code check that
the LSA size is larger than LSA header i.e. LSA is not empty.
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Diffstat (limited to 'ospfd/ospf_ext.c')
-rw-r--r-- | ospfd/ospf_ext.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/ospfd/ospf_ext.c b/ospfd/ospf_ext.c index 474f173cb..afa70c0f1 100644 --- a/ospfd/ospf_ext.c +++ b/ospfd/ospf_ext.c @@ -238,10 +238,12 @@ static struct ext_itf *lookup_ext_by_instance(struct ospf_lsa *lsa) { struct listnode *node; struct ext_itf *exti; - unsigned int key = GET_OPAQUE_ID(ntohl(lsa->data->id.s_addr)); + uint32_t key = GET_OPAQUE_ID(ntohl(lsa->data->id.s_addr)); + uint8_t type = GET_OPAQUE_TYPE(ntohl(lsa->data->id.s_addr)); + for (ALL_LIST_ELEMENTS_RO(OspfEXT.iflist, node, exti)) - if (exti->instance == key) + if ((exti->instance == key) && (exti->type == type)) return exti; return NULL; @@ -419,8 +421,8 @@ static void set_rmt_itf_addr(struct ext_itf *exti, struct in_addr rmtif) * * @return instance number if update is OK, 0 otherwise */ -int ospf_ext_schedule_prefix_index(struct interface *ifp, uint32_t index, - struct prefix_ipv4 *p, uint8_t flags) +uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp, uint32_t index, + struct prefix_ipv4 *p, uint8_t flags) { int rc = 0; struct ext_itf *exti; @@ -462,7 +464,7 @@ int ospf_ext_schedule_prefix_index(struct interface *ifp, uint32_t index, } } - return exti->instance; + return SET_OPAQUE_LSID(exti->type, exti->instance); } /* @@ -587,6 +589,7 @@ static void ospf_ext_link_ism_change(struct ospf_interface *oi, int old_status) exti->stype = ADJ_SID; exti->instance = get_ext_link_instance_value(); + exti->type = OPAQUE_TYPE_EXTENDED_LINK_LSA; zlog_debug( "EXT (%s): Set %s SID to interface %s ", __func__, @@ -616,6 +619,7 @@ static void ospf_ext_pref_ism_change(struct ospf_interface *oi, int old_status) if (oi->type == OSPF_IFTYPE_LOOPBACK) { exti->stype = PREF_SID; exti->instance = get_ext_pref_instance_value(); + exti->type = OPAQUE_TYPE_EXTENDED_PREFIX_LSA; zlog_debug( "EXT (%s): Set Node SID to interface %s ", __func__, @@ -1329,8 +1333,7 @@ static struct ospf_lsa *ospf_ext_pref_lsa_refresh(struct ospf_lsa *lsa) } /* Create new Opaque-LSA/Extended Prefix Opaque LSA instance. */ - if (exti) - new = ospf_ext_pref_lsa_new(area, exti); + new = ospf_ext_pref_lsa_new(area, exti); if (new == NULL) { zlog_warn("EXT (%s): ospf_ext_pref_lsa_new() error", __func__); |