Path computation algorithms failed during edge pruning if ClassType
is not specified raising a NPE.
In addition, setting ClassType to 0 by default ito handle the NPE is
not conform to RFC5455.
This patch modify edge pruning when ClassType is not specified (set
to 0) and remove default setting to avoid problem when enforcing LSP
with a ClassType equal 0.
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Change-Id: I8930393359960dc9406fb9cc112bc194049cb35a
(cherry picked from commit
42282fe0eac1a45e0afdedd55c4984195ceddb8d)
}
/* Check that Edge meet Bandwidth constraint */
+ int cos = 0;
+ if (constraints.getClassType() != null) {
+ cos = constraints.getClassType().intValue();
+ }
if (constraints.getBandwidth() != null) {
if (attributes.getMaxLinkBandwidth() == null || attributes.getMaxResvLinkBandwidth() == null
|| attributes.getUnreservedBandwidth() == null
- || attributes.getUnreservedBandwidth().get(constraints.getClassType().intValue()) == null) {
+ || attributes.getUnreservedBandwidth().get(cos) == null) {
return true;
} else {
Long bandwidth = constraints.getBandwidth().getValue().longValue();
Long unrsv = 0L;
for (UnreservedBandwidth unResBw : attributes.getUnreservedBandwidth()) {
- if (unResBw.getClassType().intValue() == constraints.getClassType().intValue()) {
+ if (unResBw.getClassType().intValue() == cos) {
unrsv = unResBw.getBandwidth().getValue().longValue();
break;
}
bwBuilder.setBandwidth(new Bandwidth(new Float32(ByteBuffer.allocate(4)
.putFloat(cpath.getBandwidth().getValue().floatValue()).array())));
pathBuilder.setBandwidth(bwBuilder.build());
- if (cpath.getClassType() != null) {
- pathBuilder.setClassType(new ClassTypeBuilder().setClassType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
- .ClassType(cpath.getClassType()))
- .build());
- }
+ }
+ if (cpath.getClassType() != null && !cpath.getClassType().equals(Uint8.ZERO)) {
+ pathBuilder.setClassType(new ClassTypeBuilder().setClassType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
+ .ClassType(cpath.getClassType()))
+ .build());
}
return pathBuilder;
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.P2p;
import org.opendaylight.yangtools.yang.common.Uint32;
-import org.opendaylight.yangtools.yang.common.Uint8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
ctsBuilder.setBandwidth(new DecimalBandwidth(BigDecimal.valueOf(value)));
if (classType != null) {
ctsBuilder.setClassType(classType.getClassType().getValue());
- } else {
- ctsBuilder.setClassType(Uint8.ZERO);
}
}
}