blob: 1fdf2aba6a9c576c0a132ec79ca00288c0191a39 [file] [log] [blame]
Saurav Das822c4e22015-10-23 10:51:11 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Saurav Das822c4e22015-10-23 10:51:11 -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 */
Yi Tsengef19de12017-04-24 11:33:05 -070016package org.onosproject.driver.pipeline.ofdpa;
Saurav Das822c4e22015-10-23 10:51:11 -070017
Charles Chan5270ed02016-01-30 23:22:37 -080018import com.google.common.collect.ImmutableList;
Yi Tseng47f82dc2017-03-05 22:48:39 -080019import com.google.common.collect.Sets;
Saurav Das822c4e22015-10-23 10:51:11 -070020import org.onlab.osgi.ServiceDirectory;
Saurav Das822c4e22015-10-23 10:51:11 -070021import org.onlab.packet.Ethernet;
Julia Ferguson65428c32017-08-10 18:15:24 +000022import org.onlab.packet.IpAddress;
Charles Chan14967c22015-12-07 11:11:50 -080023import org.onlab.packet.IpPrefix;
Saurav Das822c4e22015-10-23 10:51:11 -070024import org.onlab.packet.VlanId;
25import org.onlab.util.KryoNamespace;
26import org.onosproject.core.ApplicationId;
27import org.onosproject.core.CoreService;
Charles Chancad338a2016-09-16 18:03:11 -070028import org.onosproject.driver.extensions.Ofdpa3MplsType;
29import org.onosproject.driver.extensions.Ofdpa3SetMplsType;
Charles Chan14967c22015-12-07 11:11:50 -080030import org.onosproject.driver.extensions.OfdpaMatchVlanVid;
31import org.onosproject.driver.extensions.OfdpaSetVlanVid;
Saurav Das822c4e22015-10-23 10:51:11 -070032import org.onosproject.net.DeviceId;
33import org.onosproject.net.Port;
34import org.onosproject.net.PortNumber;
35import org.onosproject.net.behaviour.NextGroup;
36import org.onosproject.net.behaviour.Pipeliner;
37import org.onosproject.net.behaviour.PipelinerContext;
38import org.onosproject.net.device.DeviceService;
39import org.onosproject.net.driver.AbstractHandlerBehaviour;
40import org.onosproject.net.flow.DefaultFlowRule;
41import org.onosproject.net.flow.DefaultTrafficSelector;
42import org.onosproject.net.flow.DefaultTrafficTreatment;
43import org.onosproject.net.flow.FlowRule;
44import org.onosproject.net.flow.FlowRuleOperations;
45import org.onosproject.net.flow.FlowRuleOperationsContext;
46import org.onosproject.net.flow.FlowRuleService;
47import org.onosproject.net.flow.TrafficSelector;
48import org.onosproject.net.flow.TrafficTreatment;
49import org.onosproject.net.flow.criteria.Criteria;
50import org.onosproject.net.flow.criteria.Criterion;
51import org.onosproject.net.flow.criteria.EthCriterion;
52import org.onosproject.net.flow.criteria.EthTypeCriterion;
Charles Chan14967c22015-12-07 11:11:50 -080053import org.onosproject.net.flow.criteria.ExtensionCriterion;
Saurav Das822c4e22015-10-23 10:51:11 -070054import org.onosproject.net.flow.criteria.IPCriterion;
Pier Ventree0ae7a32016-11-23 09:57:42 -080055import org.onosproject.net.flow.criteria.Icmpv6CodeCriterion;
56import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion;
Saurav Das8a0732e2015-11-20 15:27:53 -080057import org.onosproject.net.flow.criteria.MplsBosCriterion;
58import org.onosproject.net.flow.criteria.MplsCriterion;
Saurav Das822c4e22015-10-23 10:51:11 -070059import org.onosproject.net.flow.criteria.PortCriterion;
Charles Chand9e47c62017-10-05 15:17:15 -070060import org.onosproject.net.flow.criteria.TcpPortCriterion;
61import org.onosproject.net.flow.criteria.UdpPortCriterion;
Saurav Das822c4e22015-10-23 10:51:11 -070062import org.onosproject.net.flow.criteria.VlanIdCriterion;
63import org.onosproject.net.flow.instructions.Instruction;
64import org.onosproject.net.flow.instructions.Instructions.OutputInstruction;
65import org.onosproject.net.flow.instructions.L2ModificationInstruction;
Saurav Das8a0732e2015-11-20 15:27:53 -080066import org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType;
Saurav Das822c4e22015-10-23 10:51:11 -070067import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
Charles Chan14967c22015-12-07 11:11:50 -080068import org.onosproject.net.flow.instructions.L3ModificationInstruction;
69import org.onosproject.net.flow.instructions.L3ModificationInstruction.L3SubType;
Saurav Das822c4e22015-10-23 10:51:11 -070070import org.onosproject.net.flowobjective.FilteringObjective;
71import org.onosproject.net.flowobjective.FlowObjectiveStore;
72import org.onosproject.net.flowobjective.ForwardingObjective;
73import org.onosproject.net.flowobjective.NextObjective;
74import org.onosproject.net.flowobjective.Objective;
75import org.onosproject.net.flowobjective.ObjectiveError;
Saurav Das822c4e22015-10-23 10:51:11 -070076import org.onosproject.net.group.DefaultGroupKey;
77import org.onosproject.net.group.Group;
Saurav Das822c4e22015-10-23 10:51:11 -070078import org.onosproject.net.group.GroupKey;
Saurav Das822c4e22015-10-23 10:51:11 -070079import org.onosproject.net.group.GroupService;
Saurav Das822c4e22015-10-23 10:51:11 -070080import org.onosproject.store.serializers.KryoNamespaces;
81import org.slf4j.Logger;
82
Pier Ventree0ae7a32016-11-23 09:57:42 -080083import java.util.ArrayDeque;
84import java.util.ArrayList;
85import java.util.Collection;
86import java.util.Collections;
87import java.util.Deque;
88import java.util.List;
89import java.util.Objects;
Pier Ventree0ae7a32016-11-23 09:57:42 -080090import java.util.concurrent.ScheduledExecutorService;
91import java.util.concurrent.TimeUnit;
92
93import static java.util.concurrent.Executors.newScheduledThreadPool;
Yi Tseng3a77b4f2017-02-06 15:02:17 -080094import static org.onlab.packet.MacAddress.BROADCAST;
Charles Chanb4879a52017-10-20 19:09:16 -070095import static org.onlab.packet.MacAddress.IPV4_MULTICAST;
96import static org.onlab.packet.MacAddress.IPV6_MULTICAST;
Yi Tseng3a77b4f2017-02-06 15:02:17 -080097import static org.onlab.packet.MacAddress.NONE;
Pier Ventree0ae7a32016-11-23 09:57:42 -080098import static org.onlab.util.Tools.groupedThreads;
Yi Tsengef19de12017-04-24 11:33:05 -070099import static org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.*;
Charles Chand9e47c62017-10-05 15:17:15 -0700100import static org.onosproject.net.flow.criteria.Criterion.Type.ETH_TYPE;
Pier Ventree0ae7a32016-11-23 09:57:42 -0800101import static org.slf4j.LoggerFactory.getLogger;
Pier Ventre140a8942016-11-02 07:26:38 -0700102import static org.onosproject.net.flow.criteria.Criterion.Type.MPLS_BOS;
103import static org.onosproject.net.flowobjective.NextObjective.Type.HASHED;
Pier Ventree0ae7a32016-11-23 09:57:42 -0800104
Saurav Das822c4e22015-10-23 10:51:11 -0700105/**
106 * Driver for Broadcom's OF-DPA v2.0 TTP.
Saurav Das822c4e22015-10-23 10:51:11 -0700107 */
Charles Chan361154b2016-03-24 10:23:39 -0700108public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeliner {
Pier Ventre42287df2016-11-09 14:17:26 -0800109
Saurav Das822c4e22015-10-23 10:51:11 -0700110 protected static final int PORT_TABLE = 0;
111 protected static final int VLAN_TABLE = 10;
Pier Ventre42287df2016-11-09 14:17:26 -0800112 protected static final int VLAN_1_TABLE = 11;
113 protected static final int MPLS_L2_PORT_FLOW_TABLE = 13;
114 protected static final int MPLS_L2_PORT_PCP_TRUST_FLOW_TABLE = 16;
Saurav Das822c4e22015-10-23 10:51:11 -0700115 protected static final int TMAC_TABLE = 20;
116 protected static final int UNICAST_ROUTING_TABLE = 30;
117 protected static final int MULTICAST_ROUTING_TABLE = 40;
118 protected static final int MPLS_TABLE_0 = 23;
119 protected static final int MPLS_TABLE_1 = 24;
Pier Ventre140a8942016-11-02 07:26:38 -0700120 protected static final int MPLS_L3_TYPE_TABLE = 27;
121 protected static final int MPLS_TYPE_TABLE = 29;
Saurav Das822c4e22015-10-23 10:51:11 -0700122 protected static final int BRIDGING_TABLE = 50;
123 protected static final int ACL_TABLE = 60;
124 protected static final int MAC_LEARNING_TABLE = 254;
125 protected static final long OFPP_MAX = 0xffffff00L;
126
Saurav Das52025962016-01-28 22:30:01 -0800127 protected static final int HIGHEST_PRIORITY = 0xffff;
Saurav Das2857f382015-11-03 14:39:27 -0800128 protected static final int DEFAULT_PRIORITY = 0x8000;
Saurav Das822c4e22015-10-23 10:51:11 -0700129 protected static final int LOWEST_PRIORITY = 0x0;
130
Pier Ventre42287df2016-11-09 14:17:26 -0800131 protected static final int MPLS_L2_PORT_PRIORITY = 2;
132
133 protected static final int MPLS_TUNNEL_ID_BASE = 0x10000;
134 protected static final int MPLS_TUNNEL_ID_MAX = 0x1FFFF;
135
Pier Ventre70d53ba2016-11-17 22:26:29 -0800136 protected static final int MPLS_UNI_PORT_MAX = 0x0000FFFF;
137
138 protected static final int MPLS_NNI_PORT_BASE = 0x00020000;
139 protected static final int MPLS_NNI_PORT_MAX = 0x0002FFFF;
140
Saurav Das822c4e22015-10-23 10:51:11 -0700141 private final Logger log = getLogger(getClass());
Charles Chan425854b2016-04-11 15:32:12 -0700142 protected ServiceDirectory serviceDirectory;
Saurav Das822c4e22015-10-23 10:51:11 -0700143 protected FlowRuleService flowRuleService;
Charles Chan425854b2016-04-11 15:32:12 -0700144 protected CoreService coreService;
Saurav Das8a0732e2015-11-20 15:27:53 -0800145 protected GroupService groupService;
146 protected FlowObjectiveStore flowObjectiveStore;
Saurav Das822c4e22015-10-23 10:51:11 -0700147 protected DeviceId deviceId;
148 protected ApplicationId driverId;
Saurav Das822c4e22015-10-23 10:51:11 -0700149 protected DeviceService deviceService;
Charles Chan188ebf52015-12-23 00:15:11 -0800150 protected static KryoNamespace appKryo = new KryoNamespace.Builder()
Yi Tsengef19de12017-04-24 11:33:05 -0700151 .register(KryoNamespaces.API)
152 .register(GroupKey.class)
153 .register(DefaultGroupKey.class)
154 .register(OfdpaNextGroup.class)
155 .register(ArrayDeque.class)
156 .build("Ofdpa2Pipeline");
Saurav Das822c4e22015-10-23 10:51:11 -0700157
Charles Chan425854b2016-04-11 15:32:12 -0700158 protected Ofdpa2GroupHandler groupHandler;
Saurav Das822c4e22015-10-23 10:51:11 -0700159
Saurav Das1ce0a7b2016-10-21 14:06:29 -0700160 // flows installations to be retried
161 protected ScheduledExecutorService executorService
162 = newScheduledThreadPool(5, groupedThreads("OfdpaPipeliner", "retry-%d", log));
163 protected static final int MAX_RETRY_ATTEMPTS = 10;
164 protected static final int RETRY_MS = 1000;
Saurav Das4f980082015-11-05 13:39:15 -0800165
Saurav Das822c4e22015-10-23 10:51:11 -0700166 @Override
167 public void init(DeviceId deviceId, PipelinerContext context) {
Saurav Das822c4e22015-10-23 10:51:11 -0700168 this.deviceId = deviceId;
169
Charles Chan425854b2016-04-11 15:32:12 -0700170 serviceDirectory = context.directory();
Saurav Das822c4e22015-10-23 10:51:11 -0700171 coreService = serviceDirectory.get(CoreService.class);
172 flowRuleService = serviceDirectory.get(FlowRuleService.class);
173 groupService = serviceDirectory.get(GroupService.class);
174 flowObjectiveStore = context.store();
Saurav Das822c4e22015-10-23 10:51:11 -0700175 deviceService = serviceDirectory.get(DeviceService.class);
Saurav Das822c4e22015-10-23 10:51:11 -0700176
Charles Chan40132b32017-01-22 00:19:37 -0800177 initDriverId();
178 initGroupHander(context);
Saurav Das822c4e22015-10-23 10:51:11 -0700179
Saurav Das822c4e22015-10-23 10:51:11 -0700180 initializePipeline();
Saurav Das822c4e22015-10-23 10:51:11 -0700181 }
182
Charles Chan40132b32017-01-22 00:19:37 -0800183 protected void initDriverId() {
184 driverId = coreService.registerApplication(
185 "org.onosproject.driver.Ofdpa2Pipeline");
186 }
187
188 protected void initGroupHander(PipelinerContext context) {
189 groupHandler = new Ofdpa2GroupHandler();
190 groupHandler.init(deviceId, context);
191 }
192
Saurav Das822c4e22015-10-23 10:51:11 -0700193 protected void initializePipeline() {
Charles Chan188ebf52015-12-23 00:15:11 -0800194 // OF-DPA does not require initializing the pipeline as it puts default
195 // rules automatically in the hardware. However emulation of OFDPA in
196 // software switches does require table-miss-entries.
Saurav Das822c4e22015-10-23 10:51:11 -0700197 }
198
Charles Chand1172632017-03-15 17:33:09 -0700199 /**
200 * Determines whether this pipeline requires OFDPA match and set VLAN extensions.
201 *
202 * @return true to use the extensions
203 */
204 protected boolean requireVlanExtensions() {
205 return true;
206 }
207
Saurav Das86d13e82017-04-28 17:03:48 -0700208 /**
209 * Determines whether in-port should be matched on in TMAC table rules.
210 *
211 * @return true if match on in-port should be programmed
212 */
213 protected boolean matchInPortTmacTable() {
214 return true;
215 }
216
Charles Chand9e47c62017-10-05 15:17:15 -0700217 /**
218 * Determines whether matching L4 destination port on IPv6 packets is supported in ACL table.
219 *
220 * @return true if matching L4 destination port on IPv6 packets is supported in ACL table.
221 */
222 protected boolean supportIpv6L4Dst() {
223 return true;
224 }
225
Saurav Das822c4e22015-10-23 10:51:11 -0700226 //////////////////////////////////////
227 // Flow Objectives
228 //////////////////////////////////////
229
230 @Override
231 public void filter(FilteringObjective filteringObjective) {
232 if (filteringObjective.type() == FilteringObjective.Type.PERMIT) {
233 processFilter(filteringObjective,
234 filteringObjective.op() == Objective.Operation.ADD,
235 filteringObjective.appId());
236 } else {
237 // Note that packets that don't match the PERMIT filter are
238 // automatically denied. The DENY filter is used to deny packets
239 // that are otherwise permitted by the PERMIT filter.
240 // Use ACL table flow rules here for DENY filtering objectives
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530241 log.warn("filter objective other than PERMIT currently not supported");
Saurav Das822c4e22015-10-23 10:51:11 -0700242 fail(filteringObjective, ObjectiveError.UNSUPPORTED);
243 }
244 }
245
246 @Override
247 public void forward(ForwardingObjective fwd) {
Saurav Das1ce0a7b2016-10-21 14:06:29 -0700248 Collection<FlowRule> rules = processForward(fwd);
Saurav Das25190812016-05-27 13:54:07 -0700249 if (rules == null || rules.isEmpty()) {
250 // Assumes fail message has already been generated to the objective
251 // context. Returning here prevents spurious pass message to be
252 // generated by FlowRule service for empty flowOps.
253 return;
254 }
Saurav Das1ce0a7b2016-10-21 14:06:29 -0700255 sendForward(fwd, rules);
256 }
257
258 protected void sendForward(ForwardingObjective fwd, Collection<FlowRule> rules) {
259 FlowRuleOperations.Builder flowOpsBuilder = FlowRuleOperations.builder();
Saurav Das822c4e22015-10-23 10:51:11 -0700260 switch (fwd.op()) {
Saurav Das1ce0a7b2016-10-21 14:06:29 -0700261 case ADD:
262 rules.stream()
263 .filter(Objects::nonNull)
264 .forEach(flowOpsBuilder::add);
Saurav Dasd2fded02016-12-02 15:43:47 -0800265 log.debug("Applying a add fwd-obj {} to sw:{}", fwd.id(), deviceId);
Saurav Das1ce0a7b2016-10-21 14:06:29 -0700266 break;
267 case REMOVE:
268 rules.stream()
269 .filter(Objects::nonNull)
270 .forEach(flowOpsBuilder::remove);
Pier Ventre42287df2016-11-09 14:17:26 -0800271 log.debug("Deleting a flow rule to sw:{}", deviceId);
Saurav Das1ce0a7b2016-10-21 14:06:29 -0700272 break;
273 default:
274 fail(fwd, ObjectiveError.UNKNOWN);
275 log.warn("Unknown forwarding type {}", fwd.op());
Saurav Das822c4e22015-10-23 10:51:11 -0700276 }
277
Saurav Das822c4e22015-10-23 10:51:11 -0700278 flowRuleService.apply(flowOpsBuilder.build(new FlowRuleOperationsContext() {
279 @Override
280 public void onSuccess(FlowRuleOperations ops) {
281 pass(fwd);
282 }
283
284 @Override
285 public void onError(FlowRuleOperations ops) {
286 fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED);
287 }
288 }));
Saurav Das822c4e22015-10-23 10:51:11 -0700289 }
290
291 @Override
292 public void next(NextObjective nextObjective) {
Saurav Das8a0732e2015-11-20 15:27:53 -0800293 NextGroup nextGroup = flowObjectiveStore.getNextGroup(nextObjective.id());
294 switch (nextObjective.op()) {
295 case ADD:
Saurav Das4f980082015-11-05 13:39:15 -0800296 if (nextGroup != null) {
Saurav Das8a0732e2015-11-20 15:27:53 -0800297 log.warn("Cannot add next {} that already exists in device {}",
298 nextObjective.id(), deviceId);
299 return;
300 }
Saurav Das1547b3f2017-05-05 17:01:08 -0700301 log.debug("Processing NextObjective id {} in dev {} - add group",
Saurav Das8a0732e2015-11-20 15:27:53 -0800302 nextObjective.id(), deviceId);
Charles Chan425854b2016-04-11 15:32:12 -0700303 groupHandler.addGroup(nextObjective);
Saurav Das8a0732e2015-11-20 15:27:53 -0800304 break;
305 case ADD_TO_EXISTING:
306 if (nextGroup != null) {
Saurav Das1547b3f2017-05-05 17:01:08 -0700307 log.debug("Processing NextObjective id {} in dev {} - add bucket",
Saurav Das8a0732e2015-11-20 15:27:53 -0800308 nextObjective.id(), deviceId);
Charles Chan425854b2016-04-11 15:32:12 -0700309 groupHandler.addBucketToGroup(nextObjective, nextGroup);
Saurav Das4f980082015-11-05 13:39:15 -0800310 } else {
Saurav Das8a0732e2015-11-20 15:27:53 -0800311 // it is possible that group-chain has not been fully created yet
Saurav Das423fe2b2015-12-04 10:52:59 -0800312 log.debug("Waiting to add bucket to group for next-id:{} in dev:{}",
313 nextObjective.id(), deviceId);
Yi Tseng47f82dc2017-03-05 22:48:39 -0800314
315 // by design multiple pending bucket is allowed for the group
316 groupHandler.pendingBuckets.compute(nextObjective.id(), (nextId, pendBkts) -> {
317 if (pendBkts == null) {
318 pendBkts = Sets.newHashSet();
319 }
320 pendBkts.add(nextObjective);
321 return pendBkts;
322 });
Saurav Das4f980082015-11-05 13:39:15 -0800323 }
Saurav Das8a0732e2015-11-20 15:27:53 -0800324 break;
325 case REMOVE:
326 if (nextGroup == null) {
327 log.warn("Cannot remove next {} that does not exist in device {}",
328 nextObjective.id(), deviceId);
329 return;
330 }
Saurav Das1547b3f2017-05-05 17:01:08 -0700331 log.debug("Processing NextObjective id {} in dev {} - remove group",
Saurav Das8a0732e2015-11-20 15:27:53 -0800332 nextObjective.id(), deviceId);
Charles Chan425854b2016-04-11 15:32:12 -0700333 groupHandler.removeGroup(nextObjective, nextGroup);
Saurav Das8a0732e2015-11-20 15:27:53 -0800334 break;
335 case REMOVE_FROM_EXISTING:
336 if (nextGroup == null) {
337 log.warn("Cannot remove from next {} that does not exist in device {}",
338 nextObjective.id(), deviceId);
339 return;
340 }
Saurav Das1547b3f2017-05-05 17:01:08 -0700341 log.debug("Processing NextObjective id {} in dev {} - remove bucket",
Saurav Das8a0732e2015-11-20 15:27:53 -0800342 nextObjective.id(), deviceId);
Charles Chan425854b2016-04-11 15:32:12 -0700343 groupHandler.removeBucketFromGroup(nextObjective, nextGroup);
Saurav Das8a0732e2015-11-20 15:27:53 -0800344 break;
Saurav Dasceccf242017-08-03 18:30:35 -0700345 case VERIFY:
346 if (nextGroup == null) {
347 log.warn("Cannot verify next {} that does not exist in device {}",
348 nextObjective.id(), deviceId);
349 return;
350 }
351 log.debug("Processing NextObjective id {} in dev {} - verify",
352 nextObjective.id(), deviceId);
353 groupHandler.verifyGroup(nextObjective, nextGroup);
354 break;
Saurav Das8a0732e2015-11-20 15:27:53 -0800355 default:
Saurav Das4f980082015-11-05 13:39:15 -0800356 log.warn("Unsupported operation {}", nextObjective.op());
Saurav Das822c4e22015-10-23 10:51:11 -0700357 }
358 }
359
360 //////////////////////////////////////
361 // Flow handling
362 //////////////////////////////////////
363
364 /**
Yi Tseng0fdc07e2017-04-24 19:17:08 -0700365 * As per OFDPA 2.0 TTP, filtering of VLAN ids and MAC addresses (for routing)
366 * configured on switch ports happen in different tables.
Saurav Das822c4e22015-10-23 10:51:11 -0700367 *
368 * @param filt the filtering objective
369 * @param install indicates whether to add or remove the objective
370 * @param applicationId the application that sent this objective
371 */
Saurav Das52025962016-01-28 22:30:01 -0800372 protected void processFilter(FilteringObjective filt,
373 boolean install, ApplicationId applicationId) {
Saurav Das822c4e22015-10-23 10:51:11 -0700374 // This driver only processes filtering criteria defined with switch
375 // ports as the key
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530376 PortCriterion portCriterion = null;
Saurav Das822c4e22015-10-23 10:51:11 -0700377 EthCriterion ethCriterion = null;
378 VlanIdCriterion vidCriterion = null;
Saurav Das822c4e22015-10-23 10:51:11 -0700379 if (!filt.key().equals(Criteria.dummy()) &&
380 filt.key().type() == Criterion.Type.IN_PORT) {
381 portCriterion = (PortCriterion) filt.key();
Saurav Das822c4e22015-10-23 10:51:11 -0700382 }
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530383 if (portCriterion == null) {
384 log.debug("No IN_PORT defined in filtering objective from app: {}",
385 applicationId);
386 } else {
387 log.debug("Received filtering objective for dev/port: {}/{}", deviceId,
388 portCriterion.port());
389 }
Saurav Das822c4e22015-10-23 10:51:11 -0700390 // convert filtering conditions for switch-intfs into flowrules
391 FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
392 for (Criterion criterion : filt.conditions()) {
Yi Tseng0fdc07e2017-04-24 19:17:08 -0700393 switch (criterion.type()) {
394 case ETH_DST:
395 case ETH_DST_MASKED:
396 ethCriterion = (EthCriterion) criterion;
397 break;
398 case VLAN_VID:
399 vidCriterion = (VlanIdCriterion) criterion;
400 break;
401 default:
402 log.warn("Unsupported filter {}", criterion);
403 fail(filt, ObjectiveError.UNSUPPORTED);
404 return;
Saurav Das822c4e22015-10-23 10:51:11 -0700405 }
406 }
407
Saurav Das0e99e2b2015-10-28 12:39:42 -0700408 VlanId assignedVlan = null;
Charles Chane849c192016-01-11 18:28:54 -0800409 if (vidCriterion != null) {
Charles Chand55e84d2016-03-30 17:54:24 -0700410 // Use the VLAN in metadata whenever a metadata is provided
411 if (filt.meta() != null) {
412 assignedVlan = readVlanFromTreatment(filt.meta());
413 // Use the VLAN in criterion if metadata is not present and the traffic is tagged
414 } else if (!vidCriterion.vlanId().equals(VlanId.NONE)) {
Charles Chane849c192016-01-11 18:28:54 -0800415 assignedVlan = vidCriterion.vlanId();
Charles Chand55e84d2016-03-30 17:54:24 -0700416 }
Charles Chane849c192016-01-11 18:28:54 -0800417
Charles Chand55e84d2016-03-30 17:54:24 -0700418 if (assignedVlan == null) {
419 log.error("Driver fails to extract VLAN information. "
Frank Wangd8ab0962017-08-11 11:09:30 +0800420 + "Not processing VLAN filters on device {}.", deviceId);
Charles Chand55e84d2016-03-30 17:54:24 -0700421 log.debug("VLAN ID in criterion={}, metadata={}",
422 readVlanFromTreatment(filt.meta()), vidCriterion.vlanId());
423 fail(filt, ObjectiveError.BADPARAMS);
424 return;
Saurav Das0e99e2b2015-10-28 12:39:42 -0700425 }
426 }
427
Yi Tseng3a77b4f2017-02-06 15:02:17 -0800428 if (ethCriterion == null || ethCriterion.mac().equals(NONE)) {
Charles Chan985b12e2016-05-11 19:47:22 -0700429 // NOTE: it is possible that a filtering objective only has vidCriterion
Saurav Das961beb22017-03-29 19:09:17 -0700430 log.warn("filtering objective missing dstMac, cannot program TMAC table");
Saurav Das822c4e22015-10-23 10:51:11 -0700431 } else {
432 for (FlowRule tmacRule : processEthDstFilter(portCriterion, ethCriterion,
Saurav Das0e99e2b2015-10-28 12:39:42 -0700433 vidCriterion, assignedVlan,
434 applicationId)) {
Saurav Das961beb22017-03-29 19:09:17 -0700435 log.trace("{} MAC filtering rules in TMAC table: {} for dev: {}",
Saurav Das018605f2017-02-18 14:05:44 -0800436 (install) ? "adding" : "removing", tmacRule, deviceId);
Saurav Das822c4e22015-10-23 10:51:11 -0700437 ops = install ? ops.add(tmacRule) : ops.remove(tmacRule);
438 }
439 }
440
Charles Chan985b12e2016-05-11 19:47:22 -0700441 if (vidCriterion == null) {
442 // NOTE: it is possible that a filtering objective only has ethCriterion
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530443 log.info("filtering objective missing VLAN, cannot program VLAN Table");
Saurav Das822c4e22015-10-23 10:51:11 -0700444 } else {
Charles Chan14967c22015-12-07 11:11:50 -0800445 /*
446 * NOTE: Separate vlan filtering rules and assignment rules
447 * into different stage in order to guarantee that filtering rules
Saurav Das52025962016-01-28 22:30:01 -0800448 * always go first, as required by ofdpa.
Charles Chan14967c22015-12-07 11:11:50 -0800449 */
450 List<FlowRule> allRules = processVlanIdFilter(
451 portCriterion, vidCriterion, assignedVlan, applicationId);
452 List<FlowRule> filteringRules = new ArrayList<>();
453 List<FlowRule> assignmentRules = new ArrayList<>();
454
455 allRules.forEach(flowRule -> {
Charles Chand1172632017-03-15 17:33:09 -0700456 VlanId vlanId;
457 if (requireVlanExtensions()) {
458 ExtensionCriterion extCriterion =
459 (ExtensionCriterion) flowRule.selector().getCriterion(Criterion.Type.EXTENSION);
460 vlanId = ((OfdpaMatchVlanVid) extCriterion.extensionSelector()).vlanId();
461 } else {
462 VlanIdCriterion vlanIdCriterion =
463 (VlanIdCriterion) flowRule.selector().getCriterion(Criterion.Type.VLAN_VID);
464 vlanId = vlanIdCriterion.vlanId();
465 }
Charles Chanbe8aea42016-02-24 12:04:47 -0800466 if (!vlanId.equals(VlanId.NONE)) {
Charles Chan14967c22015-12-07 11:11:50 -0800467 filteringRules.add(flowRule);
468 } else {
469 assignmentRules.add(flowRule);
470 }
471 });
472
473 for (FlowRule filteringRule : filteringRules) {
Saurav Das961beb22017-03-29 19:09:17 -0700474 log.trace("{} VLAN filtering rule in VLAN table: {} for dev: {}",
Saurav Das018605f2017-02-18 14:05:44 -0800475 (install) ? "adding" : "removing", filteringRule, deviceId);
Charles Chan14967c22015-12-07 11:11:50 -0800476 ops = install ? ops.add(filteringRule) : ops.remove(filteringRule);
477 }
478
479 ops.newStage();
480
481 for (FlowRule assignmentRule : assignmentRules) {
Saurav Das961beb22017-03-29 19:09:17 -0700482 log.trace("{} VLAN assignment rule in VLAN table: {} for dev: {}",
Saurav Das018605f2017-02-18 14:05:44 -0800483 (install) ? "adding" : "removing", assignmentRule, deviceId);
Charles Chan14967c22015-12-07 11:11:50 -0800484 ops = install ? ops.add(assignmentRule) : ops.remove(assignmentRule);
Saurav Das822c4e22015-10-23 10:51:11 -0700485 }
486 }
487
Saurav Das822c4e22015-10-23 10:51:11 -0700488 // apply filtering flow rules
489 flowRuleService.apply(ops.build(new FlowRuleOperationsContext() {
490 @Override
491 public void onSuccess(FlowRuleOperations ops) {
Saurav Das018605f2017-02-18 14:05:44 -0800492 log.debug("Applied {} filtering rules in device {}",
Saurav Das822c4e22015-10-23 10:51:11 -0700493 ops.stages().get(0).size(), deviceId);
494 pass(filt);
495 }
496
497 @Override
498 public void onError(FlowRuleOperations ops) {
499 log.info("Failed to apply all filtering rules in dev {}", deviceId);
500 fail(filt, ObjectiveError.FLOWINSTALLATIONFAILED);
501 }
502 }));
503
504 }
505
506 /**
Charles Chand1172632017-03-15 17:33:09 -0700507 * Internal implementation of processVlanIdFilter.
508 * <p>
509 * The is_present bit in set_vlan_vid action is required to be 0 in OFDPA i12.
510 * Since it is non-OF spec, we need an extension treatment for that.
511 * The useVlanExtension must be set to false for OFDPA i12.
512 * </p>
Saurav Das0e99e2b2015-10-28 12:39:42 -0700513 *
Charles Chanf9e98652016-09-07 16:54:23 -0700514 * @param portCriterion port on device for which this filter is programmed
515 * @param vidCriterion vlan assigned to port, or NONE for untagged
516 * @param assignedVlan assigned vlan-id for untagged packets
517 * @param applicationId for application programming this filter
Saurav Das822c4e22015-10-23 10:51:11 -0700518 * @return list of FlowRule for port-vlan filters
519 */
520 protected List<FlowRule> processVlanIdFilter(PortCriterion portCriterion,
Yi Tsengef19de12017-04-24 11:33:05 -0700521 VlanIdCriterion vidCriterion,
522 VlanId assignedVlan,
523 ApplicationId applicationId) {
Charles Chan14967c22015-12-07 11:11:50 -0800524 List<FlowRule> rules = new ArrayList<>();
Saurav Das822c4e22015-10-23 10:51:11 -0700525 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
526 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
Charles Chan14967c22015-12-07 11:11:50 -0800527 TrafficSelector.Builder preSelector = null;
528 TrafficTreatment.Builder preTreatment = null;
529
Saurav Das4f980082015-11-05 13:39:15 -0800530 treatment.transition(TMAC_TABLE);
531
Saurav Das822c4e22015-10-23 10:51:11 -0700532 if (vidCriterion.vlanId() == VlanId.NONE) {
533 // untagged packets are assigned vlans
Charles Chand1172632017-03-15 17:33:09 -0700534 preSelector = DefaultTrafficSelector.builder();
535 if (requireVlanExtensions()) {
536 OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(VlanId.NONE);
537 selector.extension(ofdpaMatchVlanVid, deviceId);
Charles Chanf9e98652016-09-07 16:54:23 -0700538 OfdpaSetVlanVid ofdpaSetVlanVid = new OfdpaSetVlanVid(assignedVlan);
539 treatment.extension(ofdpaSetVlanVid, deviceId);
Charles Chand1172632017-03-15 17:33:09 -0700540
541 OfdpaMatchVlanVid preOfdpaMatchVlanVid = new OfdpaMatchVlanVid(assignedVlan);
542 preSelector.extension(preOfdpaMatchVlanVid, deviceId);
Charles Chanf9e98652016-09-07 16:54:23 -0700543 } else {
Charles Chand1172632017-03-15 17:33:09 -0700544 selector.matchVlanId(VlanId.NONE);
Charles Chanf9e98652016-09-07 16:54:23 -0700545 treatment.setVlanId(assignedVlan);
Charles Chand1172632017-03-15 17:33:09 -0700546
547 preSelector.matchVlanId(assignedVlan);
548 }
549 preTreatment = DefaultTrafficTreatment.builder().transition(TMAC_TABLE);
550 } else {
551 if (requireVlanExtensions()) {
552 OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(vidCriterion.vlanId());
553 selector.extension(ofdpaMatchVlanVid, deviceId);
554 } else {
555 selector.matchVlanId(vidCriterion.vlanId());
Charles Chanf9e98652016-09-07 16:54:23 -0700556 }
Charles Chan14967c22015-12-07 11:11:50 -0800557
Charles Chand55e84d2016-03-30 17:54:24 -0700558 if (!assignedVlan.equals(vidCriterion.vlanId())) {
Charles Chand1172632017-03-15 17:33:09 -0700559 if (requireVlanExtensions()) {
Charles Chanc03782d2017-01-31 13:57:55 -0800560 OfdpaSetVlanVid ofdpaSetVlanVid = new OfdpaSetVlanVid(assignedVlan);
561 treatment.extension(ofdpaSetVlanVid, deviceId);
562 } else {
563 treatment.setVlanId(assignedVlan);
564 }
Charles Chand55e84d2016-03-30 17:54:24 -0700565 }
Saurav Das822c4e22015-10-23 10:51:11 -0700566 }
Saurav Das822c4e22015-10-23 10:51:11 -0700567
568 // ofdpa cannot match on ALL portnumber, so we need to use separate
569 // rules for each port.
Charles Chan14967c22015-12-07 11:11:50 -0800570 List<PortNumber> portnums = new ArrayList<>();
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530571 if (portCriterion != null) {
572 if (PortNumber.ALL.equals(portCriterion.port())) {
573 for (Port port : deviceService.getPorts(deviceId)) {
574 if (port.number().toLong() > 0 && port.number().toLong() < OFPP_MAX) {
575 portnums.add(port.number());
576 }
Saurav Das822c4e22015-10-23 10:51:11 -0700577 }
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530578 } else {
579 portnums.add(portCriterion.port());
Saurav Das822c4e22015-10-23 10:51:11 -0700580 }
581 } else {
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530582 log.warn("Filtering Objective missing Port Criterion . " +
583 "VLAN Table cannot be programmed for {}",
584 deviceId);
Saurav Das822c4e22015-10-23 10:51:11 -0700585 }
Saurav Das4f980082015-11-05 13:39:15 -0800586
Saurav Das822c4e22015-10-23 10:51:11 -0700587 for (PortNumber pnum : portnums) {
Saurav Das4f980082015-11-05 13:39:15 -0800588 // create rest of flowrule
Saurav Das822c4e22015-10-23 10:51:11 -0700589 selector.matchInPort(pnum);
590 FlowRule rule = DefaultFlowRule.builder()
591 .forDevice(deviceId)
592 .withSelector(selector.build())
593 .withTreatment(treatment.build())
594 .withPriority(DEFAULT_PRIORITY)
595 .fromApp(applicationId)
596 .makePermanent()
597 .forTable(VLAN_TABLE).build();
Charles Chan14967c22015-12-07 11:11:50 -0800598
599 if (preSelector != null) {
600 preSelector.matchInPort(pnum);
601 FlowRule preRule = DefaultFlowRule.builder()
602 .forDevice(deviceId)
603 .withSelector(preSelector.build())
604 .withTreatment(preTreatment.build())
605 .withPriority(DEFAULT_PRIORITY)
606 .fromApp(applicationId)
607 .makePermanent()
608 .forTable(VLAN_TABLE).build();
609 rules.add(preRule);
610 }
611
Saurav Das822c4e22015-10-23 10:51:11 -0700612 rules.add(rule);
613 }
614 return rules;
615 }
616
617 /**
618 * Allows routed packets with correct destination MAC to be directed
619 * to unicast-IP routing table or MPLS forwarding table.
Saurav Das822c4e22015-10-23 10:51:11 -0700620 *
621 * @param portCriterion port on device for which this filter is programmed
622 * @param ethCriterion dstMac of device for which is filter is programmed
623 * @param vidCriterion vlan assigned to port, or NONE for untagged
Saurav Das0e99e2b2015-10-28 12:39:42 -0700624 * @param assignedVlan assigned vlan-id for untagged packets
Saurav Das822c4e22015-10-23 10:51:11 -0700625 * @param applicationId for application programming this filter
626 * @return list of FlowRule for port-vlan filters
627
628 */
629 protected List<FlowRule> processEthDstFilter(PortCriterion portCriterion,
630 EthCriterion ethCriterion,
631 VlanIdCriterion vidCriterion,
Saurav Das0e99e2b2015-10-28 12:39:42 -0700632 VlanId assignedVlan,
Saurav Das822c4e22015-10-23 10:51:11 -0700633 ApplicationId applicationId) {
Charles Chan5270ed02016-01-30 23:22:37 -0800634 // Consider PortNumber.ANY as wildcard. Match ETH_DST only
Sivachidambaram Subramanianc598d062017-05-16 22:42:06 +0530635 if (portCriterion != null && PortNumber.ANY.equals(portCriterion.port())) {
Charles Chan5270ed02016-01-30 23:22:37 -0800636 return processEthDstOnlyFilter(ethCriterion, applicationId);
637 }
638
Charles Chan5b9df8d2016-03-28 22:21:40 -0700639 // Multicast MAC
640 if (ethCriterion.mask() != null) {
Charles Chanb4879a52017-10-20 19:09:16 -0700641 return processMcastEthDstFilter(ethCriterion, assignedVlan, applicationId);
Charles Chan5b9df8d2016-03-28 22:21:40 -0700642 }
643
Saurav Das822c4e22015-10-23 10:51:11 -0700644 //handling untagged packets via assigned VLAN
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530645 if (vidCriterion != null && vidCriterion.vlanId() == VlanId.NONE) {
Saurav Das0e99e2b2015-10-28 12:39:42 -0700646 vidCriterion = (VlanIdCriterion) Criteria.matchVlanId(assignedVlan);
Saurav Das822c4e22015-10-23 10:51:11 -0700647 }
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530648 List<FlowRule> rules = new ArrayList<>();
649 OfdpaMatchVlanVid ofdpaMatchVlanVid = null;
650 if (vidCriterion != null && requireVlanExtensions()) {
651 ofdpaMatchVlanVid = new OfdpaMatchVlanVid(vidCriterion.vlanId());
652 }
Saurav Das822c4e22015-10-23 10:51:11 -0700653 // ofdpa cannot match on ALL portnumber, so we need to use separate
654 // rules for each port.
Yuta HIGUCHI2dce08a2017-04-20 21:57:48 -0700655 List<PortNumber> portnums = new ArrayList<>();
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530656 if (portCriterion != null) {
657 if (PortNumber.ALL.equals(portCriterion.port())) {
658 for (Port port : deviceService.getPorts(deviceId)) {
659 if (port.number().toLong() > 0 && port.number().toLong() < OFPP_MAX) {
660 portnums.add(port.number());
661 }
Saurav Das822c4e22015-10-23 10:51:11 -0700662 }
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530663 } else {
664 portnums.add(portCriterion.port());
665 }
666 for (PortNumber pnum : portnums) {
667 rules.add(buildTmacRuleForIpv4(ethCriterion,
668 vidCriterion,
669 ofdpaMatchVlanVid,
670 applicationId,
671 pnum));
672 rules.add(buildTmacRuleForMpls(ethCriterion,
673 vidCriterion,
674 ofdpaMatchVlanVid,
675 applicationId,
676 pnum));
677 rules.add(buildTmacRuleForIpv6(ethCriterion,
678 vidCriterion,
679 ofdpaMatchVlanVid,
680 applicationId,
681 pnum));
Saurav Das822c4e22015-10-23 10:51:11 -0700682 }
683 } else {
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530684 rules.add(buildTmacRuleForIpv4(ethCriterion,
685 vidCriterion,
686 ofdpaMatchVlanVid,
687 applicationId,
688 null));
689 rules.add(buildTmacRuleForMpls(ethCriterion,
690 vidCriterion,
691 ofdpaMatchVlanVid,
692 applicationId,
693 null));
694 rules.add(buildTmacRuleForIpv6(ethCriterion,
695 vidCriterion,
696 ofdpaMatchVlanVid,
697 applicationId,
698 null));
Saurav Das822c4e22015-10-23 10:51:11 -0700699 }
700 return rules;
701 }
702
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530703 /**
704 * Builds TMAC rules for IPv4 packets.
705 *
706 * @param ethCriterion
707 * @param vidCriterion
708 * @param ofdpaMatchVlanVid
709 * @param applicationId
710 * @param pnum
711 * @return TMAC rule for IPV4 packets
712 */
713 private FlowRule buildTmacRuleForIpv4(EthCriterion ethCriterion,
714 VlanIdCriterion vidCriterion,
715 OfdpaMatchVlanVid ofdpaMatchVlanVid,
716 ApplicationId applicationId,
717 PortNumber pnum) {
718 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
719 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
720 if (pnum != null) {
721 if (matchInPortTmacTable()) {
722 selector.matchInPort(pnum);
723 } else {
Saurav Dasf14d9ef2017-12-05 15:00:23 -0800724 log.debug("Pipeline does not support IN_PORT matching in TMAC table, " +
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530725 "ignoring the IN_PORT criteria");
726 }
727 }
728 if (vidCriterion != null) {
729 if (requireVlanExtensions()) {
730 selector.extension(ofdpaMatchVlanVid, deviceId);
731 } else {
732 selector.matchVlanId(vidCriterion.vlanId());
733 }
734 }
735 selector.matchEthType(Ethernet.TYPE_IPV4);
736 selector.matchEthDst(ethCriterion.mac());
737 treatment.transition(UNICAST_ROUTING_TABLE);
738 return DefaultFlowRule.builder()
739 .forDevice(deviceId)
740 .withSelector(selector.build())
741 .withTreatment(treatment.build())
742 .withPriority(DEFAULT_PRIORITY)
743 .fromApp(applicationId)
744 .makePermanent()
745 .forTable(TMAC_TABLE).build();
746 }
747
748 /**
749 * Builds TMAC rule for MPLS packets.
750 *
751 * @param ethCriterion
752 * @param vidCriterion
753 * @param ofdpaMatchVlanVid
754 * @param applicationId
755 * @param pnum
756 * @return TMAC rule for MPLS packets
757 */
758 private FlowRule buildTmacRuleForMpls(EthCriterion ethCriterion,
759 VlanIdCriterion vidCriterion,
760 OfdpaMatchVlanVid ofdpaMatchVlanVid,
761 ApplicationId applicationId,
762 PortNumber pnum) {
763 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
764 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
765 if (pnum != null) {
766 if (matchInPortTmacTable()) {
767 selector.matchInPort(pnum);
768 } else {
Saurav Dasf14d9ef2017-12-05 15:00:23 -0800769 log.debug("Pipeline does not support IN_PORT matching in TMAC table, " +
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530770 "ignoring the IN_PORT criteria");
771 }
772 }
773 if (vidCriterion != null) {
774 if (requireVlanExtensions()) {
775 selector.extension(ofdpaMatchVlanVid, deviceId);
776 } else {
777 selector.matchVlanId(vidCriterion.vlanId());
778 }
779 }
780 selector.matchEthType(Ethernet.MPLS_UNICAST);
781 selector.matchEthDst(ethCriterion.mac());
782 treatment.transition(MPLS_TABLE_0);
783 return DefaultFlowRule.builder()
784 .forDevice(deviceId)
785 .withSelector(selector.build())
786 .withTreatment(treatment.build())
787 .withPriority(DEFAULT_PRIORITY)
788 .fromApp(applicationId)
789 .makePermanent()
790 .forTable(TMAC_TABLE).build();
791 }
792
793 /**
794 * Builds TMAC rules for IPv6 packets.
795 *
796 * @param ethCriterion
797 * @param vidCriterion
798 * @param ofdpaMatchVlanVid
799 * @param applicationId
800 * @param pnum
801 * @return TMAC rule for IPV6 packets
802 */
803 private FlowRule buildTmacRuleForIpv6(EthCriterion ethCriterion,
804 VlanIdCriterion vidCriterion,
805 OfdpaMatchVlanVid ofdpaMatchVlanVid,
806 ApplicationId applicationId,
807 PortNumber pnum) {
808 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
809 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
810 if (pnum != null) {
811 if (matchInPortTmacTable()) {
812 selector.matchInPort(pnum);
813 } else {
Saurav Dasf14d9ef2017-12-05 15:00:23 -0800814 log.debug("Pipeline does not support IN_PORT matching in TMAC table, " +
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530815 "ignoring the IN_PORT criteria");
816 }
817 }
818 if (vidCriterion != null) {
819 if (requireVlanExtensions()) {
820 selector.extension(ofdpaMatchVlanVid, deviceId);
821 } else {
822 selector.matchVlanId(vidCriterion.vlanId());
823 }
824 }
825 selector.matchEthType(Ethernet.TYPE_IPV6);
826 selector.matchEthDst(ethCriterion.mac());
827 treatment.transition(UNICAST_ROUTING_TABLE);
828 return DefaultFlowRule.builder()
829 .forDevice(deviceId)
830 .withSelector(selector.build())
831 .withTreatment(treatment.build())
832 .withPriority(DEFAULT_PRIORITY)
833 .fromApp(applicationId)
834 .makePermanent()
835 .forTable(TMAC_TABLE).build();
836 }
837
Charles Chan5270ed02016-01-30 23:22:37 -0800838 protected List<FlowRule> processEthDstOnlyFilter(EthCriterion ethCriterion,
Yi Tsengef19de12017-04-24 11:33:05 -0700839 ApplicationId applicationId) {
Pier Luigi0e358632017-01-31 09:35:05 -0800840 ImmutableList.Builder<FlowRule> builder = ImmutableList.builder();
841
Charles Chan5270ed02016-01-30 23:22:37 -0800842 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
843 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
844 selector.matchEthType(Ethernet.TYPE_IPV4);
845 selector.matchEthDst(ethCriterion.mac());
846 treatment.transition(UNICAST_ROUTING_TABLE);
847 FlowRule rule = DefaultFlowRule.builder()
848 .forDevice(deviceId)
849 .withSelector(selector.build())
850 .withTreatment(treatment.build())
851 .withPriority(DEFAULT_PRIORITY)
852 .fromApp(applicationId)
853 .makePermanent()
854 .forTable(TMAC_TABLE).build();
Pier Luigi0e358632017-01-31 09:35:05 -0800855 builder.add(rule);
856
857 selector = DefaultTrafficSelector.builder();
858 treatment = DefaultTrafficTreatment.builder();
859 selector.matchEthType(Ethernet.TYPE_IPV6);
860 selector.matchEthDst(ethCriterion.mac());
861 treatment.transition(UNICAST_ROUTING_TABLE);
862 rule = DefaultFlowRule.builder()
863 .forDevice(deviceId)
864 .withSelector(selector.build())
865 .withTreatment(treatment.build())
866 .withPriority(DEFAULT_PRIORITY)
867 .fromApp(applicationId)
868 .makePermanent()
869 .forTable(TMAC_TABLE).build();
870 return builder.add(rule).build();
Charles Chan5270ed02016-01-30 23:22:37 -0800871 }
872
Charles Chan5b9df8d2016-03-28 22:21:40 -0700873 protected List<FlowRule> processMcastEthDstFilter(EthCriterion ethCriterion,
Charles Chanb4879a52017-10-20 19:09:16 -0700874 VlanId assignedVlan,
Yi Tsengef19de12017-04-24 11:33:05 -0700875 ApplicationId applicationId) {
Julia Ferguson65428c32017-08-10 18:15:24 +0000876 ImmutableList.Builder<FlowRule> builder = ImmutableList.builder();
Charles Chan5b9df8d2016-03-28 22:21:40 -0700877 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
878 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
Charles Chanb4879a52017-10-20 19:09:16 -0700879 FlowRule rule;
Julia Ferguson65428c32017-08-10 18:15:24 +0000880
Charles Chanb4879a52017-10-20 19:09:16 -0700881 if (IPV4_MULTICAST.equals(ethCriterion.mac())) {
882 selector.matchEthType(Ethernet.TYPE_IPV4);
883 selector.matchEthDstMasked(ethCriterion.mac(), ethCriterion.mask());
884 selector.matchVlanId(assignedVlan);
885 treatment.transition(MULTICAST_ROUTING_TABLE);
886 rule = DefaultFlowRule.builder()
887 .forDevice(deviceId)
888 .withSelector(selector.build())
889 .withTreatment(treatment.build())
890 .withPriority(DEFAULT_PRIORITY)
891 .fromApp(applicationId)
892 .makePermanent()
893 .forTable(TMAC_TABLE).build();
894 builder.add(rule);
895 }
896
897 if (IPV6_MULTICAST.equals(ethCriterion.mac())) {
898 selector = DefaultTrafficSelector.builder();
899 treatment = DefaultTrafficTreatment.builder();
900 selector.matchEthType(Ethernet.TYPE_IPV6);
901 selector.matchEthDstMasked(ethCriterion.mac(), ethCriterion.mask());
902 selector.matchVlanId(assignedVlan);
903 treatment.transition(MULTICAST_ROUTING_TABLE);
904 rule = DefaultFlowRule.builder()
905 .forDevice(deviceId)
906 .withSelector(selector.build())
907 .withTreatment(treatment.build())
908 .withPriority(DEFAULT_PRIORITY)
909 .fromApp(applicationId)
910 .makePermanent()
911 .forTable(TMAC_TABLE).build();
912 builder.add(rule);
913 }
914 return builder.build();
Charles Chan5b9df8d2016-03-28 22:21:40 -0700915 }
916
Saurav Das822c4e22015-10-23 10:51:11 -0700917 private Collection<FlowRule> processForward(ForwardingObjective fwd) {
918 switch (fwd.flag()) {
919 case SPECIFIC:
920 return processSpecific(fwd);
921 case VERSATILE:
922 return processVersatile(fwd);
923 default:
924 fail(fwd, ObjectiveError.UNKNOWN);
925 log.warn("Unknown forwarding flag {}", fwd.flag());
926 }
927 return Collections.emptySet();
928 }
929
930 /**
931 * In the OF-DPA 2.0 pipeline, versatile forwarding objectives go to the
932 * ACL table.
933 * @param fwd the forwarding objective of type 'versatile'
934 * @return a collection of flow rules to be sent to the switch. An empty
935 * collection may be returned if there is a problem in processing
936 * the flow rule
937 */
Saurav Das52025962016-01-28 22:30:01 -0800938 protected Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
Saurav Das018605f2017-02-18 14:05:44 -0800939 log.debug("Processing versatile forwarding objective:{} in dev:{}",
Saurav Dasd2fded02016-12-02 15:43:47 -0800940 fwd.id(), deviceId);
Saurav Das822c4e22015-10-23 10:51:11 -0700941
942 EthTypeCriterion ethType =
Saurav Das77b5e902016-01-27 17:01:59 -0800943 (EthTypeCriterion) fwd.selector().getCriterion(Criterion.Type.ETH_TYPE);
Saurav Das822c4e22015-10-23 10:51:11 -0700944 if (ethType == null) {
Saurav Dasd2fded02016-12-02 15:43:47 -0800945 log.error("Versatile forwarding objective:{} must include ethType",
946 fwd.id());
Saurav Das822c4e22015-10-23 10:51:11 -0700947 fail(fwd, ObjectiveError.BADPARAMS);
948 return Collections.emptySet();
949 }
950 if (fwd.nextId() == null && fwd.treatment() == null) {
951 log.error("Forwarding objective {} from {} must contain "
952 + "nextId or Treatment", fwd.selector(), fwd.appId());
Zsolt Haraszti9faab752016-02-17 15:55:20 -0800953 fail(fwd, ObjectiveError.BADPARAMS);
Saurav Das822c4e22015-10-23 10:51:11 -0700954 return Collections.emptySet();
955 }
Saurav Das49cb5a12016-01-16 22:54:07 -0800956
Saurav Das77b5e902016-01-27 17:01:59 -0800957 TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
958 fwd.selector().criteria().forEach(criterion -> {
959 if (criterion instanceof VlanIdCriterion) {
960 VlanId vlanId = ((VlanIdCriterion) criterion).vlanId();
961 // ensure that match does not include vlan = NONE as OF-DPA does not
962 // match untagged packets this way in the ACL table.
963 if (vlanId.equals(VlanId.NONE)) {
964 return;
965 }
Charles Chand1172632017-03-15 17:33:09 -0700966 if (requireVlanExtensions()) {
967 OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(vlanId);
968 sbuilder.extension(ofdpaMatchVlanVid, deviceId);
969 } else {
970 sbuilder.matchVlanId(vlanId);
971 }
Pier Ventree0ae7a32016-11-23 09:57:42 -0800972 } else if (criterion instanceof Icmpv6TypeCriterion ||
973 criterion instanceof Icmpv6CodeCriterion) {
974 /*
975 * We silenty discard these criterions, our current
976 * OFDPA platform does not support these matches on
977 * the ACL table.
978 */
979 log.warn("ICMPv6 Type and ICMPv6 Code are not supported");
Charles Chand9e47c62017-10-05 15:17:15 -0700980 } else if (criterion instanceof TcpPortCriterion || criterion instanceof UdpPortCriterion) {
981 // FIXME: QMX switches do not support L4 dst port matching in ACL table.
982 // Currently L4 dst port matching is only used by DHCP relay feature
983 // and therefore is safe to be replaced with L4 src port matching.
984 // We need to revisit this if L4 dst port is used for other purpose in the future.
985 if (!supportIpv6L4Dst() && isIpv6(fwd.selector())) {
Charles Chand9e47c62017-10-05 15:17:15 -0700986 switch (criterion.type()) {
987 case UDP_DST:
Charles Chand9e47c62017-10-05 15:17:15 -0700988 case UDP_DST_MASKED:
Charles Chand9e47c62017-10-05 15:17:15 -0700989 case TCP_DST:
Charles Chand9e47c62017-10-05 15:17:15 -0700990 case TCP_DST_MASKED:
Charles Chand9e47c62017-10-05 15:17:15 -0700991 break;
992 default:
993 sbuilder.add(criterion);
994 }
995 } else {
996 sbuilder.add(criterion);
997 }
Saurav Das77b5e902016-01-27 17:01:59 -0800998 } else {
999 sbuilder.add(criterion);
1000 }
1001 });
1002
Saurav Das822c4e22015-10-23 10:51:11 -07001003 // XXX driver does not currently do type checking as per Tables 65-67 in
1004 // OFDPA 2.0 spec. The only allowed treatment is a punt to the controller.
Saurav Das49cb5a12016-01-16 22:54:07 -08001005 TrafficTreatment.Builder ttBuilder = DefaultTrafficTreatment.builder();
1006 if (fwd.treatment() != null) {
1007 for (Instruction ins : fwd.treatment().allInstructions()) {
1008 if (ins instanceof OutputInstruction) {
1009 OutputInstruction o = (OutputInstruction) ins;
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +05301010 if (o != null && PortNumber.CONTROLLER.equals(o.port())) {
Saurav Das49cb5a12016-01-16 22:54:07 -08001011 ttBuilder.add(o);
1012 } else {
1013 log.warn("Only allowed treatments in versatile forwarding "
1014 + "objectives are punts to the controller");
1015 }
1016 } else {
1017 log.warn("Cannot process instruction in versatile fwd {}", ins);
1018 }
Saurav Das822c4e22015-10-23 10:51:11 -07001019 }
Charles Chan2df0e8a2017-01-09 11:45:08 -08001020 if (fwd.treatment().clearedDeferred()) {
1021 ttBuilder.wipeDeferred();
1022 }
Saurav Das822c4e22015-10-23 10:51:11 -07001023 }
Saurav Das822c4e22015-10-23 10:51:11 -07001024 if (fwd.nextId() != null) {
Saurav Das49cb5a12016-01-16 22:54:07 -08001025 // overide case
1026 NextGroup next = getGroupForNextObjective(fwd.nextId());
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +05301027 if (next == null) {
1028 fail(fwd, ObjectiveError.BADPARAMS);
1029 return Collections.emptySet();
1030 }
Saurav Das49cb5a12016-01-16 22:54:07 -08001031 List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
1032 // we only need the top level group's key to point the flow to it
1033 Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst());
1034 if (group == null) {
1035 log.warn("Group with key:{} for next-id:{} not found in dev:{}",
1036 gkeys.get(0).peekFirst(), fwd.nextId(), deviceId);
1037 fail(fwd, ObjectiveError.GROUPMISSING);
1038 return Collections.emptySet();
1039 }
1040 ttBuilder.deferred().group(group.id());
Saurav Das822c4e22015-10-23 10:51:11 -07001041 }
Saurav Das49cb5a12016-01-16 22:54:07 -08001042
1043 FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
1044 .fromApp(fwd.appId())
1045 .withPriority(fwd.priority())
1046 .forDevice(deviceId)
Saurav Das77b5e902016-01-27 17:01:59 -08001047 .withSelector(sbuilder.build())
Saurav Das49cb5a12016-01-16 22:54:07 -08001048 .withTreatment(ttBuilder.build())
1049 .makePermanent()
1050 .forTable(ACL_TABLE);
1051 return Collections.singletonList(ruleBuilder.build());
Saurav Das822c4e22015-10-23 10:51:11 -07001052 }
1053
1054 /**
1055 * In the OF-DPA 2.0 pipeline, specific forwarding refers to the IP table
Saurav Das8a0732e2015-11-20 15:27:53 -08001056 * (unicast or multicast) or the L2 table (mac + vlan) or the MPLS table.
Saurav Das822c4e22015-10-23 10:51:11 -07001057 *
1058 * @param fwd the forwarding objective of type 'specific'
1059 * @return a collection of flow rules. Typically there will be only one
1060 * for this type of forwarding objective. An empty set may be
1061 * returned if there is an issue in processing the objective.
1062 */
Saurav Das8a0732e2015-11-20 15:27:53 -08001063 protected Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
Saurav Das25190812016-05-27 13:54:07 -07001064 log.debug("Processing specific fwd objective:{} in dev:{} with next:{}",
Saurav Das4ce45962015-11-24 23:21:05 -08001065 fwd.id(), deviceId, fwd.nextId());
1066 boolean isEthTypeObj = isSupportedEthTypeObjective(fwd);
1067 boolean isEthDstObj = isSupportedEthDstObjective(fwd);
1068
1069 if (isEthTypeObj) {
1070 return processEthTypeSpecific(fwd);
1071 } else if (isEthDstObj) {
1072 return processEthDstSpecific(fwd);
1073 } else {
1074 log.warn("processSpecific: Unsupported forwarding objective "
1075 + "criteria fwd:{} in dev:{}", fwd.nextId(), deviceId);
Saurav Das822c4e22015-10-23 10:51:11 -07001076 fail(fwd, ObjectiveError.UNSUPPORTED);
1077 return Collections.emptySet();
1078 }
Saurav Das4ce45962015-11-24 23:21:05 -08001079 }
1080
Saurav Das4ce45962015-11-24 23:21:05 -08001081 /**
1082 * Handles forwarding rules to the IP and MPLS tables.
1083 *
1084 * @param fwd the forwarding objective
1085 * @return A collection of flow rules, or an empty set
1086 */
1087 protected Collection<FlowRule> processEthTypeSpecific(ForwardingObjective fwd) {
Charles Chancad338a2016-09-16 18:03:11 -07001088 return processEthTypeSpecificInternal(fwd, false, ACL_TABLE);
Charles Chanf9e98652016-09-07 16:54:23 -07001089 }
1090
1091 /**
1092 * Internal implementation of processEthTypeSpecific.
1093 * <p>
1094 * Wildcarded IPv4_DST is not supported in OFDPA i12. Therefore, we break
1095 * the rule into 0.0.0.0/1 and 128.0.0.0/1.
1096 * The allowDefaultRoute must be set to false for OFDPA i12.
1097 * </p>
1098 *
1099 * @param fwd the forwarding objective
1100 * @param allowDefaultRoute allow wildcarded IPv4_DST or not
Ray Milkey0bb1e102016-11-10 14:51:27 -08001101 * @param mplsNextTable next MPLS table
Charles Chanf9e98652016-09-07 16:54:23 -07001102 * @return A collection of flow rules, or an empty set
1103 */
1104 protected Collection<FlowRule> processEthTypeSpecificInternal(ForwardingObjective fwd,
Charles Chancad338a2016-09-16 18:03:11 -07001105 boolean allowDefaultRoute,
1106 int mplsNextTable) {
Saurav Das4ce45962015-11-24 23:21:05 -08001107 TrafficSelector selector = fwd.selector();
1108 EthTypeCriterion ethType =
1109 (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
Flavio Castroe10fa242016-01-15 12:43:51 -08001110 boolean popMpls = false;
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001111 boolean emptyGroup = false;
Charles Chan188ebf52015-12-23 00:15:11 -08001112 int forTableId;
Saurav Das8a0732e2015-11-20 15:27:53 -08001113 TrafficSelector.Builder filteredSelector = DefaultTrafficSelector.builder();
Charles Chan14967c22015-12-07 11:11:50 -08001114 TrafficTreatment.Builder tb = DefaultTrafficTreatment.builder();
Flavio Castroe10fa242016-01-15 12:43:51 -08001115 TrafficSelector.Builder complementarySelector = DefaultTrafficSelector.builder();
Charles Chan14967c22015-12-07 11:11:50 -08001116
Saurav Das8a0732e2015-11-20 15:27:53 -08001117 if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) {
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001118 if (buildIpv4Selector(filteredSelector, complementarySelector, fwd, allowDefaultRoute) < 0) {
1119 return Collections.emptyList();
1120 }
1121 // We need to set properly the next table
Flavio Castroe10fa242016-01-15 12:43:51 -08001122 IpPrefix ipv4Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV4_DST)).ip();
Charles Chan5b9df8d2016-03-28 22:21:40 -07001123 if (ipv4Dst.isMulticast()) {
Charles Chan5b9df8d2016-03-28 22:21:40 -07001124 forTableId = MULTICAST_ROUTING_TABLE;
Flavio Castroe10fa242016-01-15 12:43:51 -08001125 } else {
Charles Chan5b9df8d2016-03-28 22:21:40 -07001126 forTableId = UNICAST_ROUTING_TABLE;
Flavio Castroe10fa242016-01-15 12:43:51 -08001127 }
Charles Chan14967c22015-12-07 11:11:50 -08001128 if (fwd.treatment() != null) {
1129 for (Instruction instr : fwd.treatment().allInstructions()) {
1130 if (instr instanceof L3ModificationInstruction &&
1131 ((L3ModificationInstruction) instr).subtype() == L3SubType.DEC_TTL) {
Saurav Das9c705342017-01-06 11:36:01 -08001132 // XXX decrementing IP ttl is done automatically for routing, this
1133 // action is ignored or rejected in ofdpa as it is not fully implemented
1134 //tb.deferred().add(instr);
Charles Chan14967c22015-12-07 11:11:50 -08001135 }
1136 }
1137 }
1138
Pier Ventree0ae7a32016-11-23 09:57:42 -08001139 } else if (ethType.ethType().toShort() == Ethernet.TYPE_IPV6) {
1140 if (buildIpv6Selector(filteredSelector, fwd) < 0) {
1141 return Collections.emptyList();
1142 }
Kalhee Kim3d26bf02017-10-04 14:59:11 +00001143 //We need to set the proper next table
1144 IpPrefix ipv6Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV6_DST)).ip();
1145 if (ipv6Dst.isMulticast()) {
1146 forTableId = MULTICAST_ROUTING_TABLE;
1147 } else {
1148 forTableId = UNICAST_ROUTING_TABLE;
1149 }
1150
Pier Ventree0ae7a32016-11-23 09:57:42 -08001151 if (fwd.treatment() != null) {
1152 for (Instruction instr : fwd.treatment().allInstructions()) {
1153 if (instr instanceof L3ModificationInstruction &&
1154 ((L3ModificationInstruction) instr).subtype() == L3SubType.DEC_TTL) {
1155 // XXX decrementing IP ttl is done automatically for routing, this
1156 // action is ignored or rejected in ofdpa as it is not fully implemented
1157 //tb.deferred().add(instr);
1158 }
1159 }
1160 }
Saurav Das8a0732e2015-11-20 15:27:53 -08001161 } else {
1162 filteredSelector
1163 .matchEthType(Ethernet.MPLS_UNICAST)
1164 .matchMplsLabel(((MplsCriterion)
1165 selector.getCriterion(Criterion.Type.MPLS_LABEL)).label());
1166 MplsBosCriterion bos = (MplsBosCriterion) selector
Pier Ventre140a8942016-11-02 07:26:38 -07001167 .getCriterion(MPLS_BOS);
Saurav Das8a0732e2015-11-20 15:27:53 -08001168 if (bos != null) {
1169 filteredSelector.matchMplsBos(bos.mplsBos());
1170 }
1171 forTableId = MPLS_TABLE_1;
Saurav Das4ce45962015-11-24 23:21:05 -08001172 log.debug("processing MPLS specific forwarding objective {} -> next:{}"
1173 + " in dev {}", fwd.id(), fwd.nextId(), deviceId);
Saurav Das822c4e22015-10-23 10:51:11 -07001174
Charles Chan14967c22015-12-07 11:11:50 -08001175 if (fwd.treatment() != null) {
1176 for (Instruction instr : fwd.treatment().allInstructions()) {
1177 if (instr instanceof L2ModificationInstruction &&
1178 ((L2ModificationInstruction) instr).subtype() == L2SubType.MPLS_POP) {
Saurav Das8a0732e2015-11-20 15:27:53 -08001179 popMpls = true;
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001180 // OF-DPA does not pop in MPLS table in some cases. For the L3 VPN, it requires
Saurav Das9c705342017-01-06 11:36:01 -08001181 // setting the MPLS_TYPE so pop can happen down the pipeline
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001182 if (mplsNextTable == MPLS_TYPE_TABLE && isNotMplsBos(selector)) {
1183 tb.immediate().popMpls();
1184 }
Charles Chan14967c22015-12-07 11:11:50 -08001185 }
1186 if (instr instanceof L3ModificationInstruction &&
1187 ((L3ModificationInstruction) instr).subtype() == L3SubType.DEC_TTL) {
1188 // FIXME Should modify the app to send the correct DEC_MPLS_TTL instruction
1189 tb.immediate().decMplsTtl();
1190 }
1191 if (instr instanceof L3ModificationInstruction &&
1192 ((L3ModificationInstruction) instr).subtype() == L3SubType.TTL_IN) {
1193 tb.immediate().add(instr);
1194 }
Saurav Das8a0732e2015-11-20 15:27:53 -08001195 }
1196 }
1197 }
Saurav Das822c4e22015-10-23 10:51:11 -07001198
1199 if (fwd.nextId() != null) {
Saurav Das8a0732e2015-11-20 15:27:53 -08001200 if (forTableId == MPLS_TABLE_1 && !popMpls) {
1201 log.warn("SR CONTINUE case cannot be handled as MPLS ECMP "
Saurav Das25190812016-05-27 13:54:07 -07001202 + "is not implemented in OF-DPA yet. Aborting this flow {} -> next:{}"
1203 + "in this device {}", fwd.id(), fwd.nextId(), deviceId);
Pier Ventree0ae7a32016-11-23 09:57:42 -08001204 // XXX We could convert to forwarding to a single-port, via a MPLS interface,
1205 // or a MPLS SWAP (with-same) but that would have to be handled in the next-objective.
1206 // Also the pop-mpls logic used here won't work in non-BoS case.
Saurav Das4ce45962015-11-24 23:21:05 -08001207 fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED);
Saurav Das8a0732e2015-11-20 15:27:53 -08001208 return Collections.emptySet();
1209 }
1210
Saurav Das423fe2b2015-12-04 10:52:59 -08001211 NextGroup next = getGroupForNextObjective(fwd.nextId());
1212 if (next != null) {
1213 List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
1214 // we only need the top level group's key to point the flow to it
1215 Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst());
Pier Ventre140a8942016-11-02 07:26:38 -07001216 if (isNotMplsBos(selector) && group.type().equals(HASHED)) {
1217 log.warn("SR CONTINUE case cannot be handled as MPLS ECMP "
1218 + "is not implemented in OF-DPA yet. Aborting this flow {} -> next:{}"
1219 + "in this device {}", fwd.id(), fwd.nextId(), deviceId);
1220 fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED);
1221 return Collections.emptySet();
1222 }
Saurav Das423fe2b2015-12-04 10:52:59 -08001223 if (group == null) {
1224 log.warn("Group with key:{} for next-id:{} not found in dev:{}",
1225 gkeys.get(0).peekFirst(), fwd.nextId(), deviceId);
1226 fail(fwd, ObjectiveError.GROUPMISSING);
1227 return Collections.emptySet();
1228 }
1229 tb.deferred().group(group.id());
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001230 // check if group is empty
1231 if (gkeys.size() == 1 && gkeys.get(0).size() == 1) {
1232 log.warn("Found empty group 0x{} in dev:{} .. will retry fwd:{}",
1233 Integer.toHexString(group.id().id()), deviceId, fwd.id());
1234 emptyGroup = true;
1235 }
Saurav Das25190812016-05-27 13:54:07 -07001236 } else {
1237 log.warn("Cannot find group for nextId:{} in dev:{}. Aborting fwd:{}",
1238 fwd.nextId(), deviceId, fwd.id());
1239 fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED);
1240 return Collections.emptySet();
Saurav Das822c4e22015-10-23 10:51:11 -07001241 }
Saurav Das822c4e22015-10-23 10:51:11 -07001242 }
Charles Chancad338a2016-09-16 18:03:11 -07001243
1244 if (forTableId == MPLS_TABLE_1) {
Pier Ventre140a8942016-11-02 07:26:38 -07001245 if (mplsNextTable == MPLS_L3_TYPE_TABLE) {
Charles Chancad338a2016-09-16 18:03:11 -07001246 Ofdpa3SetMplsType setMplsType = new Ofdpa3SetMplsType(Ofdpa3MplsType.L3_PHP);
Saurav Das9c705342017-01-06 11:36:01 -08001247 // set mpls type as apply_action
1248 tb.immediate().extension(setMplsType, deviceId);
Charles Chancad338a2016-09-16 18:03:11 -07001249 }
1250 tb.transition(mplsNextTable);
1251 } else {
1252 tb.transition(ACL_TABLE);
1253 }
1254
Saurav Das822c4e22015-10-23 10:51:11 -07001255 FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
1256 .fromApp(fwd.appId())
1257 .withPriority(fwd.priority())
1258 .forDevice(deviceId)
Saurav Das8a0732e2015-11-20 15:27:53 -08001259 .withSelector(filteredSelector.build())
1260 .withTreatment(tb.build())
1261 .forTable(forTableId);
Saurav Das822c4e22015-10-23 10:51:11 -07001262
1263 if (fwd.permanent()) {
1264 ruleBuilder.makePermanent();
1265 } else {
1266 ruleBuilder.makeTemporary(fwd.timeout());
1267 }
Flavio Castroe10fa242016-01-15 12:43:51 -08001268 Collection<FlowRule> flowRuleCollection = new ArrayList<>();
1269 flowRuleCollection.add(ruleBuilder.build());
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001270 if (!allowDefaultRoute) {
Pier Ventree0ae7a32016-11-23 09:57:42 -08001271 flowRuleCollection.add(
1272 defaultRoute(fwd, complementarySelector, forTableId, tb)
1273 );
Flavio Castroe10fa242016-01-15 12:43:51 -08001274 log.debug("Default rule 0.0.0.0/0 is being installed two rules");
1275 }
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001276 // XXX retrying flows may be necessary due to bug CORD-554
1277 if (emptyGroup) {
1278 executorService.schedule(new RetryFlows(fwd, flowRuleCollection),
1279 RETRY_MS, TimeUnit.MILLISECONDS);
1280 }
Flavio Castroe10fa242016-01-15 12:43:51 -08001281 return flowRuleCollection;
Saurav Das822c4e22015-10-23 10:51:11 -07001282 }
1283
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001284 protected int buildIpv4Selector(TrafficSelector.Builder builderToUpdate,
1285 TrafficSelector.Builder extBuilder,
1286 ForwardingObjective fwd,
1287 boolean allowDefaultRoute) {
1288 TrafficSelector selector = fwd.selector();
1289
1290 IpPrefix ipv4Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV4_DST)).ip();
1291 if (ipv4Dst.isMulticast()) {
1292 if (ipv4Dst.prefixLength() != 32) {
1293 log.warn("Multicast specific forwarding objective can only be /32");
1294 fail(fwd, ObjectiveError.BADPARAMS);
1295 return -1;
1296 }
1297 VlanId assignedVlan = readVlanFromSelector(fwd.meta());
1298 if (assignedVlan == null) {
1299 log.warn("VLAN ID required by multicast specific fwd obj is missing. Abort.");
1300 fail(fwd, ObjectiveError.BADPARAMS);
1301 return -1;
1302 }
Charles Chand1172632017-03-15 17:33:09 -07001303 if (requireVlanExtensions()) {
1304 OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(assignedVlan);
1305 builderToUpdate.extension(ofdpaMatchVlanVid, deviceId);
1306 } else {
1307 builderToUpdate.matchVlanId(assignedVlan);
1308 }
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001309 builderToUpdate.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(ipv4Dst);
1310 log.debug("processing IPv4 multicast specific forwarding objective {} -> next:{}"
1311 + " in dev:{}", fwd.id(), fwd.nextId(), deviceId);
1312 } else {
1313 if (ipv4Dst.prefixLength() == 0) {
1314 if (allowDefaultRoute) {
1315 // The entire IPV4_DST field is wildcarded intentionally
1316 builderToUpdate.matchEthType(Ethernet.TYPE_IPV4);
1317 } else {
1318 // NOTE: The switch does not support matching 0.0.0.0/0
1319 // Split it into 0.0.0.0/1 and 128.0.0.0/1
1320 builderToUpdate.matchEthType(Ethernet.TYPE_IPV4)
1321 .matchIPDst(IpPrefix.valueOf("0.0.0.0/1"));
1322 extBuilder.matchEthType(Ethernet.TYPE_IPV4)
1323 .matchIPDst(IpPrefix.valueOf("128.0.0.0/1"));
1324 }
1325 } else {
1326 builderToUpdate.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(ipv4Dst);
1327 }
1328 log.debug("processing IPv4 unicast specific forwarding objective {} -> next:{}"
1329 + " in dev:{}", fwd.id(), fwd.nextId(), deviceId);
1330 }
1331 return 0;
1332 }
1333
1334 /**
1335 * Helper method to build Ipv6 selector using the selector provided by
1336 * a forwarding objective.
1337 *
1338 * @param builderToUpdate the builder to update
1339 * @param fwd the selector to read
1340 * @return 0 if the update ends correctly. -1 if the matches
1341 * are not yet supported
1342 */
1343 protected int buildIpv6Selector(TrafficSelector.Builder builderToUpdate,
1344 ForwardingObjective fwd) {
1345
1346 TrafficSelector selector = fwd.selector();
1347
1348 IpPrefix ipv6Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV6_DST)).ip();
1349 if (ipv6Dst.isMulticast()) {
Julia Ferguson65428c32017-08-10 18:15:24 +00001350 if (ipv6Dst.prefixLength() != IpAddress.INET6_BIT_LENGTH) {
1351 log.warn("Multicast specific forwarding objective can only be /128");
1352 fail(fwd, ObjectiveError.BADPARAMS);
1353 return -1;
1354 }
1355 VlanId assignedVlan = readVlanFromSelector(fwd.meta());
1356 if (assignedVlan == null) {
1357 log.warn("VLAN ID required by multicast specific fwd obj is missing. Abort.");
1358 fail(fwd, ObjectiveError.BADPARAMS);
1359 return -1;
1360 }
1361 if (requireVlanExtensions()) {
1362 OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(assignedVlan);
1363 builderToUpdate.extension(ofdpaMatchVlanVid, deviceId);
1364 } else {
1365 builderToUpdate.matchVlanId(assignedVlan);
1366 }
1367 builderToUpdate.matchEthType(Ethernet.TYPE_IPV6).matchIPv6Dst(ipv6Dst);
1368 log.debug("processing IPv6 multicast specific forwarding objective {} -> next:{}"
1369 + " in dev:{}", fwd.id(), fwd.nextId(), deviceId);
1370 } else {
1371 if (ipv6Dst.prefixLength() != 0) {
1372 builderToUpdate.matchIPv6Dst(ipv6Dst);
1373 }
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001374 builderToUpdate.matchEthType(Ethernet.TYPE_IPV6);
1375 log.debug("processing IPv6 unicast specific forwarding objective {} -> next:{}"
1376 + " in dev:{}", fwd.id(), fwd.nextId(), deviceId);
Julia Ferguson65428c32017-08-10 18:15:24 +00001377 }
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001378 return 0;
1379 }
1380
Pier Ventree0ae7a32016-11-23 09:57:42 -08001381 protected FlowRule defaultRoute(ForwardingObjective fwd,
1382 TrafficSelector.Builder complementarySelector,
1383 int forTableId,
1384 TrafficTreatment.Builder tb) {
1385 FlowRule.Builder rule = DefaultFlowRule.builder()
1386 .fromApp(fwd.appId())
1387 .withPriority(fwd.priority())
1388 .forDevice(deviceId)
1389 .withSelector(complementarySelector.build())
1390 .withTreatment(tb.build())
1391 .forTable(forTableId);
1392 if (fwd.permanent()) {
1393 rule.makePermanent();
1394 } else {
1395 rule.makeTemporary(fwd.timeout());
1396 }
1397 return rule.build();
1398 }
1399
Saurav Das4ce45962015-11-24 23:21:05 -08001400 /**
1401 * Handles forwarding rules to the L2 bridging table. Flow actions are not
1402 * allowed in the bridging table - instead we use L2 Interface group or
1403 * L2 flood group
1404 *
1405 * @param fwd the forwarding objective
1406 * @return A collection of flow rules, or an empty set
1407 */
1408 protected Collection<FlowRule> processEthDstSpecific(ForwardingObjective fwd) {
1409 List<FlowRule> rules = new ArrayList<>();
1410
1411 // Build filtered selector
1412 TrafficSelector selector = fwd.selector();
1413 EthCriterion ethCriterion = (EthCriterion) selector
1414 .getCriterion(Criterion.Type.ETH_DST);
1415 VlanIdCriterion vlanIdCriterion = (VlanIdCriterion) selector
1416 .getCriterion(Criterion.Type.VLAN_VID);
1417
1418 if (vlanIdCriterion == null) {
1419 log.warn("Forwarding objective for bridging requires vlan. Not "
1420 + "installing fwd:{} in dev:{}", fwd.id(), deviceId);
1421 fail(fwd, ObjectiveError.BADPARAMS);
1422 return Collections.emptySet();
1423 }
1424
1425 TrafficSelector.Builder filteredSelectorBuilder =
1426 DefaultTrafficSelector.builder();
Yi Tseng3a77b4f2017-02-06 15:02:17 -08001427
1428 if (!ethCriterion.mac().equals(NONE) &&
1429 !ethCriterion.mac().equals(BROADCAST)) {
Saurav Das4ce45962015-11-24 23:21:05 -08001430 filteredSelectorBuilder.matchEthDst(ethCriterion.mac());
1431 log.debug("processing L2 forwarding objective:{} -> next:{} in dev:{}",
1432 fwd.id(), fwd.nextId(), deviceId);
1433 } else {
Yi Tseng3a77b4f2017-02-06 15:02:17 -08001434 // Use wildcard DST_MAC if the MacAddress is None or Broadcast
Saurav Das4ce45962015-11-24 23:21:05 -08001435 log.debug("processing L2 Broadcast forwarding objective:{} -> next:{} "
1436 + "in dev:{} for vlan:{}",
1437 fwd.id(), fwd.nextId(), deviceId, vlanIdCriterion.vlanId());
1438 }
Charles Chand1172632017-03-15 17:33:09 -07001439 if (requireVlanExtensions()) {
1440 OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(vlanIdCriterion.vlanId());
1441 filteredSelectorBuilder.extension(ofdpaMatchVlanVid, deviceId);
1442 } else {
1443 filteredSelectorBuilder.matchVlanId(vlanIdCriterion.vlanId());
1444 }
Saurav Das4ce45962015-11-24 23:21:05 -08001445 TrafficSelector filteredSelector = filteredSelectorBuilder.build();
1446
1447 if (fwd.treatment() != null) {
1448 log.warn("Ignoring traffic treatment in fwd rule {} meant for L2 table"
1449 + "for dev:{}. Expecting only nextId", fwd.id(), deviceId);
1450 }
1451
1452 TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
1453 if (fwd.nextId() != null) {
Saurav Das423fe2b2015-12-04 10:52:59 -08001454 NextGroup next = getGroupForNextObjective(fwd.nextId());
Saurav Das4ce45962015-11-24 23:21:05 -08001455 if (next != null) {
1456 List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
1457 // we only need the top level group's key to point the flow to it
1458 Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst());
1459 if (group != null) {
1460 treatmentBuilder.deferred().group(group.id());
1461 } else {
1462 log.warn("Group with key:{} for next-id:{} not found in dev:{}",
1463 gkeys.get(0).peekFirst(), fwd.nextId(), deviceId);
1464 fail(fwd, ObjectiveError.GROUPMISSING);
1465 return Collections.emptySet();
1466 }
1467 }
1468 }
1469 treatmentBuilder.immediate().transition(ACL_TABLE);
1470 TrafficTreatment filteredTreatment = treatmentBuilder.build();
1471
1472 // Build bridging table entries
1473 FlowRule.Builder flowRuleBuilder = DefaultFlowRule.builder();
1474 flowRuleBuilder.fromApp(fwd.appId())
1475 .withPriority(fwd.priority())
1476 .forDevice(deviceId)
1477 .withSelector(filteredSelector)
1478 .withTreatment(filteredTreatment)
1479 .forTable(BRIDGING_TABLE);
1480 if (fwd.permanent()) {
1481 flowRuleBuilder.makePermanent();
1482 } else {
1483 flowRuleBuilder.makeTemporary(fwd.timeout());
1484 }
1485 rules.add(flowRuleBuilder.build());
1486 return rules;
1487 }
1488
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001489 //////////////////////////////////////
1490 // Helper Methods and Classes
1491 //////////////////////////////////////
1492
1493 private boolean isSupportedEthTypeObjective(ForwardingObjective fwd) {
1494 TrafficSelector selector = fwd.selector();
1495 EthTypeCriterion ethType = (EthTypeCriterion) selector
1496 .getCriterion(Criterion.Type.ETH_TYPE);
1497 return !((ethType == null) ||
1498 ((ethType.ethType().toShort() != Ethernet.TYPE_IPV4) &&
Pier Ventree0ae7a32016-11-23 09:57:42 -08001499 (ethType.ethType().toShort() != Ethernet.MPLS_UNICAST)) &&
1500 (ethType.ethType().toShort() != Ethernet.TYPE_IPV6));
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001501 }
1502
1503 private boolean isSupportedEthDstObjective(ForwardingObjective fwd) {
1504 TrafficSelector selector = fwd.selector();
1505 EthCriterion ethDst = (EthCriterion) selector
1506 .getCriterion(Criterion.Type.ETH_DST);
1507 VlanIdCriterion vlanId = (VlanIdCriterion) selector
1508 .getCriterion(Criterion.Type.VLAN_VID);
1509 return !(ethDst == null && vlanId == null);
1510 }
1511
Saurav Das423fe2b2015-12-04 10:52:59 -08001512 protected NextGroup getGroupForNextObjective(Integer nextId) {
1513 NextGroup next = flowObjectiveStore.getNextGroup(nextId);
1514 if (next != null) {
1515 List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
1516 if (gkeys != null && !gkeys.isEmpty()) {
1517 return next;
1518 } else {
1519 log.warn("Empty next group found in FlowObjective store for "
1520 + "next-id:{} in dev:{}", nextId, deviceId);
1521 }
1522 } else {
1523 log.warn("next-id {} not found in Flow objective store for dev:{}",
1524 nextId, deviceId);
1525 }
1526 return null;
1527 }
1528
Charles Chan188ebf52015-12-23 00:15:11 -08001529 protected static void pass(Objective obj) {
Sho SHIMIZUef7e2902016-02-12 18:38:29 -08001530 obj.context().ifPresent(context -> context.onSuccess(obj));
Saurav Das822c4e22015-10-23 10:51:11 -07001531 }
1532
Charles Chan188ebf52015-12-23 00:15:11 -08001533 protected static void fail(Objective obj, ObjectiveError error) {
Sho SHIMIZUef7e2902016-02-12 18:38:29 -08001534 obj.context().ifPresent(context -> context.onError(obj, error));
Saurav Das822c4e22015-10-23 10:51:11 -07001535 }
Saurav Das24431192016-03-07 19:13:00 -08001536
Saurav Das24431192016-03-07 19:13:00 -08001537 @Override
1538 public List<String> getNextMappings(NextGroup nextGroup) {
1539 List<String> mappings = new ArrayList<>();
1540 List<Deque<GroupKey>> gkeys = appKryo.deserialize(nextGroup.data());
1541 for (Deque<GroupKey> gkd : gkeys) {
1542 Group lastGroup = null;
Yuta HIGUCHI2dce08a2017-04-20 21:57:48 -07001543 StringBuilder gchain = new StringBuilder();
Saurav Das24431192016-03-07 19:13:00 -08001544 for (GroupKey gk : gkd) {
1545 Group g = groupService.getGroup(deviceId, gk);
Saurav Das8be4e3a2016-03-11 17:19:07 -08001546 if (g == null) {
Saurav Das25190812016-05-27 13:54:07 -07001547 gchain.append(" NoGrp").append(" -->");
Saurav Das8be4e3a2016-03-11 17:19:07 -08001548 continue;
1549 }
1550 gchain.append(" 0x").append(Integer.toHexString(g.id().id()))
1551 .append(" -->");
Saurav Das24431192016-03-07 19:13:00 -08001552 lastGroup = g;
1553 }
1554 // add port information for last group in group-chain
Yuta HIGUCHI2dce08a2017-04-20 21:57:48 -07001555 List<Instruction> lastGroupIns = new ArrayList<>();
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001556 if (lastGroup != null && !lastGroup.buckets().buckets().isEmpty()) {
Saurav Das25190812016-05-27 13:54:07 -07001557 lastGroupIns = lastGroup.buckets().buckets().get(0)
1558 .treatment().allInstructions();
1559 }
1560 for (Instruction i: lastGroupIns) {
Saurav Das24431192016-03-07 19:13:00 -08001561 if (i instanceof OutputInstruction) {
Saurav Das8be4e3a2016-03-11 17:19:07 -08001562 gchain.append(" port:").append(((OutputInstruction) i).port());
Saurav Das24431192016-03-07 19:13:00 -08001563 }
1564 }
Saurav Das8be4e3a2016-03-11 17:19:07 -08001565 mappings.add(gchain.toString());
Saurav Das24431192016-03-07 19:13:00 -08001566 }
1567 return mappings;
1568 }
Charles Chan5b9df8d2016-03-28 22:21:40 -07001569
Pier Ventre140a8942016-11-02 07:26:38 -07001570 static boolean isMplsBos(TrafficSelector selector) {
1571 MplsBosCriterion bosCriterion = (MplsBosCriterion) selector.getCriterion(MPLS_BOS);
1572 return bosCriterion != null && bosCriterion.mplsBos();
1573 }
1574
1575 static boolean isNotMplsBos(TrafficSelector selector) {
1576 MplsBosCriterion bosCriterion = (MplsBosCriterion) selector.getCriterion(MPLS_BOS);
1577 return bosCriterion != null && !bosCriterion.mplsBos();
1578 }
1579
Charles Chand9e47c62017-10-05 15:17:15 -07001580 private static boolean isIpv6(TrafficSelector selector) {
1581 EthTypeCriterion ethTypeCriterion = (EthTypeCriterion) selector.getCriterion(ETH_TYPE);
1582 return ethTypeCriterion != null && ethTypeCriterion.ethType().toShort() == Ethernet.TYPE_IPV6;
1583 }
1584
1585 static VlanId readVlanFromSelector(TrafficSelector selector) {
Saurav Das59232cf2016-04-27 18:35:50 -07001586 if (selector == null) {
1587 return null;
1588 }
Charles Chan5b9df8d2016-03-28 22:21:40 -07001589 Criterion criterion = selector.getCriterion(Criterion.Type.VLAN_VID);
1590 return (criterion == null)
1591 ? null : ((VlanIdCriterion) criterion).vlanId();
1592 }
1593
Charles Chand9e47c62017-10-05 15:17:15 -07001594 static IpPrefix readIpDstFromSelector(TrafficSelector selector) {
Saurav Das59232cf2016-04-27 18:35:50 -07001595 if (selector == null) {
1596 return null;
1597 }
Charles Chan5b9df8d2016-03-28 22:21:40 -07001598 Criterion criterion = selector.getCriterion(Criterion.Type.IPV4_DST);
1599 return (criterion == null) ? null : ((IPCriterion) criterion).ip();
1600 }
Charles Chand55e84d2016-03-30 17:54:24 -07001601
1602 private static VlanId readVlanFromTreatment(TrafficTreatment treatment) {
Saurav Das59232cf2016-04-27 18:35:50 -07001603 if (treatment == null) {
1604 return null;
1605 }
Charles Chand55e84d2016-03-30 17:54:24 -07001606 for (Instruction i : treatment.allInstructions()) {
1607 if (i instanceof ModVlanIdInstruction) {
1608 return ((ModVlanIdInstruction) i).vlanId();
1609 }
1610 }
1611 return null;
1612 }
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001613
1614 /**
1615 * Utility class that retries sending flows a fixed number of times, even if
1616 * some of the attempts are successful. Used only for forwarding objectives.
1617 */
1618 protected final class RetryFlows implements Runnable {
1619 int attempts = MAX_RETRY_ATTEMPTS;
1620 private Collection<FlowRule> retryFlows;
1621 private ForwardingObjective fwd;
1622
1623 RetryFlows(ForwardingObjective fwd, Collection<FlowRule> retryFlows) {
1624 this.fwd = fwd;
1625 this.retryFlows = retryFlows;
1626 }
1627
1628 @Override
1629 public void run() {
1630 log.info("RETRY FLOWS ATTEMPT# {} for fwd:{} rules:{}",
1631 MAX_RETRY_ATTEMPTS - attempts, fwd.id(), retryFlows.size());
1632 sendForward(fwd, retryFlows);
1633 if (--attempts > 0) {
1634 executorService.schedule(this, RETRY_MS, TimeUnit.MILLISECONDS);
1635 }
1636 }
1637 }
1638
Saurav Das822c4e22015-10-23 10:51:11 -07001639}