alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 1 | /* |
Charles Chan | aedabfd | 2016-02-26 09:31:48 -0800 | [diff] [blame] | 2 | * Copyright 2015-2016 Open Networking Laboratory |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.driver.pipeline; |
| 17 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 18 | import com.google.common.cache.Cache; |
| 19 | import com.google.common.cache.CacheBuilder; |
| 20 | import com.google.common.cache.RemovalCause; |
| 21 | import com.google.common.cache.RemovalNotification; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 22 | import com.google.common.collect.Lists; |
| 23 | import org.apache.commons.lang3.tuple.ImmutablePair; |
| 24 | import org.apache.commons.lang3.tuple.Pair; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 25 | import org.onlab.osgi.ServiceDirectory; |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 26 | import org.onlab.packet.EthType; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 27 | import org.onlab.packet.IPv4; |
| 28 | import org.onlab.packet.VlanId; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 29 | import org.onlab.util.KryoNamespace; |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 30 | import org.onosproject.core.ApplicationId; |
| 31 | import org.onosproject.core.CoreService; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 32 | import org.onosproject.net.DeviceId; |
| 33 | import org.onosproject.net.PortNumber; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 34 | import org.onosproject.net.behaviour.NextGroup; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 35 | import org.onosproject.net.behaviour.Pipeliner; |
| 36 | import org.onosproject.net.behaviour.PipelinerContext; |
| 37 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| 38 | import org.onosproject.net.flow.DefaultFlowRule; |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 39 | import org.onosproject.net.flow.DefaultTrafficSelector; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 40 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
alshabib | 6cb8636 | 2016-03-03 18:00:58 -0800 | [diff] [blame] | 41 | import org.onosproject.net.flow.FlowEntry; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 42 | import org.onosproject.net.flow.FlowRule; |
| 43 | import org.onosproject.net.flow.FlowRuleOperations; |
| 44 | import org.onosproject.net.flow.FlowRuleOperationsContext; |
| 45 | import org.onosproject.net.flow.FlowRuleService; |
| 46 | import org.onosproject.net.flow.TrafficSelector; |
| 47 | import org.onosproject.net.flow.TrafficTreatment; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 48 | import org.onosproject.net.flow.criteria.Criteria; |
| 49 | import org.onosproject.net.flow.criteria.Criterion; |
| 50 | import org.onosproject.net.flow.criteria.EthTypeCriterion; |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 51 | import org.onosproject.net.flow.criteria.IPCriterion; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 52 | import org.onosproject.net.flow.criteria.IPProtocolCriterion; |
| 53 | import org.onosproject.net.flow.criteria.PortCriterion; |
alshabib | 2f74f2c | 2016-01-14 13:29:35 -0800 | [diff] [blame] | 54 | import org.onosproject.net.flow.criteria.VlanIdCriterion; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 55 | import org.onosproject.net.flow.instructions.Instruction; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 56 | import org.onosproject.net.flow.instructions.Instructions; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 57 | import org.onosproject.net.flow.instructions.L2ModificationInstruction; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 58 | import org.onosproject.net.flowobjective.FilteringObjective; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 59 | import org.onosproject.net.flowobjective.FlowObjectiveStore; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 60 | import org.onosproject.net.flowobjective.ForwardingObjective; |
| 61 | import org.onosproject.net.flowobjective.NextObjective; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 62 | import org.onosproject.net.flowobjective.Objective; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 63 | import org.onosproject.net.flowobjective.ObjectiveError; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 64 | import org.onosproject.net.group.DefaultGroupBucket; |
| 65 | import org.onosproject.net.group.DefaultGroupDescription; |
| 66 | import org.onosproject.net.group.DefaultGroupKey; |
| 67 | import org.onosproject.net.group.Group; |
| 68 | import org.onosproject.net.group.GroupBucket; |
| 69 | import org.onosproject.net.group.GroupBuckets; |
| 70 | import org.onosproject.net.group.GroupDescription; |
| 71 | import org.onosproject.net.group.GroupEvent; |
| 72 | import org.onosproject.net.group.GroupKey; |
| 73 | import org.onosproject.net.group.GroupListener; |
| 74 | import org.onosproject.net.group.GroupService; |
| 75 | import org.onosproject.store.serializers.KryoNamespaces; |
alshabib | 5ccbe3f | 2016-03-02 22:36:02 -0800 | [diff] [blame] | 76 | import org.onosproject.store.service.AtomicCounter; |
| 77 | import org.onosproject.store.service.StorageService; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 78 | import org.slf4j.Logger; |
| 79 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 80 | import java.util.Collection; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 81 | import java.util.Collections; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 82 | import java.util.List; |
| 83 | import java.util.Optional; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 84 | import java.util.concurrent.TimeUnit; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 85 | import java.util.stream.Collectors; |
| 86 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 87 | import static org.slf4j.LoggerFactory.getLogger; |
| 88 | |
| 89 | /** |
Jonathan Hart | 64da69d | 2015-07-15 15:10:28 -0700 | [diff] [blame] | 90 | * Pipeliner for OLT device. |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 91 | */ |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 92 | |
Jonathan Hart | b92cc51 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 93 | public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner { |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 94 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 95 | private static final Integer QQ_TABLE = 1; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 96 | private static final short MCAST_VLAN = 4000; |
alshabib | 5ccbe3f | 2016-03-02 22:36:02 -0800 | [diff] [blame] | 97 | private static final String OLTCOOKIES = "olt-cookies-must-be-unique"; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 98 | private final Logger log = getLogger(getClass()); |
| 99 | |
| 100 | private ServiceDirectory serviceDirectory; |
| 101 | private FlowRuleService flowRuleService; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 102 | private GroupService groupService; |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 103 | private CoreService coreService; |
alshabib | 5ccbe3f | 2016-03-02 22:36:02 -0800 | [diff] [blame] | 104 | private StorageService storageService; |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 105 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 106 | private DeviceId deviceId; |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 107 | private ApplicationId appId; |
Charles Chan | aedabfd | 2016-02-26 09:31:48 -0800 | [diff] [blame] | 108 | // NOTE: OLT currently has some issue with cookie 0. Pick something larger |
| 109 | // to avoid collision |
alshabib | 5ccbe3f | 2016-03-02 22:36:02 -0800 | [diff] [blame] | 110 | private AtomicCounter counter; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 111 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 112 | protected FlowObjectiveStore flowObjectiveStore; |
| 113 | |
| 114 | private Cache<GroupKey, NextObjective> pendingGroups; |
| 115 | |
| 116 | protected static KryoNamespace appKryo = new KryoNamespace.Builder() |
| 117 | .register(KryoNamespaces.API) |
| 118 | .register(GroupKey.class) |
| 119 | .register(DefaultGroupKey.class) |
| 120 | .register(OLTPipelineGroup.class) |
| 121 | .register(byte[].class) |
| 122 | .build(); |
alshabib | 2cc73cb | 2015-06-30 20:26:56 -0700 | [diff] [blame] | 123 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 124 | @Override |
| 125 | public void init(DeviceId deviceId, PipelinerContext context) { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 126 | log.debug("Initiate OLT pipeline"); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 127 | this.serviceDirectory = context.directory(); |
| 128 | this.deviceId = deviceId; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 129 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 130 | flowRuleService = serviceDirectory.get(FlowRuleService.class); |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 131 | coreService = serviceDirectory.get(CoreService.class); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 132 | groupService = serviceDirectory.get(GroupService.class); |
| 133 | flowObjectiveStore = context.store(); |
alshabib | 5ccbe3f | 2016-03-02 22:36:02 -0800 | [diff] [blame] | 134 | storageService = serviceDirectory.get(StorageService.class); |
| 135 | |
| 136 | counter = storageService.atomicCounterBuilder() |
| 137 | .withName(String.format(OLTCOOKIES, deviceId)) |
| 138 | .build() |
| 139 | .asAtomicCounter(); |
| 140 | |
| 141 | /* |
| 142 | magic olt number to make sure we don't collide with it's internal |
| 143 | processing |
| 144 | */ |
| 145 | counter.set(123); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 146 | |
alshabib | b32cefe | 2015-06-08 18:15:05 -0700 | [diff] [blame] | 147 | |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 148 | appId = coreService.registerApplication( |
| 149 | "org.onosproject.driver.OLTPipeline"); |
| 150 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 151 | |
| 152 | pendingGroups = CacheBuilder.newBuilder() |
| 153 | .expireAfterWrite(20, TimeUnit.SECONDS) |
| 154 | .removalListener((RemovalNotification<GroupKey, NextObjective> notification) -> { |
| 155 | if (notification.getCause() == RemovalCause.EXPIRED) { |
| 156 | fail(notification.getValue(), ObjectiveError.GROUPINSTALLATIONFAILED); |
| 157 | } |
| 158 | }).build(); |
| 159 | |
| 160 | groupService.addListener(new InnerGroupListener()); |
| 161 | |
alshabib | b32cefe | 2015-06-08 18:15:05 -0700 | [diff] [blame] | 162 | } |
| 163 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 164 | @Override |
| 165 | public void filter(FilteringObjective filter) { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 166 | Instructions.OutputInstruction output; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 167 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 168 | if (filter.meta() != null && !filter.meta().immediate().isEmpty()) { |
| 169 | output = (Instructions.OutputInstruction) filter.meta().immediate().stream() |
| 170 | .filter(t -> t.type().equals(Instruction.Type.OUTPUT)) |
| 171 | .limit(1) |
| 172 | .findFirst().get(); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 173 | |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 174 | if (output == null || !output.port().equals(PortNumber.CONTROLLER)) { |
| 175 | log.error("OLT can only filter packet to controller"); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 176 | fail(filter, ObjectiveError.UNSUPPORTED); |
| 177 | return; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 178 | } |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 179 | } else { |
| 180 | fail(filter, ObjectiveError.BADPARAMS); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 181 | return; |
| 182 | } |
| 183 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 184 | if (filter.key().type() != Criterion.Type.IN_PORT) { |
| 185 | fail(filter, ObjectiveError.BADPARAMS); |
| 186 | return; |
| 187 | } |
| 188 | |
| 189 | EthTypeCriterion ethType = (EthTypeCriterion) |
| 190 | filterForCriterion(filter.conditions(), Criterion.Type.ETH_TYPE); |
| 191 | |
| 192 | if (ethType == null) { |
| 193 | fail(filter, ObjectiveError.BADPARAMS); |
| 194 | return; |
| 195 | } |
| 196 | |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 197 | if (ethType.ethType().equals(EthType.EtherType.EAPOL.ethType())) { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 198 | provisionEapol(filter, ethType, output); |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 199 | } else if (ethType.ethType().equals(EthType.EtherType.IPV4.ethType())) { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 200 | IPProtocolCriterion ipProto = (IPProtocolCriterion) |
| 201 | filterForCriterion(filter.conditions(), Criterion.Type.IP_PROTO); |
| 202 | if (ipProto.protocol() == IPv4.PROTOCOL_IGMP) { |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 203 | provisionIgmp(filter, ethType, ipProto, output); |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 204 | } else { |
| 205 | log.error("OLT can only filter igmp"); |
| 206 | fail(filter, ObjectiveError.UNSUPPORTED); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 207 | } |
| 208 | } else { |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 209 | log.error("OLT can only filter eapol and igmp"); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 210 | fail(filter, ObjectiveError.UNSUPPORTED); |
| 211 | } |
| 212 | |
| 213 | } |
| 214 | |
| 215 | |
| 216 | @Override |
| 217 | public void forward(ForwardingObjective fwd) { |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 218 | |
| 219 | if (checkForMulticast(fwd)) { |
| 220 | processMulticastRule(fwd); |
| 221 | return; |
| 222 | } |
| 223 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 224 | TrafficTreatment treatment = fwd.treatment(); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 225 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 226 | List<Instruction> instructions = treatment.allInstructions(); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 227 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 228 | Optional<Instruction> vlanIntruction = instructions.stream() |
| 229 | .filter(i -> i.type() == Instruction.Type.L2MODIFICATION) |
| 230 | .filter(i -> ((L2ModificationInstruction) i).subtype() == |
| 231 | L2ModificationInstruction.L2SubType.VLAN_PUSH || |
| 232 | ((L2ModificationInstruction) i).subtype() == |
| 233 | L2ModificationInstruction.L2SubType.VLAN_POP) |
| 234 | .findAny(); |
| 235 | |
| 236 | if (!vlanIntruction.isPresent()) { |
| 237 | fail(fwd, ObjectiveError.BADPARAMS); |
| 238 | return; |
| 239 | } |
| 240 | |
| 241 | L2ModificationInstruction vlanIns = |
| 242 | (L2ModificationInstruction) vlanIntruction.get(); |
| 243 | |
| 244 | if (vlanIns.subtype() == L2ModificationInstruction.L2SubType.VLAN_PUSH) { |
| 245 | installUpstreamRules(fwd); |
| 246 | } else if (vlanIns.subtype() == L2ModificationInstruction.L2SubType.VLAN_POP) { |
| 247 | installDownstreamRules(fwd); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 248 | } else { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 249 | log.error("Unknown OLT operation: {}", fwd); |
| 250 | fail(fwd, ObjectiveError.UNSUPPORTED); |
| 251 | return; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 252 | } |
| 253 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 254 | pass(fwd); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 255 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 256 | } |
| 257 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 258 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 259 | @Override |
| 260 | public void next(NextObjective nextObjective) { |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 261 | if (nextObjective.type() != NextObjective.Type.BROADCAST) { |
| 262 | log.error("OLT only supports broadcast groups."); |
| 263 | fail(nextObjective, ObjectiveError.BADPARAMS); |
| 264 | } |
| 265 | |
| 266 | if (nextObjective.next().size() != 1) { |
| 267 | log.error("OLT only supports singleton broadcast groups."); |
| 268 | fail(nextObjective, ObjectiveError.BADPARAMS); |
| 269 | } |
| 270 | |
| 271 | TrafficTreatment treatment = nextObjective.next().stream().findFirst().get(); |
| 272 | |
| 273 | |
| 274 | GroupBucket bucket = DefaultGroupBucket.createAllGroupBucket(treatment); |
| 275 | GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id())); |
| 276 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 277 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 278 | pendingGroups.put(key, nextObjective); |
| 279 | |
| 280 | switch (nextObjective.op()) { |
| 281 | case ADD: |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 282 | GroupDescription groupDesc = |
| 283 | new DefaultGroupDescription(deviceId, |
| 284 | GroupDescription.Type.ALL, |
| 285 | new GroupBuckets(Collections.singletonList(bucket)), |
| 286 | key, |
| 287 | null, |
| 288 | nextObjective.appId()); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 289 | groupService.addGroup(groupDesc); |
| 290 | break; |
| 291 | case REMOVE: |
| 292 | groupService.removeGroup(deviceId, key, nextObjective.appId()); |
| 293 | break; |
| 294 | case ADD_TO_EXISTING: |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 295 | groupService.addBucketsToGroup(deviceId, key, |
| 296 | new GroupBuckets(Collections.singletonList(bucket)), |
| 297 | key, nextObjective.appId()); |
| 298 | break; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 299 | case REMOVE_FROM_EXISTING: |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 300 | groupService.removeBucketsFromGroup(deviceId, key, |
alshabib | 56efe43 | 2016-02-25 17:57:24 -0500 | [diff] [blame] | 301 | new GroupBuckets(Collections.singletonList(bucket)), |
| 302 | key, nextObjective.appId()); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 303 | break; |
| 304 | default: |
| 305 | log.warn("Unknown next objective operation: {}", nextObjective.op()); |
| 306 | } |
| 307 | |
| 308 | |
| 309 | } |
| 310 | |
| 311 | private void processMulticastRule(ForwardingObjective fwd) { |
| 312 | if (fwd.nextId() == null) { |
| 313 | log.error("Multicast objective does not have a next id"); |
| 314 | fail(fwd, ObjectiveError.BADPARAMS); |
| 315 | } |
| 316 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 317 | GroupKey key = getGroupForNextObjective(fwd.nextId()); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 318 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 319 | if (key == null) { |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 320 | log.error("Group for forwarding objective missing: {}", fwd); |
| 321 | fail(fwd, ObjectiveError.GROUPMISSING); |
| 322 | } |
| 323 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 324 | Group group = groupService.getGroup(deviceId, key); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 325 | TrafficTreatment treatment = |
| 326 | buildTreatment(Instructions.createGroup(group.id())); |
| 327 | |
| 328 | FlowRule rule = DefaultFlowRule.builder() |
alshabib | 56efe43 | 2016-02-25 17:57:24 -0500 | [diff] [blame] | 329 | .withCookie(counter.getAndIncrement()) |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 330 | .forDevice(deviceId) |
| 331 | .forTable(0) |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 332 | .makePermanent() |
| 333 | .withPriority(fwd.priority()) |
| 334 | .withSelector(fwd.selector()) |
| 335 | .withTreatment(treatment) |
| 336 | .build(); |
| 337 | |
| 338 | FlowRuleOperations.Builder builder = FlowRuleOperations.builder(); |
| 339 | switch (fwd.op()) { |
| 340 | |
| 341 | case ADD: |
| 342 | builder.add(rule); |
| 343 | break; |
| 344 | case REMOVE: |
| 345 | builder.remove(rule); |
| 346 | break; |
| 347 | case ADD_TO_EXISTING: |
| 348 | case REMOVE_FROM_EXISTING: |
| 349 | break; |
| 350 | default: |
| 351 | log.warn("Unknown forwarding operation: {}", fwd.op()); |
| 352 | } |
| 353 | |
| 354 | applyFlowRules(builder, fwd); |
| 355 | |
| 356 | } |
| 357 | |
| 358 | private boolean checkForMulticast(ForwardingObjective fwd) { |
| 359 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 360 | IPCriterion ip = (IPCriterion) filterForCriterion(fwd.selector().criteria(), |
alshabib | 56efe43 | 2016-02-25 17:57:24 -0500 | [diff] [blame] | 361 | Criterion.Type.IPV4_DST); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 362 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 363 | if (ip == null) { |
| 364 | return false; |
| 365 | } |
| 366 | |
Charles Chan | aedabfd | 2016-02-26 09:31:48 -0800 | [diff] [blame] | 367 | return ip.ip().isMulticast(); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 368 | |
| 369 | } |
| 370 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 371 | private GroupKey getGroupForNextObjective(Integer nextId) { |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 372 | NextGroup next = flowObjectiveStore.getNextGroup(nextId); |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 373 | return appKryo.deserialize(next.data()); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 374 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 375 | } |
| 376 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 377 | private void installDownstreamRules(ForwardingObjective fwd) { |
| 378 | List<Pair<Instruction, Instruction>> vlanOps = |
| 379 | vlanOps(fwd, |
| 380 | L2ModificationInstruction.L2SubType.VLAN_POP); |
| 381 | |
| 382 | if (vlanOps == null) { |
| 383 | return; |
| 384 | } |
| 385 | |
alshabib | b3c1434 | 2016-03-04 17:05:01 -0800 | [diff] [blame] | 386 | Instructions.OutputInstruction output = (Instructions.OutputInstruction) fetchOutput(fwd, "downstream"); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 387 | |
| 388 | if (output == null) { |
| 389 | return; |
| 390 | } |
| 391 | |
| 392 | Pair<Instruction, Instruction> popAndRewrite = vlanOps.remove(0); |
| 393 | |
alshabib | fa0dc66 | 2016-01-13 11:23:53 -0800 | [diff] [blame] | 394 | TrafficSelector selector = fwd.selector(); |
| 395 | |
| 396 | Criterion outerVlan = selector.getCriterion(Criterion.Type.VLAN_VID); |
| 397 | Criterion innerVlan = selector.getCriterion(Criterion.Type.INNER_VLAN_VID); |
| 398 | Criterion inport = selector.getCriterion(Criterion.Type.IN_PORT); |
alshabib | b3c1434 | 2016-03-04 17:05:01 -0800 | [diff] [blame] | 399 | Criterion bullshit = Criteria.matchMetadata(output.port().toLong()); |
alshabib | fa0dc66 | 2016-01-13 11:23:53 -0800 | [diff] [blame] | 400 | |
| 401 | if (outerVlan == null || innerVlan == null || inport == null) { |
| 402 | log.error("Forwarding objective is underspecified: {}", fwd); |
| 403 | fail(fwd, ObjectiveError.BADPARAMS); |
| 404 | return; |
| 405 | } |
| 406 | |
alshabib | 2f74f2c | 2016-01-14 13:29:35 -0800 | [diff] [blame] | 407 | Criterion innerVid = Criteria.matchVlanId(((VlanIdCriterion) innerVlan).vlanId()); |
| 408 | |
alshabib | fa0dc66 | 2016-01-13 11:23:53 -0800 | [diff] [blame] | 409 | FlowRule.Builder outer = DefaultFlowRule.builder() |
alshabib | 56efe43 | 2016-02-25 17:57:24 -0500 | [diff] [blame] | 410 | .withCookie(counter.getAndIncrement()) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 411 | .forDevice(deviceId) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 412 | .makePermanent() |
| 413 | .withPriority(fwd.priority()) |
alshabib | b3c1434 | 2016-03-04 17:05:01 -0800 | [diff] [blame] | 414 | .withSelector(buildSelector(inport, outerVlan, bullshit)) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 415 | .withTreatment(buildTreatment(popAndRewrite.getLeft(), |
| 416 | Instructions.transition(QQ_TABLE))); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 417 | |
alshabib | fa0dc66 | 2016-01-13 11:23:53 -0800 | [diff] [blame] | 418 | FlowRule.Builder inner = DefaultFlowRule.builder() |
alshabib | 56efe43 | 2016-02-25 17:57:24 -0500 | [diff] [blame] | 419 | .withCookie(counter.getAndIncrement()) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 420 | .forDevice(deviceId) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 421 | .forTable(QQ_TABLE) |
| 422 | .makePermanent() |
| 423 | .withPriority(fwd.priority()) |
alshabib | 2f74f2c | 2016-01-14 13:29:35 -0800 | [diff] [blame] | 424 | .withSelector(buildSelector(inport, innerVid)) |
alshabib | e507584 | 2016-02-04 13:28:33 -0800 | [diff] [blame] | 425 | .withTreatment(buildTreatment(popAndRewrite.getLeft(), |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 426 | output)); |
| 427 | |
| 428 | applyRules(fwd, inner, outer); |
| 429 | |
| 430 | } |
| 431 | |
| 432 | private void installUpstreamRules(ForwardingObjective fwd) { |
| 433 | List<Pair<Instruction, Instruction>> vlanOps = |
| 434 | vlanOps(fwd, |
| 435 | L2ModificationInstruction.L2SubType.VLAN_PUSH); |
| 436 | |
| 437 | if (vlanOps == null) { |
| 438 | return; |
| 439 | } |
| 440 | |
| 441 | Instruction output = fetchOutput(fwd, "upstream"); |
| 442 | |
| 443 | if (output == null) { |
| 444 | return; |
| 445 | } |
| 446 | |
| 447 | Pair<Instruction, Instruction> innerPair = vlanOps.remove(0); |
| 448 | |
| 449 | Pair<Instruction, Instruction> outerPair = vlanOps.remove(0); |
| 450 | |
| 451 | FlowRule.Builder inner = DefaultFlowRule.builder() |
alshabib | 56efe43 | 2016-02-25 17:57:24 -0500 | [diff] [blame] | 452 | .withCookie(counter.getAndIncrement()) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 453 | .forDevice(deviceId) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 454 | .makePermanent() |
| 455 | .withPriority(fwd.priority()) |
| 456 | .withSelector(fwd.selector()) |
| 457 | .withTreatment(buildTreatment(innerPair.getRight(), |
| 458 | Instructions.transition(QQ_TABLE))); |
| 459 | |
| 460 | PortCriterion inPort = (PortCriterion) |
| 461 | fwd.selector().getCriterion(Criterion.Type.IN_PORT); |
| 462 | |
| 463 | VlanId cVlanId = ((L2ModificationInstruction.ModVlanIdInstruction) |
| 464 | innerPair.getRight()).vlanId(); |
| 465 | |
| 466 | FlowRule.Builder outer = DefaultFlowRule.builder() |
alshabib | 56efe43 | 2016-02-25 17:57:24 -0500 | [diff] [blame] | 467 | .withCookie(counter.getAndIncrement()) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 468 | .forDevice(deviceId) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 469 | .forTable(QQ_TABLE) |
| 470 | .makePermanent() |
| 471 | .withPriority(fwd.priority()) |
| 472 | .withSelector(buildSelector(inPort, |
| 473 | Criteria.matchVlanId(cVlanId))) |
| 474 | .withTreatment(buildTreatment(outerPair.getLeft(), |
| 475 | outerPair.getRight(), |
| 476 | output)); |
| 477 | |
| 478 | applyRules(fwd, inner, outer); |
| 479 | |
| 480 | } |
| 481 | |
| 482 | private Instruction fetchOutput(ForwardingObjective fwd, String direction) { |
| 483 | Instruction output = fwd.treatment().allInstructions().stream() |
| 484 | .filter(i -> i.type() == Instruction.Type.OUTPUT) |
| 485 | .findFirst().orElse(null); |
| 486 | |
| 487 | if (output == null) { |
| 488 | log.error("OLT {} rule has no output", direction); |
| 489 | fail(fwd, ObjectiveError.BADPARAMS); |
| 490 | return null; |
| 491 | } |
| 492 | return output; |
| 493 | } |
| 494 | |
| 495 | private List<Pair<Instruction, Instruction>> vlanOps(ForwardingObjective fwd, |
| 496 | L2ModificationInstruction.L2SubType type) { |
| 497 | |
| 498 | List<Pair<Instruction, Instruction>> vlanOps = findVlanOps( |
| 499 | fwd.treatment().allInstructions(), type); |
| 500 | |
| 501 | if (vlanOps == null) { |
| 502 | String direction = type == L2ModificationInstruction.L2SubType.VLAN_POP |
| 503 | ? "downstream" : "upstream"; |
| 504 | log.error("Missing vlan operations in {} forwarding: {}", direction, fwd); |
| 505 | fail(fwd, ObjectiveError.BADPARAMS); |
| 506 | return null; |
| 507 | } |
| 508 | return vlanOps; |
| 509 | } |
| 510 | |
| 511 | |
| 512 | private List<Pair<Instruction, Instruction>> findVlanOps(List<Instruction> instructions, |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 513 | L2ModificationInstruction.L2SubType type) { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 514 | |
| 515 | List<Instruction> vlanPushs = findL2Instructions( |
| 516 | type, |
| 517 | instructions); |
| 518 | List<Instruction> vlanSets = findL2Instructions( |
| 519 | L2ModificationInstruction.L2SubType.VLAN_ID, |
| 520 | instructions); |
| 521 | |
| 522 | if (vlanPushs.size() != vlanSets.size()) { |
| 523 | return null; |
| 524 | } |
| 525 | |
| 526 | List<Pair<Instruction, Instruction>> pairs = Lists.newArrayList(); |
| 527 | |
| 528 | for (int i = 0; i < vlanPushs.size(); i++) { |
| 529 | pairs.add(new ImmutablePair<>(vlanPushs.get(i), vlanSets.get(i))); |
| 530 | } |
| 531 | return pairs; |
| 532 | } |
| 533 | |
| 534 | private List<Instruction> findL2Instructions(L2ModificationInstruction.L2SubType subType, |
| 535 | List<Instruction> actions) { |
| 536 | return actions.stream() |
| 537 | .filter(i -> i.type() == Instruction.Type.L2MODIFICATION) |
| 538 | .filter(i -> ((L2ModificationInstruction) i).subtype() == subType) |
| 539 | .collect(Collectors.toList()); |
| 540 | } |
| 541 | |
| 542 | private void provisionEapol(FilteringObjective filter, |
| 543 | EthTypeCriterion ethType, |
| 544 | Instructions.OutputInstruction output) { |
| 545 | |
| 546 | TrafficSelector selector = buildSelector(filter.key(), ethType); |
| 547 | TrafficTreatment treatment = buildTreatment(output); |
| 548 | buildAndApplyRule(filter, selector, treatment); |
| 549 | |
| 550 | } |
| 551 | |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 552 | private void provisionIgmp(FilteringObjective filter, EthTypeCriterion ethType, |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 553 | IPProtocolCriterion ipProto, |
| 554 | Instructions.OutputInstruction output) { |
| 555 | TrafficSelector selector = buildSelector(filter.key(), ethType, ipProto); |
| 556 | TrafficTreatment treatment = buildTreatment(output); |
| 557 | buildAndApplyRule(filter, selector, treatment); |
| 558 | } |
| 559 | |
| 560 | private void buildAndApplyRule(FilteringObjective filter, TrafficSelector selector, |
| 561 | TrafficTreatment treatment) { |
| 562 | FlowRule rule = DefaultFlowRule.builder() |
alshabib | 56efe43 | 2016-02-25 17:57:24 -0500 | [diff] [blame] | 563 | .withCookie(counter.getAndIncrement()) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 564 | .forDevice(deviceId) |
| 565 | .forTable(0) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 566 | .makePermanent() |
| 567 | .withSelector(selector) |
| 568 | .withTreatment(treatment) |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 569 | .withPriority(filter.priority()) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 570 | .build(); |
| 571 | |
| 572 | FlowRuleOperations.Builder opsBuilder = FlowRuleOperations.builder(); |
| 573 | |
| 574 | switch (filter.type()) { |
| 575 | case PERMIT: |
| 576 | opsBuilder.add(rule); |
| 577 | break; |
| 578 | case DENY: |
| 579 | opsBuilder.remove(rule); |
| 580 | break; |
| 581 | default: |
| 582 | log.warn("Unknown filter type : {}", filter.type()); |
| 583 | fail(filter, ObjectiveError.UNSUPPORTED); |
| 584 | } |
| 585 | |
| 586 | applyFlowRules(opsBuilder, filter); |
| 587 | } |
| 588 | |
| 589 | private void applyRules(ForwardingObjective fwd, |
| 590 | FlowRule.Builder inner, FlowRule.Builder outer) { |
| 591 | FlowRuleOperations.Builder builder = FlowRuleOperations.builder(); |
| 592 | switch (fwd.op()) { |
| 593 | case ADD: |
| 594 | builder.add(inner.build()).add(outer.build()); |
| 595 | break; |
| 596 | case REMOVE: |
alshabib | 6cb8636 | 2016-03-03 18:00:58 -0800 | [diff] [blame] | 597 | Iterable<FlowEntry> flows = flowRuleService.getFlowEntries(deviceId); |
| 598 | for (FlowEntry fe : flows) { |
| 599 | if (fe.equals(inner.build()) || fe.equals(outer.build())) { |
| 600 | builder.remove(fe); |
| 601 | } |
| 602 | } |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 603 | break; |
| 604 | case ADD_TO_EXISTING: |
| 605 | break; |
| 606 | case REMOVE_FROM_EXISTING: |
| 607 | break; |
| 608 | default: |
| 609 | log.warn("Unknown forwarding operation: {}", fwd.op()); |
| 610 | } |
| 611 | |
| 612 | applyFlowRules(builder, fwd); |
| 613 | } |
| 614 | |
| 615 | private void applyFlowRules(FlowRuleOperations.Builder builder, |
| 616 | Objective objective) { |
| 617 | flowRuleService.apply(builder.build(new FlowRuleOperationsContext() { |
| 618 | @Override |
| 619 | public void onSuccess(FlowRuleOperations ops) { |
| 620 | pass(objective); |
| 621 | } |
| 622 | |
| 623 | @Override |
| 624 | public void onError(FlowRuleOperations ops) { |
| 625 | fail(objective, ObjectiveError.FLOWINSTALLATIONFAILED); |
| 626 | } |
| 627 | })); |
| 628 | } |
| 629 | |
| 630 | private Criterion filterForCriterion(Collection<Criterion> criteria, Criterion.Type type) { |
| 631 | return criteria.stream() |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 632 | .filter(c -> c.type().equals(type)) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 633 | .limit(1) |
| 634 | .findFirst().orElse(null); |
| 635 | } |
| 636 | |
| 637 | private TrafficSelector buildSelector(Criterion... criteria) { |
| 638 | |
| 639 | |
| 640 | TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder(); |
| 641 | |
| 642 | for (Criterion c : criteria) { |
| 643 | sBuilder.add(c); |
| 644 | } |
| 645 | |
| 646 | return sBuilder.build(); |
| 647 | } |
| 648 | |
| 649 | private TrafficTreatment buildTreatment(Instruction... instructions) { |
| 650 | |
| 651 | |
| 652 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); |
| 653 | |
| 654 | for (Instruction i : instructions) { |
| 655 | tBuilder.add(i); |
| 656 | } |
| 657 | |
| 658 | return tBuilder.build(); |
| 659 | } |
| 660 | |
| 661 | |
| 662 | private void fail(Objective obj, ObjectiveError error) { |
Sho SHIMIZU | ef7e290 | 2016-02-12 18:38:29 -0800 | [diff] [blame] | 663 | obj.context().ifPresent(context -> context.onError(obj, error)); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | private void pass(Objective obj) { |
Sho SHIMIZU | ef7e290 | 2016-02-12 18:38:29 -0800 | [diff] [blame] | 667 | obj.context().ifPresent(context -> context.onSuccess(obj)); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 668 | } |
| 669 | |
alshabib | 2cc73cb | 2015-06-30 20:26:56 -0700 | [diff] [blame] | 670 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 671 | private class InnerGroupListener implements GroupListener { |
alshabib | 2cc73cb | 2015-06-30 20:26:56 -0700 | [diff] [blame] | 672 | @Override |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 673 | public void event(GroupEvent event) { |
| 674 | if (event.type() == GroupEvent.Type.GROUP_ADDED) { |
| 675 | GroupKey key = event.subject().appCookie(); |
alshabib | 2cc73cb | 2015-06-30 20:26:56 -0700 | [diff] [blame] | 676 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 677 | NextObjective obj = pendingGroups.getIfPresent(key); |
| 678 | if (obj != null) { |
| 679 | flowObjectiveStore.putNextGroup(obj.id(), new OLTPipelineGroup(key)); |
| 680 | pass(obj); |
| 681 | pendingGroups.invalidate(key); |
| 682 | } |
| 683 | } |
alshabib | 2cc73cb | 2015-06-30 20:26:56 -0700 | [diff] [blame] | 684 | } |
| 685 | } |
| 686 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 687 | private static class OLTPipelineGroup implements NextGroup { |
| 688 | |
| 689 | private final GroupKey key; |
| 690 | |
| 691 | public OLTPipelineGroup(GroupKey key) { |
| 692 | this.key = key; |
| 693 | } |
| 694 | |
| 695 | public GroupKey key() { |
| 696 | return key; |
| 697 | } |
| 698 | |
| 699 | @Override |
| 700 | public byte[] data() { |
| 701 | return appKryo.serialize(key); |
| 702 | } |
| 703 | |
| 704 | } |
Saurav Das | 2443119 | 2016-03-07 19:13:00 -0800 | [diff] [blame^] | 705 | |
| 706 | @Override |
| 707 | public List<String> getNextMappings(NextGroup nextGroup) { |
| 708 | // TODO Implementation deferred to vendor |
| 709 | return null; |
| 710 | } |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 711 | } |