Avantika-Huawei

[ONOS-4170] LSP-DB sync

Change-Id: Icda3afd9cca8d1fb8c58b44da6bc26064b300388
Showing 27 changed files with 931 additions and 439 deletions
...@@ -30,6 +30,9 @@ import java.util.concurrent.Executors; ...@@ -30,6 +30,9 @@ import java.util.concurrent.Executors;
30 import java.util.concurrent.ScheduledExecutorService; 30 import java.util.concurrent.ScheduledExecutorService;
31 import java.util.concurrent.TimeUnit; 31 import java.util.concurrent.TimeUnit;
32 32
33 +import org.onlab.packet.Ethernet;
34 +import org.onlab.packet.IPv4;
35 +
33 import org.apache.felix.scr.annotations.Activate; 36 import org.apache.felix.scr.annotations.Activate;
34 import org.apache.felix.scr.annotations.Component; 37 import org.apache.felix.scr.annotations.Component;
35 import org.apache.felix.scr.annotations.Deactivate; 38 import org.apache.felix.scr.annotations.Deactivate;
...@@ -38,6 +41,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; ...@@ -38,6 +41,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality;
38 import org.apache.felix.scr.annotations.Service; 41 import org.apache.felix.scr.annotations.Service;
39 import org.onlab.packet.IpAddress; 42 import org.onlab.packet.IpAddress;
40 import org.onlab.packet.IpPrefix; 43 import org.onlab.packet.IpPrefix;
44 +import org.onlab.packet.TCP;
41 import org.onlab.util.Bandwidth; 45 import org.onlab.util.Bandwidth;
42 import org.onosproject.core.ApplicationId; 46 import org.onosproject.core.ApplicationId;
43 import org.onosproject.core.CoreService; 47 import org.onosproject.core.CoreService;
...@@ -139,6 +143,7 @@ public class PceManager implements PceService { ...@@ -139,6 +143,7 @@ public class PceManager implements PceService {
139 private static final String TRUE = "true"; 143 private static final String TRUE = "true";
140 private static final String FALSE = "false"; 144 private static final String FALSE = "false";
141 private static final String END_OF_SYNC_IP_PREFIX = "0.0.0.0/32"; 145 private static final String END_OF_SYNC_IP_PREFIX = "0.0.0.0/32";
146 + public static final int PCEP_PORT = 4189;
142 147
143 private IdGenerator localLspIdIdGen; 148 private IdGenerator localLspIdIdGen;
144 protected DistributedSet<Short> localLspIdFreeList; 149 protected DistributedSet<Short> localLspIdFreeList;
...@@ -635,7 +640,7 @@ public class PceManager implements PceService { ...@@ -635,7 +640,7 @@ public class PceManager implements PceService {
635 LinkEvent linkEvent = (LinkEvent) e; 640 LinkEvent linkEvent = (LinkEvent) e;
636 if (linkEvent.type() == LinkEvent.Type.LINK_REMOVED) { 641 if (linkEvent.type() == LinkEvent.Type.LINK_REMOVED) {
637 tunnelService.queryTunnel(MPLS).forEach(t -> { 642 tunnelService.queryTunnel(MPLS).forEach(t -> {
638 - if (t.path().links().contains(((Link) e.subject()))) { 643 + if (t.path().links().contains((e.subject()))) {
639 // Check whether this ONOS instance is master for ingress device if yes, 644 // Check whether this ONOS instance is master for ingress device if yes,
640 // recompute and send update 645 // recompute and send update
641 checkForMasterAndUpdateTunnel(t.path().src().deviceId(), t); 646 checkForMasterAndUpdateTunnel(t.path().src().deviceId(), t);
...@@ -949,12 +954,30 @@ public class PceManager implements PceService { ...@@ -949,12 +954,30 @@ public class PceManager implements PceService {
949 public void process(PacketContext context) { 954 public void process(PacketContext context) {
950 // Stop processing if the packet has been handled, since we 955 // Stop processing if the packet has been handled, since we
951 // can't do any more to it. 956 // can't do any more to it.
952 -
953 if (context.isHandled()) { 957 if (context.isHandled()) {
954 return; 958 return;
955 } 959 }
956 960
957 InboundPacket pkt = context.inPacket(); 961 InboundPacket pkt = context.inPacket();
962 + if (pkt == null) {
963 + return;
964 + }
965 +
966 + Ethernet ethernet = pkt.parsed();
967 + if (ethernet == null || ethernet.getEtherType() != Ethernet.TYPE_IPV4) {
968 + return;
969 + }
970 +
971 + IPv4 ipPacket = (IPv4) ethernet.getPayload();
972 + if (ipPacket == null || ipPacket.getProtocol() != IPv4.PROTOCOL_TCP) {
973 + return;
974 + }
975 +
976 + TCP tcp = (TCP) ipPacket.getPayload();
977 + if (tcp == null || tcp.getDestinationPort() != PCEP_PORT) {
978 + return;
979 + }
980 +
958 syncLabelDb(pkt.receivedFrom().deviceId()); 981 syncLabelDb(pkt.receivedFrom().deviceId());
959 } 982 }
960 } 983 }
......
...@@ -26,7 +26,6 @@ import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED; ...@@ -26,7 +26,6 @@ import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED;
26 import static org.onosproject.net.MastershipRole.MASTER; 26 import static org.onosproject.net.MastershipRole.MASTER;
27 27
28 import java.net.URISyntaxException; 28 import java.net.URISyntaxException;
29 -import java.nio.ByteBuffer;
30 import java.util.Collection; 29 import java.util.Collection;
31 import java.util.Collections; 30 import java.util.Collections;
32 import java.util.HashMap; 31 import java.util.HashMap;
...@@ -44,6 +43,7 @@ import org.onlab.junit.TestUtils; ...@@ -44,6 +43,7 @@ import org.onlab.junit.TestUtils;
44 import org.onlab.junit.TestUtils.TestUtilsException; 43 import org.onlab.junit.TestUtils.TestUtilsException;
45 import org.onlab.packet.Ethernet; 44 import org.onlab.packet.Ethernet;
46 import org.onlab.packet.IPv4; 45 import org.onlab.packet.IPv4;
46 +import org.onlab.packet.TCP;
47 import org.onlab.util.Bandwidth; 47 import org.onlab.util.Bandwidth;
48 import org.onosproject.common.DefaultTopologyGraph; 48 import org.onosproject.common.DefaultTopologyGraph;
49 import org.onosproject.core.ApplicationId; 49 import org.onosproject.core.ApplicationId;
...@@ -112,6 +112,7 @@ import org.onosproject.pce.util.FlowObjServiceAdapter; ...@@ -112,6 +112,7 @@ import org.onosproject.pce.util.FlowObjServiceAdapter;
112 import org.onosproject.store.service.TestStorageService; 112 import org.onosproject.store.service.TestStorageService;
113 113
114 import com.google.common.collect.ImmutableSet; 114 import com.google.common.collect.ImmutableSet;
115 +import static org.onosproject.pce.pceservice.PceManager.PCEP_PORT;
115 116
116 /** 117 /**
117 * Tests the functions of PceManager. 118 * Tests the functions of PceManager.
...@@ -675,21 +676,18 @@ public class PceManagerTest { ...@@ -675,21 +676,18 @@ public class PceManagerTest {
675 * Tests packet in to trigger label DB sync. 676 * Tests packet in to trigger label DB sync.
676 */ 677 */
677 @Test 678 @Test
678 - public void packetProcessingTest() throws URISyntaxException { 679 + public void packetProcessingTest1() throws URISyntaxException {
679 680
680 build4RouterTopo(false, true, true, true, 0); // This also initializes devices etc. 681 build4RouterTopo(false, true, true, true, 0); // This also initializes devices etc.
681 682
682 - final int srcHost = 2;
683 - final int dstHost = 5;
684 -
685 LabelResourceId node1Label = LabelResourceId.labelResourceId(5200); 683 LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
686 LabelResourceId node2Label = LabelResourceId.labelResourceId(5201); 684 LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
687 685
688 pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label); 686 pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
689 pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label); 687 pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
690 688
691 - ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(srcHost)); 689 + ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(1));
692 - ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(dstHost)); 690 + ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(2));
693 691
694 Link link1 = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT) 692 Link link1 = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT)
695 .providerId(new ProviderId("eth", "1")).build(); 693 .providerId(new ProviderId("eth", "1")).build();
...@@ -697,24 +695,66 @@ public class PceManagerTest { ...@@ -697,24 +695,66 @@ public class PceManagerTest {
697 LabelResourceId link1Label = LabelResourceId.labelResourceId(5204); 695 LabelResourceId link1Label = LabelResourceId.labelResourceId(5204);
698 pceManager.pceStore.addAdjLabel(link1, link1Label); 696 pceManager.pceStore.addAdjLabel(link1, link1Label);
699 697
700 - Ethernet eth; 698 + TCP tcp = new TCP();
701 - IPv4 ipv4; 699 + tcp.setDestinationPort(PCEP_PORT);
700 +
701 + IPv4 ipv4 = new IPv4();
702 + ipv4.setProtocol(IPv4.PROTOCOL_TCP);
703 + ipv4.setPayload(tcp);
702 704
703 - ipv4 = new IPv4(); 705 + Ethernet eth = new Ethernet();
704 - eth = new Ethernet();
705 eth.setEtherType(Ethernet.TYPE_IPV4); 706 eth.setEtherType(Ethernet.TYPE_IPV4);
706 eth.setPayload(ipv4); 707 eth.setPayload(ipv4);
707 708
708 - eth.setSourceMACAddress("00:00:00:10:00:0" + srcHost).setDestinationMACAddress("00:00:00:10:00:0" + dstHost); 709 + InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(),
709 - 710 + PortNumber.portNumber(PCEP_PORT)),
710 - InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(), PortNumber.portNumber(srcHost)), 711 + eth, null);
711 - eth, ByteBuffer.wrap(eth.serialize()));
712 712
713 pktProcessor.process(new MockPcepPacketContext(inPkt, null)); 713 pktProcessor.process(new MockPcepPacketContext(inPkt, null));
714 assertThat(flowsDownloaded, is(4)); 714 assertThat(flowsDownloaded, is(4));
715 } 715 }
716 716
717 /** 717 /**
718 + * Tests faulty packet in to trigger label DB sync.
719 + */
720 + @Test
721 + public void packetProcessingTest2() throws URISyntaxException {
722 +
723 + build4RouterTopo(false, true, true, true, 0); // This also initializes devices etc.
724 +
725 + LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
726 + LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
727 +
728 + pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
729 + pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
730 +
731 + ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(1));
732 + ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(2));
733 +
734 + Link link1 = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT)
735 + .providerId(new ProviderId("eth", "1")).build();
736 +
737 + LabelResourceId link1Label = LabelResourceId.labelResourceId(5204);
738 + pceManager.pceStore.addAdjLabel(link1, link1Label);
739 +
740 + TCP tcp = new TCP(); // Not set the pcep port.
741 + IPv4 ipv4 = new IPv4();
742 + ipv4.setProtocol(IPv4.PROTOCOL_TCP);
743 + ipv4.setPayload(tcp);
744 +
745 + Ethernet eth = new Ethernet();
746 + eth.setEtherType(Ethernet.TYPE_IPV4);
747 + eth.setPayload(ipv4);
748 +
749 + InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(),
750 + PortNumber.portNumber(PCEP_PORT)),
751 + eth, null);
752 +
753 + pktProcessor.process(new MockPcepPacketContext(inPkt, null));
754 + assertThat(flowsDownloaded, is(0));
755 + }
756 +
757 + /**
718 * Tests tunnel events added and removed. 758 * Tests tunnel events added and removed.
719 */ 759 */
720 @Test 760 @Test
......
...@@ -2,6 +2,7 @@ COMPILE_DEPS = [ ...@@ -2,6 +2,7 @@ COMPILE_DEPS = [
2 '//lib:CORE_DEPS', 2 '//lib:CORE_DEPS',
3 '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', 3 '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
4 '//apps/pcep-api:onos-apps-pcep-api', 4 '//apps/pcep-api:onos-apps-pcep-api',
5 + '//incubator/api:onos-incubator-api',
5 ] 6 ]
6 7
7 osgi_jar_with_tests ( 8 osgi_jar_with_tests (
......
...@@ -52,5 +52,9 @@ ...@@ -52,5 +52,9 @@
52 <groupId>org.onosproject</groupId> 52 <groupId>org.onosproject</groupId>
53 <artifactId>onlab-misc</artifactId> 53 <artifactId>onlab-misc</artifactId>
54 </dependency> 54 </dependency>
55 + <dependency>
56 + <groupId>org.onosproject</groupId>
57 + <artifactId>onos-incubator-api</artifactId>
58 + </dependency>
55 </dependencies> 59 </dependencies>
56 </project> 60 </project>
......
...@@ -19,6 +19,7 @@ import java.util.List; ...@@ -19,6 +19,7 @@ import java.util.List;
19 19
20 import org.onosproject.pcepio.protocol.PcepFactory; 20 import org.onosproject.pcepio.protocol.PcepFactory;
21 import org.onosproject.pcepio.protocol.PcepMessage; 21 import org.onosproject.pcepio.protocol.PcepMessage;
22 +import org.onosproject.pcepio.protocol.PcepStateReport;
22 23
23 /** 24 /**
24 * Represents to provider facing side of a path computation client(pcc). 25 * Represents to provider facing side of a path computation client(pcc).
...@@ -165,4 +166,34 @@ public interface PcepClient { ...@@ -165,4 +166,34 @@ public interface PcepClient {
165 * @return delegation flag 166 * @return delegation flag
166 */ 167 */
167 Boolean delegationInfo(LspKey lspKey); 168 Boolean delegationInfo(LspKey lspKey);
169 +
170 + /**
171 + * Creates a temporary cache to hold report messages received during LSPDB sync.
172 + *
173 + * @param pccId PCC id which is the key to store report messages
174 + */
175 + void initializeSyncMsgList(PccId pccId);
176 +
177 + /**
178 + * Returns the list of report messages received during LSPDB sync.
179 + *
180 + * @param pccId PCC id which is the key for all the report messages
181 + * @return list of report messages received during LSPDB sync
182 + */
183 + List<PcepStateReport> getSyncMsgList(PccId pccId);
184 +
185 + /**
186 + * Removes the list of report messages received during LSPDB sync.
187 + *
188 + * @param pccId PCC id which is the key for all the report messages
189 + */
190 + void removeSyncMsgList(PccId pccId);
191 +
192 + /**
193 + * Adds report message received during LSPDB sync into temporary cache.
194 + *
195 + * @param pccId PCC id which is the key to store report messages
196 + * @param rptMsg the report message to be stored
197 + */
198 + void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg);
168 } 199 }
......
...@@ -85,6 +85,20 @@ public interface PcepClientController { ...@@ -85,6 +85,20 @@ public interface PcepClientController {
85 void removeNodeListener(PcepNodeListener listener); 85 void removeNodeListener(PcepNodeListener listener);
86 86
87 /** 87 /**
88 + * Register a listener for packet events.
89 + *
90 + * @param listener the listener to notify
91 + */
92 + void addPacketListener(PcepPacketListener listener);
93 +
94 + /**
95 + * Unregister a packet listener.
96 + *
97 + * @param listener the listener to unregister
98 + */
99 + void removePacketListener(PcepPacketListener listener);
100 +
101 + /**
88 * Send a message to a particular pcc client. 102 * Send a message to a particular pcc client.
89 * 103 *
90 * @param pccId the id of the client to send message. 104 * @param pccId the id of the client to send message.
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.pcep.controller; 16 package org.onosproject.pcep.controller;
17 17
18 +import org.onosproject.incubator.net.tunnel.Tunnel;
18 import org.onosproject.pcepio.protocol.PcepMessage; 19 import org.onosproject.pcepio.protocol.PcepMessage;
19 /** 20 /**
20 * Notifies providers about PCEP message events. 21 * Notifies providers about PCEP message events.
...@@ -28,4 +29,21 @@ public interface PcepEventListener { ...@@ -28,4 +29,21 @@ public interface PcepEventListener {
28 * @param msg the message 29 * @param msg the message
29 */ 30 */
30 void handleMessage(PccId pccId, PcepMessage msg); 31 void handleMessage(PccId pccId, PcepMessage msg);
32 +
33 + /**
34 + * Handles end of LSPDB sync actions.
35 + *
36 + * @param tunnel the tunnel on which action needs to be taken
37 + * @param endOfSyncAction the action that needs to be taken for the tunnel
38 + */
39 + void handleEndOfSyncAction(Tunnel tunnel, PcepLspSyncAction endOfSyncAction);
40 +
41 + /**
42 + * Handles sending PCEP message to client on end of LSPDB sync.
43 + *
44 + * @param pccId id of the pcc
45 + * @param msg the message to be sent
46 + * @param endOfSyncAction the action that needs to be taken in the message
47 + */
48 + void handleEndOfSyncAction(PccId pccId, PcepMessage msg, PcepLspSyncAction endOfSyncAction);
31 } 49 }
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.pcep.controller;
17 +
18 +/**
19 + * Representation of actions to be taken for LSPs on end of LSP-DB sync.
20 + */
21 +public enum PcepLspSyncAction {
22 +
23 + /**
24 + * Specifies that delete message for PCE intiiated tunnel should be sent.
25 + */
26 + SEND_DELETE(0),
27 +
28 + /**
29 + * Specifies that update message should be sent.
30 + */
31 + SEND_UPDATE(1),
32 +
33 + /**
34 + * Specifies that the tunnel should be removed from PCE.
35 + */
36 + REMOVE(2),
37 +
38 + /**
39 + * Specifies that the status of the tunnel should be set as unstable.
40 + */
41 + UNSTABLE(3);
42 +
43 + int value;
44 +
45 + /**
46 + * Assigns val with the value for actions to be taken for LSPs on end of LSP-DB sync.
47 + *
48 + * @param val sync status
49 + */
50 + PcepLspSyncAction(int val) {
51 + value = val;
52 + }
53 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.pcep.controller;
17 +
18 +public interface PcepPacketListener {
19 +
20 + void sendPacketIn(PccId pccId);
21 +
22 +}
...@@ -73,4 +73,12 @@ public interface PcepAgent { ...@@ -73,4 +73,12 @@ public interface PcepAgent {
73 * @param pccId PCEP client ID 73 * @param pccId PCEP client ID
74 */ 74 */
75 void deleteNode(PccId pccId); 75 void deleteNode(PccId pccId);
76 +
77 + /**
78 + * Analyzes report messages received during LSP DB sync again tunnel store and takes necessary actions.
79 + *
80 + * @param pccId the id of pcc client
81 + * @return success or failure
82 + */
83 + boolean analyzeSyncMsgList(PccId pccId);
76 } 84 }
......
...@@ -2,6 +2,7 @@ COMPILE_DEPS = [ ...@@ -2,6 +2,7 @@ COMPILE_DEPS = [
2 '//lib:CORE_DEPS', 2 '//lib:CORE_DEPS',
3 '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', 3 '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
4 '//protocols/pcep/api:onos-protocols-pcep-api', 4 '//protocols/pcep/api:onos-protocols-pcep-api',
5 + '//incubator/api:onos-incubator-api',
5 ] 6 ]
6 7
7 osgi_jar_with_tests ( 8 osgi_jar_with_tests (
......
...@@ -15,10 +15,16 @@ ...@@ -15,10 +15,16 @@
15 */ 15 */
16 package org.onosproject.pcep.controller.impl; 16 package org.onosproject.pcep.controller.impl;
17 17
18 +import java.util.Arrays;
18 import java.util.Collection; 19 import java.util.Collection;
19 import java.util.Collections; 20 import java.util.Collections;
21 +import java.util.HashMap;
20 import java.util.HashSet; 22 import java.util.HashSet;
23 +import java.util.Iterator;
21 import java.util.LinkedList; 24 import java.util.LinkedList;
25 +import java.util.List;
26 +import java.util.ListIterator;
27 +import java.util.Map;
22 import java.util.Set; 28 import java.util.Set;
23 import java.util.concurrent.ConcurrentHashMap; 29 import java.util.concurrent.ConcurrentHashMap;
24 30
...@@ -28,25 +34,47 @@ import org.apache.felix.scr.annotations.Deactivate; ...@@ -28,25 +34,47 @@ import org.apache.felix.scr.annotations.Deactivate;
28 import org.apache.felix.scr.annotations.Reference; 34 import org.apache.felix.scr.annotations.Reference;
29 import org.apache.felix.scr.annotations.ReferenceCardinality; 35 import org.apache.felix.scr.annotations.ReferenceCardinality;
30 import org.apache.felix.scr.annotations.Service; 36 import org.apache.felix.scr.annotations.Service;
37 +import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
38 +import org.onosproject.incubator.net.tunnel.Tunnel;
39 +import org.onosproject.incubator.net.tunnel.TunnelService;
40 +import org.onosproject.incubator.net.tunnel.Tunnel.State;
31 import org.onosproject.net.device.DeviceService; 41 import org.onosproject.net.device.DeviceService;
42 +import org.onosproject.pcep.controller.LspKey;
32 import org.onosproject.pcep.controller.PccId; 43 import org.onosproject.pcep.controller.PccId;
33 import org.onosproject.pcep.controller.PcepClient; 44 import org.onosproject.pcep.controller.PcepClient;
34 import org.onosproject.pcep.controller.PcepClientController; 45 import org.onosproject.pcep.controller.PcepClientController;
35 import org.onosproject.pcep.controller.PcepClientListener; 46 import org.onosproject.pcep.controller.PcepClientListener;
36 import org.onosproject.pcep.controller.PcepEventListener; 47 import org.onosproject.pcep.controller.PcepEventListener;
37 import org.onosproject.pcep.controller.PcepNodeListener; 48 import org.onosproject.pcep.controller.PcepNodeListener;
49 +import org.onosproject.pcep.controller.PcepPacketListener;
50 +import org.onosproject.pcep.controller.PcepSyncStatus;
38 import org.onosproject.pcep.controller.driver.PcepAgent; 51 import org.onosproject.pcep.controller.driver.PcepAgent;
52 +import org.onosproject.pcepio.exceptions.PcepParseException;
53 +import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
39 import org.onosproject.pcepio.protocol.PcepError; 54 import org.onosproject.pcepio.protocol.PcepError;
40 import org.onosproject.pcepio.protocol.PcepErrorInfo; 55 import org.onosproject.pcepio.protocol.PcepErrorInfo;
41 import org.onosproject.pcepio.protocol.PcepErrorMsg; 56 import org.onosproject.pcepio.protocol.PcepErrorMsg;
42 import org.onosproject.pcepio.protocol.PcepErrorObject; 57 import org.onosproject.pcepio.protocol.PcepErrorObject;
43 import org.onosproject.pcepio.protocol.PcepFactory; 58 import org.onosproject.pcepio.protocol.PcepFactory;
59 +import org.onosproject.pcepio.protocol.PcepInitiateMsg;
60 +import org.onosproject.pcepio.protocol.PcepLspObject;
44 import org.onosproject.pcepio.protocol.PcepMessage; 61 import org.onosproject.pcepio.protocol.PcepMessage;
62 +import org.onosproject.pcepio.protocol.PcepReportMsg;
63 +import org.onosproject.pcepio.protocol.PcepStateReport;
64 +import org.onosproject.pcepio.types.PcepValueType;
65 +import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
66 +import org.onosproject.pcepio.types.SymbolicPathNameTlv;
45 import org.slf4j.Logger; 67 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory; 68 import org.slf4j.LoggerFactory;
47 69
48 import com.google.common.collect.Sets; 70 import com.google.common.collect.Sets;
71 +import static com.google.common.base.Preconditions.checkNotNull;
49 72
73 +import static org.onosproject.pcep.controller.PcepSyncStatus.IN_SYNC;
74 +import static org.onosproject.pcep.controller.PcepLspSyncAction.REMOVE;
75 +import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_UPDATE;
76 +import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_DELETE;
77 +import static org.onosproject.pcep.controller.PcepLspSyncAction.UNSTABLE;
50 import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19; 78 import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19;
51 import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5; 79 import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5;
52 80
...@@ -70,9 +98,22 @@ public class PcepClientControllerImpl implements PcepClientController { ...@@ -70,9 +98,22 @@ public class PcepClientControllerImpl implements PcepClientController {
70 98
71 protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet(); 99 protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet();
72 protected Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet(); 100 protected Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet();
101 + protected Set<PcepPacketListener> pcepPacketListener = Sets.newHashSet();
73 102
74 private final Controller ctrl = new Controller(); 103 private final Controller ctrl = new Controller();
75 104
105 + public static final String BANDWIDTH = "bandwidth";
106 + public static final String LSP_SIG_TYPE = "lspSigType";
107 + public static final String PCC_TUNNEL_ID = "PccTunnelId";
108 + public static final String PLSP_ID = "PLspId";
109 + public static final String LOCAL_LSP_ID = "localLspId";
110 + public static final String PCE_INIT = "pceInit";
111 + public static final String COST_TYPE = "costType";
112 + public static final String DELEGATE = "delegation";
113 +
114 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
115 + protected TunnelService tunnelService;
116 +
76 @Activate 117 @Activate
77 public void activate() { 118 public void activate() {
78 ctrl.start(agent); 119 ctrl.start(agent);
...@@ -120,6 +161,16 @@ public class PcepClientControllerImpl implements PcepClientController { ...@@ -120,6 +161,16 @@ public class PcepClientControllerImpl implements PcepClientController {
120 } 161 }
121 162
122 @Override 163 @Override
164 + public void addPacketListener(PcepPacketListener listener) {
165 + pcepPacketListener.add(listener);
166 + }
167 +
168 + @Override
169 + public void removePacketListener(PcepPacketListener listener) {
170 + pcepPacketListener.remove(listener);
171 + }
172 +
173 + @Override
123 public void writeMessage(PccId pccId, PcepMessage msg) { 174 public void writeMessage(PccId pccId, PcepMessage msg) {
124 this.getClient(pccId).sendMessage(msg); 175 this.getClient(pccId).sendMessage(msg);
125 } 176 }
...@@ -180,8 +231,48 @@ public class PcepClientControllerImpl implements PcepClientController { ...@@ -180,8 +231,48 @@ public class PcepClientControllerImpl implements PcepClientController {
180 case REPORT: 231 case REPORT:
181 //Only update the listener if respective capability is supported else send PCEP-ERR msg 232 //Only update the listener if respective capability is supported else send PCEP-ERR msg
182 if (pc.capability().statefulPceCapability()) { 233 if (pc.capability().statefulPceCapability()) {
183 - for (PcepEventListener l : pcepEventListener) { 234 +
184 - l.handleMessage(pccId, msg); 235 + ListIterator<PcepStateReport> listIterator = ((PcepReportMsg) msg).getStateReportList().listIterator();
236 + while (listIterator.hasNext()) {
237 + PcepStateReport stateRpt = listIterator.next();
238 + if (stateRpt.getLspObject().getSFlag()) {
239 + if (pc.lspDbSyncStatus() != PcepSyncStatus.IN_SYNC) {
240 + // Initialize LSP DB sync and temporary cache.
241 + pc.setLspDbSyncStatus(PcepSyncStatus.IN_SYNC);
242 + pc.initializeSyncMsgList(pccId);
243 + }
244 + // Store stateRpt in temporary cache.
245 + pc.addSyncMsgToList(pccId, stateRpt);
246 +
247 + // Don't send to provider as of now.
248 + continue;
249 + } else {
250 + if (pc.lspDbSyncStatus() == PcepSyncStatus.IN_SYNC) {
251 + // Set end of LSPDB sync.
252 + pc.setLspDbSyncStatus(PcepSyncStatus.SYNCED);
253 +
254 + // Call packet provider to initiate label DB sync (only if PCECC capable).
255 + if (pc.capability().pceccCapability()) {
256 + pc.setLabelDbSyncStatus(IN_SYNC);
257 + for (PcepPacketListener l : pcepPacketListener) {
258 + l.sendPacketIn(pccId);
259 + }
260 + } else {
261 + // If label db sync is not to be done, handle end of LSPDB sync actions.
262 + agent.analyzeSyncMsgList(pccId);
263 + }
264 + continue;
265 + }
266 + }
267 +
268 + // It's a usual report message while sync is not undergoing. So process it immediately.
269 + LinkedList<PcepStateReport> llPcRptList = new LinkedList<>();
270 + llPcRptList.add(stateRpt);
271 + PcepMessage pcReportMsg = pc.factory().buildReportMsg().setStateReportList((llPcRptList))
272 + .build();
273 + for (PcepEventListener l : pcepEventListener) {
274 + l.handleMessage(pccId, pcReportMsg);
275 + }
185 } 276 }
186 } else { 277 } else {
187 // Send PCEP-ERROR message. 278 // Send PCEP-ERROR message.
...@@ -304,5 +395,162 @@ public class PcepClientControllerImpl implements PcepClientController { ...@@ -304,5 +395,162 @@ public class PcepClientControllerImpl implements PcepClientController {
304 l.deleteNode(pccId); 395 l.deleteNode(pccId);
305 } 396 }
306 } 397 }
398 +
399 + @SuppressWarnings({ "unchecked", "rawtypes" })
400 + @Override
401 + public boolean analyzeSyncMsgList(PccId pccId) {
402 + PcepClient pc = getClient(pccId);
403 + /*
404 + * PLSP_ID is null while tunnel is created at PCE and PCInit msg carries it as 0. It is allocated by PCC and
405 + * in that case it becomes the first PCRpt msg from PCC for this LSP, and hence symbolic path name must be
406 + * carried in the PCRpt msg. Draft says: The SYMBOLIC-PATH-NAME TLV "MUST" be included in the LSP object in
407 + * the LSP State Report (PCRpt) message when during a given PCEP session an LSP is "first" reported to a
408 + * PCE. So two separate lists with separate keys are maintained.
409 + */
410 + Map<LspKey, Tunnel> preSyncLspDbByKey = new HashMap<>();
411 + Map<String, Tunnel> preSyncLspDbByName = new HashMap<>();
412 +
413 + // Query tunnel service and fetch all the tunnels with this PCC as ingress.
414 + // Organize into two maps, with LSP key if known otherwise with symbolic path name, for quick search.
415 + Collection<Tunnel> queriedTunnels = tunnelService.queryTunnel(Tunnel.Type.MPLS);
416 + for (Tunnel tunnel : queriedTunnels) {
417 + if (((IpTunnelEndPoint) tunnel.src()).ip().equals(pccId.ipAddress())) {
418 + String pLspId = tunnel.annotations().value(PLSP_ID);
419 + if (pLspId != null) {
420 + String localLspId = tunnel.annotations().value(LOCAL_LSP_ID);
421 + checkNotNull(localLspId);
422 + LspKey lspKey = new LspKey(Integer.valueOf(pLspId), Short.valueOf(localLspId));
423 + preSyncLspDbByKey.put(lspKey, tunnel);
424 + } else {
425 + preSyncLspDbByName.put(tunnel.tunnelName().value(), tunnel);
426 + }
427 + }
428 + }
429 +
430 + List<PcepStateReport> syncStateRptList = pc.getSyncMsgList(pccId);
431 + Iterator<PcepStateReport> stateRptListIterator = syncStateRptList.iterator();
432 +
433 + // For every report, fetch PLSP id, local LSP id and symbolic path name from the message.
434 + while (syncStateRptList.iterator().hasNext()) {
435 + PcepStateReport stateRpt = stateRptListIterator.next();
436 + Tunnel tunnel = null;
437 +
438 + PcepLspObject lspObj = stateRpt.getLspObject();
439 + ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator();
440 + StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv = null;
441 + SymbolicPathNameTlv pathNameTlv = null;
442 +
443 + while (listTlvIterator.hasNext()) {
444 + PcepValueType tlv = listTlvIterator.next();
445 + switch (tlv.getType()) {
446 + case StatefulIPv4LspIdentifiersTlv.TYPE:
447 + ipv4LspIdenTlv = (StatefulIPv4LspIdentifiersTlv) tlv;
448 + break;
449 +
450 + case SymbolicPathNameTlv.TYPE:
451 + pathNameTlv = (SymbolicPathNameTlv) tlv;
452 + break;
453 +
454 + default:
455 + break;
456 + }
457 + }
458 +
459 + LspKey lspKeyOfRpt = new LspKey(lspObj.getPlspId(), ipv4LspIdenTlv.getLspId());
460 + tunnel = preSyncLspDbByKey.get(lspKeyOfRpt);
461 + // PCE tunnel is matched with PCRpt LSP. Now delete it from the preSyncLspDb list as the residual
462 + // non-matching list will be processed at the end.
463 + if (tunnel != null) {
464 + preSyncLspDbByKey.remove(lspKeyOfRpt);
465 + } else if (pathNameTlv != null) {
466 + tunnel = preSyncLspDbByName.get(Arrays.toString(pathNameTlv.getValue()));
467 + if (tunnel != null) {
468 + preSyncLspDbByName.remove(tunnel.tunnelName());
469 + }
470 + }
471 +
472 + if (tunnel == null) {
473 + // If remove flag is set, and tunnel is not known to PCE, ignore it.
474 + if (lspObj.getCFlag() && !lspObj.getRFlag()) {
475 + // For initiated LSP, need to send PCInit delete msg.
476 + try {
477 + PcInitiatedLspRequest releaseLspRequest = pc.factory().buildPcInitiatedLspRequest()
478 + .setLspObject(lspObj).build();
479 + LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList
480 + = new LinkedList<PcInitiatedLspRequest>();
481 + llPcInitiatedLspRequestList.add(releaseLspRequest);
482 +
483 + PcepInitiateMsg pcInitiateMsg = pc.factory().buildPcepInitiateMsg()
484 + .setPcInitiatedLspRequestList(llPcInitiatedLspRequestList).build();
485 +
486 + for (PcepEventListener l : pcepEventListener) {
487 + l.handleEndOfSyncAction(pccId, pcInitiateMsg, SEND_DELETE);
488 + }
489 +
490 + } catch (PcepParseException e) {
491 + log.error("Exception occured while sending initiate delete message {}", e.getMessage());
492 + }
493 + }
494 + continue;
495 + }
496 +
497 + if (!lspObj.getCFlag()) {
498 + // For learned LSP process both add/update PCRpt.
499 + LinkedList<PcepStateReport> llPcRptList = new LinkedList<>();
500 + llPcRptList.add(stateRpt);
501 + PcepMessage pcReportMsg = pc.factory().buildReportMsg().setStateReportList((llPcRptList))
502 + .build();
503 +
504 + for (PcepEventListener l : pcepEventListener) {
505 + l.handleMessage(pccId, pcReportMsg);
506 + }
507 + continue;
508 + }
509 +
510 + // Implied that tunnel != null and lspObj.getCFlag() is set
511 + // State different for PCC sent LSP and PCE known LSP, send PCUpd msg.
512 + State tunnelState = PcepLspStatus
513 + .getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]);
514 + if (tunnelState != tunnel.state()) {
515 + for (PcepEventListener l : pcepEventListener) {
516 + l.handleEndOfSyncAction(tunnel, SEND_UPDATE);
517 + }
518 + }
519 + }
520 +
521 + // Check which tunnels are extra at PCE that were not reported by PCC.
522 + Map<Object, Tunnel> preSyncLspDb = (Map) preSyncLspDbByKey;
523 + handleResidualTunnels(preSyncLspDb);
524 + preSyncLspDbByKey = null;
525 +
526 + preSyncLspDb = (Map) preSyncLspDbByName;
527 + handleResidualTunnels(preSyncLspDb);
528 + preSyncLspDbByName = null;
529 + preSyncLspDb = null;
530 +
531 + pc.removeSyncMsgList(pccId);
532 + return true;
533 + }
534 +
535 + /*
536 + * Go through the tunnels which are known by PCE but were not reported by PCC during LSP DB sync and take
537 + * appropriate actions.
538 + */
539 + private void handleResidualTunnels(Map<Object, Tunnel> preSyncLspDb) {
540 + for (Tunnel pceExtraTunnel : preSyncLspDb.values()) {
541 + if (pceExtraTunnel.annotations().value(PCE_INIT) == null
542 + || "false".equalsIgnoreCase(pceExtraTunnel.annotations().value(PCE_INIT))) {
543 + // PCC initiated tunnels should be removed from tunnel store.
544 + for (PcepEventListener l : pcepEventListener) {
545 + l.handleEndOfSyncAction(pceExtraTunnel, REMOVE);
546 + }
547 + } else {
548 + // PCE initiated tunnels should be initiated again.
549 + for (PcepEventListener l : pcepEventListener) {
550 + l.handleEndOfSyncAction(pceExtraTunnel, UNSTABLE);
551 + }
552 + }
553 + }
554 + }
307 } 555 }
308 } 556 }
......
...@@ -19,6 +19,8 @@ package org.onosproject.pcep.controller.impl; ...@@ -19,6 +19,8 @@ package org.onosproject.pcep.controller.impl;
19 import java.net.InetSocketAddress; 19 import java.net.InetSocketAddress;
20 import java.net.SocketAddress; 20 import java.net.SocketAddress;
21 import java.util.Collections; 21 import java.util.Collections;
22 +import java.util.HashMap;
23 +import java.util.LinkedList;
22 import java.util.List; 24 import java.util.List;
23 import java.util.Map; 25 import java.util.Map;
24 import java.util.concurrent.RejectedExecutionException; 26 import java.util.concurrent.RejectedExecutionException;
...@@ -36,6 +38,7 @@ import org.onosproject.pcep.controller.driver.PcepClientDriver; ...@@ -36,6 +38,7 @@ import org.onosproject.pcep.controller.driver.PcepClientDriver;
36 import org.onosproject.pcepio.protocol.PcepFactories; 38 import org.onosproject.pcepio.protocol.PcepFactories;
37 import org.onosproject.pcepio.protocol.PcepFactory; 39 import org.onosproject.pcepio.protocol.PcepFactory;
38 import org.onosproject.pcepio.protocol.PcepMessage; 40 import org.onosproject.pcepio.protocol.PcepMessage;
41 +import org.onosproject.pcepio.protocol.PcepStateReport;
39 import org.onosproject.pcepio.protocol.PcepVersion; 42 import org.onosproject.pcepio.protocol.PcepVersion;
40 import org.slf4j.Logger; 43 import org.slf4j.Logger;
41 import org.slf4j.LoggerFactory; 44 import org.slf4j.LoggerFactory;
...@@ -70,6 +73,7 @@ public class PcepClientImpl implements PcepClientDriver { ...@@ -70,6 +73,7 @@ public class PcepClientImpl implements PcepClientDriver {
70 private byte sessionId; 73 private byte sessionId;
71 private PcepPacketStatsImpl pktStats; 74 private PcepPacketStatsImpl pktStats;
72 private Map<LspKey, Boolean> lspDelegationInfo; 75 private Map<LspKey, Boolean> lspDelegationInfo;
76 + private Map<PccId, List<PcepStateReport>> sycRptCache = new HashMap<>();
73 77
74 @Override 78 @Override
75 public void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats) { 79 public void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats) {
...@@ -192,7 +196,14 @@ public class PcepClientImpl implements PcepClientDriver { ...@@ -192,7 +196,14 @@ public class PcepClientImpl implements PcepClientDriver {
192 196
193 @Override 197 @Override
194 public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) { 198 public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) {
199 +
200 + PcepSyncStatus syncOldStatus = labelDbSyncStatus();
195 this.labelDbSyncStatus = syncStatus; 201 this.labelDbSyncStatus = syncStatus;
202 +
203 + if ((syncOldStatus == PcepSyncStatus.IN_SYNC) && (syncStatus == PcepSyncStatus.SYNCED)) {
204 + // Perform end of LSP DB sync actions.
205 + this.agent.analyzeSyncMsgList(pccId);
206 + }
196 } 207 }
197 208
198 @Override 209 @Override
...@@ -254,6 +265,29 @@ public class PcepClientImpl implements PcepClientDriver { ...@@ -254,6 +265,29 @@ public class PcepClientImpl implements PcepClientDriver {
254 } 265 }
255 266
256 @Override 267 @Override
268 + public void initializeSyncMsgList(PccId pccId) {
269 + List<PcepStateReport> rptMsgList = new LinkedList<>();
270 + sycRptCache.put(pccId, rptMsgList);
271 + }
272 +
273 + @Override
274 + public List<PcepStateReport> getSyncMsgList(PccId pccId) {
275 + return sycRptCache.get(pccId);
276 + }
277 +
278 + @Override
279 + public void removeSyncMsgList(PccId pccId) {
280 + sycRptCache.remove(pccId);
281 + }
282 +
283 + @Override
284 + public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
285 + List<PcepStateReport> rptMsgList = sycRptCache.get(pccId);
286 + rptMsgList.add(rptMsg);
287 + sycRptCache.put(pccId, rptMsgList);
288 + }
289 +
290 + @Override
257 public boolean isOptical() { 291 public boolean isOptical() {
258 return false; 292 return false;
259 } 293 }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.provider.pcep.tunnel.impl; 16 +package org.onosproject.pcep.controller.impl;
17 17
18 import org.onosproject.incubator.net.tunnel.Tunnel.State; 18 import org.onosproject.incubator.net.tunnel.Tunnel.State;
19 19
...@@ -51,6 +51,7 @@ public enum PcepLspStatus { ...@@ -51,6 +51,7 @@ public enum PcepLspStatus {
51 * Returns the applicable PCEP LSP status corresponding to ONOS tunnel state. 51 * Returns the applicable PCEP LSP status corresponding to ONOS tunnel state.
52 * 52 *
53 * @param tunnelState ONOS tunnel state 53 * @param tunnelState ONOS tunnel state
54 + * @return LSP status as per protocol
54 */ 55 */
55 public static PcepLspStatus getLspStatusFromTunnelStatus(State tunnelState) { 56 public static PcepLspStatus getLspStatusFromTunnelStatus(State tunnelState) {
56 57
...@@ -76,6 +77,7 @@ public enum PcepLspStatus { ...@@ -76,6 +77,7 @@ public enum PcepLspStatus {
76 * Returns the applicable ONOS tunnel state corresponding to PCEP LSP status. 77 * Returns the applicable ONOS tunnel state corresponding to PCEP LSP status.
77 * 78 *
78 * @param lspState PCEP LSP status 79 * @param lspState PCEP LSP status
80 + * @return tunnel state
79 */ 81 */
80 public static State getTunnelStatusFromLspStatus(PcepLspStatus lspState) { 82 public static State getTunnelStatusFromLspStatus(PcepLspStatus lspState) {
81 83
......
...@@ -57,6 +57,10 @@ public class PcepMetricObjectVer1 implements PcepMetricObject { ...@@ -57,6 +57,10 @@ public class PcepMetricObjectVer1 implements PcepMetricObject {
57 public static final int BFLAG_RESET = 0; 57 public static final int BFLAG_RESET = 0;
58 public static final byte CFLAG_CHECK = 0x02; 58 public static final byte CFLAG_CHECK = 0x02;
59 59
60 + public static final byte IGP_METRIC = 0x01;
61 + public static final byte TE_METRIC = 0x02;
62 + public static final byte HOP_COUNT_METRIC = 0x03;
63 +
60 static final PcepObjectHeader DEFAULT_METRIC_OBJECT_HEADER = new PcepObjectHeader(METRIC_OBJ_CLASS, 64 static final PcepObjectHeader DEFAULT_METRIC_OBJECT_HEADER = new PcepObjectHeader(METRIC_OBJ_CLASS,
61 METRIC_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, 65 METRIC_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
62 METRIC_OBJ_MINIMUM_LENGTH); 66 METRIC_OBJ_MINIMUM_LENGTH);
......
1 +<!--
2 + ~ Copyright 2016-present Open Networking Laboratory
3 + ~
4 + ~ Licensed under the Apache License, Version 2.0 (the "License");
5 + ~ you may not use this file except in compliance with the License.
6 + ~ You may obtain a copy of the License at
7 + ~
8 + ~ http://www.apache.org/licenses/LICENSE-2.0
9 + ~
10 + ~ Unless required by applicable law or agreed to in writing, software
11 + ~ distributed under the License is distributed on an "AS IS" BASIS,
12 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + ~ See the License for the specific language governing permissions and
14 + ~ limitations under the License.
15 + -->
16 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18 + <modelVersion>4.0.0</modelVersion>
19 + <parent>
20 + <groupId>org.onosproject</groupId>
21 + <artifactId>onos-pcep-providers</artifactId>
22 + <version>1.7.0-SNAPSHOT</version>
23 + <relativePath>../pom.xml</relativePath>
24 + </parent>
25 + <artifactId>onos-pcep-provider-packet</artifactId>
26 + <packaging>bundle</packaging>
27 + <description>PCEP packet provider</description>
28 + <dependencies>
29 + <dependency>
30 + <groupId>org.onosproject</groupId>
31 + <artifactId>onos-pcep-controller-api</artifactId>
32 + </dependency>
33 + </dependencies>
34 +</project>
1 +package org.onosproject.provider.pcep.packet.impl;
2 +
3 +import static org.slf4j.LoggerFactory.getLogger;
4 +
5 +import org.apache.felix.scr.annotations.Activate;
6 +import org.apache.felix.scr.annotations.Component;
7 +import org.apache.felix.scr.annotations.Deactivate;
8 +import org.apache.felix.scr.annotations.Reference;
9 +import org.apache.felix.scr.annotations.ReferenceCardinality;
10 +import org.apache.felix.scr.annotations.Service;
11 +import org.onlab.packet.Ethernet;
12 +import org.onlab.packet.IPv4;
13 +import org.onlab.packet.TCP;
14 +import org.onosproject.net.AnnotationKeys;
15 +import org.onosproject.net.ConnectPoint;
16 +import org.onosproject.net.Device;
17 +import org.onosproject.net.DeviceId;
18 +import org.onosproject.net.PortNumber;
19 +import org.onosproject.net.device.DeviceService;
20 +import org.onosproject.net.packet.DefaultInboundPacket;
21 +import org.onosproject.net.packet.DefaultPacketContext;
22 +import org.onosproject.net.packet.InboundPacket;
23 +import org.onosproject.net.packet.OutboundPacket;
24 +import org.onosproject.net.packet.PacketProvider;
25 +import org.onosproject.net.packet.PacketProviderRegistry;
26 +import org.onosproject.net.packet.PacketProviderService;
27 +import org.onosproject.net.provider.AbstractProvider;
28 +import org.onosproject.net.provider.ProviderId;
29 +import org.onosproject.pcep.controller.PccId;
30 +import org.onosproject.pcep.controller.PcepClientController;
31 +import org.onosproject.pcep.controller.PcepPacketListener;
32 +import org.slf4j.Logger;
33 +
34 +/**
35 + * Provider which uses an PCEP controller to process packets.
36 + */
37 +@Component(immediate = true)
38 +@Service
39 +public class PcepPacketProvider extends AbstractProvider implements PacketProvider {
40 +
41 + private static final Logger log = getLogger(PcepPacketProvider.class);
42 + static final String PROVIDER_ID = "org.onosproject.provider.packet.pcep";
43 +
44 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
45 + protected PacketProviderRegistry packetProviderRegistry;
46 +
47 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
48 + protected PcepClientController pcepClientController;
49 +
50 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
51 + protected DeviceService deviceService;
52 +
53 + PacketProviderService packetProviderService;
54 +
55 + private InnerPacketProvider listener = new InnerPacketProvider();
56 + public static final String LSRID = "lsrId";
57 + public static final int PCEP_PORT = 4189;
58 +
59 + /**
60 + * Creates a Packet provider.
61 + */
62 + public PcepPacketProvider() {
63 + super(new ProviderId("pcep", PROVIDER_ID));
64 + }
65 +
66 + @Activate
67 + public void activate() {
68 + packetProviderService = packetProviderRegistry.register(this);
69 + pcepClientController.addPacketListener(listener);
70 + log.info("Started");
71 + }
72 +
73 + @Deactivate
74 + public void deactivate() {
75 + packetProviderRegistry.unregister(this);
76 + pcepClientController.removePacketListener(listener);
77 + log.info("Stopped");
78 + }
79 +
80 + private class InnerPacketProvider implements PcepPacketListener {
81 + @Override
82 + public void sendPacketIn(PccId pccId) {
83 + TCP tcp = new TCP();
84 + // Set the well known PCEP port. To be used to decide to process/discard the packet while processing.
85 + tcp.setDestinationPort(PCEP_PORT);
86 +
87 + IPv4 ipv4 = new IPv4();
88 + ipv4.setProtocol(IPv4.PROTOCOL_TCP);
89 + ipv4.setPayload(tcp);
90 +
91 + Ethernet eth = new Ethernet();
92 + eth.setEtherType(Ethernet.TYPE_IPV4);
93 + eth.setPayload(ipv4);
94 +
95 + // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
96 + String lsrId = String.valueOf(pccId.ipAddress());
97 + DeviceId pccDeviceId = null;
98 +
99 + // Find PCC deviceID from lsrId stored as annotations
100 + Iterable<Device> devices = deviceService.getAvailableDevices();
101 + for (Device dev : devices) {
102 + if ("L3".equals(dev.annotations().value(AnnotationKeys.TYPE))
103 + && lsrId.equals(dev.annotations().value(LSRID))) {
104 + pccDeviceId = dev.id();
105 + break;
106 + }
107 + }
108 +
109 + if (pccDeviceId == null) {
110 + return;
111 + }
112 +
113 + InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(pccDeviceId,
114 + PortNumber.portNumber(PCEP_PORT)),
115 + eth, null);
116 +
117 + packetProviderService.processPacket(new PcepPacketContext(inPkt, null));
118 + }
119 + }
120 +
121 + // Minimal PacketContext to make core and applications happy.
122 + private final class PcepPacketContext extends DefaultPacketContext {
123 + private PcepPacketContext(InboundPacket inPkt, OutboundPacket outPkt) {
124 + super(System.currentTimeMillis(), inPkt, outPkt, false);
125 + }
126 +
127 + @Override
128 + public void send() {
129 + // We don't send anything out.
130 + return;
131 + }
132 + }
133 +
134 + @Override
135 + public void emit(OutboundPacket packet) {
136 + // Nothing to emit
137 + return;
138 +
139 + }
140 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +/**
17 + *Provider that uses PCEP controller as a means to send packets.
18 + */
19 +package org.onosproject.provider.pcep.packet.impl;
...\ No newline at end of file ...\ No newline at end of file
...@@ -28,5 +28,6 @@ ...@@ -28,5 +28,6 @@
28 <module>topology</module> 28 <module>topology</module>
29 <module>tunnel</module> 29 <module>tunnel</module>
30 <module>app</module> 30 <module>app</module>
31 + <module>packet</module>
31 </modules> 32 </modules>
32 </project> 33 </project>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -31,6 +31,7 @@ import org.onosproject.pcep.controller.PcepSyncStatus; ...@@ -31,6 +31,7 @@ import org.onosproject.pcep.controller.PcepSyncStatus;
31 import org.onosproject.pcepio.protocol.PcepFactories; 31 import org.onosproject.pcepio.protocol.PcepFactories;
32 import org.onosproject.pcepio.protocol.PcepFactory; 32 import org.onosproject.pcepio.protocol.PcepFactory;
33 import org.onosproject.pcepio.protocol.PcepMessage; 33 import org.onosproject.pcepio.protocol.PcepMessage;
34 +import org.onosproject.pcepio.protocol.PcepStateReport;
34 import org.onosproject.pcepio.protocol.PcepVersion; 35 import org.onosproject.pcepio.protocol.PcepVersion;
35 36
36 /** 37 /**
...@@ -161,4 +162,28 @@ public class PcepClientAdapter implements PcepClient { ...@@ -161,4 +162,28 @@ public class PcepClientAdapter implements PcepClient {
161 public Boolean delegationInfo(LspKey lspKey) { 162 public Boolean delegationInfo(LspKey lspKey) {
162 return lspDelegationInfo.get(lspKey); 163 return lspDelegationInfo.get(lspKey);
163 } 164 }
165 +
166 + @Override
167 + public void initializeSyncMsgList(PccId pccId) {
168 + // TODO Auto-generated method stub
169 +
170 + }
171 +
172 + @Override
173 + public List<PcepStateReport> getSyncMsgList(PccId pccId) {
174 + // TODO Auto-generated method stub
175 + return null;
176 + }
177 +
178 + @Override
179 + public void removeSyncMsgList(PccId pccId) {
180 + // TODO Auto-generated method stub
181 +
182 + }
183 +
184 + @Override
185 + public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
186 + // TODO Auto-generated method stub
187 +
188 + }
164 } 189 }
......
...@@ -32,6 +32,7 @@ import org.onosproject.pcep.controller.PcepClientController; ...@@ -32,6 +32,7 @@ import org.onosproject.pcep.controller.PcepClientController;
32 import org.onosproject.pcep.controller.PcepClientListener; 32 import org.onosproject.pcep.controller.PcepClientListener;
33 import org.onosproject.pcep.controller.PcepEventListener; 33 import org.onosproject.pcep.controller.PcepEventListener;
34 import org.onosproject.pcep.controller.PcepNodeListener; 34 import org.onosproject.pcep.controller.PcepNodeListener;
35 +import org.onosproject.pcep.controller.PcepPacketListener;
35 import org.onosproject.pcep.controller.driver.PcepAgent; 36 import org.onosproject.pcep.controller.driver.PcepAgent;
36 import org.onosproject.pcepio.protocol.PcepError; 37 import org.onosproject.pcepio.protocol.PcepError;
37 import org.onosproject.pcepio.protocol.PcepErrorInfo; 38 import org.onosproject.pcepio.protocol.PcepErrorInfo;
...@@ -280,5 +281,23 @@ public class PcepClientControllerAdapter implements PcepClientController { ...@@ -280,5 +281,23 @@ public class PcepClientControllerAdapter implements PcepClientController {
280 l.deleteNode(pccId); 281 l.deleteNode(pccId);
281 } 282 }
282 } 283 }
284 +
285 + @Override
286 + public boolean analyzeSyncMsgList(PccId pccId) {
287 + // TODO Auto-generated method stub
288 + return false;
289 + }
290 + }
291 +
292 + @Override
293 + public void addPacketListener(PcepPacketListener listener) {
294 + // TODO Auto-generated method stub
295 +
296 + }
297 +
298 + @Override
299 + public void removePacketListener(PcepPacketListener listener) {
300 + // TODO Auto-generated method stub
301 +
283 } 302 }
284 } 303 }
......
...@@ -6,6 +6,7 @@ COMPILE_DEPS = [ ...@@ -6,6 +6,7 @@ COMPILE_DEPS = [
6 '//incubator/api:onos-incubator-api', 6 '//incubator/api:onos-incubator-api',
7 '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', 7 '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
8 '//protocols/pcep/api:onos-protocols-pcep-api', 8 '//protocols/pcep/api:onos-protocols-pcep-api',
9 + '//protocols/pcep/ctl:onos-protocols-pcep-ctl',
9 ] 10 ]
10 11
11 TEST_DEPS = [ 12 TEST_DEPS = [
......
...@@ -50,5 +50,10 @@ ...@@ -50,5 +50,10 @@
50 <version>${project.version} </version> 50 <version>${project.version} </version>
51 <scope>test</scope> 51 <scope>test</scope>
52 </dependency> 52 </dependency>
53 + <dependency>
54 + <groupId>org.onosproject</groupId>
55 + <artifactId>onos-pcep-controller-impl</artifactId>
56 + <version>${project.version} </version>
57 + </dependency>
53 </dependencies> 58 </dependencies>
54 </project> 59 </project>
......
...@@ -79,7 +79,8 @@ import org.onosproject.pcep.controller.PcepClient; ...@@ -79,7 +79,8 @@ import org.onosproject.pcep.controller.PcepClient;
79 import org.onosproject.pcep.controller.PcepClientController; 79 import org.onosproject.pcep.controller.PcepClientController;
80 import org.onosproject.pcep.controller.PcepClientListener; 80 import org.onosproject.pcep.controller.PcepClientListener;
81 import org.onosproject.pcep.controller.PcepEventListener; 81 import org.onosproject.pcep.controller.PcepEventListener;
82 -import org.onosproject.pcep.controller.PcepSyncStatus; 82 +import org.onosproject.pcep.controller.PcepLspSyncAction;
83 +import org.onosproject.pcep.controller.impl.PcepLspStatus;
83 import org.onosproject.pcepio.exceptions.PcepParseException; 84 import org.onosproject.pcepio.exceptions.PcepParseException;
84 import org.onosproject.pcepio.protocol.PcInitiatedLspRequest; 85 import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
85 import org.onosproject.pcepio.protocol.PcepAttribute; 86 import org.onosproject.pcepio.protocol.PcepAttribute;
...@@ -89,6 +90,7 @@ import org.onosproject.pcepio.protocol.PcepEroObject; ...@@ -89,6 +90,7 @@ import org.onosproject.pcepio.protocol.PcepEroObject;
89 import org.onosproject.pcepio.protocol.PcepInitiateMsg; 90 import org.onosproject.pcepio.protocol.PcepInitiateMsg;
90 import org.onosproject.pcepio.protocol.PcepLspObject; 91 import org.onosproject.pcepio.protocol.PcepLspObject;
91 import org.onosproject.pcepio.protocol.PcepMessage; 92 import org.onosproject.pcepio.protocol.PcepMessage;
93 +import org.onosproject.pcepio.protocol.PcepMetricObject;
92 import org.onosproject.pcepio.protocol.PcepMsgPath; 94 import org.onosproject.pcepio.protocol.PcepMsgPath;
93 import org.onosproject.pcepio.protocol.PcepReportMsg; 95 import org.onosproject.pcepio.protocol.PcepReportMsg;
94 import org.onosproject.pcepio.protocol.PcepSrpObject; 96 import org.onosproject.pcepio.protocol.PcepSrpObject;
...@@ -113,7 +115,6 @@ import java.util.HashMap; ...@@ -113,7 +115,6 @@ import java.util.HashMap;
113 import java.util.LinkedList; 115 import java.util.LinkedList;
114 import java.util.List; 116 import java.util.List;
115 import java.util.ListIterator; 117 import java.util.ListIterator;
116 -import java.util.Map;
117 import java.util.Optional; 118 import java.util.Optional;
118 import java.util.concurrent.Executors; 119 import java.util.concurrent.Executors;
119 import java.util.concurrent.ScheduledExecutorService; 120 import java.util.concurrent.ScheduledExecutorService;
...@@ -134,15 +135,18 @@ import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LOCAL ...@@ -134,15 +135,18 @@ import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LOCAL
134 import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE; 135 import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
135 import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCC_TUNNEL_ID; 136 import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCC_TUNNEL_ID;
136 import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ID; 137 import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ID;
137 -import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCE_INIT;
138 import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.DELEGATE; 138 import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.DELEGATE;
139 +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.COST_TYPE;
139 import static org.onosproject.provider.pcep.tunnel.impl.RequestType.CREATE; 140 import static org.onosproject.provider.pcep.tunnel.impl.RequestType.CREATE;
140 import static org.onosproject.provider.pcep.tunnel.impl.RequestType.DELETE; 141 import static org.onosproject.provider.pcep.tunnel.impl.RequestType.DELETE;
141 import static org.onosproject.provider.pcep.tunnel.impl.RequestType.LSP_STATE_RPT; 142 import static org.onosproject.provider.pcep.tunnel.impl.RequestType.LSP_STATE_RPT;
142 import static org.onosproject.provider.pcep.tunnel.impl.RequestType.UPDATE; 143 import static org.onosproject.provider.pcep.tunnel.impl.RequestType.UPDATE;
143 -import static org.onosproject.pcep.controller.PcepSyncStatus.IN_SYNC;
144 -import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED;
145 import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; 144 import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
145 +import static org.onosproject.pcep.controller.PcepLspSyncAction.REMOVE;
146 +import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_UPDATE;
147 +import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_DELETE;
148 +import static org.onosproject.pcepio.protocol.ver1.PcepMetricObjectVer1.IGP_METRIC;
149 +import static org.onosproject.pcepio.protocol.ver1.PcepMetricObjectVer1.TE_METRIC;
146 import static org.slf4j.LoggerFactory.getLogger; 150 import static org.slf4j.LoggerFactory.getLogger;
147 151
148 /** 152 /**
...@@ -206,10 +210,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -206,10 +210,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
206 protected PcepTunnelApiMapper pcepTunnelApiMapper = new PcepTunnelApiMapper(); 210 protected PcepTunnelApiMapper pcepTunnelApiMapper = new PcepTunnelApiMapper();
207 private static final int DEFAULT_BANDWIDTH_VALUE = 10; 211 private static final int DEFAULT_BANDWIDTH_VALUE = 10;
208 212
209 - private Map<IpAddress, Map<TunnelId, Tunnel>> preSyncLspDbMap = new HashMap<>();
210 - private Map<IpAddress, List<Tunnel>> syncCompleteDeleteList = new HashMap<>();
211 - private Map<IpAddress, List<Tunnel>> syncCompleteUpdateList = new HashMap<>();
212 -
213 /** 213 /**
214 * Creates a Tunnel provider. 214 * Creates a Tunnel provider.
215 */ 215 */
...@@ -760,7 +760,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -760,7 +760,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
760 path, 760 path,
761 annotations); 761 annotations);
762 return tunnel; 762 return tunnel;
763 -
764 } 763 }
765 764
766 /** 765 /**
...@@ -1177,41 +1176,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1177,41 +1176,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1177 log.debug("SRP ID in handle message " + srpId); 1176 log.debug("SRP ID in handle message " + srpId);
1178 1177
1179 if (!(pcepTunnelApiMapper.checkFromTunnelRequestQueue(srpId))) { 1178 if (!(pcepTunnelApiMapper.checkFromTunnelRequestQueue(srpId))) {
1180 - 1179 + // For PCRpt without matching SRP id.
1181 - // Check the sync status 1180 + handleRptWithoutSrpId(stateRpt, pccId);
1182 - if (lspObj.getSFlag()) {
1183 - if (pcepClientController.getClient(pccId).lspDbSyncStatus() != IN_SYNC) {
1184 - pcepClientController.getClient(pccId).setLspDbSyncStatus(IN_SYNC);
1185 -
1186 - // On starting LSP-DB sync, store LSP DB locally for this PCC.
1187 - Map<TunnelId, Tunnel> preSyncLspDb = new HashMap<>();
1188 - Collection<Tunnel> queriedTunnels = tunnelService.queryTunnel(MPLS);
1189 -
1190 - for (Tunnel tunnel : queriedTunnels) {
1191 - if (((IpTunnelEndPoint) tunnel.src()).ip().equals(pccId.ipAddress())) {
1192 - preSyncLspDb.put(tunnel.tunnelId(), tunnel);
1193 - }
1194 - }
1195 -
1196 - preSyncLspDbMap.put(pccId.ipAddress(), preSyncLspDb);
1197 - syncCompleteDeleteList.put(pccId.ipAddress(), new LinkedList<>());
1198 - syncCompleteUpdateList.put(pccId.ipAddress(), new LinkedList<>());
1199 - }
1200 - handleRptWithoutSrpId(stateRpt, pccId, IN_SYNC);
1201 - continue;
1202 -
1203 - } else if (pcepClientController.getClient(pccId).lspDbSyncStatus() == IN_SYNC) {
1204 - // If sync flag is not set in the msg, and the
1205 - // previous state was "in sync" means this is
1206 - // end of sync message. PCRpt for end of sync
1207 - // does not carry any LSP report.
1208 - pcepClientController.getClient(pccId).setLspDbSyncStatus(SYNCED);
1209 - handleEndOfSyncAction(pccId);
1210 - continue;
1211 - }
1212 -
1213 - // For PCRpt without matching SRP id not during LSPDB sync.
1214 - handleRptWithoutSrpId(stateRpt, pccId, SYNCED);
1215 continue; 1181 continue;
1216 } 1182 }
1217 1183
...@@ -1306,8 +1272,19 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1306,8 +1272,19 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1306 } 1272 }
1307 1273
1308 private SparseAnnotations getAnnotations(PcepLspObject lspObj, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv, 1274 private SparseAnnotations getAnnotations(PcepLspObject lspObj, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv,
1309 - float bandwidth, LspType lspType) { 1275 + float bandwidth, LspType lspType, String costType) {
1310 - SparseAnnotations annotations = DefaultAnnotations.builder() 1276 +
1277 + Builder builder = DefaultAnnotations.builder();
1278 +
1279 + /*
1280 + * [RFC 5440] The absence of the METRIC object MUST be interpreted by the PCE as a path computation request
1281 + * for which no constraints need be applied to any of the metrics.
1282 + */
1283 + if (costType != null) {
1284 + builder.set(COST_TYPE, costType);
1285 + }
1286 +
1287 + SparseAnnotations annotations = builder
1311 .set(BANDWIDTH, (new Float(bandwidth)).toString()).set(LSP_SIG_TYPE, lspType.name()) 1288 .set(BANDWIDTH, (new Float(bandwidth)).toString()).set(LSP_SIG_TYPE, lspType.name())
1312 .set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId())) 1289 .set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId()))
1313 .set(PLSP_ID, String.valueOf(lspObj.getPlspId())) 1290 .set(PLSP_ID, String.valueOf(lspObj.getPlspId()))
...@@ -1340,8 +1317,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1340,8 +1317,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1340 return lspType; 1317 return lspType;
1341 } 1318 }
1342 1319
1343 - private void handleRptWithoutSrpId(PcepStateReport stateRpt, PccId pccId, PcepSyncStatus syncStatus) { 1320 + private void handleRptWithoutSrpId(PcepStateReport stateRpt, PccId pccId) {
1344 ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); 1321 ProviderId providerId = new ProviderId("pcep", PROVIDER_ID);
1322 + String costType = null;
1345 PcepStateReport.PcepMsgPath msgPath = stateRpt.getMsgPath(); 1323 PcepStateReport.PcepMsgPath msgPath = stateRpt.getMsgPath();
1346 checkNotNull(msgPath); 1324 checkNotNull(msgPath);
1347 PcepEroObject eroObj = msgPath.getEroObject(); 1325 PcepEroObject eroObj = msgPath.getEroObject();
...@@ -1349,7 +1327,30 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1349,7 +1327,30 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1349 log.error("ERO object is null in report message."); 1327 log.error("ERO object is null in report message.");
1350 return; 1328 return;
1351 } 1329 }
1352 - Path path = buildPathFromEroObj(eroObj, providerId); 1330 +
1331 + PcepAttribute attributes = msgPath.getPcepAttribute();
1332 + int cost = 0;
1333 + if (attributes != null && attributes.getMetricObjectList() != null) {
1334 + ListIterator<PcepMetricObject> iterator = attributes.getMetricObjectList().listIterator();
1335 + PcepMetricObject metricObj = iterator.next();
1336 +
1337 + while (metricObj != null) {
1338 + if (metricObj.getBType() == IGP_METRIC) {
1339 + costType = "COST";
1340 + } else if (metricObj.getBType() == TE_METRIC) {
1341 + costType = "TE_COST";
1342 + }
1343 +
1344 + if (costType != null) {
1345 + cost = metricObj.getMetricVal();
1346 + log.debug("Path cost {}", cost);
1347 + break;
1348 + }
1349 + metricObj = iterator.next();
1350 + }
1351 + }
1352 +
1353 + Path path = buildPathFromEroObj(eroObj, providerId, cost);
1353 1354
1354 float bandwidth = 0; 1355 float bandwidth = 0;
1355 if (msgPath.getBandwidthObject() != null) { 1356 if (msgPath.getBandwidthObject() != null) {
...@@ -1443,48 +1444,23 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1443,48 +1444,23 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1443 return; 1444 return;
1444 } 1445 }
1445 1446
1446 - if (lspObj.getCFlag()) {
1447 - /*
1448 - * While in sync, if PCRpt is received for PCE init LSP and PCE doesn't have entry, mark to send
1449 - * delete message on end of sync.
1450 - */
1451 - annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType);
1452 -
1453 - // Generate tunnel id for the temporary tunnel.
1454 - String onosTunnelId = "PCC" + String.valueOf(ipv4LspIdenTlv.getTunnelId());
1455 - Tunnel tunnelToBeDeleted = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, MPLS,
1456 - new DefaultGroupId(0), TunnelId.valueOf(onosTunnelId),
1457 - TunnelName.tunnelName(String
1458 - .valueOf(pathNameTlv.getValue())),
1459 - path, annotations);
1460 - /*
1461 - * Need to send PCInitiate delete msg for a tunnel which does not exist at PCE. For that some dummy
1462 - * data-structures need to be populated.
1463 - */
1464 - PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnelToBeDeleted, path, RequestType.DELETE);
1465 - pcepTunnelData.setPlspId(lspObj.getPlspId());
1466 - pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdenTlv);
1467 - pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
1468 - pcepTunnelApiMapper.handleCreateTunnelRequestQueue(0, pcepTunnelData);
1469 -
1470 - /*
1471 - * Add to the list of tunnels for which PCInit delete will be sent at the end of sync.
1472 - */
1473 - List<Tunnel> tunnelToBeDeletedList = syncCompleteDeleteList.get(pccId.ipAddress());
1474 - tunnelToBeDeletedList.add(tunnelToBeDeleted);
1475 - syncCompleteDeleteList.put(pccId.ipAddress(), tunnelToBeDeletedList);
1476 - return;
1477 - }
1478 DeviceId deviceId = getDevice(pccId); 1447 DeviceId deviceId = getDevice(pccId);
1479 if (deviceId == null) { 1448 if (deviceId == null) {
1480 log.error("Ingress deviceId not found"); 1449 log.error("Ingress deviceId not found");
1481 return; 1450 return;
1482 } 1451 }
1483 - annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType); 1452 + annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType);
1484 1453
1485 td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( 1454 td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId(
1486 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, 1455 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path,
1487 annotations); 1456 annotations);
1457 +
1458 + // Do not support PCC initiated LSP after LSP DB sync is completed.
1459 + if (!lspObj.getSFlag() && !lspObj.getCFlag()) {
1460 + log.error("Received PCC initiated LSP while not in sync.");
1461 + return;
1462 + }
1463 +
1488 /* 1464 /*
1489 * If ONOS instance is master for PCC then set delegated flag as annotation and add the tunnel to store. 1465 * If ONOS instance is master for PCC then set delegated flag as annotation and add the tunnel to store.
1490 * Because all LSPs need not be delegated, hence mastership for the PCC is confirmed whereas not the 1466 * Because all LSPs need not be delegated, hence mastership for the PCC is confirmed whereas not the
...@@ -1523,35 +1499,24 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1523,35 +1499,24 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1523 1499
1524 //delegated owner will update can be a master or non-master 1500 //delegated owner will update can be a master or non-master
1525 if (lspObj.getDFlag()) { 1501 if (lspObj.getDFlag()) {
1526 - annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType); 1502 + annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType);
1527 td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( 1503 td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId(
1528 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, 1504 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path,
1529 annotations); 1505 annotations);
1530 tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId); 1506 tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId);
1531 } 1507 }
1532 - 1508 + removeOrUpdatetunnel(tunnel, pccId, lspObj, providerId, tunnelState);
1533 - if ((syncStatus == IN_SYNC) && (lspObj.getCFlag()) && (tunnelState != tunnel.state())) {
1534 - // Mark to send PCUpd msg with state known at PCE.
1535 - List<Tunnel> tunnelToBeUpdateList = syncCompleteUpdateList.get(pccId.ipAddress());
1536 - tunnelToBeUpdateList.add(tunnel);
1537 - syncCompleteUpdateList.put(pccId.ipAddress(), tunnelToBeUpdateList);
1538 - return;
1539 - }
1540 - removeOrUpdatetunnel(tunnel, pccId, lspObj, providerId, syncStatus, tunnelState);
1541 return; 1509 return;
1542 } 1510 }
1543 1511
1544 private void removeOrUpdatetunnel(Tunnel tunnel, PccId pccId, PcepLspObject lspObj, ProviderId providerId, 1512 private void removeOrUpdatetunnel(Tunnel tunnel, PccId pccId, PcepLspObject lspObj, ProviderId providerId,
1545 - PcepSyncStatus syncStatus, State tunnelState) { 1513 + State tunnelState) {
1546 DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), tunnel.dst(), 1514 DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), tunnel.dst(),
1547 tunnel.type(), tunnel.groupId(), providerId, tunnel.tunnelName(), tunnel.path(), 1515 tunnel.type(), tunnel.groupId(), providerId, tunnel.tunnelName(), tunnel.path(),
1548 (SparseAnnotations) tunnel.annotations()); 1516 (SparseAnnotations) tunnel.annotations());
1549 if (lspObj.getRFlag()) { 1517 if (lspObj.getRFlag()) {
1550 tunnelRemoved(td); 1518 tunnelRemoved(td);
1551 } else { 1519 } else {
1552 - if (syncStatus == IN_SYNC) {
1553 - markLspDbEntryAsLatest(pccId, tunnel.tunnelId());
1554 - }
1555 tunnelUpdated(td, tunnelState); 1520 tunnelUpdated(td, tunnelState);
1556 } 1521 }
1557 } 1522 }
...@@ -1576,9 +1541,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1576,9 +1541,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1576 * 1541 *
1577 * @param eroObj ERO object 1542 * @param eroObj ERO object
1578 * @param providerId provider id 1543 * @param providerId provider id
1544 + * @param cost cost of path
1579 * @return path object 1545 * @return path object
1580 */ 1546 */
1581 - private Path buildPathFromEroObj(PcepEroObject eroObj, ProviderId providerId) { 1547 + private Path buildPathFromEroObj(PcepEroObject eroObj, ProviderId providerId, int cost) {
1582 checkNotNull(eroObj); 1548 checkNotNull(eroObj);
1583 List<Link> links = new ArrayList<Link>(); 1549 List<Link> links = new ArrayList<Link>();
1584 LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects(); 1550 LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects();
...@@ -1618,7 +1584,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1618,7 +1584,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1618 // the other sub objects are not required 1584 // the other sub objects are not required
1619 } 1585 }
1620 } 1586 }
1621 - return new DefaultPath(providerId, links, 0, EMPTY); 1587 +
1588 + return new DefaultPath(providerId, links, cost, EMPTY);
1622 } 1589 }
1623 1590
1624 @Override 1591 @Override
...@@ -1637,44 +1604,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1637,44 +1604,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1637 TunnelStatistics tunnelStatistics = buildTunnelStatistics(pcepTunnelStatistics); 1604 TunnelStatistics tunnelStatistics = buildTunnelStatistics(pcepTunnelStatistics);
1638 tunnelStatisticsMap.put(id, tunnelStatistics); 1605 tunnelStatisticsMap.put(id, tunnelStatistics);
1639 } 1606 }
1640 - }
1641 1607
1642 - @Override 1608 + @Override
1643 - public Tunnel tunnelQueryById(TunnelId tunnelId) { 1609 + public void handleEndOfSyncAction(Tunnel tunnel, PcepLspSyncAction endOfSyncAction) {
1644 - return service.tunnelQueryById(tunnelId);
1645 - }
1646 -
1647 - /**
1648 - * Removes the entry from temporary copy of LSPDB, signifying its status as upto date.
1649 - *
1650 - * @param pccId the key for temporary LSPDB
1651 - * @param tunnelId the tunnel id for which information is updated.
1652 - */
1653 - private void markLspDbEntryAsLatest(PccId pccId, TunnelId tunnelId) {
1654 - checkNotNull(pccId);
1655 - checkNotNull(tunnelId);
1656 -
1657 - Map<TunnelId, Tunnel> preSyncLspDb = preSyncLspDbMap.get(pccId.ipAddress());
1658 - checkNotNull(preSyncLspDb);
1659 -
1660 - preSyncLspDb.remove(tunnelId);
1661 - preSyncLspDbMap.put(pccId.ipAddress(), preSyncLspDb);
1662 - }
1663 -
1664 - /**
1665 - * Sends PCInit, PCInit(R) or PCUpd messages for initiated LSPs at the end
1666 - * of LSP DB sync based on actions decided while sync was in progress. Also
1667 - * triggers label DB sync.
1668 - *
1669 - * @param pccId the key for temporary DBs storing required end of sync
1670 - * actions.
1671 - */
1672 - private void handleEndOfSyncAction(PccId pccId) {
1673 -
1674 - Map<TunnelId, Tunnel> preSyncLspDb = preSyncLspDbMap.get(pccId.ipAddress());
1675 - checkNotNull(preSyncLspDb);
1676 1610
1677 - for (Tunnel tunnel : preSyncLspDb.values()) { 1611 + if (endOfSyncAction == SEND_UPDATE) {
1612 + updateTunnel(tunnel, tunnel.path());
1613 + return;
1614 + }
1678 1615
1679 TunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), 1616 TunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(),
1680 tunnel.src(), tunnel.dst(), 1617 tunnel.src(), tunnel.dst(),
...@@ -1685,43 +1622,56 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1685,43 +1622,56 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1685 tunnel.path(), 1622 tunnel.path(),
1686 (SparseAnnotations) tunnel.annotations()); 1623 (SparseAnnotations) tunnel.annotations());
1687 1624
1688 - if ((tunnel.annotations().value(PCE_INIT) == null)
1689 - || (tunnel.annotations().value(PCE_INIT).equals("false"))) {
1690 1625
1691 - tunnelRemoved(td); 1626 + if (endOfSyncAction == PcepLspSyncAction.UNSTABLE) {
1692 - } else { 1627 +
1693 // Send PCInit msg again after global reoptimization. 1628 // Send PCInit msg again after global reoptimization.
1694 tunnelUpdated(td, UNSTABLE); 1629 tunnelUpdated(td, UNSTABLE);
1695 1630
1696 // To remove the old tunnel from store whose PLSPID is not 1631 // To remove the old tunnel from store whose PLSPID is not
1697 // recognized by ingress PCC. 1632 // recognized by ingress PCC.
1698 tunnelRemoved(td); 1633 tunnelRemoved(td);
1634 +
1635 + } else if (endOfSyncAction == REMOVE) {
1636 + tunnelRemoved(td);
1699 } 1637 }
1700 } 1638 }
1701 1639
1702 - List<Tunnel> tunnelsToBeDeletedList = syncCompleteDeleteList.get(pccId.ipAddress()); 1640 + @Override
1703 - checkNotNull(tunnelsToBeDeletedList); 1641 + public void handleEndOfSyncAction(PccId pccId, PcepMessage msg, PcepLspSyncAction endOfSyncAction) {
1704 - for (Tunnel tunnel: tunnelsToBeDeletedList) { 1642 + try {
1705 - releaseTunnel(tunnel); 1643 + if ((msg instanceof PcepInitiateMsg) && (endOfSyncAction == SEND_DELETE)) {
1706 - } 1644 + PcepClient pc = pcepClientController.getClient(pccId);
1645 + LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = ((PcepInitiateMsg) msg)
1646 + .getPcInitiatedLspRequestList();
1647 + PcInitiatedLspRequest pcInitMsg = llPcInitiatedLspRequestList.iterator().next();
1707 1648
1708 - List<Tunnel> tunnelsToBeUpdatedList = syncCompleteUpdateList.get(pccId.ipAddress()); 1649 + if (pcInitMsg != null) {
1709 - checkNotNull(tunnelsToBeUpdatedList); 1650 + PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(SrpIdGenerators.create())
1710 - for (Tunnel tunnel: tunnelsToBeUpdatedList) { 1651 + .setRFlag(true).build();
1711 - updateTunnel(tunnel, tunnel.path()); 1652 +
1712 - } 1653 + PcInitiatedLspRequest releaseLspRequest = pc.factory().buildPcInitiatedLspRequest()
1654 + .setLspObject(pcInitMsg.getLspObject()).setSrpObject(srpobj).build();
1713 1655
1714 - /* On end of sync, empty all temporary data structures. */ 1656 + llPcInitiatedLspRequestList.remove(pcInitMsg);
1715 - preSyncLspDbMap.remove(pccId.ipAddress()); 1657 + llPcInitiatedLspRequestList.add(releaseLspRequest);
1716 - syncCompleteDeleteList.remove(pccId.ipAddress());
1717 - syncCompleteUpdateList.remove(pccId.ipAddress());
1718 1658
1719 - // TODO: If SR capable, send a notification to 1659 + PcepInitiateMsg pcInitiateMsg = pc.factory().buildPcepInitiateMsg()
1720 - // PCE APP to start label DB sync. 1660 + .setPcInitiatedLspRequestList(llPcInitiatedLspRequestList).build();
1721 - if (true) { 1661 +
1722 - pcepClientController.getClient(pccId).setLabelDbSyncStatus(IN_SYNC); 1662 + pc.sendMessage(Collections.singletonList(pcInitiateMsg));
1663 + }
1664 + }
1665 + } catch (PcepParseException e) {
1666 + log.error("Exception occured while sending initiate delete message {}", e.getMessage());
1667 + }
1723 } 1668 }
1724 } 1669 }
1670 + @Override
1671 + public Tunnel tunnelQueryById(TunnelId tunnelId) {
1672 + return service.tunnelQueryById(tunnelId);
1673 + }
1674 +
1725 1675
1726 private DeviceId getDevice(PccId pccId) { 1676 private DeviceId getDevice(PccId pccId) {
1727 // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID. 1677 // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
......
...@@ -18,6 +18,7 @@ package org.onosproject.provider.pcep.tunnel.impl; ...@@ -18,6 +18,7 @@ package org.onosproject.provider.pcep.tunnel.impl;
18 import static org.junit.Assert.assertNotNull; 18 import static org.junit.Assert.assertNotNull;
19 19
20 import java.util.HashMap; 20 import java.util.HashMap;
21 +import java.util.LinkedList;
21 import java.util.List; 22 import java.util.List;
22 import java.util.Map; 23 import java.util.Map;
23 import java.util.concurrent.RejectedExecutionException; 24 import java.util.concurrent.RejectedExecutionException;
...@@ -31,6 +32,7 @@ import org.onosproject.pcep.controller.PcepSyncStatus; ...@@ -31,6 +32,7 @@ import org.onosproject.pcep.controller.PcepSyncStatus;
31 import org.onosproject.pcepio.protocol.PcepFactories; 32 import org.onosproject.pcepio.protocol.PcepFactories;
32 import org.onosproject.pcepio.protocol.PcepFactory; 33 import org.onosproject.pcepio.protocol.PcepFactory;
33 import org.onosproject.pcepio.protocol.PcepMessage; 34 import org.onosproject.pcepio.protocol.PcepMessage;
35 +import org.onosproject.pcepio.protocol.PcepStateReport;
34 import org.onosproject.pcepio.protocol.PcepVersion; 36 import org.onosproject.pcepio.protocol.PcepVersion;
35 37
36 /** 38 /**
...@@ -49,6 +51,7 @@ public class PcepClientAdapter implements PcepClient { ...@@ -49,6 +51,7 @@ public class PcepClientAdapter implements PcepClient {
49 private PcepSyncStatus lspDbSyncStatus; 51 private PcepSyncStatus lspDbSyncStatus;
50 private PcepSyncStatus labelDbSyncStatus; 52 private PcepSyncStatus labelDbSyncStatus;
51 private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>(); 53 private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>();
54 + private Map<PccId, List<PcepStateReport>> sycRptCache = new HashMap<>();
52 55
53 /** 56 /**
54 * Initialize instance with specified parameters. 57 * Initialize instance with specified parameters.
...@@ -161,4 +164,27 @@ public class PcepClientAdapter implements PcepClient { ...@@ -161,4 +164,27 @@ public class PcepClientAdapter implements PcepClient {
161 public Boolean delegationInfo(LspKey lspKey) { 164 public Boolean delegationInfo(LspKey lspKey) {
162 return lspDelegationInfo.get(lspKey); 165 return lspDelegationInfo.get(lspKey);
163 } 166 }
167 +
168 + @Override
169 + public void initializeSyncMsgList(PccId pccId) {
170 + List<PcepStateReport> rptMsgList = new LinkedList<>();
171 + sycRptCache.put(pccId, rptMsgList);
172 + }
173 +
174 + @Override
175 + public List<PcepStateReport> getSyncMsgList(PccId pccId) {
176 + return sycRptCache.get(pccId);
177 + }
178 +
179 + @Override
180 + public void removeSyncMsgList(PccId pccId) {
181 + sycRptCache.remove(pccId);
182 + }
183 +
184 + @Override
185 + public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
186 + List<PcepStateReport> rptMsgList = sycRptCache.get(pccId);
187 + rptMsgList.add(rptMsg);
188 + sycRptCache.put(pccId, rptMsgList);
189 + }
164 } 190 }
......
...@@ -30,6 +30,7 @@ import org.onosproject.pcep.controller.PcepClientController; ...@@ -30,6 +30,7 @@ import org.onosproject.pcep.controller.PcepClientController;
30 import org.onosproject.pcep.controller.PcepClientListener; 30 import org.onosproject.pcep.controller.PcepClientListener;
31 import org.onosproject.pcep.controller.PcepEventListener; 31 import org.onosproject.pcep.controller.PcepEventListener;
32 import org.onosproject.pcep.controller.PcepNodeListener; 32 import org.onosproject.pcep.controller.PcepNodeListener;
33 +import org.onosproject.pcep.controller.PcepPacketListener;
33 import org.onosproject.pcep.controller.driver.PcepAgent; 34 import org.onosproject.pcep.controller.driver.PcepAgent;
34 import org.onosproject.pcepio.protocol.PcepError; 35 import org.onosproject.pcepio.protocol.PcepError;
35 import org.onosproject.pcepio.protocol.PcepErrorInfo; 36 import org.onosproject.pcepio.protocol.PcepErrorInfo;
...@@ -57,6 +58,7 @@ public class PcepClientControllerAdapter implements PcepClientController { ...@@ -57,6 +58,7 @@ public class PcepClientControllerAdapter implements PcepClientController {
57 58
58 protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet(); 59 protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet();
59 public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet(); 60 public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet();
61 + protected Set<PcepPacketListener> pcepPacketListener = Sets.newHashSet();
60 62
61 @Activate 63 @Activate
62 public void activate() { 64 public void activate() {
...@@ -116,6 +118,16 @@ public class PcepClientControllerAdapter implements PcepClientController { ...@@ -116,6 +118,16 @@ public class PcepClientControllerAdapter implements PcepClientController {
116 } 118 }
117 119
118 @Override 120 @Override
121 + public void addPacketListener(PcepPacketListener listener) {
122 + pcepPacketListener.add(listener);
123 + }
124 +
125 + @Override
126 + public void removePacketListener(PcepPacketListener listener) {
127 + pcepPacketListener.remove(listener);
128 + }
129 +
130 + @Override
119 public void writeMessage(PccId pccId, PcepMessage msg) { 131 public void writeMessage(PccId pccId, PcepMessage msg) {
120 this.getClient(pccId).sendMessage(msg); 132 this.getClient(pccId).sendMessage(msg);
121 } 133 }
...@@ -273,5 +285,11 @@ public class PcepClientControllerAdapter implements PcepClientController { ...@@ -273,5 +285,11 @@ public class PcepClientControllerAdapter implements PcepClientController {
273 l.deleteNode(pccId); 285 l.deleteNode(pccId);
274 } 286 }
275 } 287 }
288 +
289 + @Override
290 + public boolean analyzeSyncMsgList(PccId pccId) {
291 + // TODO Auto-generated method stub
292 + return false;
293 + }
276 } 294 }
277 } 295 }
......
...@@ -27,7 +27,6 @@ import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ ...@@ -27,7 +27,6 @@ import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_
27 import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.DELEGATE; 27 import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.DELEGATE;
28 import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; 28 import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
29 import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED; 29 import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED;
30 -import static org.onosproject.pcep.controller.PcepSyncStatus.IN_SYNC;
31 import static org.onosproject.net.Device.Type.ROUTER; 30 import static org.onosproject.net.Device.Type.ROUTER;
32 import static org.onosproject.net.MastershipRole.MASTER; 31 import static org.onosproject.net.MastershipRole.MASTER;
33 32
...@@ -404,7 +403,7 @@ public class PcepTunnelAddedTest { ...@@ -404,7 +403,7 @@ public class PcepTunnelAddedTest {
404 0x00, 0x00, 0x00, 0x00, 403 0x00, 0x00, 0x00, 0x00,
405 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV 404 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
406 0x00, 0x00, 0x00, 0x02, 405 0x00, 0x00, 0x00, 0x02,
407 - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, // LSP object 406 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x1B, // LSP object
408 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV 407 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV
409 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV 408 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
410 0x01, 0x01, 0x01, 0x01, 409 0x01, 0x01, 0x01, 0x01,
...@@ -552,173 +551,18 @@ public class PcepTunnelAddedTest { ...@@ -552,173 +551,18 @@ public class PcepTunnelAddedTest {
552 } 551 }
553 552
554 /** 553 /**
555 - * Tests LSPDB sync where PCC reports less LSPs than known by PCE and PCE deletes at the end of DB sync. 554 + * Tests adding PCC Init LSP after LSP DB sync is over.
556 - */
557 - @Test
558 - public void testCaseLspDbSync1() throws PcepParseException, PcepOutOfBoundMessageException {
559 - /* Step 1 create 2 LSPs */
560 - byte[] reportMsg1 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
561 - 0x21, 0x10, 0x00, 0x14, //SRP object
562 - 0x00, 0x00, 0x00, 0x00,
563 - 0x00, 0x00, 0x00, 0x00,
564 - 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
565 - 0x00, 0x00, 0x00, 0x00,
566 - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, // LSP object
567 - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV
568 - 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
569 - 0x01, 0x01, 0x01, 0x01,
570 - 0x00, 0x01, 0x00, 0x01,
571 - 0x01, 0x01, 0x01, 0x01,
572 - 0x05, 0x05, 0x05, 0x05,
573 -
574 - 0x07, 0x10, 0x00, 0x14, //ERO object
575 - 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
576 - 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
577 -
578 - 0x08, 0x10, 0x00, 0x34, //RRO object
579 - 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
580 - 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
581 - 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
582 - 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
583 - 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
584 - 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
585 - };
586 -
587 - ChannelBuffer buffer1 = ChannelBuffers.dynamicBuffer();
588 - buffer1.writeBytes(reportMsg1);
589 -
590 - PcepMessageReader<PcepMessage> reader1 = PcepFactories.getGenericReader();
591 - PcepMessage message1 = reader1.readFrom(buffer1);
592 -
593 - DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
594 - newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1");
595 - newBuilder.set(AnnotationKeys.TYPE, "L3");
596 - Device device = new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("1.1.1.1"), ROUTER,
597 - UNKOWN, UNKOWN, UNKOWN,
598 - UNKOWN, new ChassisId(),
599 - newBuilder.build());
600 -
601 - deviceService.addDevice(device);
602 -
603 - PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1"));
604 - controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
605 -
606 - PcepClientAdapter pc = new PcepClientAdapter();
607 - pc.init(pccId, PcepVersion.PCEP_1);
608 - controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(2, (short) 2), true);
609 - masterShipService.setMaster(true);
610 - controller.processClientMessage(pccId, message1);
611 -
612 - /* create 2nd LSP */
613 - byte[] reportMsg2 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
614 - 0x21, 0x10, 0x00, 0x14, //SRP object
615 - 0x00, 0x00, 0x00, 0x00,
616 - 0x00, 0x00, 0x00, 0x00,
617 - 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
618 - 0x00, 0x00, 0x00, 0x00,
619 - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x20, 0x19, // LSP object
620 - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV
621 - 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
622 - 0x01, 0x01, 0x01, 0x01,
623 - 0x00, 0x02, 0x00, 0x02,
624 - 0x01, 0x01, 0x01, 0x01,
625 - 0x05, 0x05, 0x05, 0x05,
626 -
627 - 0x07, 0x10, 0x00, 0x14, //ERO object
628 - 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
629 - 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
630 -
631 - 0x08, 0x10, 0x00, 0x34, //RRO object
632 - 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
633 - 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
634 - 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
635 - 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
636 - 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
637 - 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
638 - };
639 -
640 - ChannelBuffer buffer2 = ChannelBuffers.dynamicBuffer();
641 - buffer2.writeBytes(reportMsg2);
642 -
643 - PcepMessageReader<PcepMessage> reader2 = PcepFactories.getGenericReader();
644 - PcepMessage message2 = reader2.readFrom(buffer2);
645 -
646 - controller.processClientMessage(pccId, message2);
647 -
648 - /* Assert number of LSPs in DB to be 2. */
649 - assertThat(registry.tunnelIdCounter, is((long) 2));
650 -
651 - /* Step 2 send sync begin message and LSP 1. */
652 - byte[] reportMsg3 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
653 - 0x21, 0x10, 0x00, 0x14, //SRP object
654 - 0x00, 0x00, 0x00, 0x00,
655 - 0x00, 0x00, 0x00, 0x00,
656 - 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
657 - 0x00, 0x00, 0x00, 0x00,
658 - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x1B, // LSP object
659 - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV
660 - 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
661 - 0x01, 0x01, 0x01, 0x01,
662 - 0x00, 0x01, 0x00, 0x01,
663 - 0x01, 0x01, 0x01, 0x01,
664 - 0x05, 0x05, 0x05, 0x05,
665 -
666 - 0x07, 0x10, 0x00, 0x14, //ERO object
667 - 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
668 - 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
669 -
670 - 0x08, 0x10, 0x00, 0x34, //RRO object
671 - 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
672 - 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
673 - 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
674 - 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
675 - 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
676 - 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
677 - };
678 -
679 - ChannelBuffer buffer3 = ChannelBuffers.dynamicBuffer();
680 - buffer3.writeBytes(reportMsg3);
681 - PcepMessageReader<PcepMessage> reader3 = PcepFactories.getGenericReader();
682 - PcepMessage message3 = reader3.readFrom(buffer3);
683 - controller.processClientMessage(pccId, message3);
684 -
685 - assertThat(controller.getClient(pccId).lspDbSyncStatus(), is(IN_SYNC));
686 -
687 - /* Step 3 send end of sync marker */
688 - byte[] reportMsg4 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x24,
689 - 0x20, 0x10, 0x00, 0x1C, // LSP object
690 - 0x00, 0x00, 0x10, 0x19,
691 - 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
692 - 0x00, 0x00, 0x00, 0x00,
693 - 0x00, 0x00, 0x00, 0x00,
694 - 0x00, 0x00, 0x00, 0x00,
695 - 0x00, 0x00, 0x00, 0x00,
696 - 0x07, 0x10, 0x00, 0x04, //ERO object
697 - };
698 -
699 - ChannelBuffer buffer4 = ChannelBuffers.dynamicBuffer();
700 - buffer4.writeBytes(reportMsg4);
701 - PcepMessageReader<PcepMessage> reader4 = PcepFactories.getGenericReader();
702 - PcepMessage message4 = reader4.readFrom(buffer4);
703 - controller.processClientMessage(pccId, message4);
704 -
705 - assertThat(controller.getClient(pccId).lspDbSyncStatus(), is(SYNCED));
706 - }
707 -
708 - /**
709 - * Tests PCC PCRpt PCE initiated LSP which PCE doesn't know and hence should send PCInit delete msg.
710 */ 555 */
711 @Test 556 @Test
712 - public void testCaseLspDbSync2() throws PcepParseException, PcepOutOfBoundMessageException { 557 + public void tunnelProviderAddedTest5() throws PcepParseException, PcepOutOfBoundMessageException {
713 - /* Step 1 create 2 LSPs */ 558 + byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
714 - byte[] reportMsg1 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
715 0x21, 0x10, 0x00, 0x14, //SRP object 559 0x21, 0x10, 0x00, 0x14, //SRP object
716 0x00, 0x00, 0x00, 0x00, 560 0x00, 0x00, 0x00, 0x00,
717 0x00, 0x00, 0x00, 0x00, 561 0x00, 0x00, 0x00, 0x00,
718 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV 562 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
719 - 0x00, 0x00, 0x00, 0x00, 563 + 0x00, 0x00, 0x00, 0x02,
720 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, // LSP object 564 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, // LSP object
721 - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV 565 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV
722 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV 566 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
723 0x01, 0x01, 0x01, 0x01, 567 0x01, 0x01, 0x01, 0x01,
724 0x00, 0x01, 0x00, 0x01, 568 0x00, 0x01, 0x00, 0x01,
...@@ -738,11 +582,11 @@ public class PcepTunnelAddedTest { ...@@ -738,11 +582,11 @@ public class PcepTunnelAddedTest {
738 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 582 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
739 }; 583 };
740 584
741 - ChannelBuffer buffer1 = ChannelBuffers.dynamicBuffer(); 585 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
742 - buffer1.writeBytes(reportMsg1); 586 + buffer.writeBytes(reportMsg);
743 587
744 - PcepMessageReader<PcepMessage> reader1 = PcepFactories.getGenericReader(); 588 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
745 - PcepMessage message1 = reader1.readFrom(buffer1); 589 + PcepMessage message = reader.readFrom(buffer);
746 590
747 DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); 591 DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
748 newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1"); 592 newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1");
...@@ -755,109 +599,16 @@ public class PcepTunnelAddedTest { ...@@ -755,109 +599,16 @@ public class PcepTunnelAddedTest {
755 deviceService.addDevice(device); 599 deviceService.addDevice(device);
756 600
757 PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1")); 601 PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1"));
602 + controller.getClient(pccId).setLspDbSyncStatus(SYNCED);
758 controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true)); 603 controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
759 604
760 PcepClientAdapter pc = new PcepClientAdapter(); 605 PcepClientAdapter pc = new PcepClientAdapter();
761 pc.init(pccId, PcepVersion.PCEP_1); 606 pc.init(pccId, PcepVersion.PCEP_1);
607 + controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
762 masterShipService.setMaster(true); 608 masterShipService.setMaster(true);
763 - controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(2, (short) 2), true); 609 + controller.processClientMessage(pccId, message);
764 -
765 - controller.processClientMessage(pccId, message1);
766 -
767 - /* create 2nd LSP */
768 - byte[] reportMsg2 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
769 - 0x21, 0x10, 0x00, 0x14, //SRP object
770 - 0x00, 0x00, 0x00, 0x00,
771 - 0x00, 0x00, 0x00, 0x00,
772 - 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
773 - 0x00, 0x00, 0x00, 0x00,
774 - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x20, 0x19, // LSP object
775 - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV
776 - 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
777 - 0x01, 0x01, 0x01, 0x01,
778 - 0x00, 0x02, 0x00, 0x02,
779 - 0x01, 0x01, 0x01, 0x01,
780 - 0x05, 0x05, 0x05, 0x05,
781 -
782 - 0x07, 0x10, 0x00, 0x14, //ERO object
783 - 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
784 - 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
785 -
786 - 0x08, 0x10, 0x00, 0x34, //RRO object
787 - 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
788 - 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
789 - 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
790 - 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
791 - 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
792 - 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
793 - };
794 -
795 - ChannelBuffer buffer2 = ChannelBuffers.dynamicBuffer();
796 - buffer2.writeBytes(reportMsg2);
797 -
798 - PcepMessageReader<PcepMessage> reader2 = PcepFactories.getGenericReader();
799 - PcepMessage message2 = reader2.readFrom(buffer2);
800 -
801 - controller.processClientMessage(pccId, message2);
802 -
803 - /* Assert number of LSPs in DB to be 2. */
804 - assertThat(registry.tunnelIdCounter, is((long) 2));
805 -
806 - /* Step 2 send sync begin message and LSP 1. */
807 - byte[] reportMsg3 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
808 - 0x21, 0x10, 0x00, 0x14, //SRP object
809 - 0x00, 0x00, 0x00, 0x00,
810 - 0x00, 0x00, 0x00, 0x00,
811 - 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
812 - 0x00, 0x00, 0x00, 0x00,
813 - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, (byte) 0x9B, // LSP object
814 - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV
815 - 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
816 - 0x01, 0x01, 0x01, 0x01,
817 - 0x00, 0x01, 0x00, 0x03,
818 - 0x01, 0x01, 0x01, 0x01,
819 - 0x05, 0x05, 0x05, 0x05,
820 -
821 - 0x07, 0x10, 0x00, 0x14, //ERO object
822 - 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
823 - 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
824 -
825 - 0x08, 0x10, 0x00, 0x34, //RRO object
826 - 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
827 - 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
828 - 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
829 - 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
830 - 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
831 - 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
832 - };
833 -
834 - ChannelBuffer buffer3 = ChannelBuffers.dynamicBuffer();
835 - buffer3.writeBytes(reportMsg3);
836 - PcepMessageReader<PcepMessage> reader3 = PcepFactories.getGenericReader();
837 - PcepMessage message3 = reader3.readFrom(buffer3);
838 - controller.processClientMessage(pccId, message3);
839 -
840 - assertThat(controller.getClient(pccId).lspDbSyncStatus(), is(IN_SYNC));
841 -
842 - /* Step 3 send end of sync marker */
843 - byte[] reportMsg4 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x24,
844 - 0x20, 0x10, 0x00, 0x1C, // LSP object
845 - 0x00, 0x00, 0x10, 0x19,
846 - 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
847 - 0x00, 0x00, 0x00, 0x00,
848 - 0x00, 0x00, 0x00, 0x00,
849 - 0x00, 0x00, 0x00, 0x00,
850 - 0x00, 0x00, 0x00, 0x00,
851 - 0x07, 0x10, 0x00, 0x04, //ERO object
852 - };
853 -
854 - ChannelBuffer buffer4 = ChannelBuffers.dynamicBuffer();
855 - buffer4.writeBytes(reportMsg4);
856 - PcepMessageReader<PcepMessage> reader4 = PcepFactories.getGenericReader();
857 - PcepMessage message4 = reader4.readFrom(buffer4);
858 - controller.processClientMessage(pccId, message4);
859 610
860 - assertThat(controller.getClient(pccId).lspDbSyncStatus(), is(SYNCED)); 611 + assertThat(registry.tunnelIdCounter, is((long) 0));
861 } 612 }
862 613
863 @After 614 @After
......