blob: e00d5fc4fee46b03bbd7efd71550c748aa32ab90 [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;
Charles Chand9e47c62017-10-05 15:17:15 -070024import org.onlab.packet.TpPort;
Saurav Das822c4e22015-10-23 10:51:11 -070025import org.onlab.packet.VlanId;
26import org.onlab.util.KryoNamespace;
27import org.onosproject.core.ApplicationId;
28import org.onosproject.core.CoreService;
Charles Chancad338a2016-09-16 18:03:11 -070029import org.onosproject.driver.extensions.Ofdpa3MplsType;
30import org.onosproject.driver.extensions.Ofdpa3SetMplsType;
Charles Chan14967c22015-12-07 11:11:50 -080031import org.onosproject.driver.extensions.OfdpaMatchVlanVid;
32import org.onosproject.driver.extensions.OfdpaSetVlanVid;
Saurav Das822c4e22015-10-23 10:51:11 -070033import org.onosproject.net.DeviceId;
34import org.onosproject.net.Port;
35import org.onosproject.net.PortNumber;
36import org.onosproject.net.behaviour.NextGroup;
37import org.onosproject.net.behaviour.Pipeliner;
38import org.onosproject.net.behaviour.PipelinerContext;
39import org.onosproject.net.device.DeviceService;
40import org.onosproject.net.driver.AbstractHandlerBehaviour;
41import org.onosproject.net.flow.DefaultFlowRule;
42import org.onosproject.net.flow.DefaultTrafficSelector;
43import org.onosproject.net.flow.DefaultTrafficTreatment;
44import org.onosproject.net.flow.FlowRule;
45import org.onosproject.net.flow.FlowRuleOperations;
46import org.onosproject.net.flow.FlowRuleOperationsContext;
47import org.onosproject.net.flow.FlowRuleService;
48import org.onosproject.net.flow.TrafficSelector;
49import org.onosproject.net.flow.TrafficTreatment;
50import org.onosproject.net.flow.criteria.Criteria;
51import org.onosproject.net.flow.criteria.Criterion;
52import org.onosproject.net.flow.criteria.EthCriterion;
53import org.onosproject.net.flow.criteria.EthTypeCriterion;
Charles Chan14967c22015-12-07 11:11:50 -080054import org.onosproject.net.flow.criteria.ExtensionCriterion;
Saurav Das822c4e22015-10-23 10:51:11 -070055import org.onosproject.net.flow.criteria.IPCriterion;
Pier Ventree0ae7a32016-11-23 09:57:42 -080056import org.onosproject.net.flow.criteria.Icmpv6CodeCriterion;
57import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion;
Saurav Das8a0732e2015-11-20 15:27:53 -080058import org.onosproject.net.flow.criteria.MplsBosCriterion;
59import org.onosproject.net.flow.criteria.MplsCriterion;
Saurav Das822c4e22015-10-23 10:51:11 -070060import org.onosproject.net.flow.criteria.PortCriterion;
Charles Chand9e47c62017-10-05 15:17:15 -070061import org.onosproject.net.flow.criteria.TcpPortCriterion;
62import org.onosproject.net.flow.criteria.UdpPortCriterion;
Saurav Das822c4e22015-10-23 10:51:11 -070063import org.onosproject.net.flow.criteria.VlanIdCriterion;
64import org.onosproject.net.flow.instructions.Instruction;
65import org.onosproject.net.flow.instructions.Instructions.OutputInstruction;
66import org.onosproject.net.flow.instructions.L2ModificationInstruction;
Saurav Das8a0732e2015-11-20 15:27:53 -080067import org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType;
Saurav Das822c4e22015-10-23 10:51:11 -070068import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
Charles Chan14967c22015-12-07 11:11:50 -080069import org.onosproject.net.flow.instructions.L3ModificationInstruction;
70import org.onosproject.net.flow.instructions.L3ModificationInstruction.L3SubType;
Saurav Das822c4e22015-10-23 10:51:11 -070071import org.onosproject.net.flowobjective.FilteringObjective;
72import org.onosproject.net.flowobjective.FlowObjectiveStore;
73import org.onosproject.net.flowobjective.ForwardingObjective;
74import org.onosproject.net.flowobjective.NextObjective;
75import org.onosproject.net.flowobjective.Objective;
76import org.onosproject.net.flowobjective.ObjectiveError;
Saurav Das822c4e22015-10-23 10:51:11 -070077import org.onosproject.net.group.DefaultGroupKey;
78import org.onosproject.net.group.Group;
Saurav Das822c4e22015-10-23 10:51:11 -070079import org.onosproject.net.group.GroupKey;
Saurav Das822c4e22015-10-23 10:51:11 -070080import org.onosproject.net.group.GroupService;
Saurav Das822c4e22015-10-23 10:51:11 -070081import org.onosproject.store.serializers.KryoNamespaces;
82import org.slf4j.Logger;
83
Pier Ventree0ae7a32016-11-23 09:57:42 -080084import java.util.ArrayDeque;
85import java.util.ArrayList;
86import java.util.Collection;
87import java.util.Collections;
88import java.util.Deque;
89import java.util.List;
90import java.util.Objects;
Pier Ventree0ae7a32016-11-23 09:57:42 -080091import java.util.concurrent.ScheduledExecutorService;
92import java.util.concurrent.TimeUnit;
93
94import static java.util.concurrent.Executors.newScheduledThreadPool;
Yi Tseng3a77b4f2017-02-06 15:02:17 -080095import static org.onlab.packet.MacAddress.BROADCAST;
Charles Chanb4879a52017-10-20 19:09:16 -070096import static org.onlab.packet.MacAddress.IPV4_MULTICAST;
97import static org.onlab.packet.MacAddress.IPV6_MULTICAST;
Yi Tseng3a77b4f2017-02-06 15:02:17 -080098import static org.onlab.packet.MacAddress.NONE;
Pier Ventree0ae7a32016-11-23 09:57:42 -080099import static org.onlab.util.Tools.groupedThreads;
Yi Tsengef19de12017-04-24 11:33:05 -0700100import static org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.*;
Charles Chand9e47c62017-10-05 15:17:15 -0700101import static org.onosproject.net.flow.criteria.Criterion.Type.ETH_TYPE;
Pier Ventree0ae7a32016-11-23 09:57:42 -0800102import static org.slf4j.LoggerFactory.getLogger;
Pier Ventre140a8942016-11-02 07:26:38 -0700103import static org.onosproject.net.flow.criteria.Criterion.Type.MPLS_BOS;
104import static org.onosproject.net.flowobjective.NextObjective.Type.HASHED;
Pier Ventree0ae7a32016-11-23 09:57:42 -0800105
Saurav Das822c4e22015-10-23 10:51:11 -0700106/**
107 * Driver for Broadcom's OF-DPA v2.0 TTP.
Saurav Das822c4e22015-10-23 10:51:11 -0700108 */
Charles Chan361154b2016-03-24 10:23:39 -0700109public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeliner {
Pier Ventre42287df2016-11-09 14:17:26 -0800110
Saurav Das822c4e22015-10-23 10:51:11 -0700111 protected static final int PORT_TABLE = 0;
112 protected static final int VLAN_TABLE = 10;
Pier Ventre42287df2016-11-09 14:17:26 -0800113 protected static final int VLAN_1_TABLE = 11;
114 protected static final int MPLS_L2_PORT_FLOW_TABLE = 13;
115 protected static final int MPLS_L2_PORT_PCP_TRUST_FLOW_TABLE = 16;
Saurav Das822c4e22015-10-23 10:51:11 -0700116 protected static final int TMAC_TABLE = 20;
117 protected static final int UNICAST_ROUTING_TABLE = 30;
118 protected static final int MULTICAST_ROUTING_TABLE = 40;
119 protected static final int MPLS_TABLE_0 = 23;
120 protected static final int MPLS_TABLE_1 = 24;
Pier Ventre140a8942016-11-02 07:26:38 -0700121 protected static final int MPLS_L3_TYPE_TABLE = 27;
122 protected static final int MPLS_TYPE_TABLE = 29;
Saurav Das822c4e22015-10-23 10:51:11 -0700123 protected static final int BRIDGING_TABLE = 50;
124 protected static final int ACL_TABLE = 60;
125 protected static final int MAC_LEARNING_TABLE = 254;
126 protected static final long OFPP_MAX = 0xffffff00L;
127
Saurav Das52025962016-01-28 22:30:01 -0800128 protected static final int HIGHEST_PRIORITY = 0xffff;
Saurav Das2857f382015-11-03 14:39:27 -0800129 protected static final int DEFAULT_PRIORITY = 0x8000;
Saurav Das822c4e22015-10-23 10:51:11 -0700130 protected static final int LOWEST_PRIORITY = 0x0;
131
Pier Ventre42287df2016-11-09 14:17:26 -0800132 protected static final int MPLS_L2_PORT_PRIORITY = 2;
133
134 protected static final int MPLS_TUNNEL_ID_BASE = 0x10000;
135 protected static final int MPLS_TUNNEL_ID_MAX = 0x1FFFF;
136
Pier Ventre70d53ba2016-11-17 22:26:29 -0800137 protected static final int MPLS_UNI_PORT_MAX = 0x0000FFFF;
138
139 protected static final int MPLS_NNI_PORT_BASE = 0x00020000;
140 protected static final int MPLS_NNI_PORT_MAX = 0x0002FFFF;
141
Saurav Das822c4e22015-10-23 10:51:11 -0700142 private final Logger log = getLogger(getClass());
Charles Chan425854b2016-04-11 15:32:12 -0700143 protected ServiceDirectory serviceDirectory;
Saurav Das822c4e22015-10-23 10:51:11 -0700144 protected FlowRuleService flowRuleService;
Charles Chan425854b2016-04-11 15:32:12 -0700145 protected CoreService coreService;
Saurav Das8a0732e2015-11-20 15:27:53 -0800146 protected GroupService groupService;
147 protected FlowObjectiveStore flowObjectiveStore;
Saurav Das822c4e22015-10-23 10:51:11 -0700148 protected DeviceId deviceId;
149 protected ApplicationId driverId;
Saurav Das822c4e22015-10-23 10:51:11 -0700150 protected DeviceService deviceService;
Charles Chan188ebf52015-12-23 00:15:11 -0800151 protected static KryoNamespace appKryo = new KryoNamespace.Builder()
Yi Tsengef19de12017-04-24 11:33:05 -0700152 .register(KryoNamespaces.API)
153 .register(GroupKey.class)
154 .register(DefaultGroupKey.class)
155 .register(OfdpaNextGroup.class)
156 .register(ArrayDeque.class)
157 .build("Ofdpa2Pipeline");
Saurav Das822c4e22015-10-23 10:51:11 -0700158
Charles Chan425854b2016-04-11 15:32:12 -0700159 protected Ofdpa2GroupHandler groupHandler;
Saurav Das822c4e22015-10-23 10:51:11 -0700160
Saurav Das1ce0a7b2016-10-21 14:06:29 -0700161 // flows installations to be retried
162 protected ScheduledExecutorService executorService
163 = newScheduledThreadPool(5, groupedThreads("OfdpaPipeliner", "retry-%d", log));
164 protected static final int MAX_RETRY_ATTEMPTS = 10;
165 protected static final int RETRY_MS = 1000;
Saurav Das4f980082015-11-05 13:39:15 -0800166
Saurav Das822c4e22015-10-23 10:51:11 -0700167 @Override
168 public void init(DeviceId deviceId, PipelinerContext context) {
Saurav Das822c4e22015-10-23 10:51:11 -0700169 this.deviceId = deviceId;
170
Charles Chan425854b2016-04-11 15:32:12 -0700171 serviceDirectory = context.directory();
Saurav Das822c4e22015-10-23 10:51:11 -0700172 coreService = serviceDirectory.get(CoreService.class);
173 flowRuleService = serviceDirectory.get(FlowRuleService.class);
174 groupService = serviceDirectory.get(GroupService.class);
175 flowObjectiveStore = context.store();
Saurav Das822c4e22015-10-23 10:51:11 -0700176 deviceService = serviceDirectory.get(DeviceService.class);
Saurav Das822c4e22015-10-23 10:51:11 -0700177
Charles Chan40132b32017-01-22 00:19:37 -0800178 initDriverId();
179 initGroupHander(context);
Saurav Das822c4e22015-10-23 10:51:11 -0700180
Saurav Das822c4e22015-10-23 10:51:11 -0700181 initializePipeline();
Saurav Das822c4e22015-10-23 10:51:11 -0700182 }
183
Charles Chan40132b32017-01-22 00:19:37 -0800184 protected void initDriverId() {
185 driverId = coreService.registerApplication(
186 "org.onosproject.driver.Ofdpa2Pipeline");
187 }
188
189 protected void initGroupHander(PipelinerContext context) {
190 groupHandler = new Ofdpa2GroupHandler();
191 groupHandler.init(deviceId, context);
192 }
193
Saurav Das822c4e22015-10-23 10:51:11 -0700194 protected void initializePipeline() {
Charles Chan188ebf52015-12-23 00:15:11 -0800195 // OF-DPA does not require initializing the pipeline as it puts default
196 // rules automatically in the hardware. However emulation of OFDPA in
197 // software switches does require table-miss-entries.
Saurav Das822c4e22015-10-23 10:51:11 -0700198 }
199
Charles Chand1172632017-03-15 17:33:09 -0700200 /**
201 * Determines whether this pipeline requires OFDPA match and set VLAN extensions.
202 *
203 * @return true to use the extensions
204 */
205 protected boolean requireVlanExtensions() {
206 return true;
207 }
208
Saurav Das86d13e82017-04-28 17:03:48 -0700209 /**
210 * Determines whether in-port should be matched on in TMAC table rules.
211 *
212 * @return true if match on in-port should be programmed
213 */
214 protected boolean matchInPortTmacTable() {
215 return true;
216 }
217
Charles Chand9e47c62017-10-05 15:17:15 -0700218 /**
219 * Determines whether matching L4 destination port on IPv6 packets is supported in ACL table.
220 *
221 * @return true if matching L4 destination port on IPv6 packets is supported in ACL table.
222 */
223 protected boolean supportIpv6L4Dst() {
224 return true;
225 }
226
Saurav Das822c4e22015-10-23 10:51:11 -0700227 //////////////////////////////////////
228 // Flow Objectives
229 //////////////////////////////////////
230
231 @Override
232 public void filter(FilteringObjective filteringObjective) {
233 if (filteringObjective.type() == FilteringObjective.Type.PERMIT) {
234 processFilter(filteringObjective,
235 filteringObjective.op() == Objective.Operation.ADD,
236 filteringObjective.appId());
237 } else {
238 // Note that packets that don't match the PERMIT filter are
239 // automatically denied. The DENY filter is used to deny packets
240 // that are otherwise permitted by the PERMIT filter.
241 // Use ACL table flow rules here for DENY filtering objectives
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530242 log.warn("filter objective other than PERMIT currently not supported");
Saurav Das822c4e22015-10-23 10:51:11 -0700243 fail(filteringObjective, ObjectiveError.UNSUPPORTED);
244 }
245 }
246
247 @Override
248 public void forward(ForwardingObjective fwd) {
Saurav Das1ce0a7b2016-10-21 14:06:29 -0700249 Collection<FlowRule> rules = processForward(fwd);
Saurav Das25190812016-05-27 13:54:07 -0700250 if (rules == null || rules.isEmpty()) {
251 // Assumes fail message has already been generated to the objective
252 // context. Returning here prevents spurious pass message to be
253 // generated by FlowRule service for empty flowOps.
254 return;
255 }
Saurav Das1ce0a7b2016-10-21 14:06:29 -0700256 sendForward(fwd, rules);
257 }
258
259 protected void sendForward(ForwardingObjective fwd, Collection<FlowRule> rules) {
260 FlowRuleOperations.Builder flowOpsBuilder = FlowRuleOperations.builder();
Saurav Das822c4e22015-10-23 10:51:11 -0700261 switch (fwd.op()) {
Saurav Das1ce0a7b2016-10-21 14:06:29 -0700262 case ADD:
263 rules.stream()
264 .filter(Objects::nonNull)
265 .forEach(flowOpsBuilder::add);
Saurav Dasd2fded02016-12-02 15:43:47 -0800266 log.debug("Applying a add fwd-obj {} to sw:{}", fwd.id(), deviceId);
Saurav Das1ce0a7b2016-10-21 14:06:29 -0700267 break;
268 case REMOVE:
269 rules.stream()
270 .filter(Objects::nonNull)
271 .forEach(flowOpsBuilder::remove);
Pier Ventre42287df2016-11-09 14:17:26 -0800272 log.debug("Deleting a flow rule to sw:{}", deviceId);
Saurav Das1ce0a7b2016-10-21 14:06:29 -0700273 break;
274 default:
275 fail(fwd, ObjectiveError.UNKNOWN);
276 log.warn("Unknown forwarding type {}", fwd.op());
Saurav Das822c4e22015-10-23 10:51:11 -0700277 }
278
Saurav Das822c4e22015-10-23 10:51:11 -0700279 flowRuleService.apply(flowOpsBuilder.build(new FlowRuleOperationsContext() {
280 @Override
281 public void onSuccess(FlowRuleOperations ops) {
282 pass(fwd);
283 }
284
285 @Override
286 public void onError(FlowRuleOperations ops) {
287 fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED);
288 }
289 }));
Saurav Das822c4e22015-10-23 10:51:11 -0700290 }
291
292 @Override
293 public void next(NextObjective nextObjective) {
Saurav Das8a0732e2015-11-20 15:27:53 -0800294 NextGroup nextGroup = flowObjectiveStore.getNextGroup(nextObjective.id());
295 switch (nextObjective.op()) {
296 case ADD:
Saurav Das4f980082015-11-05 13:39:15 -0800297 if (nextGroup != null) {
Saurav Das8a0732e2015-11-20 15:27:53 -0800298 log.warn("Cannot add next {} that already exists in device {}",
299 nextObjective.id(), deviceId);
300 return;
301 }
Saurav Das1547b3f2017-05-05 17:01:08 -0700302 log.debug("Processing NextObjective id {} in dev {} - add group",
Saurav Das8a0732e2015-11-20 15:27:53 -0800303 nextObjective.id(), deviceId);
Charles Chan425854b2016-04-11 15:32:12 -0700304 groupHandler.addGroup(nextObjective);
Saurav Das8a0732e2015-11-20 15:27:53 -0800305 break;
306 case ADD_TO_EXISTING:
307 if (nextGroup != null) {
Saurav Das1547b3f2017-05-05 17:01:08 -0700308 log.debug("Processing NextObjective id {} in dev {} - add bucket",
Saurav Das8a0732e2015-11-20 15:27:53 -0800309 nextObjective.id(), deviceId);
Charles Chan425854b2016-04-11 15:32:12 -0700310 groupHandler.addBucketToGroup(nextObjective, nextGroup);
Saurav Das4f980082015-11-05 13:39:15 -0800311 } else {
Saurav Das8a0732e2015-11-20 15:27:53 -0800312 // it is possible that group-chain has not been fully created yet
Saurav Das423fe2b2015-12-04 10:52:59 -0800313 log.debug("Waiting to add bucket to group for next-id:{} in dev:{}",
314 nextObjective.id(), deviceId);
Yi Tseng47f82dc2017-03-05 22:48:39 -0800315
316 // by design multiple pending bucket is allowed for the group
317 groupHandler.pendingBuckets.compute(nextObjective.id(), (nextId, pendBkts) -> {
318 if (pendBkts == null) {
319 pendBkts = Sets.newHashSet();
320 }
321 pendBkts.add(nextObjective);
322 return pendBkts;
323 });
Saurav Das4f980082015-11-05 13:39:15 -0800324 }
Saurav Das8a0732e2015-11-20 15:27:53 -0800325 break;
326 case REMOVE:
327 if (nextGroup == null) {
328 log.warn("Cannot remove next {} that does not exist in device {}",
329 nextObjective.id(), deviceId);
330 return;
331 }
Saurav Das1547b3f2017-05-05 17:01:08 -0700332 log.debug("Processing NextObjective id {} in dev {} - remove group",
Saurav Das8a0732e2015-11-20 15:27:53 -0800333 nextObjective.id(), deviceId);
Charles Chan425854b2016-04-11 15:32:12 -0700334 groupHandler.removeGroup(nextObjective, nextGroup);
Saurav Das8a0732e2015-11-20 15:27:53 -0800335 break;
336 case REMOVE_FROM_EXISTING:
337 if (nextGroup == null) {
338 log.warn("Cannot remove from next {} that does not exist in device {}",
339 nextObjective.id(), deviceId);
340 return;
341 }
Saurav Das1547b3f2017-05-05 17:01:08 -0700342 log.debug("Processing NextObjective id {} in dev {} - remove bucket",
Saurav Das8a0732e2015-11-20 15:27:53 -0800343 nextObjective.id(), deviceId);
Charles Chan425854b2016-04-11 15:32:12 -0700344 groupHandler.removeBucketFromGroup(nextObjective, nextGroup);
Saurav Das8a0732e2015-11-20 15:27:53 -0800345 break;
Saurav Dasceccf242017-08-03 18:30:35 -0700346 case VERIFY:
347 if (nextGroup == null) {
348 log.warn("Cannot verify next {} that does not exist in device {}",
349 nextObjective.id(), deviceId);
350 return;
351 }
352 log.debug("Processing NextObjective id {} in dev {} - verify",
353 nextObjective.id(), deviceId);
354 groupHandler.verifyGroup(nextObjective, nextGroup);
355 break;
Saurav Das8a0732e2015-11-20 15:27:53 -0800356 default:
Saurav Das4f980082015-11-05 13:39:15 -0800357 log.warn("Unsupported operation {}", nextObjective.op());
Saurav Das822c4e22015-10-23 10:51:11 -0700358 }
359 }
360
361 //////////////////////////////////////
362 // Flow handling
363 //////////////////////////////////////
364
365 /**
Yi Tseng0fdc07e2017-04-24 19:17:08 -0700366 * As per OFDPA 2.0 TTP, filtering of VLAN ids and MAC addresses (for routing)
367 * configured on switch ports happen in different tables.
Saurav Das822c4e22015-10-23 10:51:11 -0700368 *
369 * @param filt the filtering objective
370 * @param install indicates whether to add or remove the objective
371 * @param applicationId the application that sent this objective
372 */
Saurav Das52025962016-01-28 22:30:01 -0800373 protected void processFilter(FilteringObjective filt,
374 boolean install, ApplicationId applicationId) {
Saurav Das822c4e22015-10-23 10:51:11 -0700375 // This driver only processes filtering criteria defined with switch
376 // ports as the key
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530377 PortCriterion portCriterion = null;
Saurav Das822c4e22015-10-23 10:51:11 -0700378 EthCriterion ethCriterion = null;
379 VlanIdCriterion vidCriterion = null;
Saurav Das822c4e22015-10-23 10:51:11 -0700380 if (!filt.key().equals(Criteria.dummy()) &&
381 filt.key().type() == Criterion.Type.IN_PORT) {
382 portCriterion = (PortCriterion) filt.key();
Saurav Das822c4e22015-10-23 10:51:11 -0700383 }
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530384 if (portCriterion == null) {
385 log.debug("No IN_PORT defined in filtering objective from app: {}",
386 applicationId);
387 } else {
388 log.debug("Received filtering objective for dev/port: {}/{}", deviceId,
389 portCriterion.port());
390 }
Saurav Das822c4e22015-10-23 10:51:11 -0700391 // convert filtering conditions for switch-intfs into flowrules
392 FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
393 for (Criterion criterion : filt.conditions()) {
Yi Tseng0fdc07e2017-04-24 19:17:08 -0700394 switch (criterion.type()) {
395 case ETH_DST:
396 case ETH_DST_MASKED:
397 ethCriterion = (EthCriterion) criterion;
398 break;
399 case VLAN_VID:
400 vidCriterion = (VlanIdCriterion) criterion;
401 break;
402 default:
403 log.warn("Unsupported filter {}", criterion);
404 fail(filt, ObjectiveError.UNSUPPORTED);
405 return;
Saurav Das822c4e22015-10-23 10:51:11 -0700406 }
407 }
408
Saurav Das0e99e2b2015-10-28 12:39:42 -0700409 VlanId assignedVlan = null;
Charles Chane849c192016-01-11 18:28:54 -0800410 if (vidCriterion != null) {
Charles Chand55e84d2016-03-30 17:54:24 -0700411 // Use the VLAN in metadata whenever a metadata is provided
412 if (filt.meta() != null) {
413 assignedVlan = readVlanFromTreatment(filt.meta());
414 // Use the VLAN in criterion if metadata is not present and the traffic is tagged
415 } else if (!vidCriterion.vlanId().equals(VlanId.NONE)) {
Charles Chane849c192016-01-11 18:28:54 -0800416 assignedVlan = vidCriterion.vlanId();
Charles Chand55e84d2016-03-30 17:54:24 -0700417 }
Charles Chane849c192016-01-11 18:28:54 -0800418
Charles Chand55e84d2016-03-30 17:54:24 -0700419 if (assignedVlan == null) {
420 log.error("Driver fails to extract VLAN information. "
Frank Wangd8ab0962017-08-11 11:09:30 +0800421 + "Not processing VLAN filters on device {}.", deviceId);
Charles Chand55e84d2016-03-30 17:54:24 -0700422 log.debug("VLAN ID in criterion={}, metadata={}",
423 readVlanFromTreatment(filt.meta()), vidCriterion.vlanId());
424 fail(filt, ObjectiveError.BADPARAMS);
425 return;
Saurav Das0e99e2b2015-10-28 12:39:42 -0700426 }
427 }
428
Yi Tseng3a77b4f2017-02-06 15:02:17 -0800429 if (ethCriterion == null || ethCriterion.mac().equals(NONE)) {
Charles Chan985b12e2016-05-11 19:47:22 -0700430 // NOTE: it is possible that a filtering objective only has vidCriterion
Saurav Das961beb22017-03-29 19:09:17 -0700431 log.warn("filtering objective missing dstMac, cannot program TMAC table");
Saurav Das822c4e22015-10-23 10:51:11 -0700432 } else {
433 for (FlowRule tmacRule : processEthDstFilter(portCriterion, ethCriterion,
Saurav Das0e99e2b2015-10-28 12:39:42 -0700434 vidCriterion, assignedVlan,
435 applicationId)) {
Saurav Das961beb22017-03-29 19:09:17 -0700436 log.trace("{} MAC filtering rules in TMAC table: {} for dev: {}",
Saurav Das018605f2017-02-18 14:05:44 -0800437 (install) ? "adding" : "removing", tmacRule, deviceId);
Saurav Das822c4e22015-10-23 10:51:11 -0700438 ops = install ? ops.add(tmacRule) : ops.remove(tmacRule);
439 }
440 }
441
Charles Chan985b12e2016-05-11 19:47:22 -0700442 if (vidCriterion == null) {
443 // NOTE: it is possible that a filtering objective only has ethCriterion
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530444 log.info("filtering objective missing VLAN, cannot program VLAN Table");
Saurav Das822c4e22015-10-23 10:51:11 -0700445 } else {
Charles Chan14967c22015-12-07 11:11:50 -0800446 /*
447 * NOTE: Separate vlan filtering rules and assignment rules
448 * into different stage in order to guarantee that filtering rules
Saurav Das52025962016-01-28 22:30:01 -0800449 * always go first, as required by ofdpa.
Charles Chan14967c22015-12-07 11:11:50 -0800450 */
451 List<FlowRule> allRules = processVlanIdFilter(
452 portCriterion, vidCriterion, assignedVlan, applicationId);
453 List<FlowRule> filteringRules = new ArrayList<>();
454 List<FlowRule> assignmentRules = new ArrayList<>();
455
456 allRules.forEach(flowRule -> {
Charles Chand1172632017-03-15 17:33:09 -0700457 VlanId vlanId;
458 if (requireVlanExtensions()) {
459 ExtensionCriterion extCriterion =
460 (ExtensionCriterion) flowRule.selector().getCriterion(Criterion.Type.EXTENSION);
461 vlanId = ((OfdpaMatchVlanVid) extCriterion.extensionSelector()).vlanId();
462 } else {
463 VlanIdCriterion vlanIdCriterion =
464 (VlanIdCriterion) flowRule.selector().getCriterion(Criterion.Type.VLAN_VID);
465 vlanId = vlanIdCriterion.vlanId();
466 }
Charles Chanbe8aea42016-02-24 12:04:47 -0800467 if (!vlanId.equals(VlanId.NONE)) {
Charles Chan14967c22015-12-07 11:11:50 -0800468 filteringRules.add(flowRule);
469 } else {
470 assignmentRules.add(flowRule);
471 }
472 });
473
474 for (FlowRule filteringRule : filteringRules) {
Saurav Das961beb22017-03-29 19:09:17 -0700475 log.trace("{} VLAN filtering rule in VLAN table: {} for dev: {}",
Saurav Das018605f2017-02-18 14:05:44 -0800476 (install) ? "adding" : "removing", filteringRule, deviceId);
Charles Chan14967c22015-12-07 11:11:50 -0800477 ops = install ? ops.add(filteringRule) : ops.remove(filteringRule);
478 }
479
480 ops.newStage();
481
482 for (FlowRule assignmentRule : assignmentRules) {
Saurav Das961beb22017-03-29 19:09:17 -0700483 log.trace("{} VLAN assignment rule in VLAN table: {} for dev: {}",
Saurav Das018605f2017-02-18 14:05:44 -0800484 (install) ? "adding" : "removing", assignmentRule, deviceId);
Charles Chan14967c22015-12-07 11:11:50 -0800485 ops = install ? ops.add(assignmentRule) : ops.remove(assignmentRule);
Saurav Das822c4e22015-10-23 10:51:11 -0700486 }
487 }
488
Saurav Das822c4e22015-10-23 10:51:11 -0700489 // apply filtering flow rules
490 flowRuleService.apply(ops.build(new FlowRuleOperationsContext() {
491 @Override
492 public void onSuccess(FlowRuleOperations ops) {
Saurav Das018605f2017-02-18 14:05:44 -0800493 log.debug("Applied {} filtering rules in device {}",
Saurav Das822c4e22015-10-23 10:51:11 -0700494 ops.stages().get(0).size(), deviceId);
495 pass(filt);
496 }
497
498 @Override
499 public void onError(FlowRuleOperations ops) {
500 log.info("Failed to apply all filtering rules in dev {}", deviceId);
501 fail(filt, ObjectiveError.FLOWINSTALLATIONFAILED);
502 }
503 }));
504
505 }
506
507 /**
Charles Chand1172632017-03-15 17:33:09 -0700508 * Internal implementation of processVlanIdFilter.
509 * <p>
510 * The is_present bit in set_vlan_vid action is required to be 0 in OFDPA i12.
511 * Since it is non-OF spec, we need an extension treatment for that.
512 * The useVlanExtension must be set to false for OFDPA i12.
513 * </p>
Saurav Das0e99e2b2015-10-28 12:39:42 -0700514 *
Charles Chanf9e98652016-09-07 16:54:23 -0700515 * @param portCriterion port on device for which this filter is programmed
516 * @param vidCriterion vlan assigned to port, or NONE for untagged
517 * @param assignedVlan assigned vlan-id for untagged packets
518 * @param applicationId for application programming this filter
Saurav Das822c4e22015-10-23 10:51:11 -0700519 * @return list of FlowRule for port-vlan filters
520 */
521 protected List<FlowRule> processVlanIdFilter(PortCriterion portCriterion,
Yi Tsengef19de12017-04-24 11:33:05 -0700522 VlanIdCriterion vidCriterion,
523 VlanId assignedVlan,
524 ApplicationId applicationId) {
Charles Chan14967c22015-12-07 11:11:50 -0800525 List<FlowRule> rules = new ArrayList<>();
Saurav Das822c4e22015-10-23 10:51:11 -0700526 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
527 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
Charles Chan14967c22015-12-07 11:11:50 -0800528 TrafficSelector.Builder preSelector = null;
529 TrafficTreatment.Builder preTreatment = null;
530
Saurav Das4f980082015-11-05 13:39:15 -0800531 treatment.transition(TMAC_TABLE);
532
Saurav Das822c4e22015-10-23 10:51:11 -0700533 if (vidCriterion.vlanId() == VlanId.NONE) {
534 // untagged packets are assigned vlans
Charles Chand1172632017-03-15 17:33:09 -0700535 preSelector = DefaultTrafficSelector.builder();
536 if (requireVlanExtensions()) {
537 OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(VlanId.NONE);
538 selector.extension(ofdpaMatchVlanVid, deviceId);
Charles Chanf9e98652016-09-07 16:54:23 -0700539 OfdpaSetVlanVid ofdpaSetVlanVid = new OfdpaSetVlanVid(assignedVlan);
540 treatment.extension(ofdpaSetVlanVid, deviceId);
Charles Chand1172632017-03-15 17:33:09 -0700541
542 OfdpaMatchVlanVid preOfdpaMatchVlanVid = new OfdpaMatchVlanVid(assignedVlan);
543 preSelector.extension(preOfdpaMatchVlanVid, deviceId);
Charles Chanf9e98652016-09-07 16:54:23 -0700544 } else {
Charles Chand1172632017-03-15 17:33:09 -0700545 selector.matchVlanId(VlanId.NONE);
Charles Chanf9e98652016-09-07 16:54:23 -0700546 treatment.setVlanId(assignedVlan);
Charles Chand1172632017-03-15 17:33:09 -0700547
548 preSelector.matchVlanId(assignedVlan);
549 }
550 preTreatment = DefaultTrafficTreatment.builder().transition(TMAC_TABLE);
551 } else {
552 if (requireVlanExtensions()) {
553 OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(vidCriterion.vlanId());
554 selector.extension(ofdpaMatchVlanVid, deviceId);
555 } else {
556 selector.matchVlanId(vidCriterion.vlanId());
Charles Chanf9e98652016-09-07 16:54:23 -0700557 }
Charles Chan14967c22015-12-07 11:11:50 -0800558
Charles Chand55e84d2016-03-30 17:54:24 -0700559 if (!assignedVlan.equals(vidCriterion.vlanId())) {
Charles Chand1172632017-03-15 17:33:09 -0700560 if (requireVlanExtensions()) {
Charles Chanc03782d2017-01-31 13:57:55 -0800561 OfdpaSetVlanVid ofdpaSetVlanVid = new OfdpaSetVlanVid(assignedVlan);
562 treatment.extension(ofdpaSetVlanVid, deviceId);
563 } else {
564 treatment.setVlanId(assignedVlan);
565 }
Charles Chand55e84d2016-03-30 17:54:24 -0700566 }
Saurav Das822c4e22015-10-23 10:51:11 -0700567 }
Saurav Das822c4e22015-10-23 10:51:11 -0700568
569 // ofdpa cannot match on ALL portnumber, so we need to use separate
570 // rules for each port.
Charles Chan14967c22015-12-07 11:11:50 -0800571 List<PortNumber> portnums = new ArrayList<>();
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530572 if (portCriterion != null) {
573 if (PortNumber.ALL.equals(portCriterion.port())) {
574 for (Port port : deviceService.getPorts(deviceId)) {
575 if (port.number().toLong() > 0 && port.number().toLong() < OFPP_MAX) {
576 portnums.add(port.number());
577 }
Saurav Das822c4e22015-10-23 10:51:11 -0700578 }
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530579 } else {
580 portnums.add(portCriterion.port());
Saurav Das822c4e22015-10-23 10:51:11 -0700581 }
582 } else {
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530583 log.warn("Filtering Objective missing Port Criterion . " +
584 "VLAN Table cannot be programmed for {}",
585 deviceId);
Saurav Das822c4e22015-10-23 10:51:11 -0700586 }
Saurav Das4f980082015-11-05 13:39:15 -0800587
Saurav Das822c4e22015-10-23 10:51:11 -0700588 for (PortNumber pnum : portnums) {
Saurav Das4f980082015-11-05 13:39:15 -0800589 // create rest of flowrule
Saurav Das822c4e22015-10-23 10:51:11 -0700590 selector.matchInPort(pnum);
591 FlowRule rule = DefaultFlowRule.builder()
592 .forDevice(deviceId)
593 .withSelector(selector.build())
594 .withTreatment(treatment.build())
595 .withPriority(DEFAULT_PRIORITY)
596 .fromApp(applicationId)
597 .makePermanent()
598 .forTable(VLAN_TABLE).build();
Charles Chan14967c22015-12-07 11:11:50 -0800599
600 if (preSelector != null) {
601 preSelector.matchInPort(pnum);
602 FlowRule preRule = DefaultFlowRule.builder()
603 .forDevice(deviceId)
604 .withSelector(preSelector.build())
605 .withTreatment(preTreatment.build())
606 .withPriority(DEFAULT_PRIORITY)
607 .fromApp(applicationId)
608 .makePermanent()
609 .forTable(VLAN_TABLE).build();
610 rules.add(preRule);
611 }
612
Saurav Das822c4e22015-10-23 10:51:11 -0700613 rules.add(rule);
614 }
615 return rules;
616 }
617
618 /**
619 * Allows routed packets with correct destination MAC to be directed
620 * to unicast-IP routing table or MPLS forwarding table.
Saurav Das822c4e22015-10-23 10:51:11 -0700621 *
622 * @param portCriterion port on device for which this filter is programmed
623 * @param ethCriterion dstMac of device for which is filter is programmed
624 * @param vidCriterion vlan assigned to port, or NONE for untagged
Saurav Das0e99e2b2015-10-28 12:39:42 -0700625 * @param assignedVlan assigned vlan-id for untagged packets
Saurav Das822c4e22015-10-23 10:51:11 -0700626 * @param applicationId for application programming this filter
627 * @return list of FlowRule for port-vlan filters
628
629 */
630 protected List<FlowRule> processEthDstFilter(PortCriterion portCriterion,
631 EthCriterion ethCriterion,
632 VlanIdCriterion vidCriterion,
Saurav Das0e99e2b2015-10-28 12:39:42 -0700633 VlanId assignedVlan,
Saurav Das822c4e22015-10-23 10:51:11 -0700634 ApplicationId applicationId) {
Charles Chan5270ed02016-01-30 23:22:37 -0800635 // Consider PortNumber.ANY as wildcard. Match ETH_DST only
Sivachidambaram Subramanianc598d062017-05-16 22:42:06 +0530636 if (portCriterion != null && PortNumber.ANY.equals(portCriterion.port())) {
Charles Chan5270ed02016-01-30 23:22:37 -0800637 return processEthDstOnlyFilter(ethCriterion, applicationId);
638 }
639
Charles Chan5b9df8d2016-03-28 22:21:40 -0700640 // Multicast MAC
641 if (ethCriterion.mask() != null) {
Charles Chanb4879a52017-10-20 19:09:16 -0700642 return processMcastEthDstFilter(ethCriterion, assignedVlan, applicationId);
Charles Chan5b9df8d2016-03-28 22:21:40 -0700643 }
644
Saurav Das822c4e22015-10-23 10:51:11 -0700645 //handling untagged packets via assigned VLAN
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530646 if (vidCriterion != null && vidCriterion.vlanId() == VlanId.NONE) {
Saurav Das0e99e2b2015-10-28 12:39:42 -0700647 vidCriterion = (VlanIdCriterion) Criteria.matchVlanId(assignedVlan);
Saurav Das822c4e22015-10-23 10:51:11 -0700648 }
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530649 List<FlowRule> rules = new ArrayList<>();
650 OfdpaMatchVlanVid ofdpaMatchVlanVid = null;
651 if (vidCriterion != null && requireVlanExtensions()) {
652 ofdpaMatchVlanVid = new OfdpaMatchVlanVid(vidCriterion.vlanId());
653 }
Saurav Das822c4e22015-10-23 10:51:11 -0700654 // ofdpa cannot match on ALL portnumber, so we need to use separate
655 // rules for each port.
Yuta HIGUCHI2dce08a2017-04-20 21:57:48 -0700656 List<PortNumber> portnums = new ArrayList<>();
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530657 if (portCriterion != null) {
658 if (PortNumber.ALL.equals(portCriterion.port())) {
659 for (Port port : deviceService.getPorts(deviceId)) {
660 if (port.number().toLong() > 0 && port.number().toLong() < OFPP_MAX) {
661 portnums.add(port.number());
662 }
Saurav Das822c4e22015-10-23 10:51:11 -0700663 }
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530664 } else {
665 portnums.add(portCriterion.port());
666 }
667 for (PortNumber pnum : portnums) {
668 rules.add(buildTmacRuleForIpv4(ethCriterion,
669 vidCriterion,
670 ofdpaMatchVlanVid,
671 applicationId,
672 pnum));
673 rules.add(buildTmacRuleForMpls(ethCriterion,
674 vidCriterion,
675 ofdpaMatchVlanVid,
676 applicationId,
677 pnum));
678 rules.add(buildTmacRuleForIpv6(ethCriterion,
679 vidCriterion,
680 ofdpaMatchVlanVid,
681 applicationId,
682 pnum));
Saurav Das822c4e22015-10-23 10:51:11 -0700683 }
684 } else {
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530685 rules.add(buildTmacRuleForIpv4(ethCriterion,
686 vidCriterion,
687 ofdpaMatchVlanVid,
688 applicationId,
689 null));
690 rules.add(buildTmacRuleForMpls(ethCriterion,
691 vidCriterion,
692 ofdpaMatchVlanVid,
693 applicationId,
694 null));
695 rules.add(buildTmacRuleForIpv6(ethCriterion,
696 vidCriterion,
697 ofdpaMatchVlanVid,
698 applicationId,
699 null));
Saurav Das822c4e22015-10-23 10:51:11 -0700700 }
701 return rules;
702 }
703
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +0530704 /**
705 * Builds TMAC rules for IPv4 packets.
706 *
707 * @param ethCriterion
708 * @param vidCriterion
709 * @param ofdpaMatchVlanVid
710 * @param applicationId
711 * @param pnum
712 * @return TMAC rule for IPV4 packets
713 */
714 private FlowRule buildTmacRuleForIpv4(EthCriterion ethCriterion,
715 VlanIdCriterion vidCriterion,
716 OfdpaMatchVlanVid ofdpaMatchVlanVid,
717 ApplicationId applicationId,
718 PortNumber pnum) {
719 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
720 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
721 if (pnum != null) {
722 if (matchInPortTmacTable()) {
723 selector.matchInPort(pnum);
724 } else {
725 log.info("Pipeline does not support IN_PORT matching in TMAC table, " +
726 "ignoring the IN_PORT criteria");
727 }
728 }
729 if (vidCriterion != null) {
730 if (requireVlanExtensions()) {
731 selector.extension(ofdpaMatchVlanVid, deviceId);
732 } else {
733 selector.matchVlanId(vidCriterion.vlanId());
734 }
735 }
736 selector.matchEthType(Ethernet.TYPE_IPV4);
737 selector.matchEthDst(ethCriterion.mac());
738 treatment.transition(UNICAST_ROUTING_TABLE);
739 return DefaultFlowRule.builder()
740 .forDevice(deviceId)
741 .withSelector(selector.build())
742 .withTreatment(treatment.build())
743 .withPriority(DEFAULT_PRIORITY)
744 .fromApp(applicationId)
745 .makePermanent()
746 .forTable(TMAC_TABLE).build();
747 }
748
749 /**
750 * Builds TMAC rule for MPLS packets.
751 *
752 * @param ethCriterion
753 * @param vidCriterion
754 * @param ofdpaMatchVlanVid
755 * @param applicationId
756 * @param pnum
757 * @return TMAC rule for MPLS packets
758 */
759 private FlowRule buildTmacRuleForMpls(EthCriterion ethCriterion,
760 VlanIdCriterion vidCriterion,
761 OfdpaMatchVlanVid ofdpaMatchVlanVid,
762 ApplicationId applicationId,
763 PortNumber pnum) {
764 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
765 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
766 if (pnum != null) {
767 if (matchInPortTmacTable()) {
768 selector.matchInPort(pnum);
769 } else {
770 log.info("Pipeline does not support IN_PORT matching in TMAC table, " +
771 "ignoring the IN_PORT criteria");
772 }
773 }
774 if (vidCriterion != null) {
775 if (requireVlanExtensions()) {
776 selector.extension(ofdpaMatchVlanVid, deviceId);
777 } else {
778 selector.matchVlanId(vidCriterion.vlanId());
779 }
780 }
781 selector.matchEthType(Ethernet.MPLS_UNICAST);
782 selector.matchEthDst(ethCriterion.mac());
783 treatment.transition(MPLS_TABLE_0);
784 return DefaultFlowRule.builder()
785 .forDevice(deviceId)
786 .withSelector(selector.build())
787 .withTreatment(treatment.build())
788 .withPriority(DEFAULT_PRIORITY)
789 .fromApp(applicationId)
790 .makePermanent()
791 .forTable(TMAC_TABLE).build();
792 }
793
794 /**
795 * Builds TMAC rules for IPv6 packets.
796 *
797 * @param ethCriterion
798 * @param vidCriterion
799 * @param ofdpaMatchVlanVid
800 * @param applicationId
801 * @param pnum
802 * @return TMAC rule for IPV6 packets
803 */
804 private FlowRule buildTmacRuleForIpv6(EthCriterion ethCriterion,
805 VlanIdCriterion vidCriterion,
806 OfdpaMatchVlanVid ofdpaMatchVlanVid,
807 ApplicationId applicationId,
808 PortNumber pnum) {
809 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
810 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
811 if (pnum != null) {
812 if (matchInPortTmacTable()) {
813 selector.matchInPort(pnum);
814 } else {
815 log.info("Pipeline does not support IN_PORT matching in TMAC table, " +
816 "ignoring the IN_PORT criteria");
817 }
818 }
819 if (vidCriterion != null) {
820 if (requireVlanExtensions()) {
821 selector.extension(ofdpaMatchVlanVid, deviceId);
822 } else {
823 selector.matchVlanId(vidCriterion.vlanId());
824 }
825 }
826 selector.matchEthType(Ethernet.TYPE_IPV6);
827 selector.matchEthDst(ethCriterion.mac());
828 treatment.transition(UNICAST_ROUTING_TABLE);
829 return DefaultFlowRule.builder()
830 .forDevice(deviceId)
831 .withSelector(selector.build())
832 .withTreatment(treatment.build())
833 .withPriority(DEFAULT_PRIORITY)
834 .fromApp(applicationId)
835 .makePermanent()
836 .forTable(TMAC_TABLE).build();
837 }
838
Charles Chan5270ed02016-01-30 23:22:37 -0800839 protected List<FlowRule> processEthDstOnlyFilter(EthCriterion ethCriterion,
Yi Tsengef19de12017-04-24 11:33:05 -0700840 ApplicationId applicationId) {
Pier Luigi0e358632017-01-31 09:35:05 -0800841 ImmutableList.Builder<FlowRule> builder = ImmutableList.builder();
842
Charles Chan5270ed02016-01-30 23:22:37 -0800843 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
844 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
845 selector.matchEthType(Ethernet.TYPE_IPV4);
846 selector.matchEthDst(ethCriterion.mac());
847 treatment.transition(UNICAST_ROUTING_TABLE);
848 FlowRule rule = DefaultFlowRule.builder()
849 .forDevice(deviceId)
850 .withSelector(selector.build())
851 .withTreatment(treatment.build())
852 .withPriority(DEFAULT_PRIORITY)
853 .fromApp(applicationId)
854 .makePermanent()
855 .forTable(TMAC_TABLE).build();
Pier Luigi0e358632017-01-31 09:35:05 -0800856 builder.add(rule);
857
858 selector = DefaultTrafficSelector.builder();
859 treatment = DefaultTrafficTreatment.builder();
860 selector.matchEthType(Ethernet.TYPE_IPV6);
861 selector.matchEthDst(ethCriterion.mac());
862 treatment.transition(UNICAST_ROUTING_TABLE);
863 rule = DefaultFlowRule.builder()
864 .forDevice(deviceId)
865 .withSelector(selector.build())
866 .withTreatment(treatment.build())
867 .withPriority(DEFAULT_PRIORITY)
868 .fromApp(applicationId)
869 .makePermanent()
870 .forTable(TMAC_TABLE).build();
871 return builder.add(rule).build();
Charles Chan5270ed02016-01-30 23:22:37 -0800872 }
873
Charles Chan5b9df8d2016-03-28 22:21:40 -0700874 protected List<FlowRule> processMcastEthDstFilter(EthCriterion ethCriterion,
Charles Chanb4879a52017-10-20 19:09:16 -0700875 VlanId assignedVlan,
Yi Tsengef19de12017-04-24 11:33:05 -0700876 ApplicationId applicationId) {
Julia Ferguson65428c32017-08-10 18:15:24 +0000877 ImmutableList.Builder<FlowRule> builder = ImmutableList.builder();
Charles Chan5b9df8d2016-03-28 22:21:40 -0700878 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
879 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
Charles Chanb4879a52017-10-20 19:09:16 -0700880 FlowRule rule;
Julia Ferguson65428c32017-08-10 18:15:24 +0000881
Charles Chanb4879a52017-10-20 19:09:16 -0700882 if (IPV4_MULTICAST.equals(ethCriterion.mac())) {
883 selector.matchEthType(Ethernet.TYPE_IPV4);
884 selector.matchEthDstMasked(ethCriterion.mac(), ethCriterion.mask());
885 selector.matchVlanId(assignedVlan);
886 treatment.transition(MULTICAST_ROUTING_TABLE);
887 rule = DefaultFlowRule.builder()
888 .forDevice(deviceId)
889 .withSelector(selector.build())
890 .withTreatment(treatment.build())
891 .withPriority(DEFAULT_PRIORITY)
892 .fromApp(applicationId)
893 .makePermanent()
894 .forTable(TMAC_TABLE).build();
895 builder.add(rule);
896 }
897
898 if (IPV6_MULTICAST.equals(ethCriterion.mac())) {
899 selector = DefaultTrafficSelector.builder();
900 treatment = DefaultTrafficTreatment.builder();
901 selector.matchEthType(Ethernet.TYPE_IPV6);
902 selector.matchEthDstMasked(ethCriterion.mac(), ethCriterion.mask());
903 selector.matchVlanId(assignedVlan);
904 treatment.transition(MULTICAST_ROUTING_TABLE);
905 rule = DefaultFlowRule.builder()
906 .forDevice(deviceId)
907 .withSelector(selector.build())
908 .withTreatment(treatment.build())
909 .withPriority(DEFAULT_PRIORITY)
910 .fromApp(applicationId)
911 .makePermanent()
912 .forTable(TMAC_TABLE).build();
913 builder.add(rule);
914 }
915 return builder.build();
Charles Chan5b9df8d2016-03-28 22:21:40 -0700916 }
917
Saurav Das822c4e22015-10-23 10:51:11 -0700918 private Collection<FlowRule> processForward(ForwardingObjective fwd) {
919 switch (fwd.flag()) {
920 case SPECIFIC:
921 return processSpecific(fwd);
922 case VERSATILE:
923 return processVersatile(fwd);
924 default:
925 fail(fwd, ObjectiveError.UNKNOWN);
926 log.warn("Unknown forwarding flag {}", fwd.flag());
927 }
928 return Collections.emptySet();
929 }
930
931 /**
932 * In the OF-DPA 2.0 pipeline, versatile forwarding objectives go to the
933 * ACL table.
934 * @param fwd the forwarding objective of type 'versatile'
935 * @return a collection of flow rules to be sent to the switch. An empty
936 * collection may be returned if there is a problem in processing
937 * the flow rule
938 */
Saurav Das52025962016-01-28 22:30:01 -0800939 protected Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
Saurav Das018605f2017-02-18 14:05:44 -0800940 log.debug("Processing versatile forwarding objective:{} in dev:{}",
Saurav Dasd2fded02016-12-02 15:43:47 -0800941 fwd.id(), deviceId);
Saurav Das822c4e22015-10-23 10:51:11 -0700942
943 EthTypeCriterion ethType =
Saurav Das77b5e902016-01-27 17:01:59 -0800944 (EthTypeCriterion) fwd.selector().getCriterion(Criterion.Type.ETH_TYPE);
Saurav Das822c4e22015-10-23 10:51:11 -0700945 if (ethType == null) {
Saurav Dasd2fded02016-12-02 15:43:47 -0800946 log.error("Versatile forwarding objective:{} must include ethType",
947 fwd.id());
Saurav Das822c4e22015-10-23 10:51:11 -0700948 fail(fwd, ObjectiveError.BADPARAMS);
949 return Collections.emptySet();
950 }
951 if (fwd.nextId() == null && fwd.treatment() == null) {
952 log.error("Forwarding objective {} from {} must contain "
953 + "nextId or Treatment", fwd.selector(), fwd.appId());
Zsolt Haraszti9faab752016-02-17 15:55:20 -0800954 fail(fwd, ObjectiveError.BADPARAMS);
Saurav Das822c4e22015-10-23 10:51:11 -0700955 return Collections.emptySet();
956 }
Saurav Das49cb5a12016-01-16 22:54:07 -0800957
Saurav Das77b5e902016-01-27 17:01:59 -0800958 TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
959 fwd.selector().criteria().forEach(criterion -> {
960 if (criterion instanceof VlanIdCriterion) {
961 VlanId vlanId = ((VlanIdCriterion) criterion).vlanId();
962 // ensure that match does not include vlan = NONE as OF-DPA does not
963 // match untagged packets this way in the ACL table.
964 if (vlanId.equals(VlanId.NONE)) {
965 return;
966 }
Charles Chand1172632017-03-15 17:33:09 -0700967 if (requireVlanExtensions()) {
968 OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(vlanId);
969 sbuilder.extension(ofdpaMatchVlanVid, deviceId);
970 } else {
971 sbuilder.matchVlanId(vlanId);
972 }
Pier Ventree0ae7a32016-11-23 09:57:42 -0800973 } else if (criterion instanceof Icmpv6TypeCriterion ||
974 criterion instanceof Icmpv6CodeCriterion) {
975 /*
976 * We silenty discard these criterions, our current
977 * OFDPA platform does not support these matches on
978 * the ACL table.
979 */
980 log.warn("ICMPv6 Type and ICMPv6 Code are not supported");
Charles Chand9e47c62017-10-05 15:17:15 -0700981 } else if (criterion instanceof TcpPortCriterion || criterion instanceof UdpPortCriterion) {
982 // FIXME: QMX switches do not support L4 dst port matching in ACL table.
983 // Currently L4 dst port matching is only used by DHCP relay feature
984 // and therefore is safe to be replaced with L4 src port matching.
985 // We need to revisit this if L4 dst port is used for other purpose in the future.
986 if (!supportIpv6L4Dst() && isIpv6(fwd.selector())) {
987 TpPort tpPort = (criterion instanceof TcpPortCriterion) ?
988 ((TcpPortCriterion) criterion).tcpPort() :
989 ((UdpPortCriterion) criterion).udpPort();
990 TpPort tpMask = (criterion instanceof TcpPortCriterion) ?
991 ((TcpPortCriterion) criterion).mask() :
992 ((UdpPortCriterion) criterion).mask();
993 switch (criterion.type()) {
994 case UDP_DST:
995 sbuilder.matchUdpSrc(tpPort);
996 break;
997 case UDP_DST_MASKED:
998 sbuilder.matchUdpSrcMasked(tpPort, tpMask);
999 break;
1000 case TCP_DST:
1001 sbuilder.matchTcpSrc(tpPort);
1002 break;
1003 case TCP_DST_MASKED:
1004 sbuilder.matchTcpSrcMasked(tpPort, tpMask);
1005 break;
1006 default:
1007 sbuilder.add(criterion);
1008 }
1009 } else {
1010 sbuilder.add(criterion);
1011 }
Saurav Das77b5e902016-01-27 17:01:59 -08001012 } else {
1013 sbuilder.add(criterion);
1014 }
1015 });
1016
Saurav Das822c4e22015-10-23 10:51:11 -07001017 // XXX driver does not currently do type checking as per Tables 65-67 in
1018 // OFDPA 2.0 spec. The only allowed treatment is a punt to the controller.
Saurav Das49cb5a12016-01-16 22:54:07 -08001019 TrafficTreatment.Builder ttBuilder = DefaultTrafficTreatment.builder();
1020 if (fwd.treatment() != null) {
1021 for (Instruction ins : fwd.treatment().allInstructions()) {
1022 if (ins instanceof OutputInstruction) {
1023 OutputInstruction o = (OutputInstruction) ins;
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +05301024 if (o != null && PortNumber.CONTROLLER.equals(o.port())) {
Saurav Das49cb5a12016-01-16 22:54:07 -08001025 ttBuilder.add(o);
1026 } else {
1027 log.warn("Only allowed treatments in versatile forwarding "
1028 + "objectives are punts to the controller");
1029 }
1030 } else {
1031 log.warn("Cannot process instruction in versatile fwd {}", ins);
1032 }
Saurav Das822c4e22015-10-23 10:51:11 -07001033 }
Charles Chan2df0e8a2017-01-09 11:45:08 -08001034 if (fwd.treatment().clearedDeferred()) {
1035 ttBuilder.wipeDeferred();
1036 }
Saurav Das822c4e22015-10-23 10:51:11 -07001037 }
Saurav Das822c4e22015-10-23 10:51:11 -07001038 if (fwd.nextId() != null) {
Saurav Das49cb5a12016-01-16 22:54:07 -08001039 // overide case
1040 NextGroup next = getGroupForNextObjective(fwd.nextId());
Sivachidambaram Subramaniana0efdcc2017-06-22 05:26:46 +05301041 if (next == null) {
1042 fail(fwd, ObjectiveError.BADPARAMS);
1043 return Collections.emptySet();
1044 }
Saurav Das49cb5a12016-01-16 22:54:07 -08001045 List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
1046 // we only need the top level group's key to point the flow to it
1047 Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst());
1048 if (group == null) {
1049 log.warn("Group with key:{} for next-id:{} not found in dev:{}",
1050 gkeys.get(0).peekFirst(), fwd.nextId(), deviceId);
1051 fail(fwd, ObjectiveError.GROUPMISSING);
1052 return Collections.emptySet();
1053 }
1054 ttBuilder.deferred().group(group.id());
Saurav Das822c4e22015-10-23 10:51:11 -07001055 }
Saurav Das49cb5a12016-01-16 22:54:07 -08001056
1057 FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
1058 .fromApp(fwd.appId())
1059 .withPriority(fwd.priority())
1060 .forDevice(deviceId)
Saurav Das77b5e902016-01-27 17:01:59 -08001061 .withSelector(sbuilder.build())
Saurav Das49cb5a12016-01-16 22:54:07 -08001062 .withTreatment(ttBuilder.build())
1063 .makePermanent()
1064 .forTable(ACL_TABLE);
1065 return Collections.singletonList(ruleBuilder.build());
Saurav Das822c4e22015-10-23 10:51:11 -07001066 }
1067
1068 /**
1069 * In the OF-DPA 2.0 pipeline, specific forwarding refers to the IP table
Saurav Das8a0732e2015-11-20 15:27:53 -08001070 * (unicast or multicast) or the L2 table (mac + vlan) or the MPLS table.
Saurav Das822c4e22015-10-23 10:51:11 -07001071 *
1072 * @param fwd the forwarding objective of type 'specific'
1073 * @return a collection of flow rules. Typically there will be only one
1074 * for this type of forwarding objective. An empty set may be
1075 * returned if there is an issue in processing the objective.
1076 */
Saurav Das8a0732e2015-11-20 15:27:53 -08001077 protected Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
Saurav Das25190812016-05-27 13:54:07 -07001078 log.debug("Processing specific fwd objective:{} in dev:{} with next:{}",
Saurav Das4ce45962015-11-24 23:21:05 -08001079 fwd.id(), deviceId, fwd.nextId());
1080 boolean isEthTypeObj = isSupportedEthTypeObjective(fwd);
1081 boolean isEthDstObj = isSupportedEthDstObjective(fwd);
1082
1083 if (isEthTypeObj) {
1084 return processEthTypeSpecific(fwd);
1085 } else if (isEthDstObj) {
1086 return processEthDstSpecific(fwd);
1087 } else {
1088 log.warn("processSpecific: Unsupported forwarding objective "
1089 + "criteria fwd:{} in dev:{}", fwd.nextId(), deviceId);
Saurav Das822c4e22015-10-23 10:51:11 -07001090 fail(fwd, ObjectiveError.UNSUPPORTED);
1091 return Collections.emptySet();
1092 }
Saurav Das4ce45962015-11-24 23:21:05 -08001093 }
1094
Saurav Das4ce45962015-11-24 23:21:05 -08001095 /**
1096 * Handles forwarding rules to the IP and MPLS tables.
1097 *
1098 * @param fwd the forwarding objective
1099 * @return A collection of flow rules, or an empty set
1100 */
1101 protected Collection<FlowRule> processEthTypeSpecific(ForwardingObjective fwd) {
Charles Chancad338a2016-09-16 18:03:11 -07001102 return processEthTypeSpecificInternal(fwd, false, ACL_TABLE);
Charles Chanf9e98652016-09-07 16:54:23 -07001103 }
1104
1105 /**
1106 * Internal implementation of processEthTypeSpecific.
1107 * <p>
1108 * Wildcarded IPv4_DST is not supported in OFDPA i12. Therefore, we break
1109 * the rule into 0.0.0.0/1 and 128.0.0.0/1.
1110 * The allowDefaultRoute must be set to false for OFDPA i12.
1111 * </p>
1112 *
1113 * @param fwd the forwarding objective
1114 * @param allowDefaultRoute allow wildcarded IPv4_DST or not
Ray Milkey0bb1e102016-11-10 14:51:27 -08001115 * @param mplsNextTable next MPLS table
Charles Chanf9e98652016-09-07 16:54:23 -07001116 * @return A collection of flow rules, or an empty set
1117 */
1118 protected Collection<FlowRule> processEthTypeSpecificInternal(ForwardingObjective fwd,
Charles Chancad338a2016-09-16 18:03:11 -07001119 boolean allowDefaultRoute,
1120 int mplsNextTable) {
Saurav Das4ce45962015-11-24 23:21:05 -08001121 TrafficSelector selector = fwd.selector();
1122 EthTypeCriterion ethType =
1123 (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
Flavio Castroe10fa242016-01-15 12:43:51 -08001124 boolean popMpls = false;
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001125 boolean emptyGroup = false;
Charles Chan188ebf52015-12-23 00:15:11 -08001126 int forTableId;
Saurav Das8a0732e2015-11-20 15:27:53 -08001127 TrafficSelector.Builder filteredSelector = DefaultTrafficSelector.builder();
Charles Chan14967c22015-12-07 11:11:50 -08001128 TrafficTreatment.Builder tb = DefaultTrafficTreatment.builder();
Flavio Castroe10fa242016-01-15 12:43:51 -08001129 TrafficSelector.Builder complementarySelector = DefaultTrafficSelector.builder();
Charles Chan14967c22015-12-07 11:11:50 -08001130
Saurav Das8a0732e2015-11-20 15:27:53 -08001131 if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) {
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001132 if (buildIpv4Selector(filteredSelector, complementarySelector, fwd, allowDefaultRoute) < 0) {
1133 return Collections.emptyList();
1134 }
1135 // We need to set properly the next table
Flavio Castroe10fa242016-01-15 12:43:51 -08001136 IpPrefix ipv4Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV4_DST)).ip();
Charles Chan5b9df8d2016-03-28 22:21:40 -07001137 if (ipv4Dst.isMulticast()) {
Charles Chan5b9df8d2016-03-28 22:21:40 -07001138 forTableId = MULTICAST_ROUTING_TABLE;
Flavio Castroe10fa242016-01-15 12:43:51 -08001139 } else {
Charles Chan5b9df8d2016-03-28 22:21:40 -07001140 forTableId = UNICAST_ROUTING_TABLE;
Flavio Castroe10fa242016-01-15 12:43:51 -08001141 }
Charles Chan14967c22015-12-07 11:11:50 -08001142 if (fwd.treatment() != null) {
1143 for (Instruction instr : fwd.treatment().allInstructions()) {
1144 if (instr instanceof L3ModificationInstruction &&
1145 ((L3ModificationInstruction) instr).subtype() == L3SubType.DEC_TTL) {
Saurav Das9c705342017-01-06 11:36:01 -08001146 // XXX decrementing IP ttl is done automatically for routing, this
1147 // action is ignored or rejected in ofdpa as it is not fully implemented
1148 //tb.deferred().add(instr);
Charles Chan14967c22015-12-07 11:11:50 -08001149 }
1150 }
1151 }
1152
Pier Ventree0ae7a32016-11-23 09:57:42 -08001153 } else if (ethType.ethType().toShort() == Ethernet.TYPE_IPV6) {
1154 if (buildIpv6Selector(filteredSelector, fwd) < 0) {
1155 return Collections.emptyList();
1156 }
Kalhee Kim3d26bf02017-10-04 14:59:11 +00001157 //We need to set the proper next table
1158 IpPrefix ipv6Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV6_DST)).ip();
1159 if (ipv6Dst.isMulticast()) {
1160 forTableId = MULTICAST_ROUTING_TABLE;
1161 } else {
1162 forTableId = UNICAST_ROUTING_TABLE;
1163 }
1164
Pier Ventree0ae7a32016-11-23 09:57:42 -08001165 if (fwd.treatment() != null) {
1166 for (Instruction instr : fwd.treatment().allInstructions()) {
1167 if (instr instanceof L3ModificationInstruction &&
1168 ((L3ModificationInstruction) instr).subtype() == L3SubType.DEC_TTL) {
1169 // XXX decrementing IP ttl is done automatically for routing, this
1170 // action is ignored or rejected in ofdpa as it is not fully implemented
1171 //tb.deferred().add(instr);
1172 }
1173 }
1174 }
Saurav Das8a0732e2015-11-20 15:27:53 -08001175 } else {
1176 filteredSelector
1177 .matchEthType(Ethernet.MPLS_UNICAST)
1178 .matchMplsLabel(((MplsCriterion)
1179 selector.getCriterion(Criterion.Type.MPLS_LABEL)).label());
1180 MplsBosCriterion bos = (MplsBosCriterion) selector
Pier Ventre140a8942016-11-02 07:26:38 -07001181 .getCriterion(MPLS_BOS);
Saurav Das8a0732e2015-11-20 15:27:53 -08001182 if (bos != null) {
1183 filteredSelector.matchMplsBos(bos.mplsBos());
1184 }
1185 forTableId = MPLS_TABLE_1;
Saurav Das4ce45962015-11-24 23:21:05 -08001186 log.debug("processing MPLS specific forwarding objective {} -> next:{}"
1187 + " in dev {}", fwd.id(), fwd.nextId(), deviceId);
Saurav Das822c4e22015-10-23 10:51:11 -07001188
Charles Chan14967c22015-12-07 11:11:50 -08001189 if (fwd.treatment() != null) {
1190 for (Instruction instr : fwd.treatment().allInstructions()) {
1191 if (instr instanceof L2ModificationInstruction &&
1192 ((L2ModificationInstruction) instr).subtype() == L2SubType.MPLS_POP) {
Saurav Das8a0732e2015-11-20 15:27:53 -08001193 popMpls = true;
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001194 // OF-DPA does not pop in MPLS table in some cases. For the L3 VPN, it requires
Saurav Das9c705342017-01-06 11:36:01 -08001195 // setting the MPLS_TYPE so pop can happen down the pipeline
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001196 if (mplsNextTable == MPLS_TYPE_TABLE && isNotMplsBos(selector)) {
1197 tb.immediate().popMpls();
1198 }
Charles Chan14967c22015-12-07 11:11:50 -08001199 }
1200 if (instr instanceof L3ModificationInstruction &&
1201 ((L3ModificationInstruction) instr).subtype() == L3SubType.DEC_TTL) {
1202 // FIXME Should modify the app to send the correct DEC_MPLS_TTL instruction
1203 tb.immediate().decMplsTtl();
1204 }
1205 if (instr instanceof L3ModificationInstruction &&
1206 ((L3ModificationInstruction) instr).subtype() == L3SubType.TTL_IN) {
1207 tb.immediate().add(instr);
1208 }
Saurav Das8a0732e2015-11-20 15:27:53 -08001209 }
1210 }
1211 }
Saurav Das822c4e22015-10-23 10:51:11 -07001212
1213 if (fwd.nextId() != null) {
Saurav Das8a0732e2015-11-20 15:27:53 -08001214 if (forTableId == MPLS_TABLE_1 && !popMpls) {
1215 log.warn("SR CONTINUE case cannot be handled as MPLS ECMP "
Saurav Das25190812016-05-27 13:54:07 -07001216 + "is not implemented in OF-DPA yet. Aborting this flow {} -> next:{}"
1217 + "in this device {}", fwd.id(), fwd.nextId(), deviceId);
Pier Ventree0ae7a32016-11-23 09:57:42 -08001218 // XXX We could convert to forwarding to a single-port, via a MPLS interface,
1219 // or a MPLS SWAP (with-same) but that would have to be handled in the next-objective.
1220 // Also the pop-mpls logic used here won't work in non-BoS case.
Saurav Das4ce45962015-11-24 23:21:05 -08001221 fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED);
Saurav Das8a0732e2015-11-20 15:27:53 -08001222 return Collections.emptySet();
1223 }
1224
Saurav Das423fe2b2015-12-04 10:52:59 -08001225 NextGroup next = getGroupForNextObjective(fwd.nextId());
1226 if (next != null) {
1227 List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
1228 // we only need the top level group's key to point the flow to it
1229 Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst());
Pier Ventre140a8942016-11-02 07:26:38 -07001230 if (isNotMplsBos(selector) && group.type().equals(HASHED)) {
1231 log.warn("SR CONTINUE case cannot be handled as MPLS ECMP "
1232 + "is not implemented in OF-DPA yet. Aborting this flow {} -> next:{}"
1233 + "in this device {}", fwd.id(), fwd.nextId(), deviceId);
1234 fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED);
1235 return Collections.emptySet();
1236 }
Saurav Das423fe2b2015-12-04 10:52:59 -08001237 if (group == null) {
1238 log.warn("Group with key:{} for next-id:{} not found in dev:{}",
1239 gkeys.get(0).peekFirst(), fwd.nextId(), deviceId);
1240 fail(fwd, ObjectiveError.GROUPMISSING);
1241 return Collections.emptySet();
1242 }
1243 tb.deferred().group(group.id());
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001244 // check if group is empty
1245 if (gkeys.size() == 1 && gkeys.get(0).size() == 1) {
1246 log.warn("Found empty group 0x{} in dev:{} .. will retry fwd:{}",
1247 Integer.toHexString(group.id().id()), deviceId, fwd.id());
1248 emptyGroup = true;
1249 }
Saurav Das25190812016-05-27 13:54:07 -07001250 } else {
1251 log.warn("Cannot find group for nextId:{} in dev:{}. Aborting fwd:{}",
1252 fwd.nextId(), deviceId, fwd.id());
1253 fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED);
1254 return Collections.emptySet();
Saurav Das822c4e22015-10-23 10:51:11 -07001255 }
Saurav Das822c4e22015-10-23 10:51:11 -07001256 }
Charles Chancad338a2016-09-16 18:03:11 -07001257
1258 if (forTableId == MPLS_TABLE_1) {
Pier Ventre140a8942016-11-02 07:26:38 -07001259 if (mplsNextTable == MPLS_L3_TYPE_TABLE) {
Charles Chancad338a2016-09-16 18:03:11 -07001260 Ofdpa3SetMplsType setMplsType = new Ofdpa3SetMplsType(Ofdpa3MplsType.L3_PHP);
Saurav Das9c705342017-01-06 11:36:01 -08001261 // set mpls type as apply_action
1262 tb.immediate().extension(setMplsType, deviceId);
Charles Chancad338a2016-09-16 18:03:11 -07001263 }
1264 tb.transition(mplsNextTable);
1265 } else {
1266 tb.transition(ACL_TABLE);
1267 }
1268
Saurav Das822c4e22015-10-23 10:51:11 -07001269 FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
1270 .fromApp(fwd.appId())
1271 .withPriority(fwd.priority())
1272 .forDevice(deviceId)
Saurav Das8a0732e2015-11-20 15:27:53 -08001273 .withSelector(filteredSelector.build())
1274 .withTreatment(tb.build())
1275 .forTable(forTableId);
Saurav Das822c4e22015-10-23 10:51:11 -07001276
1277 if (fwd.permanent()) {
1278 ruleBuilder.makePermanent();
1279 } else {
1280 ruleBuilder.makeTemporary(fwd.timeout());
1281 }
Flavio Castroe10fa242016-01-15 12:43:51 -08001282 Collection<FlowRule> flowRuleCollection = new ArrayList<>();
1283 flowRuleCollection.add(ruleBuilder.build());
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001284 if (!allowDefaultRoute) {
Pier Ventree0ae7a32016-11-23 09:57:42 -08001285 flowRuleCollection.add(
1286 defaultRoute(fwd, complementarySelector, forTableId, tb)
1287 );
Flavio Castroe10fa242016-01-15 12:43:51 -08001288 log.debug("Default rule 0.0.0.0/0 is being installed two rules");
1289 }
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001290 // XXX retrying flows may be necessary due to bug CORD-554
1291 if (emptyGroup) {
1292 executorService.schedule(new RetryFlows(fwd, flowRuleCollection),
1293 RETRY_MS, TimeUnit.MILLISECONDS);
1294 }
Flavio Castroe10fa242016-01-15 12:43:51 -08001295 return flowRuleCollection;
Saurav Das822c4e22015-10-23 10:51:11 -07001296 }
1297
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001298 protected int buildIpv4Selector(TrafficSelector.Builder builderToUpdate,
1299 TrafficSelector.Builder extBuilder,
1300 ForwardingObjective fwd,
1301 boolean allowDefaultRoute) {
1302 TrafficSelector selector = fwd.selector();
1303
1304 IpPrefix ipv4Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV4_DST)).ip();
1305 if (ipv4Dst.isMulticast()) {
1306 if (ipv4Dst.prefixLength() != 32) {
1307 log.warn("Multicast specific forwarding objective can only be /32");
1308 fail(fwd, ObjectiveError.BADPARAMS);
1309 return -1;
1310 }
1311 VlanId assignedVlan = readVlanFromSelector(fwd.meta());
1312 if (assignedVlan == null) {
1313 log.warn("VLAN ID required by multicast specific fwd obj is missing. Abort.");
1314 fail(fwd, ObjectiveError.BADPARAMS);
1315 return -1;
1316 }
Charles Chand1172632017-03-15 17:33:09 -07001317 if (requireVlanExtensions()) {
1318 OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(assignedVlan);
1319 builderToUpdate.extension(ofdpaMatchVlanVid, deviceId);
1320 } else {
1321 builderToUpdate.matchVlanId(assignedVlan);
1322 }
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001323 builderToUpdate.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(ipv4Dst);
1324 log.debug("processing IPv4 multicast specific forwarding objective {} -> next:{}"
1325 + " in dev:{}", fwd.id(), fwd.nextId(), deviceId);
1326 } else {
1327 if (ipv4Dst.prefixLength() == 0) {
1328 if (allowDefaultRoute) {
1329 // The entire IPV4_DST field is wildcarded intentionally
1330 builderToUpdate.matchEthType(Ethernet.TYPE_IPV4);
1331 } else {
1332 // NOTE: The switch does not support matching 0.0.0.0/0
1333 // Split it into 0.0.0.0/1 and 128.0.0.0/1
1334 builderToUpdate.matchEthType(Ethernet.TYPE_IPV4)
1335 .matchIPDst(IpPrefix.valueOf("0.0.0.0/1"));
1336 extBuilder.matchEthType(Ethernet.TYPE_IPV4)
1337 .matchIPDst(IpPrefix.valueOf("128.0.0.0/1"));
1338 }
1339 } else {
1340 builderToUpdate.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(ipv4Dst);
1341 }
1342 log.debug("processing IPv4 unicast specific forwarding objective {} -> next:{}"
1343 + " in dev:{}", fwd.id(), fwd.nextId(), deviceId);
1344 }
1345 return 0;
1346 }
1347
1348 /**
1349 * Helper method to build Ipv6 selector using the selector provided by
1350 * a forwarding objective.
1351 *
1352 * @param builderToUpdate the builder to update
1353 * @param fwd the selector to read
1354 * @return 0 if the update ends correctly. -1 if the matches
1355 * are not yet supported
1356 */
1357 protected int buildIpv6Selector(TrafficSelector.Builder builderToUpdate,
1358 ForwardingObjective fwd) {
1359
1360 TrafficSelector selector = fwd.selector();
1361
1362 IpPrefix ipv6Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV6_DST)).ip();
1363 if (ipv6Dst.isMulticast()) {
Julia Ferguson65428c32017-08-10 18:15:24 +00001364 if (ipv6Dst.prefixLength() != IpAddress.INET6_BIT_LENGTH) {
1365 log.warn("Multicast specific forwarding objective can only be /128");
1366 fail(fwd, ObjectiveError.BADPARAMS);
1367 return -1;
1368 }
1369 VlanId assignedVlan = readVlanFromSelector(fwd.meta());
1370 if (assignedVlan == null) {
1371 log.warn("VLAN ID required by multicast specific fwd obj is missing. Abort.");
1372 fail(fwd, ObjectiveError.BADPARAMS);
1373 return -1;
1374 }
1375 if (requireVlanExtensions()) {
1376 OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(assignedVlan);
1377 builderToUpdate.extension(ofdpaMatchVlanVid, deviceId);
1378 } else {
1379 builderToUpdate.matchVlanId(assignedVlan);
1380 }
1381 builderToUpdate.matchEthType(Ethernet.TYPE_IPV6).matchIPv6Dst(ipv6Dst);
1382 log.debug("processing IPv6 multicast specific forwarding objective {} -> next:{}"
1383 + " in dev:{}", fwd.id(), fwd.nextId(), deviceId);
1384 } else {
1385 if (ipv6Dst.prefixLength() != 0) {
1386 builderToUpdate.matchIPv6Dst(ipv6Dst);
1387 }
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001388 builderToUpdate.matchEthType(Ethernet.TYPE_IPV6);
1389 log.debug("processing IPv6 unicast specific forwarding objective {} -> next:{}"
1390 + " in dev:{}", fwd.id(), fwd.nextId(), deviceId);
Julia Ferguson65428c32017-08-10 18:15:24 +00001391 }
Pier Luigi3bfe32c2017-01-30 09:47:36 -08001392 return 0;
1393 }
1394
Pier Ventree0ae7a32016-11-23 09:57:42 -08001395 protected FlowRule defaultRoute(ForwardingObjective fwd,
1396 TrafficSelector.Builder complementarySelector,
1397 int forTableId,
1398 TrafficTreatment.Builder tb) {
1399 FlowRule.Builder rule = DefaultFlowRule.builder()
1400 .fromApp(fwd.appId())
1401 .withPriority(fwd.priority())
1402 .forDevice(deviceId)
1403 .withSelector(complementarySelector.build())
1404 .withTreatment(tb.build())
1405 .forTable(forTableId);
1406 if (fwd.permanent()) {
1407 rule.makePermanent();
1408 } else {
1409 rule.makeTemporary(fwd.timeout());
1410 }
1411 return rule.build();
1412 }
1413
Saurav Das4ce45962015-11-24 23:21:05 -08001414 /**
1415 * Handles forwarding rules to the L2 bridging table. Flow actions are not
1416 * allowed in the bridging table - instead we use L2 Interface group or
1417 * L2 flood group
1418 *
1419 * @param fwd the forwarding objective
1420 * @return A collection of flow rules, or an empty set
1421 */
1422 protected Collection<FlowRule> processEthDstSpecific(ForwardingObjective fwd) {
1423 List<FlowRule> rules = new ArrayList<>();
1424
1425 // Build filtered selector
1426 TrafficSelector selector = fwd.selector();
1427 EthCriterion ethCriterion = (EthCriterion) selector
1428 .getCriterion(Criterion.Type.ETH_DST);
1429 VlanIdCriterion vlanIdCriterion = (VlanIdCriterion) selector
1430 .getCriterion(Criterion.Type.VLAN_VID);
1431
1432 if (vlanIdCriterion == null) {
1433 log.warn("Forwarding objective for bridging requires vlan. Not "
1434 + "installing fwd:{} in dev:{}", fwd.id(), deviceId);
1435 fail(fwd, ObjectiveError.BADPARAMS);
1436 return Collections.emptySet();
1437 }
1438
1439 TrafficSelector.Builder filteredSelectorBuilder =
1440 DefaultTrafficSelector.builder();
Yi Tseng3a77b4f2017-02-06 15:02:17 -08001441
1442 if (!ethCriterion.mac().equals(NONE) &&
1443 !ethCriterion.mac().equals(BROADCAST)) {
Saurav Das4ce45962015-11-24 23:21:05 -08001444 filteredSelectorBuilder.matchEthDst(ethCriterion.mac());
1445 log.debug("processing L2 forwarding objective:{} -> next:{} in dev:{}",
1446 fwd.id(), fwd.nextId(), deviceId);
1447 } else {
Yi Tseng3a77b4f2017-02-06 15:02:17 -08001448 // Use wildcard DST_MAC if the MacAddress is None or Broadcast
Saurav Das4ce45962015-11-24 23:21:05 -08001449 log.debug("processing L2 Broadcast forwarding objective:{} -> next:{} "
1450 + "in dev:{} for vlan:{}",
1451 fwd.id(), fwd.nextId(), deviceId, vlanIdCriterion.vlanId());
1452 }
Charles Chand1172632017-03-15 17:33:09 -07001453 if (requireVlanExtensions()) {
1454 OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(vlanIdCriterion.vlanId());
1455 filteredSelectorBuilder.extension(ofdpaMatchVlanVid, deviceId);
1456 } else {
1457 filteredSelectorBuilder.matchVlanId(vlanIdCriterion.vlanId());
1458 }
Saurav Das4ce45962015-11-24 23:21:05 -08001459 TrafficSelector filteredSelector = filteredSelectorBuilder.build();
1460
1461 if (fwd.treatment() != null) {
1462 log.warn("Ignoring traffic treatment in fwd rule {} meant for L2 table"
1463 + "for dev:{}. Expecting only nextId", fwd.id(), deviceId);
1464 }
1465
1466 TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
1467 if (fwd.nextId() != null) {
Saurav Das423fe2b2015-12-04 10:52:59 -08001468 NextGroup next = getGroupForNextObjective(fwd.nextId());
Saurav Das4ce45962015-11-24 23:21:05 -08001469 if (next != null) {
1470 List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
1471 // we only need the top level group's key to point the flow to it
1472 Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst());
1473 if (group != null) {
1474 treatmentBuilder.deferred().group(group.id());
1475 } else {
1476 log.warn("Group with key:{} for next-id:{} not found in dev:{}",
1477 gkeys.get(0).peekFirst(), fwd.nextId(), deviceId);
1478 fail(fwd, ObjectiveError.GROUPMISSING);
1479 return Collections.emptySet();
1480 }
1481 }
1482 }
1483 treatmentBuilder.immediate().transition(ACL_TABLE);
1484 TrafficTreatment filteredTreatment = treatmentBuilder.build();
1485
1486 // Build bridging table entries
1487 FlowRule.Builder flowRuleBuilder = DefaultFlowRule.builder();
1488 flowRuleBuilder.fromApp(fwd.appId())
1489 .withPriority(fwd.priority())
1490 .forDevice(deviceId)
1491 .withSelector(filteredSelector)
1492 .withTreatment(filteredTreatment)
1493 .forTable(BRIDGING_TABLE);
1494 if (fwd.permanent()) {
1495 flowRuleBuilder.makePermanent();
1496 } else {
1497 flowRuleBuilder.makeTemporary(fwd.timeout());
1498 }
1499 rules.add(flowRuleBuilder.build());
1500 return rules;
1501 }
1502
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001503 //////////////////////////////////////
1504 // Helper Methods and Classes
1505 //////////////////////////////////////
1506
1507 private boolean isSupportedEthTypeObjective(ForwardingObjective fwd) {
1508 TrafficSelector selector = fwd.selector();
1509 EthTypeCriterion ethType = (EthTypeCriterion) selector
1510 .getCriterion(Criterion.Type.ETH_TYPE);
1511 return !((ethType == null) ||
1512 ((ethType.ethType().toShort() != Ethernet.TYPE_IPV4) &&
Pier Ventree0ae7a32016-11-23 09:57:42 -08001513 (ethType.ethType().toShort() != Ethernet.MPLS_UNICAST)) &&
1514 (ethType.ethType().toShort() != Ethernet.TYPE_IPV6));
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001515 }
1516
1517 private boolean isSupportedEthDstObjective(ForwardingObjective fwd) {
1518 TrafficSelector selector = fwd.selector();
1519 EthCriterion ethDst = (EthCriterion) selector
1520 .getCriterion(Criterion.Type.ETH_DST);
1521 VlanIdCriterion vlanId = (VlanIdCriterion) selector
1522 .getCriterion(Criterion.Type.VLAN_VID);
1523 return !(ethDst == null && vlanId == null);
1524 }
1525
Saurav Das423fe2b2015-12-04 10:52:59 -08001526 protected NextGroup getGroupForNextObjective(Integer nextId) {
1527 NextGroup next = flowObjectiveStore.getNextGroup(nextId);
1528 if (next != null) {
1529 List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
1530 if (gkeys != null && !gkeys.isEmpty()) {
1531 return next;
1532 } else {
1533 log.warn("Empty next group found in FlowObjective store for "
1534 + "next-id:{} in dev:{}", nextId, deviceId);
1535 }
1536 } else {
1537 log.warn("next-id {} not found in Flow objective store for dev:{}",
1538 nextId, deviceId);
1539 }
1540 return null;
1541 }
1542
Charles Chan188ebf52015-12-23 00:15:11 -08001543 protected static void pass(Objective obj) {
Sho SHIMIZUef7e2902016-02-12 18:38:29 -08001544 obj.context().ifPresent(context -> context.onSuccess(obj));
Saurav Das822c4e22015-10-23 10:51:11 -07001545 }
1546
Charles Chan188ebf52015-12-23 00:15:11 -08001547 protected static void fail(Objective obj, ObjectiveError error) {
Sho SHIMIZUef7e2902016-02-12 18:38:29 -08001548 obj.context().ifPresent(context -> context.onError(obj, error));
Saurav Das822c4e22015-10-23 10:51:11 -07001549 }
Saurav Das24431192016-03-07 19:13:00 -08001550
Saurav Das24431192016-03-07 19:13:00 -08001551 @Override
1552 public List<String> getNextMappings(NextGroup nextGroup) {
1553 List<String> mappings = new ArrayList<>();
1554 List<Deque<GroupKey>> gkeys = appKryo.deserialize(nextGroup.data());
1555 for (Deque<GroupKey> gkd : gkeys) {
1556 Group lastGroup = null;
Yuta HIGUCHI2dce08a2017-04-20 21:57:48 -07001557 StringBuilder gchain = new StringBuilder();
Saurav Das24431192016-03-07 19:13:00 -08001558 for (GroupKey gk : gkd) {
1559 Group g = groupService.getGroup(deviceId, gk);
Saurav Das8be4e3a2016-03-11 17:19:07 -08001560 if (g == null) {
Saurav Das25190812016-05-27 13:54:07 -07001561 gchain.append(" NoGrp").append(" -->");
Saurav Das8be4e3a2016-03-11 17:19:07 -08001562 continue;
1563 }
1564 gchain.append(" 0x").append(Integer.toHexString(g.id().id()))
1565 .append(" -->");
Saurav Das24431192016-03-07 19:13:00 -08001566 lastGroup = g;
1567 }
1568 // add port information for last group in group-chain
Yuta HIGUCHI2dce08a2017-04-20 21:57:48 -07001569 List<Instruction> lastGroupIns = new ArrayList<>();
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001570 if (lastGroup != null && !lastGroup.buckets().buckets().isEmpty()) {
Saurav Das25190812016-05-27 13:54:07 -07001571 lastGroupIns = lastGroup.buckets().buckets().get(0)
1572 .treatment().allInstructions();
1573 }
1574 for (Instruction i: lastGroupIns) {
Saurav Das24431192016-03-07 19:13:00 -08001575 if (i instanceof OutputInstruction) {
Saurav Das8be4e3a2016-03-11 17:19:07 -08001576 gchain.append(" port:").append(((OutputInstruction) i).port());
Saurav Das24431192016-03-07 19:13:00 -08001577 }
1578 }
Saurav Das8be4e3a2016-03-11 17:19:07 -08001579 mappings.add(gchain.toString());
Saurav Das24431192016-03-07 19:13:00 -08001580 }
1581 return mappings;
1582 }
Charles Chan5b9df8d2016-03-28 22:21:40 -07001583
Pier Ventre140a8942016-11-02 07:26:38 -07001584 static boolean isMplsBos(TrafficSelector selector) {
1585 MplsBosCriterion bosCriterion = (MplsBosCriterion) selector.getCriterion(MPLS_BOS);
1586 return bosCriterion != null && bosCriterion.mplsBos();
1587 }
1588
1589 static boolean isNotMplsBos(TrafficSelector selector) {
1590 MplsBosCriterion bosCriterion = (MplsBosCriterion) selector.getCriterion(MPLS_BOS);
1591 return bosCriterion != null && !bosCriterion.mplsBos();
1592 }
1593
Charles Chand9e47c62017-10-05 15:17:15 -07001594 private static boolean isIpv6(TrafficSelector selector) {
1595 EthTypeCriterion ethTypeCriterion = (EthTypeCriterion) selector.getCriterion(ETH_TYPE);
1596 return ethTypeCriterion != null && ethTypeCriterion.ethType().toShort() == Ethernet.TYPE_IPV6;
1597 }
1598
1599 static VlanId readVlanFromSelector(TrafficSelector selector) {
Saurav Das59232cf2016-04-27 18:35:50 -07001600 if (selector == null) {
1601 return null;
1602 }
Charles Chan5b9df8d2016-03-28 22:21:40 -07001603 Criterion criterion = selector.getCriterion(Criterion.Type.VLAN_VID);
1604 return (criterion == null)
1605 ? null : ((VlanIdCriterion) criterion).vlanId();
1606 }
1607
Charles Chand9e47c62017-10-05 15:17:15 -07001608 static IpPrefix readIpDstFromSelector(TrafficSelector selector) {
Saurav Das59232cf2016-04-27 18:35:50 -07001609 if (selector == null) {
1610 return null;
1611 }
Charles Chan5b9df8d2016-03-28 22:21:40 -07001612 Criterion criterion = selector.getCriterion(Criterion.Type.IPV4_DST);
1613 return (criterion == null) ? null : ((IPCriterion) criterion).ip();
1614 }
Charles Chand55e84d2016-03-30 17:54:24 -07001615
1616 private static VlanId readVlanFromTreatment(TrafficTreatment treatment) {
Saurav Das59232cf2016-04-27 18:35:50 -07001617 if (treatment == null) {
1618 return null;
1619 }
Charles Chand55e84d2016-03-30 17:54:24 -07001620 for (Instruction i : treatment.allInstructions()) {
1621 if (i instanceof ModVlanIdInstruction) {
1622 return ((ModVlanIdInstruction) i).vlanId();
1623 }
1624 }
1625 return null;
1626 }
Saurav Das1ce0a7b2016-10-21 14:06:29 -07001627
1628 /**
1629 * Utility class that retries sending flows a fixed number of times, even if
1630 * some of the attempts are successful. Used only for forwarding objectives.
1631 */
1632 protected final class RetryFlows implements Runnable {
1633 int attempts = MAX_RETRY_ATTEMPTS;
1634 private Collection<FlowRule> retryFlows;
1635 private ForwardingObjective fwd;
1636
1637 RetryFlows(ForwardingObjective fwd, Collection<FlowRule> retryFlows) {
1638 this.fwd = fwd;
1639 this.retryFlows = retryFlows;
1640 }
1641
1642 @Override
1643 public void run() {
1644 log.info("RETRY FLOWS ATTEMPT# {} for fwd:{} rules:{}",
1645 MAX_RETRY_ATTEMPTS - attempts, fwd.id(), retryFlows.size());
1646 sendForward(fwd, retryFlows);
1647 if (--attempts > 0) {
1648 executorService.schedule(this, RETRY_MS, TimeUnit.MILLISECONDS);
1649 }
1650 }
1651 }
1652
Saurav Das822c4e22015-10-23 10:51:11 -07001653}