opsfd: Correct MPLS-TE bug with LSA Flush

When an interface goes down, if it is MPLS-TE enabled, the corresponding
TE Opaque LSA is not flushed and continue to be advertised.
The problem is due to bugs in ISM and NSM handler functions of ospf_te.c file:

- ospf_mpls_te_ism_change():
  - flag associated with Link Parameters is reset
  - ISM_Down state is not correctly handle

- ospf_mpls_te_nsm_change():
  - flag associated with Link Parameters is reset
  - NSM_Down and NSM_Delete states are not handle

This patch correct this problem.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
This commit is contained in:
Olivier Dugeon 2021-02-12 18:47:36 +01:00
parent b0c0b43348
commit 50ec09db39

View File

@ -939,9 +939,6 @@ static void ospf_mpls_te_ism_change(struct ospf_interface *oi, int old_state)
/* Keep Area information in combination with linkparams. */ /* Keep Area information in combination with linkparams. */
lp->area = oi->area; lp->area = oi->area;
/* Keep interface MPLS-TE status */
lp->flags = HAS_LINK_PARAMS(oi->ifp);
switch (oi->state) { switch (oi->state) {
case ISM_PointToPoint: case ISM_PointToPoint:
case ISM_DROther: case ISM_DROther:
@ -952,10 +949,17 @@ static void ospf_mpls_te_ism_change(struct ospf_interface *oi, int old_state)
set_linkparams_lclif_ipaddr(lp, oi->address->u.prefix4); set_linkparams_lclif_ipaddr(lp, oi->address->u.prefix4);
break; break;
default: case ISM_Down:
/* State is undefined: Flush LSA if engaged */ /* Interface goes Down: Flush LSA if engaged */
if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)) if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)) {
ote_debug(
"MPLS-TE (%s): Interface %s goes down: flush LSA",
__func__, IF_NAME(oi));
ospf_mpls_te_lsa_schedule(lp, FLUSH_THIS_LSA); ospf_mpls_te_lsa_schedule(lp, FLUSH_THIS_LSA);
return;
}
break;
default:
break; break;
} }
@ -997,12 +1001,21 @@ static void ospf_mpls_te_nsm_change(struct ospf_neighbor *nbr, int old_state)
return; return;
} }
/* Flush TE Opaque LSA if Neighbor State goes Down or Deleted */
if (OspfMplsTE.enabled
&& (nbr->state == NSM_Down || nbr->state == NSM_Deleted)) {
if (CHECK_FLAG(lp->flags, EXT_LPFLG_LSA_ENGAGED)) {
ote_debug(
"MPLS-TE (%s): Interface %s goes down: flush LSA",
__func__, IF_NAME(oi));
ospf_mpls_te_lsa_schedule(lp, FLUSH_THIS_LSA);
}
return;
}
/* Keep Area information in combination with SR info. */ /* Keep Area information in combination with SR info. */
lp->area = oi->area; lp->area = oi->area;
/* Keep interface MPLS-TE status */
lp->flags = HAS_LINK_PARAMS(oi->ifp);
/* /*
* The Link ID is identical to the contents of the Link ID field * The Link ID is identical to the contents of the Link ID field
* in the Router LSA for these link types. * in the Router LSA for these link types.
@ -1022,12 +1035,19 @@ static void ospf_mpls_te_nsm_change(struct ospf_neighbor *nbr, int old_state)
set_linkparams_link_id(lp, DR(oi)); set_linkparams_link_id(lp, DR(oi));
break; break;
default: case ISM_Down:
/* State is undefined: Flush LSA if engaged */ /* State goes Down: Flush LSA if engaged */
if (OspfMplsTE.enabled && if (OspfMplsTE.enabled &&
CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)) CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)) {
ote_debug(
"MPLS-TE (%s): Interface %s goes down: flush LSA",
__func__, IF_NAME(oi));
ospf_mpls_te_lsa_schedule(lp, FLUSH_THIS_LSA); ospf_mpls_te_lsa_schedule(lp, FLUSH_THIS_LSA);
}
return; return;
break;
default:
break;
} }
ote_debug("MPLS-TE (%s): Add Link-ID %pI4 for interface %s ", __func__, ote_debug("MPLS-TE (%s): Add Link-ID %pI4 for interface %s ", __func__,
@ -1173,7 +1193,7 @@ static struct ospf_lsa *ospf_mpls_te_lsa_new(struct ospf *ospf,
} }
ote_debug( ote_debug(
"MPLS-TE (%s): LSA[Type%d:%pI4]: Create an Opaque-LSA/MPLS-TE instance", "MPLS-TE (%s): LSA[Type%d:%pI4]: Create an Opaque-LSA/MPLS-TE instance",
__func__, lsa_type, &lsa_id); __func__, lsa_type, &lsa_id);
/* Set opaque-LSA body fields. */ /* Set opaque-LSA body fields. */