blob: 95b5be537b260d16f72ec39a515236d6dd63b57c [file] [log] [blame]
sangho27462c62015-05-14 00:39:53 -07001/*
Brian O'Connor0947d7e2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
sangho27462c62015-05-14 00:39:53 -07003 *
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 */
16package org.onosproject.segmentrouting;
17
Pier71c55772018-04-17 17:25:22 +020018import com.google.common.collect.Multimap;
Charles Chan8d316332018-06-19 20:31:57 -070019import org.apache.commons.lang3.NotImplementedException;
Pier Luigi0f9635b2018-01-15 18:06:43 +010020import org.onlab.packet.IpAddress;
Pier Ventreb6a7f342016-11-26 21:05:22 -080021import org.onlab.packet.IpPrefix;
Charles Chan8d316332018-06-19 20:31:57 -070022import org.onlab.packet.VlanId;
Pierdb27b8d2018-04-17 16:29:56 +020023import org.onosproject.cluster.NodeId;
Charles Chan8d316332018-06-19 20:31:57 -070024import org.onosproject.core.ApplicationId;
Pier Luigi0f9635b2018-01-15 18:06:43 +010025import org.onosproject.net.ConnectPoint;
Charles Chand7844e52016-10-20 17:02:44 -070026import org.onosproject.net.DeviceId;
Saurav Das6430f412018-01-25 09:49:01 -080027import org.onosproject.net.Link;
28import org.onosproject.net.PortNumber;
Charles Chan0b1dd7e2018-08-19 19:21:46 -070029import org.onosproject.net.flowobjective.NextObjective;
Saurav Das261c3002017-06-13 15:35:54 -070030import org.onosproject.segmentrouting.grouphandler.NextNeighbors;
Harshada Chaundkar9204f312019-07-02 16:01:24 +000031import org.onosproject.segmentrouting.mcast.McastFilteringObjStoreKey;
Pier Luigi69f774d2018-02-28 12:10:50 +010032import org.onosproject.segmentrouting.mcast.McastRole;
Piere99511d2018-04-19 16:47:06 +020033import org.onosproject.segmentrouting.mcast.McastRoleStoreKey;
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -070034import org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription;
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080035import org.onosproject.segmentrouting.pwaas.L2Tunnel;
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070036import org.onosproject.segmentrouting.pwaas.L2TunnelHandler;
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080037import org.onosproject.segmentrouting.pwaas.L2TunnelPolicy;
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -080038import org.onosproject.segmentrouting.pwaas.L2TunnelDescription;
Saurav Das261c3002017-06-13 15:35:54 -070039import org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey;
Saurav Das62ae6792017-05-15 15:34:25 -070040
41import com.google.common.collect.ImmutableMap;
Piere99511d2018-04-19 16:47:06 +020042import org.onosproject.segmentrouting.mcast.McastStoreKey;
Charles Chan0b1dd7e2018-08-19 19:21:46 -070043import org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey;
44import org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey;
Ruchi Sahota71bcb4e2019-01-28 01:08:18 +000045import org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey;
Charles Chand7844e52016-10-20 17:02:44 -070046
sangho27462c62015-05-14 00:39:53 -070047import java.util.List;
Charles Chand7844e52016-10-20 17:02:44 -070048import java.util.Map;
Charles Chan8d316332018-06-19 20:31:57 -070049import java.util.Optional;
Charles Chand7844e52016-10-20 17:02:44 -070050import java.util.Set;
sangho27462c62015-05-14 00:39:53 -070051
52/**
53 * Segment Routing Service for REST API.
54 */
55public interface SegmentRoutingService {
Charles Chan82ab1932016-01-30 23:22:37 -080056 /**
Charles Chan868c9572018-06-15 18:54:18 -070057 * VLAN cross-connect ACL priority.
Charles Chan8d316332018-06-19 20:31:57 -070058 *
59 * @deprecated in ONOS 1.12. Replaced by {@link org.onosproject.segmentrouting.xconnect.api.XconnectService}
Charles Chan868c9572018-06-15 18:54:18 -070060 */
Charles Chan8d316332018-06-19 20:31:57 -070061 @Deprecated
Charles Chan868c9572018-06-15 18:54:18 -070062 int XCONNECT_ACL_PRIORITY = 60000;
63
64 /**
65 * VLAN cross-connect Bridging priority.
Charles Chan8d316332018-06-19 20:31:57 -070066 *
67 * @deprecated in ONOS 1.12. Replaced by {@link org.onosproject.segmentrouting.xconnect.api.XconnectService}
Charles Chan82ab1932016-01-30 23:22:37 -080068 */
Charles Chan8d316332018-06-19 20:31:57 -070069 @Deprecated
Charles Chan82ab1932016-01-30 23:22:37 -080070 int XCONNECT_PRIORITY = 1000;
71
72 /**
73 * Default flow priority.
74 */
75 int DEFAULT_PRIORITY = 100;
76
77 /**
78 * Minimum IP priority.
79 *
Charles Chand86904c2016-02-18 10:43:46 -080080 * Should < 0 such that priority of /0 will not conflict with lowest
Charles Chan82ab1932016-01-30 23:22:37 -080081 * priority default entries.
82 */
83 int MIN_IP_PRIORITY = 10;
84
85 /**
86 * Subnet flooding flow priority.
87 */
88 int FLOOD_PRIORITY = 5;
89
sangho27462c62015-05-14 00:39:53 -070090 /**
91 * Returns all tunnels.
92 *
93 * @return list of tunnels
94 */
95 List<Tunnel> getTunnels();
96
97 /**
98 * Creates a tunnel.
99 *
100 * @param tunnel tunnel reference to create
sanghobd812f82015-06-29 14:58:47 -0700101 * @return WRONG_PATH if the tunnel path is wrong, ID_EXISTS if the tunnel ID
102 * exists already, TUNNEL_EXISTS if the same tunnel exists, INTERNAL_ERROR
103 * if the tunnel creation failed internally, SUCCESS if the tunnel is created
104 * successfully
sangho27462c62015-05-14 00:39:53 -0700105 */
sanghobd812f82015-06-29 14:58:47 -0700106 TunnelHandler.Result createTunnel(Tunnel tunnel);
sangho27462c62015-05-14 00:39:53 -0700107
108 /**
109 * Returns all policies.
110 *
111 * @return list of policy
112 */
113 List<Policy> getPolicies();
114
115 /**
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700116 * Returns the l2 tunnel descriptions.
117 *
Andreas Pantelopoulosd988c1a2018-03-15 16:56:09 -0700118 * @param pending if true fetch pending pseudowires, else fetch installed
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700119 * @return set of l2 tunnel descriptions.
120 */
Andreas Pantelopoulosd988c1a2018-03-15 16:56:09 -0700121 Set<L2TunnelDescription> getL2TunnelDescriptions(boolean pending);
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700122
123 /**
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700124 * Returns all l2 tunnels of pseudowires.
125 *
126 * @return list of l2 tunnels
127 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800128 List<L2Tunnel> getL2Tunnels();
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700129
130 /**
131 * Returns all l2 policie of pseudowires.
132 *
133 * @return list of l2 policies.
134 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800135 List<L2TunnelPolicy> getL2Policies();
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700136
137 /**
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700138 * Removes pseudowire.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700139 *
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800140 * @param pwId The id of the pseudowire.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700141 * @return SUCCESS if operation successful or a descriptive error otherwise.
142 */
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800143 L2TunnelHandler.Result removePseudowire(Integer pwId);
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700144
145 /**
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700146 * Adds a Pseudowire to the system.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700147 *
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800148 * @param tunnel The pseudowire tunnel.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700149 * @return SUCCESS if operation is successful or a descriptive error otherwise.
150 */
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800151 L2TunnelHandler.Result addPseudowire(L2TunnelDescription tunnel);
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700152
153 /**
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700154 * Adds a set of pseudowires.
155 *
156 *
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700157 * @param l2TunnelDescriptions The pseudowires to add.
158 * @return SUCCESS if ALL pseudowires can be instantiated and are deployed, or a
159 * a descriptive error otherwise, without deploying any pseudowire.
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700160 * @deprecated onos-1.12 use addPseudowire instead
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700161 */
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700162 @Deprecated
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700163 L2TunnelHandler.Result addPseudowiresBulk(List<DefaultL2TunnelDescription> l2TunnelDescriptions);
164
165 /**
sangho27462c62015-05-14 00:39:53 -0700166 * Creates a policy.
167 *
168 * @param policy policy reference to create
sanghobd812f82015-06-29 14:58:47 -0700169 * @return ID_EXISTS if the same policy ID exists,
170 * POLICY_EXISTS if the same policy exists, TUNNEL_NOT_FOUND if the tunnel
171 * does not exists, UNSUPPORTED_TYPE if the policy type is not supported,
172 * SUCCESS if the policy is created successfully.
sangho27462c62015-05-14 00:39:53 -0700173 */
sanghobd812f82015-06-29 14:58:47 -0700174 PolicyHandler.Result createPolicy(Policy policy);
sangho27462c62015-05-14 00:39:53 -0700175
176 /**
177 * Removes a tunnel.
178 *
179 * @param tunnel tunnel reference to remove
sanghobd812f82015-06-29 14:58:47 -0700180 * @return TUNNEL_NOT_FOUND if the tunnel to remove does not exists,
181 * INTERNAL_ERROR if the tunnel creation failed internally, SUCCESS
182 * if the tunnel is created successfully.
sangho27462c62015-05-14 00:39:53 -0700183 */
sanghobd812f82015-06-29 14:58:47 -0700184 TunnelHandler.Result removeTunnel(Tunnel tunnel);
sangho27462c62015-05-14 00:39:53 -0700185
186 /**
187 * Removes a policy.
188 *
189 * @param policy policy reference to remove
sanghobd812f82015-06-29 14:58:47 -0700190 * @return POLICY_NOT_FOUND if the policy to remove does not exists,
191 * SUCCESS if it is removed successfully
sangho27462c62015-05-14 00:39:53 -0700192 */
sanghobd812f82015-06-29 14:58:47 -0700193 PolicyHandler.Result removePolicy(Policy policy);
Saurav Das07c74602016-04-27 18:35:50 -0700194
195 /**
196 * Use current state of the network to repopulate forwarding rules.
197 *
198 */
199 void rerouteNetwork();
Charles Chand7844e52016-10-20 17:02:44 -0700200
201 /**
202 * Returns device-subnet mapping.
203 *
204 * @return device-subnet mapping
205 */
Pier Ventreb6a7f342016-11-26 21:05:22 -0800206 Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap();
Saurav Das62ae6792017-05-15 15:34:25 -0700207
208 /**
209 * Returns the current ECMP shortest path graph in this controller instance.
210 *
211 * @return ECMP shortest path graph
212 */
213 ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg();
214
215 /**
Saurav Das261c3002017-06-13 15:35:54 -0700216 * Returns the destinatiomSet-NextObjective store contents.
Saurav Das62ae6792017-05-15 15:34:25 -0700217 *
Charles Chan0b1dd7e2018-08-19 19:21:46 -0700218 * @return current contents of the dstNextObjStore
Saurav Das62ae6792017-05-15 15:34:25 -0700219 */
Charles Chan0b1dd7e2018-08-19 19:21:46 -0700220 ImmutableMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> getDstNextObjStore();
221
222 /**
223 * Returns the VLAN next objective store.
224 *
225 * @return current contents of the vlanNextObjStore
226 */
227 ImmutableMap<VlanNextObjectiveStoreKey, Integer> getVlanNextObjStore();
228
229 /**
Ruchi Sahota71bcb4e2019-01-28 01:08:18 +0000230 * Returns the Mac Vlan next objective store.
231 *
232 * @return current contents of the macVlanNextObjStore
233 */
234 ImmutableMap<MacVlanNextObjectiveStoreKey, Integer> getMacVlanNextObjStore();
235
236 /**
Charles Chan0b1dd7e2018-08-19 19:21:46 -0700237 * Returns the port next objective store.
238 *
239 * @return current contents of the portNextObjStore
240 */
241 ImmutableMap<PortNextObjectiveStoreKey, Integer> getPortNextObjStore();
242
243 /**
244 * Returns the associated next ids to the mcast groups or to the single
245 * group if mcastIp is present.
246 *
247 * @param mcastIp the group ip
248 * @return the mapping mcastIp-device to next id
249 */
250 Map<McastStoreKey, Integer> getMcastNextIds(IpAddress mcastIp);
251
252 /**
253 * Returns the PW init next objective store.
254 *
255 * @return current contents of the l2InitiationNextObjStore
256 */
257 ImmutableMap<String, NextObjective> getPwInitNext();
258
259 /**
260 * Returns the PW termination next objective store.
261 *
262 * @return current contents of the l2TerminationNextObjStore
263 */
264 ImmutableMap<String, NextObjective> getPwTermNext();
265
266 /**
267 * Removes all entries in dst/vlan/port/mcast NextObjectiveStore that are associated with the given nextId.
268 *
269 * @param nextId nextId
270 */
271 void invalidateNextObj(int nextId);
Saurav Dasfbe74572017-08-03 18:30:35 -0700272
273 /**
274 * Triggers the verification of all ECMP groups in the specified device.
275 * Adjusts the group buckets if verification finds that there are more or less
276 * buckets than what should be there.
277 *
278 * @param id the device identifier
279 */
280 void verifyGroups(DeviceId id);
Saurav Das6430f412018-01-25 09:49:01 -0800281
282 /**
283 * Returns the internal link state as seen by this instance of the
284 * controller.
285 *
286 * @return the internal link state
287 */
288 ImmutableMap<Link, Boolean> getSeenLinks();
289
290 /**
291 * Returns the ports administratively disabled by the controller.
292 *
293 * @return a map of devices and port numbers for administratively disabled
294 * ports. Does not include ports manually disabled by the operator.
295 */
296 ImmutableMap<DeviceId, Set<PortNumber>> getDownedPortState();
Pier Luigi0f9635b2018-01-15 18:06:43 +0100297
Piere99511d2018-04-19 16:47:06 +0200298 /**
Piere99511d2018-04-19 16:47:06 +0200299 * Returns the associated roles to the mcast groups.
300 *
301 * @param mcastIp the group ip
302 * @param sourcecp the source connect point
303 * @return the mapping mcastIp-device to mcast role
304 */
305 Map<McastRoleStoreKey, McastRole> getMcastRoles(IpAddress mcastIp,
306 ConnectPoint sourcecp);
307
308 /**
Pier71c55772018-04-17 17:25:22 +0200309 * Returns the associated trees to the mcast group.
310 *
311 * @param mcastIp the group ip
312 * @param sourcecp the source connect point
313 * @return the mapping egress point to mcast path
314 */
315 Multimap<ConnectPoint, List<ConnectPoint>> getMcastTrees(IpAddress mcastIp,
316 ConnectPoint sourcecp);
317
Pierdb27b8d2018-04-17 16:29:56 +0200318 /**
319 * Return the leaders of the mcast groups.
320 *
321 * @param mcastIp the group ip
322 * @return the mapping group-node
323 */
324 Map<IpAddress, NodeId> getMcastLeaders(IpAddress mcastIp);
Charles Chanb13e0702018-04-17 18:56:53 -0700325
326 /**
327 * Returns shouldProgram map.
328 *
329 * @return shouldProgram map
330 */
331 Map<Set<DeviceId>, NodeId> getShouldProgram();
332
333 /**
334 * Returns shouldProgram local cache.
335 *
336 * @return shouldProgram local cache
337 */
338 Map<DeviceId, Boolean> getShouldProgramCache();
Charles Chan8d316332018-06-19 20:31:57 -0700339
340 /**
jayakumarthazhath66c9ec12018-10-01 00:51:54 +0530341 * Returns whether instance should program device or not.
342 *
343 * @param deviceId .
344 * @return boolean status saying instance should program device or not.
345 */
346 boolean shouldProgram(DeviceId deviceId);
347
348 /**
Harshada Chaundkar9204f312019-07-02 16:01:24 +0000349 * Returns the mcast filtering obj.
350 *
351 * @return the mapping group-node
352 */
353 Map<DeviceId, List<McastFilteringObjStoreKey>> getMcastFilters();
354
355 /**
Charles Chan12a8a842020-02-14 13:23:57 -0800356 * Determines if routing in the network has been stable in the last
357 * STABILITY_THRESHOLD seconds, by comparing the current time to the last
358 * routing change timestamp.
359 *
360 * @return true if stable
361 */
362 boolean isRoutingStable();
363
364 /**
365 * Invoke hostHandler.init() for given device.
366 *
367 * @param deviceId device ID
368 */
369 void initHost(DeviceId deviceId);
370
371 /**
372 * Invoke routeHandler.init() for given device.
373 *
374 * @param deviceId device ID
375 */
376 void initRoute(DeviceId deviceId);
377
378 /**
Charles Chan8d316332018-06-19 20:31:57 -0700379 * Gets application id.
380 *
381 * @return application id
382 */
383 default ApplicationId appId() {
384 throw new NotImplementedException("appId not implemented");
385 }
386
387 /**
388 * Returns internal VLAN for untagged hosts on given connect point.
389 * <p>
390 * The internal VLAN is either vlan-untagged for an access port,
391 * or vlan-native for a trunk port.
392 *
393 * @param connectPoint connect point
394 * @return internal VLAN or null if both vlan-untagged and vlan-native are undefined
395 */
Charles Chan8d316332018-06-19 20:31:57 -0700396 default VlanId getInternalVlanId(ConnectPoint connectPoint) {
397 throw new NotImplementedException("getInternalVlanId not implemented");
398 }
399
Charles Chan8d316332018-06-19 20:31:57 -0700400 /**
401 * Returns optional pair device ID of given device.
402 *
403 * @param deviceId device ID
404 * @return optional pair device ID. Might be empty if pair device is not configured
405 */
Charles Chan8d316332018-06-19 20:31:57 -0700406 default Optional<DeviceId> getPairDeviceId(DeviceId deviceId) {
407 throw new NotImplementedException("getPairDeviceId not implemented");
408 }
409
Charles Chan8d316332018-06-19 20:31:57 -0700410 /**
411 * Returns optional pair device local port of given device.
412 *
413 * @param deviceId device ID
414 * @return optional pair device ID. Might be empty if pair device is not configured
415 */
Charles Chan8d316332018-06-19 20:31:57 -0700416 default Optional<PortNumber> getPairLocalPort(DeviceId deviceId) {
417 throw new NotImplementedException("getPairLocalPort not implemented");
418 }
Harshada Chaundkar9204f312019-07-02 16:01:24 +0000419
Charles Chan12a8a842020-02-14 13:23:57 -0800420 /**
421 * Returns a set of infrastructure ports on the given device.
422 *
423 * @param deviceId device ID
424 * @return a set of ports that does not have interface configuration
425 */
426 default Set<PortNumber> getInfraPorts(DeviceId deviceId) {
427 throw new NotImplementedException("getInfraPorts not implemented");
428 }
429
430 /**
431 * Returns a set of edge ports on the given device.
432 *
433 * @param deviceId device ID
434 * @return a set of ports that has interface configuration
435 */
436 default Set<PortNumber> getEdgePorts(DeviceId deviceId) {
437 throw new NotImplementedException("getEdgePorts not implemented");
438 }
pierventre30368ab2021-02-24 23:23:22 +0100439
440 /**
441 * Returns a list of edge devices.
442 *
443 * @return list of the edge device ids
444 */
445 List<DeviceId> getEdgeDeviceIds();
sangho27462c62015-05-14 00:39:53 -0700446}