Priyanka B
Committed by Gerrit Code Review

[ONOS] RSVP defect fix in master

Change-Id: I090d389f65a457cf5756ce73fe0c37468b46db5b
...@@ -86,10 +86,9 @@ public class PceSetupPathCommand extends AbstractShellCommand { ...@@ -86,10 +86,9 @@ public class PceSetupPathCommand extends AbstractShellCommand {
86 LspType lspType = LspType.values()[type]; 86 LspType lspType = LspType.values()[type];
87 87
88 // Add bandwidth 88 // Add bandwidth
89 - // bandwidth default data rate unit is in MBPS, since bandwidth value in network config 89 + // bandwidth default data rate unit is in BPS
90 - //stored in MPBS
91 if (bandwidth != 0.0) { 90 if (bandwidth != 0.0) {
92 - listConstrnt.add(BandwidthConstraint.of(bandwidth, DataRateUnit.valueOf("MBPS"))); 91 + listConstrnt.add(BandwidthConstraint.of(bandwidth, DataRateUnit.valueOf("BPS")));
93 } 92 }
94 93
95 // Add cost 94 // Add cost
......
...@@ -515,7 +515,14 @@ public class PceManager implements PceService { ...@@ -515,7 +515,14 @@ public class PceManager implements PceService {
515 } 515 }
516 516
517 if (existingBwValue != null) { 517 if (existingBwValue != null) {
518 - shBwConstraint = new SharedBandwidthConstraint(links, existingBwValue, bwConstraint.bandwidth()); 518 + if (bwConstraintValue == 0) {
519 + bwConstraintValue = existingBwValue.bps();
520 + }
521 + //If bandwidth constraints not specified , take existing bandwidth for shared bandwidth calculation
522 + shBwConstraint = bwConstraint != null ? new SharedBandwidthConstraint(links,
523 + existingBwValue, bwConstraint.bandwidth()) : new SharedBandwidthConstraint(links,
524 + existingBwValue, existingBwValue);
525 +
519 constraints.add(shBwConstraint); 526 constraints.add(shBwConstraint);
520 } 527 }
521 } else { 528 } else {
......
...@@ -72,7 +72,7 @@ public class PcepClientImpl implements PcepClientDriver { ...@@ -72,7 +72,7 @@ public class PcepClientImpl implements PcepClientDriver {
72 private byte deadTime; 72 private byte deadTime;
73 private byte sessionId; 73 private byte sessionId;
74 private PcepPacketStatsImpl pktStats; 74 private PcepPacketStatsImpl pktStats;
75 - private Map<LspKey, Boolean> lspDelegationInfo; 75 + private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>();
76 private Map<PccId, List<PcepStateReport>> syncRptCache = new HashMap<>(); 76 private Map<PccId, List<PcepStateReport>> syncRptCache = new HashMap<>();
77 77
78 @Override 78 @Override
......
...@@ -125,6 +125,7 @@ import java.util.concurrent.TimeUnit; ...@@ -125,6 +125,7 @@ import java.util.concurrent.TimeUnit;
125 import static com.google.common.base.Preconditions.checkNotNull; 125 import static com.google.common.base.Preconditions.checkNotNull;
126 import static com.google.common.base.Strings.isNullOrEmpty; 126 import static com.google.common.base.Strings.isNullOrEmpty;
127 import static org.onlab.util.Tools.get; 127 import static org.onlab.util.Tools.get;
128 +import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT;
128 import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; 129 import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS;
129 import static org.onosproject.net.DefaultAnnotations.EMPTY; 130 import static org.onosproject.net.DefaultAnnotations.EMPTY;
130 import static org.onosproject.net.DeviceId.deviceId; 131 import static org.onosproject.net.DeviceId.deviceId;
...@@ -136,6 +137,7 @@ import static org.onosproject.pcep.controller.PcepAnnotationKeys.BANDWIDTH; ...@@ -136,6 +137,7 @@ import static org.onosproject.pcep.controller.PcepAnnotationKeys.BANDWIDTH;
136 import static org.onosproject.pcep.controller.PcepAnnotationKeys.LOCAL_LSP_ID; 137 import static org.onosproject.pcep.controller.PcepAnnotationKeys.LOCAL_LSP_ID;
137 import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; 138 import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
138 import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCC_TUNNEL_ID; 139 import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCC_TUNNEL_ID;
140 +import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCE_INIT;
139 import static org.onosproject.pcep.controller.PcepAnnotationKeys.PLSP_ID; 141 import static org.onosproject.pcep.controller.PcepAnnotationKeys.PLSP_ID;
140 import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE; 142 import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE;
141 import static org.onosproject.pcep.controller.PcepAnnotationKeys.COST_TYPE; 143 import static org.onosproject.pcep.controller.PcepAnnotationKeys.COST_TYPE;
...@@ -298,6 +300,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -298,6 +300,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
298 @Override 300 @Override
299 public void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path) { 301 public void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path) {
300 302
303 + //TODO: tunnel which is passed doesn't have tunnelID
301 if (tunnel.annotations().value(PLSP_ID) != null) { 304 if (tunnel.annotations().value(PLSP_ID) != null) {
302 updateTunnel(tunnel, path); 305 updateTunnel(tunnel, path);
303 return; 306 return;
...@@ -317,8 +320,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -317,8 +320,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
317 PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpTunnelEndPoint) tunnel.src()).ip())); 320 PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpTunnelEndPoint) tunnel.src()).ip()));
318 321
319 if (!(pc instanceof PcepClient)) { 322 if (!(pc instanceof PcepClient)) {
320 - log.error("There is no PCC connected with ip addresss {}" 323 + log.error("There is no PCC connected with this device {}"
321 - + ((IpElementId) srcElement).ipAddress().toString()); 324 + + srcElement.toString());
322 return; 325 return;
323 } 326 }
324 327
...@@ -405,6 +408,22 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -405,6 +408,22 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
405 return; 408 return;
406 } 409 }
407 410
411 + //To get new tunnel ID (modified tunnel ID)
412 + Collection<Tunnel> tunnels = tunnelService.queryTunnel(tunnel.src(), tunnel.dst());
413 + for (Tunnel t : tunnels) {
414 + if (t.state().equals(INIT) && t.tunnelName().equals(tunnel.tunnelName())) {
415 + tunnel = new DefaultTunnel(tunnel.providerId(), tunnel.src(),
416 + tunnel.dst(), tunnel.type(),
417 + t.state(), tunnel.groupId(),
418 + t.tunnelId(),
419 + tunnel.tunnelName(),
420 + tunnel.path(),
421 + tunnel.resource(),
422 + tunnel.annotations());
423 + break;
424 + }
425 + }
426 +
408 PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpTunnelEndPoint) tunnel.src()).ip())); 427 PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpTunnelEndPoint) tunnel.src()).ip()));
409 428
410 if (!(pc instanceof PcepClient)) { 429 if (!(pc instanceof PcepClient)) {
...@@ -415,11 +434,27 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -415,11 +434,27 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
415 434
416 // If delegation flag is set then only send update message[means delegated PCE can send update msg for that 435 // If delegation flag is set then only send update message[means delegated PCE can send update msg for that
417 // LSP].If annotation is null D flag is not set else it is set. 436 // LSP].If annotation is null D flag is not set else it is set.
418 - if (pc.capability().statefulPceCapability() 437 + Short localLspId = 0;
419 - && pc.delegationInfo( 438 + for (Tunnel t : tunnels) {
420 - new LspKey(Integer.valueOf(tunnel.annotations().value(PLSP_ID)), Short.valueOf(tunnel 439 + if (!t.tunnelId().equals(tunnel.tunnelId()) && t.tunnelName().equals(tunnel.tunnelName())) {
421 - .annotations().value(LOCAL_LSP_ID)))) != null) { 440 + localLspId = Short.valueOf(t.annotations().value(LOCAL_LSP_ID));
422 - pcepUpdateTunnel(tunnel, path, pc); 441 + }
442 + }
443 +
444 + if (localLspId == 0) {
445 + log.error("Local LSP ID for old tunnel not found");
446 + return;
447 + }
448 +
449 + //PCInitiate tunnels are always have D flag set, else check for tunnels who are delegated via LspKey
450 + if (pc.capability().statefulPceCapability()) {
451 + if (tunnel.annotations().value(PCE_INIT) != null && tunnel.annotations().value(PCE_INIT).equals("true")) {
452 + pcepUpdateTunnel(tunnel, path, pc);
453 + } else if (pc.delegationInfo(
454 + new LspKey(Integer.valueOf(tunnel.annotations().value(PLSP_ID)),
455 + localLspId.shortValue())) != null) {
456 + pcepUpdateTunnel(tunnel, path, pc);
457 + }
423 } 458 }
424 } 459 }
425 460
...@@ -886,6 +921,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -886,6 +921,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
886 } 921 }
887 } 922 }
888 923
924 + tunnel.annotations().value(LSP_SIG_TYPE);
889 tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt()), 925 tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt()),
890 localLspId, (short) 0, 0, (((IpTunnelEndPoint) tunnel.dst()).ip() 926 localLspId, (short) 0, 0, (((IpTunnelEndPoint) tunnel.dst()).ip()
891 .getIp4Address().toInt())); 927 .getIp4Address().toInt()));
...@@ -907,9 +943,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -907,9 +943,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
907 //build ERO object 943 //build ERO object
908 PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); 944 PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build();
909 945
910 - float iBandwidth = DEFAULT_BANDWIDTH_VALUE; 946 + int iBandwidth = DEFAULT_BANDWIDTH_VALUE;
911 if (tunnel.annotations().value(BANDWIDTH) != null) { 947 if (tunnel.annotations().value(BANDWIDTH) != null) {
912 - iBandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH)); 948 + iBandwidth = Float.floatToIntBits(Float.parseFloat(tunnel.annotations().value(BANDWIDTH)));
913 } 949 }
914 // build bandwidth object 950 // build bandwidth object
915 PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build(); 951 PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build();
...@@ -933,6 +969,26 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -933,6 +969,26 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
933 private void pcepSetupTunnel(Tunnel tunnel, Path path, PcepClient pc) { 969 private void pcepSetupTunnel(Tunnel tunnel, Path path, PcepClient pc) {
934 try { 970 try {
935 int srpId = SrpIdGenerators.create(); 971 int srpId = SrpIdGenerators.create();
972 + Collection<Tunnel> tunnels = tunnelService.queryTunnel(tunnel.src(), tunnel.dst());
973 + for (Tunnel t : tunnels) {
974 + if (t.tunnelName().equals(tunnel.tunnelName())) {
975 + tunnel = new DefaultTunnel(tunnel.providerId(), tunnel.src(),
976 + tunnel.dst(), tunnel.type(),
977 + t.state(), tunnel.groupId(),
978 + t.tunnelId(),
979 + tunnel.tunnelName(),
980 + tunnel.path(),
981 + tunnel.resource(),
982 + tunnel.annotations());
983 + break;
984 + }
985 + }
986 +
987 + if (tunnel.tunnelId() == null) {
988 + log.error("Tunnel ID not found");
989 + return;
990 + }
991 +
936 PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, CREATE); 992 PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, CREATE);
937 993
938 pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData); 994 pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData);
...@@ -996,6 +1052,26 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -996,6 +1052,26 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
996 1052
997 tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); 1053 tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes());
998 llOptionalTlv.add(tlv); 1054 llOptionalTlv.add(tlv);
1055 +
1056 + String localLspIdString = tunnel.annotations().value(LOCAL_LSP_ID);
1057 + String pccTunnelIdString = tunnel.annotations().value(PCC_TUNNEL_ID);
1058 + short localLspId = 0;
1059 + short pccTunnelId = 0;
1060 +
1061 + if (localLspIdString != null) {
1062 + localLspId = Short.valueOf(localLspIdString);
1063 + }
1064 +
1065 + if (pccTunnelIdString != null) {
1066 + pccTunnelId = Short.valueOf(pccTunnelIdString);
1067 + }
1068 +
1069 + tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src())
1070 + .ip().getIp4Address().toInt()),
1071 + localLspId, pccTunnelId, 0, (((IpTunnelEndPoint) tunnel.dst()).ip()
1072 + .getIp4Address().toInt()));
1073 + llOptionalTlv.add(tlv);
1074 +
999 // build lsp object, set r flag as false to delete the tunnel 1075 // build lsp object, set r flag as false to delete the tunnel
1000 PcepLspObject lspobj = pc.factory().buildLspObject().setRFlag(false).setPlspId(plspId) 1076 PcepLspObject lspobj = pc.factory().buildLspObject().setRFlag(false).setPlspId(plspId)
1001 .setOptionalTlv(llOptionalTlv).build(); 1077 .setOptionalTlv(llOptionalTlv).build();
...@@ -1047,14 +1123,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1047,14 +1123,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1047 1123
1048 llOptionalTlv = new LinkedList<PcepValueType>(); 1124 llOptionalTlv = new LinkedList<PcepValueType>();
1049 1125
1050 - if (!(pcepTunnelApiMapper.checkFromTunnelDBQueue(tunnelId))) {
1051 - log.error("Tunnel doesnot exists in DB");
1052 - return;
1053 - } else {
1054 - PcepTunnelData pcepTunnelDBData = pcepTunnelApiMapper.getDataFromTunnelDBQueue(tunnelId);
1055 - plspId = pcepTunnelDBData.plspId();
1056 - }
1057 -
1058 if (lspSigType != WITH_SIGNALLING) { 1126 if (lspSigType != WITH_SIGNALLING) {
1059 String localLspIdString = tunnel.annotations().value(LOCAL_LSP_ID); 1127 String localLspIdString = tunnel.annotations().value(LOCAL_LSP_ID);
1060 String pccTunnelIdString = tunnel.annotations().value(PCC_TUNNEL_ID); 1128 String pccTunnelIdString = tunnel.annotations().value(PCC_TUNNEL_ID);
...@@ -1082,14 +1150,15 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1082,14 +1150,15 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1082 } 1150 }
1083 1151
1084 // build lsp object 1152 // build lsp object
1085 - PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true).setPlspId(plspId) 1153 + PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true)
1154 + .setPlspId(Integer.valueOf(tunnel.annotations().value(PLSP_ID)))
1086 .setOptionalTlv(llOptionalTlv).build(); 1155 .setOptionalTlv(llOptionalTlv).build();
1087 // build ero object 1156 // build ero object
1088 PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); 1157 PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build();
1089 1158
1090 - int iBandwidth = DEFAULT_BANDWIDTH_VALUE; 1159 + float iBandwidth = DEFAULT_BANDWIDTH_VALUE;
1091 if (tunnel.annotations().value(BANDWIDTH) != null) { 1160 if (tunnel.annotations().value(BANDWIDTH) != null) {
1092 - iBandwidth = Integer.parseInt(tunnel.annotations().value(BANDWIDTH)); 1161 + iBandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH));
1093 } 1162 }
1094 // build bandwidth object 1163 // build bandwidth object
1095 PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build(); 1164 PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build();
...@@ -1241,6 +1310,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1241,6 +1310,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1241 annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(ipv4LspTlv.getLspId())); 1310 annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(ipv4LspTlv.getLspId()));
1242 } 1311 }
1243 1312
1313 + if (tunnel.annotations().value(PCC_TUNNEL_ID) == null) {
1314 + annotationBuilder.set(PCC_TUNNEL_ID, String.valueOf(ipv4LspTlv.getTunnelId()));
1315 + }
1316 +
1244 SparseAnnotations annotations = annotationBuilder.build(); 1317 SparseAnnotations annotations = annotationBuilder.build();
1245 DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), 1318 DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(),
1246 tunnel.dst(), tunnel.type(), tunnel.groupId(), 1319 tunnel.dst(), tunnel.type(), tunnel.groupId(),
...@@ -1248,6 +1321,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1248,6 +1321,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1248 annotations); 1321 annotations);
1249 1322
1250 if (CREATE == pcepTunnelData.requestType()) { 1323 if (CREATE == pcepTunnelData.requestType()) {
1324 + pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
1251 pcepTunnelApiMapper.handleCreateTunnelRequestQueue(srpId, pcepTunnelData); 1325 pcepTunnelApiMapper.handleCreateTunnelRequestQueue(srpId, pcepTunnelData);
1252 } else if (DELETE == pcepTunnelData.requestType()) { 1326 } else if (DELETE == pcepTunnelData.requestType()) {
1253 pcepTunnelApiMapper.handleRemoveFromTunnelRequestQueue(srpId, pcepTunnelData); 1327 pcepTunnelApiMapper.handleRemoveFromTunnelRequestQueue(srpId, pcepTunnelData);
...@@ -1552,7 +1626,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1552,7 +1626,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1552 List<Link> links = new ArrayList<Link>(); 1626 List<Link> links = new ArrayList<Link>();
1553 LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects(); 1627 LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects();
1554 if (0 == llSubObj.size()) { 1628 if (0 == llSubObj.size()) {
1555 - log.error("ERO in report message does not have hop information"); 1629 + log.debug("ERO in report message does not have hop information");
1630 + return null;
1556 } 1631 }
1557 ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator(); 1632 ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator();
1558 1633
......