blob: 061e2463b00571ecb1c03b048ea0b24472f8e584 [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;
pierventre4f68ffa2021-03-09 22:52:14 +010022import org.onlab.packet.MacAddress;
Charles Chan8d316332018-06-19 20:31:57 -070023import org.onlab.packet.VlanId;
Pierdb27b8d2018-04-17 16:29:56 +020024import org.onosproject.cluster.NodeId;
Charles Chan8d316332018-06-19 20:31:57 -070025import org.onosproject.core.ApplicationId;
Pier Luigi0f9635b2018-01-15 18:06:43 +010026import org.onosproject.net.ConnectPoint;
Charles Chand7844e52016-10-20 17:02:44 -070027import org.onosproject.net.DeviceId;
Saurav Das6430f412018-01-25 09:49:01 -080028import org.onosproject.net.Link;
29import org.onosproject.net.PortNumber;
Charles Chan0b1dd7e2018-08-19 19:21:46 -070030import org.onosproject.net.flowobjective.NextObjective;
pierventre4f68ffa2021-03-09 22:52:14 +010031import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
Saurav Das261c3002017-06-13 15:35:54 -070032import org.onosproject.segmentrouting.grouphandler.NextNeighbors;
Harshada Chaundkar9204f312019-07-02 16:01:24 +000033import org.onosproject.segmentrouting.mcast.McastFilteringObjStoreKey;
Pier Luigi69f774d2018-02-28 12:10:50 +010034import org.onosproject.segmentrouting.mcast.McastRole;
Piere99511d2018-04-19 16:47:06 +020035import org.onosproject.segmentrouting.mcast.McastRoleStoreKey;
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -070036import org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription;
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080037import org.onosproject.segmentrouting.pwaas.L2Tunnel;
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -070038import org.onosproject.segmentrouting.pwaas.L2TunnelHandler;
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -080039import org.onosproject.segmentrouting.pwaas.L2TunnelPolicy;
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -080040import org.onosproject.segmentrouting.pwaas.L2TunnelDescription;
Saurav Das261c3002017-06-13 15:35:54 -070041import org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey;
Saurav Das62ae6792017-05-15 15:34:25 -070042
43import com.google.common.collect.ImmutableMap;
Piere99511d2018-04-19 16:47:06 +020044import org.onosproject.segmentrouting.mcast.McastStoreKey;
Charles Chan0b1dd7e2018-08-19 19:21:46 -070045import org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey;
46import org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey;
Ruchi Sahota71bcb4e2019-01-28 01:08:18 +000047import org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey;
Charles Chand7844e52016-10-20 17:02:44 -070048
sangho27462c62015-05-14 00:39:53 -070049import java.util.List;
Charles Chand7844e52016-10-20 17:02:44 -070050import java.util.Map;
Charles Chan8d316332018-06-19 20:31:57 -070051import java.util.Optional;
Charles Chand7844e52016-10-20 17:02:44 -070052import java.util.Set;
sangho27462c62015-05-14 00:39:53 -070053
54/**
55 * Segment Routing Service for REST API.
56 */
57public interface SegmentRoutingService {
Charles Chan82ab1932016-01-30 23:22:37 -080058 /**
Charles Chan868c9572018-06-15 18:54:18 -070059 * VLAN cross-connect ACL priority.
Charles Chan8d316332018-06-19 20:31:57 -070060 *
61 * @deprecated in ONOS 1.12. Replaced by {@link org.onosproject.segmentrouting.xconnect.api.XconnectService}
Charles Chan868c9572018-06-15 18:54:18 -070062 */
Charles Chan8d316332018-06-19 20:31:57 -070063 @Deprecated
Charles Chan868c9572018-06-15 18:54:18 -070064 int XCONNECT_ACL_PRIORITY = 60000;
65
66 /**
67 * VLAN cross-connect Bridging priority.
Charles Chan8d316332018-06-19 20:31:57 -070068 *
69 * @deprecated in ONOS 1.12. Replaced by {@link org.onosproject.segmentrouting.xconnect.api.XconnectService}
Charles Chan82ab1932016-01-30 23:22:37 -080070 */
Charles Chan8d316332018-06-19 20:31:57 -070071 @Deprecated
Charles Chan82ab1932016-01-30 23:22:37 -080072 int XCONNECT_PRIORITY = 1000;
73
74 /**
75 * Default flow priority.
76 */
77 int DEFAULT_PRIORITY = 100;
78
79 /**
80 * Minimum IP priority.
81 *
Charles Chand86904c2016-02-18 10:43:46 -080082 * Should < 0 such that priority of /0 will not conflict with lowest
Charles Chan82ab1932016-01-30 23:22:37 -080083 * priority default entries.
84 */
85 int MIN_IP_PRIORITY = 10;
86
87 /**
88 * Subnet flooding flow priority.
89 */
90 int FLOOD_PRIORITY = 5;
91
sangho27462c62015-05-14 00:39:53 -070092 /**
93 * Returns all tunnels.
94 *
95 * @return list of tunnels
96 */
97 List<Tunnel> getTunnels();
98
99 /**
100 * Creates a tunnel.
101 *
102 * @param tunnel tunnel reference to create
sanghobd812f82015-06-29 14:58:47 -0700103 * @return WRONG_PATH if the tunnel path is wrong, ID_EXISTS if the tunnel ID
104 * exists already, TUNNEL_EXISTS if the same tunnel exists, INTERNAL_ERROR
105 * if the tunnel creation failed internally, SUCCESS if the tunnel is created
106 * successfully
sangho27462c62015-05-14 00:39:53 -0700107 */
sanghobd812f82015-06-29 14:58:47 -0700108 TunnelHandler.Result createTunnel(Tunnel tunnel);
sangho27462c62015-05-14 00:39:53 -0700109
110 /**
111 * Returns all policies.
112 *
113 * @return list of policy
114 */
115 List<Policy> getPolicies();
116
117 /**
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700118 * Returns the l2 tunnel descriptions.
119 *
Andreas Pantelopoulosd988c1a2018-03-15 16:56:09 -0700120 * @param pending if true fetch pending pseudowires, else fetch installed
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700121 * @return set of l2 tunnel descriptions.
122 */
Andreas Pantelopoulosd988c1a2018-03-15 16:56:09 -0700123 Set<L2TunnelDescription> getL2TunnelDescriptions(boolean pending);
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700124
125 /**
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700126 * Returns all l2 tunnels of pseudowires.
127 *
128 * @return list of l2 tunnels
129 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800130 List<L2Tunnel> getL2Tunnels();
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700131
132 /**
133 * Returns all l2 policie of pseudowires.
134 *
135 * @return list of l2 policies.
136 */
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800137 List<L2TunnelPolicy> getL2Policies();
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700138
139 /**
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700140 * Removes pseudowire.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700141 *
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800142 * @param pwId The id of the pseudowire.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700143 * @return SUCCESS if operation successful or a descriptive error otherwise.
144 */
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800145 L2TunnelHandler.Result removePseudowire(Integer pwId);
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700146
147 /**
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700148 * Adds a Pseudowire to the system.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700149 *
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800150 * @param tunnel The pseudowire tunnel.
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700151 * @return SUCCESS if operation is successful or a descriptive error otherwise.
152 */
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800153 L2TunnelHandler.Result addPseudowire(L2TunnelDescription tunnel);
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700154
155 /**
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700156 * Adds a set of pseudowires.
157 *
158 *
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700159 * @param l2TunnelDescriptions The pseudowires to add.
160 * @return SUCCESS if ALL pseudowires can be instantiated and are deployed, or a
161 * a descriptive error otherwise, without deploying any pseudowire.
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700162 * @deprecated onos-1.12 use addPseudowire instead
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700163 */
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700164 @Deprecated
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700165 L2TunnelHandler.Result addPseudowiresBulk(List<DefaultL2TunnelDescription> l2TunnelDescriptions);
166
167 /**
sangho27462c62015-05-14 00:39:53 -0700168 * Creates a policy.
169 *
170 * @param policy policy reference to create
sanghobd812f82015-06-29 14:58:47 -0700171 * @return ID_EXISTS if the same policy ID exists,
172 * POLICY_EXISTS if the same policy exists, TUNNEL_NOT_FOUND if the tunnel
173 * does not exists, UNSUPPORTED_TYPE if the policy type is not supported,
174 * SUCCESS if the policy is created successfully.
sangho27462c62015-05-14 00:39:53 -0700175 */
sanghobd812f82015-06-29 14:58:47 -0700176 PolicyHandler.Result createPolicy(Policy policy);
sangho27462c62015-05-14 00:39:53 -0700177
178 /**
179 * Removes a tunnel.
180 *
181 * @param tunnel tunnel reference to remove
sanghobd812f82015-06-29 14:58:47 -0700182 * @return TUNNEL_NOT_FOUND if the tunnel to remove does not exists,
183 * INTERNAL_ERROR if the tunnel creation failed internally, SUCCESS
184 * if the tunnel is created successfully.
sangho27462c62015-05-14 00:39:53 -0700185 */
sanghobd812f82015-06-29 14:58:47 -0700186 TunnelHandler.Result removeTunnel(Tunnel tunnel);
sangho27462c62015-05-14 00:39:53 -0700187
188 /**
189 * Removes a policy.
190 *
191 * @param policy policy reference to remove
sanghobd812f82015-06-29 14:58:47 -0700192 * @return POLICY_NOT_FOUND if the policy to remove does not exists,
193 * SUCCESS if it is removed successfully
sangho27462c62015-05-14 00:39:53 -0700194 */
sanghobd812f82015-06-29 14:58:47 -0700195 PolicyHandler.Result removePolicy(Policy policy);
Saurav Das07c74602016-04-27 18:35:50 -0700196
197 /**
198 * Use current state of the network to repopulate forwarding rules.
199 *
200 */
201 void rerouteNetwork();
Charles Chand7844e52016-10-20 17:02:44 -0700202
203 /**
204 * Returns device-subnet mapping.
205 *
206 * @return device-subnet mapping
207 */
Pier Ventreb6a7f342016-11-26 21:05:22 -0800208 Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap();
Saurav Das62ae6792017-05-15 15:34:25 -0700209
210 /**
211 * Returns the current ECMP shortest path graph in this controller instance.
212 *
213 * @return ECMP shortest path graph
214 */
215 ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg();
216
217 /**
Saurav Das261c3002017-06-13 15:35:54 -0700218 * Returns the destinatiomSet-NextObjective store contents.
Saurav Das62ae6792017-05-15 15:34:25 -0700219 *
Charles Chan0b1dd7e2018-08-19 19:21:46 -0700220 * @return current contents of the dstNextObjStore
Saurav Das62ae6792017-05-15 15:34:25 -0700221 */
Charles Chan0b1dd7e2018-08-19 19:21:46 -0700222 ImmutableMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> getDstNextObjStore();
223
224 /**
225 * Returns the VLAN next objective store.
226 *
227 * @return current contents of the vlanNextObjStore
228 */
229 ImmutableMap<VlanNextObjectiveStoreKey, Integer> getVlanNextObjStore();
230
231 /**
Ruchi Sahota71bcb4e2019-01-28 01:08:18 +0000232 * Returns the Mac Vlan next objective store.
233 *
234 * @return current contents of the macVlanNextObjStore
235 */
236 ImmutableMap<MacVlanNextObjectiveStoreKey, Integer> getMacVlanNextObjStore();
237
238 /**
Charles Chan0b1dd7e2018-08-19 19:21:46 -0700239 * Returns the port next objective store.
240 *
241 * @return current contents of the portNextObjStore
242 */
243 ImmutableMap<PortNextObjectiveStoreKey, Integer> getPortNextObjStore();
244
245 /**
246 * Returns the associated next ids to the mcast groups or to the single
247 * group if mcastIp is present.
248 *
249 * @param mcastIp the group ip
250 * @return the mapping mcastIp-device to next id
251 */
252 Map<McastStoreKey, Integer> getMcastNextIds(IpAddress mcastIp);
253
254 /**
255 * Returns the PW init next objective store.
256 *
257 * @return current contents of the l2InitiationNextObjStore
258 */
259 ImmutableMap<String, NextObjective> getPwInitNext();
260
261 /**
262 * Returns the PW termination next objective store.
263 *
264 * @return current contents of the l2TerminationNextObjStore
265 */
266 ImmutableMap<String, NextObjective> getPwTermNext();
267
268 /**
269 * Removes all entries in dst/vlan/port/mcast NextObjectiveStore that are associated with the given nextId.
270 *
271 * @param nextId nextId
272 */
273 void invalidateNextObj(int nextId);
Saurav Dasfbe74572017-08-03 18:30:35 -0700274
275 /**
276 * Triggers the verification of all ECMP groups in the specified device.
277 * Adjusts the group buckets if verification finds that there are more or less
278 * buckets than what should be there.
279 *
280 * @param id the device identifier
281 */
282 void verifyGroups(DeviceId id);
Saurav Das6430f412018-01-25 09:49:01 -0800283
284 /**
285 * Returns the internal link state as seen by this instance of the
286 * controller.
287 *
288 * @return the internal link state
289 */
290 ImmutableMap<Link, Boolean> getSeenLinks();
291
292 /**
293 * Returns the ports administratively disabled by the controller.
294 *
295 * @return a map of devices and port numbers for administratively disabled
296 * ports. Does not include ports manually disabled by the operator.
297 */
298 ImmutableMap<DeviceId, Set<PortNumber>> getDownedPortState();
Pier Luigi0f9635b2018-01-15 18:06:43 +0100299
Piere99511d2018-04-19 16:47:06 +0200300 /**
Piere99511d2018-04-19 16:47:06 +0200301 * Returns the associated roles to the mcast groups.
302 *
303 * @param mcastIp the group ip
304 * @param sourcecp the source connect point
305 * @return the mapping mcastIp-device to mcast role
306 */
307 Map<McastRoleStoreKey, McastRole> getMcastRoles(IpAddress mcastIp,
308 ConnectPoint sourcecp);
309
310 /**
Pier71c55772018-04-17 17:25:22 +0200311 * Returns the associated trees to the mcast group.
312 *
313 * @param mcastIp the group ip
314 * @param sourcecp the source connect point
315 * @return the mapping egress point to mcast path
316 */
317 Multimap<ConnectPoint, List<ConnectPoint>> getMcastTrees(IpAddress mcastIp,
318 ConnectPoint sourcecp);
319
Pierdb27b8d2018-04-17 16:29:56 +0200320 /**
321 * Return the leaders of the mcast groups.
322 *
323 * @param mcastIp the group ip
324 * @return the mapping group-node
325 */
326 Map<IpAddress, NodeId> getMcastLeaders(IpAddress mcastIp);
Charles Chanb13e0702018-04-17 18:56:53 -0700327
328 /**
329 * Returns shouldProgram map.
330 *
331 * @return shouldProgram map
332 */
333 Map<Set<DeviceId>, NodeId> getShouldProgram();
334
335 /**
336 * Returns shouldProgram local cache.
337 *
338 * @return shouldProgram local cache
339 */
340 Map<DeviceId, Boolean> getShouldProgramCache();
Charles Chan8d316332018-06-19 20:31:57 -0700341
342 /**
jayakumarthazhath66c9ec12018-10-01 00:51:54 +0530343 * Returns whether instance should program device or not.
344 *
345 * @param deviceId .
346 * @return boolean status saying instance should program device or not.
347 */
348 boolean shouldProgram(DeviceId deviceId);
349
350 /**
Harshada Chaundkar9204f312019-07-02 16:01:24 +0000351 * Returns the mcast filtering obj.
352 *
353 * @return the mapping group-node
354 */
355 Map<DeviceId, List<McastFilteringObjStoreKey>> getMcastFilters();
356
357 /**
Charles Chan12a8a842020-02-14 13:23:57 -0800358 * Determines if routing in the network has been stable in the last
359 * STABILITY_THRESHOLD seconds, by comparing the current time to the last
360 * routing change timestamp.
361 *
362 * @return true if stable
363 */
364 boolean isRoutingStable();
365
366 /**
367 * Invoke hostHandler.init() for given device.
368 *
369 * @param deviceId device ID
370 */
371 void initHost(DeviceId deviceId);
372
373 /**
374 * Invoke routeHandler.init() for given device.
375 *
376 * @param deviceId device ID
377 */
378 void initRoute(DeviceId deviceId);
379
380 /**
Charles Chan8d316332018-06-19 20:31:57 -0700381 * Gets application id.
382 *
383 * @return application id
384 */
385 default ApplicationId appId() {
386 throw new NotImplementedException("appId not implemented");
387 }
388
389 /**
390 * Returns internal VLAN for untagged hosts on given connect point.
391 * <p>
392 * The internal VLAN is either vlan-untagged for an access port,
393 * or vlan-native for a trunk port.
394 *
395 * @param connectPoint connect point
396 * @return internal VLAN or null if both vlan-untagged and vlan-native are undefined
397 */
Charles Chan8d316332018-06-19 20:31:57 -0700398 default VlanId getInternalVlanId(ConnectPoint connectPoint) {
399 throw new NotImplementedException("getInternalVlanId not implemented");
400 }
401
Charles Chan8d316332018-06-19 20:31:57 -0700402 /**
403 * Returns optional pair device ID of given device.
404 *
405 * @param deviceId device ID
406 * @return optional pair device ID. Might be empty if pair device is not configured
407 */
Charles Chan8d316332018-06-19 20:31:57 -0700408 default Optional<DeviceId> getPairDeviceId(DeviceId deviceId) {
409 throw new NotImplementedException("getPairDeviceId not implemented");
410 }
411
Charles Chan8d316332018-06-19 20:31:57 -0700412 /**
413 * Returns optional pair device local port of given device.
414 *
415 * @param deviceId device ID
416 * @return optional pair device ID. Might be empty if pair device is not configured
417 */
Charles Chan8d316332018-06-19 20:31:57 -0700418 default Optional<PortNumber> getPairLocalPort(DeviceId deviceId) {
419 throw new NotImplementedException("getPairLocalPort not implemented");
420 }
Harshada Chaundkar9204f312019-07-02 16:01:24 +0000421
Charles Chan12a8a842020-02-14 13:23:57 -0800422 /**
423 * Returns a set of infrastructure ports on the given device.
424 *
425 * @param deviceId device ID
426 * @return a set of ports that does not have interface configuration
427 */
428 default Set<PortNumber> getInfraPorts(DeviceId deviceId) {
429 throw new NotImplementedException("getInfraPorts not implemented");
430 }
431
432 /**
433 * Returns a set of edge ports on the given device.
434 *
435 * @param deviceId device ID
436 * @return a set of ports that has interface configuration
437 */
438 default Set<PortNumber> getEdgePorts(DeviceId deviceId) {
439 throw new NotImplementedException("getEdgePorts not implemented");
440 }
pierventre30368ab2021-02-24 23:23:22 +0100441
442 /**
443 * Returns a list of edge devices.
444 *
445 * @return list of the edge device ids
446 */
447 List<DeviceId> getEdgeDeviceIds();
pierventre4f68ffa2021-03-09 22:52:14 +0100448
449 /**
Charles Chana2401452021-06-03 15:57:48 -0700450 * Returns a list of infra devices.
451 *
452 * @return list of the infra device ids
453 */
454 List<DeviceId> getInfraDeviceIds();
455
456 /**
pierventre4f68ffa2021-03-09 22:52:14 +0100457 * Returns the configured mac address of the device.
458 *
459 * @param deviceId the device id
460 * @return the configured mac address
461 * @throws DeviceConfigNotFoundException if config is not present
462 */
463 MacAddress getDeviceMacAddress(DeviceId deviceId) throws DeviceConfigNotFoundException;
464
465 /**
466 * Returns the VlanId assigned internally by default to unconfigured ports.
467 *
468 * @return the default internal vlan id
469 */
470 VlanId getDefaultInternalVlan();
sangho27462c62015-05-14 00:39:53 -0700471}