Priyanka B
Committed by Gerrit Code Review

cherry pick of [ONOS-4807] [ONOS-4808] [ONOS-4669]SR-TE resilency defect fix and…

… networkconfig exception

Change-Id: I59d865cdd98ee80e1273ec1f9f8bd56a24e8c8b0
...@@ -641,7 +641,7 @@ public class PceManager implements PceService { ...@@ -641,7 +641,7 @@ public class PceManager implements PceService {
641 * 641 *
642 * @return value of local LSP identifier 642 * @return value of local LSP identifier
643 */ 643 */
644 - private short getNextLocalLspId() { 644 + private synchronized short getNextLocalLspId() {
645 // If there is any free id use it. Otherwise generate new id. 645 // If there is any free id use it. Otherwise generate new id.
646 if (localLspIdFreeList.isEmpty()) { 646 if (localLspIdFreeList.isEmpty()) {
647 return (short) localLspIdIdGen.getNewId(); 647 return (short) localLspIdIdGen.getNewId();
......
...@@ -44,6 +44,7 @@ import org.onosproject.pce.pceservice.constraint.CapabilityConstraint; ...@@ -44,6 +44,7 @@ import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
44 import org.onosproject.pce.pceservice.constraint.CostConstraint; 44 import org.onosproject.pce.pceservice.constraint.CostConstraint;
45 import org.onosproject.pce.pceservice.TunnelConsumerId; 45 import org.onosproject.pce.pceservice.TunnelConsumerId;
46 import org.onosproject.pce.pceservice.LspType; 46 import org.onosproject.pce.pceservice.LspType;
47 +import org.onosproject.pce.pceservice.constraint.SharedBandwidthConstraint;
47 import org.onosproject.pce.pcestore.api.LspLocalLabelInfo; 48 import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
48 import org.onosproject.pce.pcestore.api.PceStore; 49 import org.onosproject.pce.pcestore.api.PceStore;
49 import org.onosproject.store.serializers.KryoNamespaces; 50 import org.onosproject.store.serializers.KryoNamespaces;
...@@ -142,6 +143,7 @@ public class DistributedPceStore implements PceStore { ...@@ -142,6 +143,7 @@ public class DistributedPceStore implements PceStore {
142 CostConstraint.class, 143 CostConstraint.class,
143 CostConstraint.Type.class, 144 CostConstraint.Type.class,
144 BandwidthConstraint.class, 145 BandwidthConstraint.class,
146 + SharedBandwidthConstraint.class,
145 CapabilityConstraint.class, 147 CapabilityConstraint.class,
146 CapabilityConstraint.CapabilityType.class, 148 CapabilityConstraint.CapabilityType.class,
147 LspType.class) 149 LspType.class)
......
...@@ -61,7 +61,7 @@ public class BgpMessageDecoder extends FrameDecoder { ...@@ -61,7 +61,7 @@ public class BgpMessageDecoder extends FrameDecoder {
61 BgpMessage message = reader.readFrom(buffer, bgpHeader); 61 BgpMessage message = reader.readFrom(buffer, bgpHeader);
62 msgList.add(message); 62 msgList.add(message);
63 } 63 }
64 - 64 + ctx.setAttachment(null);
65 return msgList; 65 return msgList;
66 } catch (Exception e) { 66 } catch (Exception e) {
67 log.debug("Bgp protocol message decode error"); 67 log.debug("Bgp protocol message decode error");
......
...@@ -1504,7 +1504,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1504,7 +1504,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1504 log.error("ERO object is null in report message."); 1504 log.error("ERO object is null in report message.");
1505 return; 1505 return;
1506 } 1506 }
1507 -
1508 PcepAttribute attributes = msgPath.getPcepAttribute(); 1507 PcepAttribute attributes = msgPath.getPcepAttribute();
1509 float bandwidth = 0; 1508 float bandwidth = 0;
1510 int cost = 0; 1509 int cost = 0;
...@@ -1541,6 +1540,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1541,6 +1540,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1541 labels.add(LabelResourceId.labelResourceId(((Integer) linkOrLabel).longValue())); 1540 labels.add(LabelResourceId.labelResourceId(((Integer) linkOrLabel).longValue()));
1542 } 1541 }
1543 } 1542 }
1543 + if (links.isEmpty()) {
1544 + return;
1545 + }
1544 Path path = new DefaultPath(providerId, links, cost, EMPTY); 1546 Path path = new DefaultPath(providerId, links, cost, EMPTY);
1545 NetworkResource labelStack = new DefaultLabelStack(labels); 1547 NetworkResource labelStack = new DefaultLabelStack(labels);
1546 // To carry PST TLV, SRP object can be present with value 0 even when PCRpt is not in response to any action 1548 // To carry PST TLV, SRP object can be present with value 0 even when PCRpt is not in response to any action
...@@ -1579,7 +1581,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1579,7 +1581,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1579 IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint 1581 IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint
1580 .ipTunnelPoint(IpAddress.valueOf(ipv4LspIdenTlv.getIpv4EgressAddress())); 1582 .ipTunnelPoint(IpAddress.valueOf(ipv4LspIdenTlv.getIpv4EgressAddress()));
1581 Collection<Tunnel> tunnelQueryResult = tunnelService.queryTunnel(tunnelEndPointSrc, tunnelEndPointDst); 1583 Collection<Tunnel> tunnelQueryResult = tunnelService.queryTunnel(tunnelEndPointSrc, tunnelEndPointDst);
1582 -
1583 // Store delegation flag info and that LSP info because only delegated PCE sends update message 1584 // Store delegation flag info and that LSP info because only delegated PCE sends update message
1584 // Storing if D flag is set, if not dont store. while checking whether delegation if annotation for D flag 1585 // Storing if D flag is set, if not dont store. while checking whether delegation if annotation for D flag
1585 // not present then non-delegated , if present it is delegated. 1586 // not present then non-delegated , if present it is delegated.
...@@ -1623,7 +1624,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1623,7 +1624,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1623 */ 1624 */
1624 return; 1625 return;
1625 } 1626 }
1626 -
1627 DeviceId deviceId = getDevice(pccId); 1627 DeviceId deviceId = getDevice(pccId);
1628 if (deviceId == null) { 1628 if (deviceId == null) {
1629 log.error("Ingress deviceId not found"); 1629 log.error("Ingress deviceId not found");
...@@ -1640,7 +1640,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1640,7 +1640,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1640 log.error("Received PCC initiated LSP while not in sync."); 1640 log.error("Received PCC initiated LSP while not in sync.");
1641 return; 1641 return;
1642 } 1642 }
1643 -
1644 /* 1643 /*
1645 * If ONOS instance is master for PCC then set delegated flag as annotation and add the tunnel to store. 1644 * If ONOS instance is master for PCC then set delegated flag as annotation and add the tunnel to store.
1646 * Because all LSPs need not be delegated, hence mastership for the PCC is confirmed whereas not the 1645 * Because all LSPs need not be delegated, hence mastership for the PCC is confirmed whereas not the
...@@ -1735,7 +1734,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1735,7 +1734,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1735 LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects(); 1734 LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects();
1736 if (0 == llSubObj.size()) { 1735 if (0 == llSubObj.size()) {
1737 log.error("ERO in report message does not have hop information"); 1736 log.error("ERO in report message does not have hop information");
1738 - return null; 1737 + return new ArrayList<>();
1739 } 1738 }
1740 ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator(); 1739 ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator();
1741 1740
...@@ -1789,10 +1788,29 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1789,10 +1788,29 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1789 1788
1790 if (srEroSubObj.getSt() == PcepNaiIpv4Adjacency.ST_TYPE) { 1789 if (srEroSubObj.getSt() == PcepNaiIpv4Adjacency.ST_TYPE) {
1791 PcepNaiIpv4Adjacency nai = (PcepNaiIpv4Adjacency) (srEroSubObj.getNai()); 1790 PcepNaiIpv4Adjacency nai = (PcepNaiIpv4Adjacency) (srEroSubObj.getNai());
1792 - IpAddress srcIp = IpAddress.valueOf(nai.getLocalIpv4Addr()); 1791 + int srcIp = nai.getLocalIpv4Addr();
1793 - src = new ConnectPoint(IpElementId.ipElement(srcIp), PortNumber.portNumber(0)); 1792 + int dstIp = nai.getRemoteIpv4Addr();
1794 - IpAddress dstIp = IpAddress.valueOf(nai.getRemoteIpv4Addr()); 1793 + Iterable<Link> links = linkService.getActiveLinks();
1795 - dst = new ConnectPoint(IpElementId.ipElement(dstIp), PortNumber.portNumber(0)); 1794 + for (Link l : links) {
1795 + long lSrc = l.src().port().toLong();
1796 + long lDst = l.dst().port().toLong();
1797 + if (lSrc == srcIp) {
1798 + src = l.src();
1799 + } else if (lDst == srcIp) {
1800 + src = l.dst();
1801 + }
1802 + if (lSrc == dstIp) {
1803 + dst = l.src();
1804 + } else if (lDst == dstIp) {
1805 + dst = l.dst();
1806 + }
1807 + if (src != null && dst != null) {
1808 + break;
1809 + }
1810 + }
1811 + if (src == null || dst == null) {
1812 + return new ArrayList<>();
1813 + }
1796 Link link = DefaultLink.builder() 1814 Link link = DefaultLink.builder()
1797 .providerId(providerId) 1815 .providerId(providerId)
1798 .src(src) 1816 .src(src)
......