alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
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; |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 22 | import com.google.common.collect.ImmutableList; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 23 | import com.google.common.collect.Lists; |
| 24 | import org.apache.commons.lang3.tuple.ImmutablePair; |
| 25 | import org.apache.commons.lang3.tuple.Pair; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 26 | import org.onlab.osgi.ServiceDirectory; |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 27 | import org.onlab.packet.EthType; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 28 | import org.onlab.packet.IPv4; |
Matteo Scandolo | 9f4f007 | 2018-11-02 16:09:39 -0700 | [diff] [blame] | 29 | import org.onlab.packet.IPv6; |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 30 | import org.onlab.packet.IpPrefix; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 31 | import org.onlab.packet.VlanId; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 32 | import org.onlab.util.KryoNamespace; |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 33 | import org.onosproject.core.ApplicationId; |
| 34 | import org.onosproject.core.CoreService; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 35 | import org.onosproject.net.DeviceId; |
| 36 | import org.onosproject.net.PortNumber; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 37 | import org.onosproject.net.behaviour.NextGroup; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 38 | import org.onosproject.net.behaviour.Pipeliner; |
| 39 | import org.onosproject.net.behaviour.PipelinerContext; |
| 40 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| 41 | import org.onosproject.net.flow.DefaultFlowRule; |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 42 | import org.onosproject.net.flow.DefaultTrafficSelector; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 43 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 44 | import org.onosproject.net.flow.FlowRule; |
| 45 | import org.onosproject.net.flow.FlowRuleOperations; |
| 46 | import org.onosproject.net.flow.FlowRuleOperationsContext; |
| 47 | import org.onosproject.net.flow.FlowRuleService; |
| 48 | import org.onosproject.net.flow.TrafficSelector; |
| 49 | import org.onosproject.net.flow.TrafficTreatment; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 50 | import org.onosproject.net.flow.criteria.Criteria; |
| 51 | import org.onosproject.net.flow.criteria.Criterion; |
| 52 | import org.onosproject.net.flow.criteria.EthTypeCriterion; |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 53 | import org.onosproject.net.flow.criteria.IPCriterion; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 54 | import org.onosproject.net.flow.criteria.IPProtocolCriterion; |
| 55 | import org.onosproject.net.flow.criteria.PortCriterion; |
Amit Ghosh | cbaf867 | 2016-12-23 21:36:19 +0000 | [diff] [blame] | 56 | import org.onosproject.net.flow.criteria.UdpPortCriterion; |
alshabib | 2f74f2c | 2016-01-14 13:29:35 -0800 | [diff] [blame] | 57 | import org.onosproject.net.flow.criteria.VlanIdCriterion; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 58 | import org.onosproject.net.flow.instructions.Instruction; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 59 | import org.onosproject.net.flow.instructions.Instructions; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 60 | import org.onosproject.net.flow.instructions.L2ModificationInstruction; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 61 | import org.onosproject.net.flowobjective.FilteringObjective; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 62 | import org.onosproject.net.flowobjective.FlowObjectiveStore; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 63 | import org.onosproject.net.flowobjective.ForwardingObjective; |
| 64 | import org.onosproject.net.flowobjective.NextObjective; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 65 | import org.onosproject.net.flowobjective.Objective; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 66 | import org.onosproject.net.flowobjective.ObjectiveError; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 67 | import org.onosproject.net.group.DefaultGroupBucket; |
| 68 | import org.onosproject.net.group.DefaultGroupDescription; |
| 69 | import org.onosproject.net.group.DefaultGroupKey; |
| 70 | import org.onosproject.net.group.Group; |
| 71 | import org.onosproject.net.group.GroupBucket; |
| 72 | import org.onosproject.net.group.GroupBuckets; |
| 73 | import org.onosproject.net.group.GroupDescription; |
| 74 | import org.onosproject.net.group.GroupEvent; |
| 75 | import org.onosproject.net.group.GroupKey; |
| 76 | import org.onosproject.net.group.GroupListener; |
| 77 | import org.onosproject.net.group.GroupService; |
| 78 | import org.onosproject.store.serializers.KryoNamespaces; |
alshabib | 5ccbe3f | 2016-03-02 22:36:02 -0800 | [diff] [blame] | 79 | import org.onosproject.store.service.StorageService; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 80 | import org.slf4j.Logger; |
| 81 | |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 82 | import java.util.Arrays; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 83 | import java.util.Collection; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 84 | import java.util.Collections; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 85 | import java.util.List; |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 86 | import java.util.Objects; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 87 | import java.util.Optional; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 88 | import java.util.concurrent.TimeUnit; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 89 | import java.util.stream.Collectors; |
| 90 | |
Andrea Campanella | ae6284c | 2020-07-09 11:39:08 +0200 | [diff] [blame] | 91 | import static org.onosproject.core.CoreService.CORE_APP_NAME; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 92 | import static org.slf4j.LoggerFactory.getLogger; |
| 93 | |
| 94 | /** |
Jonathan Hart | 64da69d | 2015-07-15 15:10:28 -0700 | [diff] [blame] | 95 | * Pipeliner for OLT device. |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 96 | */ |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 97 | |
Jonathan Hart | b92cc51 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 98 | public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner { |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 99 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 100 | private static final Integer QQ_TABLE = 1; |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 101 | private static final int NO_ACTION_PRIORITY = 500; |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 102 | private static final String DOWNSTREAM = "downstream"; |
| 103 | private static final String UPSTREAM = "upstream"; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 104 | private final Logger log = getLogger(getClass()); |
| 105 | |
| 106 | private ServiceDirectory serviceDirectory; |
| 107 | private FlowRuleService flowRuleService; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 108 | private GroupService groupService; |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 109 | private CoreService coreService; |
alshabib | 5ccbe3f | 2016-03-02 22:36:02 -0800 | [diff] [blame] | 110 | private StorageService storageService; |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 111 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 112 | private DeviceId deviceId; |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 113 | private ApplicationId appId; |
alshabib | 8336447 | 2016-03-25 09:59:55 -0700 | [diff] [blame] | 114 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 115 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 116 | protected FlowObjectiveStore flowObjectiveStore; |
| 117 | |
| 118 | private Cache<GroupKey, NextObjective> pendingGroups; |
| 119 | |
| 120 | protected static KryoNamespace appKryo = new KryoNamespace.Builder() |
| 121 | .register(KryoNamespaces.API) |
| 122 | .register(GroupKey.class) |
| 123 | .register(DefaultGroupKey.class) |
| 124 | .register(OLTPipelineGroup.class) |
Charles Chan | eefdedf | 2016-05-23 16:45:45 -0700 | [diff] [blame] | 125 | .build("OltPipeline"); |
alshabib | 2cc73cb | 2015-06-30 20:26:56 -0700 | [diff] [blame] | 126 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 127 | @Override |
| 128 | public void init(DeviceId deviceId, PipelinerContext context) { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 129 | log.debug("Initiate OLT pipeline"); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 130 | this.serviceDirectory = context.directory(); |
| 131 | this.deviceId = deviceId; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 132 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 133 | flowRuleService = serviceDirectory.get(FlowRuleService.class); |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 134 | coreService = serviceDirectory.get(CoreService.class); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 135 | groupService = serviceDirectory.get(GroupService.class); |
| 136 | flowObjectiveStore = context.store(); |
alshabib | 5ccbe3f | 2016-03-02 22:36:02 -0800 | [diff] [blame] | 137 | storageService = serviceDirectory.get(StorageService.class); |
| 138 | |
Jonathan Hart | dfc3b86 | 2015-07-01 14:49:56 -0700 | [diff] [blame] | 139 | appId = coreService.registerApplication( |
| 140 | "org.onosproject.driver.OLTPipeline"); |
| 141 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 142 | |
| 143 | pendingGroups = CacheBuilder.newBuilder() |
| 144 | .expireAfterWrite(20, TimeUnit.SECONDS) |
| 145 | .removalListener((RemovalNotification<GroupKey, NextObjective> notification) -> { |
| 146 | if (notification.getCause() == RemovalCause.EXPIRED) { |
| 147 | fail(notification.getValue(), ObjectiveError.GROUPINSTALLATIONFAILED); |
| 148 | } |
| 149 | }).build(); |
| 150 | |
| 151 | groupService.addListener(new InnerGroupListener()); |
| 152 | |
alshabib | b32cefe | 2015-06-08 18:15:05 -0700 | [diff] [blame] | 153 | } |
| 154 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 155 | @Override |
| 156 | public void filter(FilteringObjective filter) { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 157 | Instructions.OutputInstruction output; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 158 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 159 | if (filter.meta() != null && !filter.meta().immediate().isEmpty()) { |
| 160 | output = (Instructions.OutputInstruction) filter.meta().immediate().stream() |
| 161 | .filter(t -> t.type().equals(Instruction.Type.OUTPUT)) |
| 162 | .limit(1) |
| 163 | .findFirst().get(); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 164 | |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 165 | if (output == null || !output.port().equals(PortNumber.CONTROLLER)) { |
dvaddire | 8e6b89a | 2017-08-31 21:54:03 +0530 | [diff] [blame] | 166 | log.warn("OLT can only filter packet to controller"); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 167 | fail(filter, ObjectiveError.UNSUPPORTED); |
| 168 | return; |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 169 | } |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 170 | } else { |
| 171 | fail(filter, ObjectiveError.BADPARAMS); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 172 | return; |
| 173 | } |
| 174 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 175 | if (filter.key().type() != Criterion.Type.IN_PORT) { |
| 176 | fail(filter, ObjectiveError.BADPARAMS); |
| 177 | return; |
| 178 | } |
| 179 | |
| 180 | EthTypeCriterion ethType = (EthTypeCriterion) |
| 181 | filterForCriterion(filter.conditions(), Criterion.Type.ETH_TYPE); |
| 182 | |
| 183 | if (ethType == null) { |
| 184 | fail(filter, ObjectiveError.BADPARAMS); |
| 185 | return; |
| 186 | } |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 187 | Optional<Instruction> vlanId = filter.meta().immediate().stream() |
| 188 | .filter(t -> t.type().equals(Instruction.Type.L2MODIFICATION) |
| 189 | && ((L2ModificationInstruction) t).subtype() |
| 190 | .equals(L2ModificationInstruction.L2SubType.VLAN_ID)) |
| 191 | .limit(1) |
| 192 | .findFirst(); |
| 193 | |
| 194 | Optional<Instruction> vlanPcp = filter.meta().immediate().stream() |
| 195 | .filter(t -> t.type().equals(Instruction.Type.L2MODIFICATION) |
| 196 | && ((L2ModificationInstruction) t).subtype() |
| 197 | .equals(L2ModificationInstruction.L2SubType.VLAN_PCP)) |
| 198 | .limit(1) |
| 199 | .findFirst(); |
| 200 | |
| 201 | Optional<Instruction> vlanPush = filter.meta().immediate().stream() |
| 202 | .filter(t -> t.type().equals(Instruction.Type.L2MODIFICATION) |
| 203 | && ((L2ModificationInstruction) t).subtype() |
| 204 | .equals(L2ModificationInstruction.L2SubType.VLAN_PUSH)) |
| 205 | .limit(1) |
| 206 | .findFirst(); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 207 | |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 208 | if (ethType.ethType().equals(EthType.EtherType.EAPOL.ethType())) { |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 209 | |
| 210 | if (vlanId.isEmpty() || vlanPush.isEmpty()) { |
| 211 | log.warn("Missing EAPOL vlan or vlanPush"); |
| 212 | fail(filter, ObjectiveError.BADPARAMS); |
| 213 | return; |
| 214 | } |
| 215 | provisionEthTypeBasedFilter(filter, ethType, output, |
| 216 | (L2ModificationInstruction) vlanId.get(), |
| 217 | (L2ModificationInstruction) vlanPush.get()); |
Gustavo Silva | 197fd40 | 2021-02-12 08:35:16 -0300 | [diff] [blame^] | 218 | } else if (ethType.ethType().equals(EthType.EtherType.PPPoED.ethType())) { |
| 219 | provisionPPPoED(filter, ethType, vlanId.orElse(null), vlanPcp.orElse(null), output); |
| 220 | } else if (ethType.ethType().equals(EthType.EtherType.LLDP.ethType())) { |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 221 | provisionEthTypeBasedFilter(filter, ethType, output, null, null); |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 222 | } else if (ethType.ethType().equals(EthType.EtherType.IPV4.ethType())) { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 223 | IPProtocolCriterion ipProto = (IPProtocolCriterion) |
| 224 | filterForCriterion(filter.conditions(), Criterion.Type.IP_PROTO); |
dvaddire | 8e6b89a | 2017-08-31 21:54:03 +0530 | [diff] [blame] | 225 | if (ipProto == null) { |
| 226 | log.warn("OLT can only filter IGMP and DHCP"); |
| 227 | fail(filter, ObjectiveError.UNSUPPORTED); |
| 228 | return; |
| 229 | } |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 230 | if (ipProto.protocol() == IPv4.PROTOCOL_IGMP) { |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 231 | provisionIgmp(filter, ethType, ipProto, output, |
Andrea Campanella | 0956dba | 2020-09-21 14:34:00 +0200 | [diff] [blame] | 232 | vlanId.orElse(null), |
| 233 | vlanPcp.orElse(null)); |
Amit Ghosh | cbaf867 | 2016-12-23 21:36:19 +0000 | [diff] [blame] | 234 | } else if (ipProto.protocol() == IPv4.PROTOCOL_UDP) { |
| 235 | UdpPortCriterion udpSrcPort = (UdpPortCriterion) |
| 236 | filterForCriterion(filter.conditions(), Criterion.Type.UDP_SRC); |
| 237 | |
| 238 | UdpPortCriterion udpDstPort = (UdpPortCriterion) |
| 239 | filterForCriterion(filter.conditions(), Criterion.Type.UDP_DST); |
| 240 | |
Matteo Scandolo | 9f4f007 | 2018-11-02 16:09:39 -0700 | [diff] [blame] | 241 | if ((udpSrcPort.udpPort().toInt() == 67 && udpDstPort.udpPort().toInt() == 68) || |
| 242 | (udpSrcPort.udpPort().toInt() == 68 && udpDstPort.udpPort().toInt() == 67)) { |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 243 | provisionDhcp(filter, ethType, ipProto, udpSrcPort, udpDstPort, vlanId.orElse(null), |
| 244 | vlanPcp.orElse(null), output); |
Matteo Scandolo | 9f4f007 | 2018-11-02 16:09:39 -0700 | [diff] [blame] | 245 | } else { |
| 246 | log.warn("Filtering rule with unsupported UDP src {} or dst {} port", udpSrcPort, udpDstPort); |
Amit Ghosh | cbaf867 | 2016-12-23 21:36:19 +0000 | [diff] [blame] | 247 | fail(filter, ObjectiveError.UNSUPPORTED); |
| 248 | } |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 249 | } else { |
Matteo Scandolo | 9f4f007 | 2018-11-02 16:09:39 -0700 | [diff] [blame] | 250 | log.warn("Currently supporting only IGMP and DHCP filters for IPv4 packets"); |
| 251 | fail(filter, ObjectiveError.UNSUPPORTED); |
| 252 | } |
| 253 | } else if (ethType.ethType().equals(EthType.EtherType.IPV6.ethType())) { |
| 254 | IPProtocolCriterion ipProto = (IPProtocolCriterion) |
| 255 | filterForCriterion(filter.conditions(), Criterion.Type.IP_PROTO); |
| 256 | if (ipProto == null) { |
| 257 | log.warn("OLT can only filter DHCP"); |
| 258 | fail(filter, ObjectiveError.UNSUPPORTED); |
| 259 | return; |
| 260 | } |
| 261 | if (ipProto.protocol() == IPv6.PROTOCOL_UDP) { |
| 262 | UdpPortCriterion udpSrcPort = (UdpPortCriterion) |
| 263 | filterForCriterion(filter.conditions(), Criterion.Type.UDP_SRC); |
| 264 | |
| 265 | UdpPortCriterion udpDstPort = (UdpPortCriterion) |
| 266 | filterForCriterion(filter.conditions(), Criterion.Type.UDP_DST); |
| 267 | |
| 268 | if ((udpSrcPort.udpPort().toInt() == 546 && udpDstPort.udpPort().toInt() == 547) || |
| 269 | (udpSrcPort.udpPort().toInt() == 547 && udpDstPort.udpPort().toInt() == 546)) { |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 270 | provisionDhcp(filter, ethType, ipProto, udpSrcPort, udpDstPort, vlanId.orElse(null), |
| 271 | vlanPcp.orElse(null), output); |
Matteo Scandolo | 9f4f007 | 2018-11-02 16:09:39 -0700 | [diff] [blame] | 272 | } else { |
| 273 | log.warn("Filtering rule with unsupported UDP src {} or dst {} port", udpSrcPort, udpDstPort); |
| 274 | fail(filter, ObjectiveError.UNSUPPORTED); |
| 275 | } |
| 276 | } else { |
| 277 | log.warn("Currently supporting only DHCP filters for IPv6 packets"); |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 278 | fail(filter, ObjectiveError.UNSUPPORTED); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 279 | } |
| 280 | } else { |
dvaddire | 8e6b89a | 2017-08-31 21:54:03 +0530 | [diff] [blame] | 281 | log.warn("\nOnly the following are Supported in OLT for filter ->\n" |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 282 | + "ETH TYPE : EAPOL, LLDP and IPV4\n" |
Matteo Scandolo | 9f4f007 | 2018-11-02 16:09:39 -0700 | [diff] [blame] | 283 | + "IPV4 TYPE: IGMP and UDP (for DHCP)" |
| 284 | + "IPV6 TYPE: UDP (for DHCP)"); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 285 | fail(filter, ObjectiveError.UNSUPPORTED); |
| 286 | } |
| 287 | |
| 288 | } |
| 289 | |
| 290 | |
| 291 | @Override |
| 292 | public void forward(ForwardingObjective fwd) { |
Andrea Campanella | bee52b9 | 2020-01-29 14:41:42 +0100 | [diff] [blame] | 293 | log.debug("Installing forwarding objective {}", fwd); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 294 | if (checkForMulticast(fwd)) { |
| 295 | processMulticastRule(fwd); |
| 296 | return; |
| 297 | } |
| 298 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 299 | TrafficTreatment treatment = fwd.treatment(); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 300 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 301 | List<Instruction> instructions = treatment.allInstructions(); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 302 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 303 | Optional<Instruction> vlanInstruction = instructions.stream() |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 304 | .filter(i -> i.type() == Instruction.Type.L2MODIFICATION) |
| 305 | .filter(i -> ((L2ModificationInstruction) i).subtype() == |
| 306 | L2ModificationInstruction.L2SubType.VLAN_PUSH || |
| 307 | ((L2ModificationInstruction) i).subtype() == |
| 308 | L2ModificationInstruction.L2SubType.VLAN_POP) |
| 309 | .findAny(); |
| 310 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 311 | |
| 312 | if (!vlanInstruction.isPresent()) { |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 313 | installNoModificationRules(fwd); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 314 | } else { |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 315 | L2ModificationInstruction vlanIns = |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 316 | (L2ModificationInstruction) vlanInstruction.get(); |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 317 | if (vlanIns.subtype() == L2ModificationInstruction.L2SubType.VLAN_PUSH) { |
| 318 | installUpstreamRules(fwd); |
| 319 | } else if (vlanIns.subtype() == L2ModificationInstruction.L2SubType.VLAN_POP) { |
| 320 | installDownstreamRules(fwd); |
| 321 | } else { |
| 322 | log.error("Unknown OLT operation: {}", fwd); |
| 323 | fail(fwd, ObjectiveError.UNSUPPORTED); |
| 324 | return; |
| 325 | } |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 326 | } |
| 327 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 328 | pass(fwd); |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 329 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 330 | } |
| 331 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 332 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 333 | @Override |
| 334 | public void next(NextObjective nextObjective) { |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 335 | if (nextObjective.type() != NextObjective.Type.BROADCAST) { |
| 336 | log.error("OLT only supports broadcast groups."); |
| 337 | fail(nextObjective, ObjectiveError.BADPARAMS); |
Andrea Campanella | 63b17dc | 2020-05-06 16:09:10 +0200 | [diff] [blame] | 338 | return; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 339 | } |
| 340 | |
Andrea Campanella | 63b17dc | 2020-05-06 16:09:10 +0200 | [diff] [blame] | 341 | if (nextObjective.next().size() != 1 && !nextObjective.op().equals(Objective.Operation.REMOVE)) { |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 342 | log.error("OLT only supports singleton broadcast groups."); |
| 343 | fail(nextObjective, ObjectiveError.BADPARAMS); |
Andrea Campanella | 63b17dc | 2020-05-06 16:09:10 +0200 | [diff] [blame] | 344 | return; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 345 | } |
| 346 | |
Andrea Campanella | 63b17dc | 2020-05-06 16:09:10 +0200 | [diff] [blame] | 347 | Optional<TrafficTreatment> treatmentOpt = nextObjective.next().stream().findFirst(); |
| 348 | if (treatmentOpt.isEmpty() && !nextObjective.op().equals(Objective.Operation.REMOVE)) { |
| 349 | log.error("Next objective {} does not have a treatment", nextObjective); |
| 350 | fail(nextObjective, ObjectiveError.BADPARAMS); |
| 351 | return; |
| 352 | } |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 353 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 354 | GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id())); |
| 355 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 356 | pendingGroups.put(key, nextObjective); |
Andrea Campanella | 63b17dc | 2020-05-06 16:09:10 +0200 | [diff] [blame] | 357 | log.trace("NextObjective Operation {}", nextObjective.op()); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 358 | switch (nextObjective.op()) { |
| 359 | case ADD: |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 360 | GroupDescription groupDesc = |
| 361 | new DefaultGroupDescription(deviceId, |
| 362 | GroupDescription.Type.ALL, |
Andrea Campanella | 63b17dc | 2020-05-06 16:09:10 +0200 | [diff] [blame] | 363 | new GroupBuckets( |
| 364 | Collections.singletonList( |
| 365 | buildBucket(treatmentOpt.get()))), |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 366 | key, |
| 367 | null, |
| 368 | nextObjective.appId()); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 369 | groupService.addGroup(groupDesc); |
| 370 | break; |
| 371 | case REMOVE: |
| 372 | groupService.removeGroup(deviceId, key, nextObjective.appId()); |
| 373 | break; |
| 374 | case ADD_TO_EXISTING: |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 375 | groupService.addBucketsToGroup(deviceId, key, |
Andrea Campanella | 63b17dc | 2020-05-06 16:09:10 +0200 | [diff] [blame] | 376 | new GroupBuckets( |
| 377 | Collections.singletonList( |
| 378 | buildBucket(treatmentOpt.get()))), |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 379 | key, nextObjective.appId()); |
| 380 | break; |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 381 | case REMOVE_FROM_EXISTING: |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 382 | groupService.removeBucketsFromGroup(deviceId, key, |
Andrea Campanella | 63b17dc | 2020-05-06 16:09:10 +0200 | [diff] [blame] | 383 | new GroupBuckets( |
| 384 | Collections.singletonList( |
| 385 | buildBucket(treatmentOpt.get()))), |
alshabib | 56efe43 | 2016-02-25 17:57:24 -0500 | [diff] [blame] | 386 | key, nextObjective.appId()); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 387 | break; |
| 388 | default: |
| 389 | log.warn("Unknown next objective operation: {}", nextObjective.op()); |
| 390 | } |
| 391 | |
| 392 | |
| 393 | } |
| 394 | |
Andrea Campanella | 63b17dc | 2020-05-06 16:09:10 +0200 | [diff] [blame] | 395 | private GroupBucket buildBucket(TrafficTreatment treatment) { |
| 396 | return DefaultGroupBucket.createAllGroupBucket(treatment); |
| 397 | } |
| 398 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 399 | private void processMulticastRule(ForwardingObjective fwd) { |
| 400 | if (fwd.nextId() == null) { |
| 401 | log.error("Multicast objective does not have a next id"); |
| 402 | fail(fwd, ObjectiveError.BADPARAMS); |
| 403 | } |
| 404 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 405 | GroupKey key = getGroupForNextObjective(fwd.nextId()); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 406 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 407 | if (key == null) { |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 408 | log.error("Group for forwarding objective missing: {}", fwd); |
| 409 | fail(fwd, ObjectiveError.GROUPMISSING); |
| 410 | } |
| 411 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 412 | Group group = groupService.getGroup(deviceId, key); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 413 | TrafficTreatment treatment = |
| 414 | buildTreatment(Instructions.createGroup(group.id())); |
| 415 | |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 416 | TrafficSelector.Builder selectorBuilder = buildIpv4SelectorForMulticast(fwd); |
| 417 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 418 | FlowRule rule = DefaultFlowRule.builder() |
alshabib | 8336447 | 2016-03-25 09:59:55 -0700 | [diff] [blame] | 419 | .fromApp(fwd.appId()) |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 420 | .forDevice(deviceId) |
| 421 | .forTable(0) |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 422 | .makePermanent() |
| 423 | .withPriority(fwd.priority()) |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 424 | .withSelector(selectorBuilder.build()) |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 425 | .withTreatment(treatment) |
| 426 | .build(); |
| 427 | |
| 428 | FlowRuleOperations.Builder builder = FlowRuleOperations.builder(); |
| 429 | switch (fwd.op()) { |
| 430 | |
| 431 | case ADD: |
| 432 | builder.add(rule); |
| 433 | break; |
| 434 | case REMOVE: |
| 435 | builder.remove(rule); |
| 436 | break; |
| 437 | case ADD_TO_EXISTING: |
| 438 | case REMOVE_FROM_EXISTING: |
| 439 | break; |
| 440 | default: |
| 441 | log.warn("Unknown forwarding operation: {}", fwd.op()); |
| 442 | } |
| 443 | |
| 444 | applyFlowRules(builder, fwd); |
| 445 | |
| 446 | } |
| 447 | |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 448 | private TrafficSelector.Builder buildIpv4SelectorForMulticast(ForwardingObjective fwd) { |
| 449 | TrafficSelector.Builder builderToUpdate = DefaultTrafficSelector.builder(); |
| 450 | |
| 451 | Optional<Criterion> vlanIdCriterion = readFromSelector(fwd.meta(), Criterion.Type.VLAN_VID); |
| 452 | if (vlanIdCriterion.isPresent()) { |
| 453 | VlanId assignedVlan = ((VlanIdCriterion) vlanIdCriterion.get()).vlanId(); |
| 454 | builderToUpdate.matchVlanId(assignedVlan); |
| 455 | } |
| 456 | |
Esin Karaman | 2786122 | 2020-03-17 17:09:36 +0000 | [diff] [blame] | 457 | Optional<Criterion> innerVlanIdCriterion = readFromSelector(fwd.meta(), Criterion.Type.INNER_VLAN_VID); |
| 458 | if (innerVlanIdCriterion.isPresent()) { |
| 459 | VlanId assignedInnerVlan = ((VlanIdCriterion) innerVlanIdCriterion.get()).vlanId(); |
| 460 | builderToUpdate.matchMetadata(assignedInnerVlan.toShort()); |
| 461 | } |
| 462 | |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 463 | Optional<Criterion> ethTypeCriterion = readFromSelector(fwd.selector(), Criterion.Type.ETH_TYPE); |
| 464 | if (ethTypeCriterion.isPresent()) { |
| 465 | EthType ethType = ((EthTypeCriterion) ethTypeCriterion.get()).ethType(); |
| 466 | builderToUpdate.matchEthType(ethType.toShort()); |
| 467 | } |
| 468 | |
| 469 | Optional<Criterion> ipv4DstCriterion = readFromSelector(fwd.selector(), Criterion.Type.IPV4_DST); |
| 470 | if (ipv4DstCriterion.isPresent()) { |
| 471 | IpPrefix ipv4Dst = ((IPCriterion) ipv4DstCriterion.get()).ip(); |
| 472 | builderToUpdate.matchIPDst(ipv4Dst); |
| 473 | } |
| 474 | |
| 475 | return builderToUpdate; |
| 476 | } |
| 477 | |
| 478 | static Optional<Criterion> readFromSelector(TrafficSelector selector, Criterion.Type type) { |
| 479 | if (selector == null) { |
| 480 | return Optional.empty(); |
| 481 | } |
| 482 | Criterion criterion = selector.getCriterion(type); |
| 483 | return (criterion == null) |
| 484 | ? Optional.empty() : Optional.of(criterion); |
| 485 | } |
| 486 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 487 | private boolean checkForMulticast(ForwardingObjective fwd) { |
| 488 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 489 | IPCriterion ip = (IPCriterion) filterForCriterion(fwd.selector().criteria(), |
alshabib | 56efe43 | 2016-02-25 17:57:24 -0500 | [diff] [blame] | 490 | Criterion.Type.IPV4_DST); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 491 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 492 | if (ip == null) { |
| 493 | return false; |
| 494 | } |
| 495 | |
Charles Chan | aedabfd | 2016-02-26 09:31:48 -0800 | [diff] [blame] | 496 | return ip.ip().isMulticast(); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 497 | |
| 498 | } |
| 499 | |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 500 | private GroupKey getGroupForNextObjective(Integer nextId) { |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 501 | NextGroup next = flowObjectiveStore.getNextGroup(nextId); |
alshabib | 1aa5814 | 2016-02-17 15:37:56 -0800 | [diff] [blame] | 502 | return appKryo.deserialize(next.data()); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 503 | |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 504 | } |
| 505 | |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 506 | private void installNoModificationRules(ForwardingObjective fwd) { |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 507 | Instructions.OutputInstruction output = (Instructions.OutputInstruction) fetchOutput(fwd, DOWNSTREAM); |
Gamze Abaka | a34469f | 2019-04-19 08:30:16 +0000 | [diff] [blame] | 508 | Instructions.MetadataInstruction writeMetadata = fetchWriteMetadata(fwd); |
| 509 | Instructions.MeterInstruction meter = (Instructions.MeterInstruction) fetchMeter(fwd); |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 510 | |
| 511 | TrafficSelector selector = fwd.selector(); |
| 512 | |
| 513 | Criterion inport = selector.getCriterion(Criterion.Type.IN_PORT); |
| 514 | Criterion outerVlan = selector.getCriterion(Criterion.Type.VLAN_VID); |
| 515 | Criterion innerVlan = selector.getCriterion(Criterion.Type.INNER_VLAN_VID); |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 516 | |
| 517 | if (inport == null || output == null || innerVlan == null || outerVlan == null) { |
Andrea Campanella | ae6284c | 2020-07-09 11:39:08 +0200 | [diff] [blame] | 518 | // Avoid logging a non-error from lldp, bbdp and eapol core flows. |
| 519 | if (!fwd.appId().name().equals(CORE_APP_NAME)) { |
| 520 | log.error("Forwarding objective is underspecified: {}", fwd); |
| 521 | } else { |
| 522 | log.debug("Not installing unsupported core generated flow {}", fwd); |
| 523 | } |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 524 | fail(fwd, ObjectiveError.BADPARAMS); |
| 525 | return; |
| 526 | } |
| 527 | |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 528 | |
| 529 | FlowRule.Builder outer = DefaultFlowRule.builder() |
| 530 | .fromApp(fwd.appId()) |
| 531 | .forDevice(deviceId) |
| 532 | .makePermanent() |
| 533 | .withPriority(fwd.priority()) |
Gamze Abaka | a34469f | 2019-04-19 08:30:16 +0000 | [diff] [blame] | 534 | .withSelector(buildSelector(inport, outerVlan)) |
| 535 | .withTreatment(buildTreatment(output, writeMetadata, meter)); |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 536 | |
| 537 | applyRules(fwd, outer); |
| 538 | } |
| 539 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 540 | private void installDownstreamRules(ForwardingObjective fwd) { |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 541 | Instructions.OutputInstruction output = (Instructions.OutputInstruction) fetchOutput(fwd, DOWNSTREAM); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 542 | |
| 543 | if (output == null) { |
| 544 | return; |
| 545 | } |
| 546 | |
alshabib | fa0dc66 | 2016-01-13 11:23:53 -0800 | [diff] [blame] | 547 | TrafficSelector selector = fwd.selector(); |
| 548 | |
| 549 | Criterion outerVlan = selector.getCriterion(Criterion.Type.VLAN_VID); |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 550 | Criterion outerPbit = selector.getCriterion(Criterion.Type.VLAN_PCP); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 551 | Criterion innerVlanCriterion = selector.getCriterion(Criterion.Type.INNER_VLAN_VID); |
alshabib | fa0dc66 | 2016-01-13 11:23:53 -0800 | [diff] [blame] | 552 | Criterion inport = selector.getCriterion(Criterion.Type.IN_PORT); |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 553 | Criterion dstMac = selector.getCriterion(Criterion.Type.ETH_DST); |
cboling | 651c687 | 2018-10-05 11:09:22 -0500 | [diff] [blame] | 554 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 555 | if (outerVlan == null || innerVlanCriterion == null || inport == null) { |
Andrea Campanella | ae6284c | 2020-07-09 11:39:08 +0200 | [diff] [blame] | 556 | // Avoid logging a non-error from lldp, bbdp and eapol core flows. |
| 557 | if (!fwd.appId().name().equals(CORE_APP_NAME)) { |
| 558 | log.error("Forwarding objective is underspecified: {}", fwd); |
| 559 | } else { |
| 560 | log.debug("Not installing unsupported core generated flow {}", fwd); |
| 561 | } |
alshabib | fa0dc66 | 2016-01-13 11:23:53 -0800 | [diff] [blame] | 562 | fail(fwd, ObjectiveError.BADPARAMS); |
| 563 | return; |
| 564 | } |
| 565 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 566 | VlanId innerVlan = ((VlanIdCriterion) innerVlanCriterion).vlanId(); |
| 567 | Criterion innerVid = Criteria.matchVlanId(innerVlan); |
alshabib | 2f74f2c | 2016-01-14 13:29:35 -0800 | [diff] [blame] | 568 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 569 | if (innerVlan.toShort() == VlanId.ANY_VALUE) { |
Andrea Campanella | bee52b9 | 2020-01-29 14:41:42 +0100 | [diff] [blame] | 570 | TrafficSelector outerSelector = buildSelector(inport, outerVlan, outerPbit, dstMac); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 571 | installDownstreamRulesForAnyVlan(fwd, output, outerSelector, buildSelector(inport, |
| 572 | Criteria.matchVlanId(VlanId.ANY))); |
| 573 | } else { |
Andrea Campanella | bee52b9 | 2020-01-29 14:41:42 +0100 | [diff] [blame] | 574 | // Required to differentiate the same match flows |
| 575 | // Please note that S tag and S p bit values will be same for the same service - so conflict flows! |
| 576 | // Metadata match criteria solves the conflict issue - but not used by the voltha |
| 577 | // Maybe - find a better way to solve the above problem |
| 578 | Criterion metadata = Criteria.matchMetadata(innerVlan.toShort()); |
| 579 | TrafficSelector outerSelector = buildSelector(inport, metadata, outerVlan, outerPbit, dstMac); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 580 | installDownstreamRulesForVlans(fwd, output, outerSelector, buildSelector(inport, innerVid)); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | private void installDownstreamRulesForVlans(ForwardingObjective fwd, Instruction output, |
| 585 | TrafficSelector outerSelector, TrafficSelector innerSelector) { |
| 586 | |
| 587 | List<Pair<Instruction, Instruction>> vlanOps = |
| 588 | vlanOps(fwd, |
| 589 | L2ModificationInstruction.L2SubType.VLAN_POP); |
| 590 | |
| 591 | if (vlanOps == null || vlanOps.isEmpty()) { |
| 592 | return; |
| 593 | } |
| 594 | |
| 595 | Pair<Instruction, Instruction> popAndRewrite = vlanOps.remove(0); |
| 596 | |
| 597 | TrafficTreatment innerTreatment; |
| 598 | VlanId setVlanId = ((L2ModificationInstruction.ModVlanIdInstruction) popAndRewrite.getRight()).vlanId(); |
| 599 | if (VlanId.NONE.equals(setVlanId)) { |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 600 | innerTreatment = (buildTreatment(popAndRewrite.getLeft(), fetchMeter(fwd), |
| 601 | writeMetadataIncludingOnlyTp(fwd), output)); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 602 | } else { |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 603 | innerTreatment = (buildTreatment(popAndRewrite.getRight(), |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 604 | fetchMeter(fwd), writeMetadataIncludingOnlyTp(fwd), output)); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 605 | } |
| 606 | |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 607 | List<Instruction> setVlanPcps = findL2Instructions(L2ModificationInstruction.L2SubType.VLAN_PCP, |
| 608 | fwd.treatment().allInstructions()); |
| 609 | |
| 610 | Instruction innerPbitSet = null; |
| 611 | |
| 612 | if (setVlanPcps != null && !setVlanPcps.isEmpty()) { |
| 613 | innerPbitSet = setVlanPcps.get(0); |
| 614 | } |
| 615 | |
| 616 | VlanId remarkInnerVlan = null; |
| 617 | Optional<Criterion> vlanIdCriterion = readFromSelector(innerSelector, Criterion.Type.VLAN_VID); |
| 618 | if (vlanIdCriterion.isPresent()) { |
| 619 | remarkInnerVlan = ((VlanIdCriterion) vlanIdCriterion.get()).vlanId(); |
| 620 | } |
| 621 | |
| 622 | Instruction modVlanId = null; |
| 623 | if (innerPbitSet != null) { |
| 624 | modVlanId = Instructions.modVlanId(remarkInnerVlan); |
| 625 | } |
| 626 | |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 627 | //match: in port (nni), s-tag |
| 628 | //action: pop vlan (s-tag), write metadata, go to table 1, meter |
alshabib | fa0dc66 | 2016-01-13 11:23:53 -0800 | [diff] [blame] | 629 | FlowRule.Builder outer = DefaultFlowRule.builder() |
alshabib | 8336447 | 2016-03-25 09:59:55 -0700 | [diff] [blame] | 630 | .fromApp(fwd.appId()) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 631 | .forDevice(deviceId) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 632 | .makePermanent() |
| 633 | .withPriority(fwd.priority()) |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 634 | .withSelector(outerSelector) |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 635 | .withTreatment(buildTreatment(popAndRewrite.getLeft(), modVlanId, |
| 636 | innerPbitSet, fetchMeter(fwd), fetchWriteMetadata(fwd), Instructions.transition(QQ_TABLE))); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 637 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 638 | //match: in port (nni), c-tag |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 639 | //action: immediate: write metadata and pop, meter, output |
alshabib | fa0dc66 | 2016-01-13 11:23:53 -0800 | [diff] [blame] | 640 | FlowRule.Builder inner = DefaultFlowRule.builder() |
alshabib | 8336447 | 2016-03-25 09:59:55 -0700 | [diff] [blame] | 641 | .fromApp(fwd.appId()) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 642 | .forDevice(deviceId) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 643 | .forTable(QQ_TABLE) |
| 644 | .makePermanent() |
| 645 | .withPriority(fwd.priority()) |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 646 | .withSelector(innerSelector) |
| 647 | .withTreatment(innerTreatment); |
| 648 | applyRules(fwd, inner, outer); |
| 649 | } |
| 650 | |
| 651 | private void installDownstreamRulesForAnyVlan(ForwardingObjective fwd, Instruction output, |
| 652 | TrafficSelector outerSelector, TrafficSelector innerSelector) { |
| 653 | |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 654 | //match: in port (nni), s-tag |
| 655 | //action: immediate: write metadata, pop vlan, meter and go to table 1 |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 656 | FlowRule.Builder outer = DefaultFlowRule.builder() |
| 657 | .fromApp(fwd.appId()) |
| 658 | .forDevice(deviceId) |
| 659 | .makePermanent() |
| 660 | .withPriority(fwd.priority()) |
| 661 | .withSelector(outerSelector) |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 662 | .withTreatment(buildTreatment(Instructions.popVlan(), fetchMeter(fwd), |
| 663 | fetchWriteMetadata(fwd), Instructions.transition(QQ_TABLE))); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 664 | |
| 665 | //match: in port (nni) and s-tag |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 666 | //action: immediate : write metadata, meter and output |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 667 | FlowRule.Builder inner = DefaultFlowRule.builder() |
| 668 | .fromApp(fwd.appId()) |
| 669 | .forDevice(deviceId) |
| 670 | .forTable(QQ_TABLE) |
| 671 | .makePermanent() |
| 672 | .withPriority(fwd.priority()) |
| 673 | .withSelector(innerSelector) |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 674 | .withTreatment(buildTreatment(fetchMeter(fwd), |
| 675 | writeMetadataIncludingOnlyTp(fwd), output)); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 676 | |
| 677 | applyRules(fwd, inner, outer); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | private void installUpstreamRules(ForwardingObjective fwd) { |
| 681 | List<Pair<Instruction, Instruction>> vlanOps = |
| 682 | vlanOps(fwd, |
| 683 | L2ModificationInstruction.L2SubType.VLAN_PUSH); |
| 684 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 685 | if (vlanOps == null || vlanOps.isEmpty()) { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 686 | return; |
| 687 | } |
| 688 | |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 689 | Instruction output = fetchOutput(fwd, UPSTREAM); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 690 | |
| 691 | if (output == null) { |
| 692 | return; |
| 693 | } |
| 694 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 695 | Pair<Instruction, Instruction> outerPair = vlanOps.remove(0); |
| 696 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 697 | boolean noneValueVlanStatus = checkNoneVlanCriteria(fwd); |
| 698 | boolean anyValueVlanStatus = checkAnyVlanMatchCriteria(fwd); |
Jonathan Hart | 3dc474c | 2018-08-15 18:15:45 -0700 | [diff] [blame] | 699 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 700 | if (anyValueVlanStatus) { |
| 701 | installUpstreamRulesForAnyVlan(fwd, output, outerPair); |
| 702 | } else { |
Andrea Campanella | bee52b9 | 2020-01-29 14:41:42 +0100 | [diff] [blame] | 703 | Pair<Instruction, Instruction> innerPair = outerPair; |
| 704 | outerPair = vlanOps.remove(0); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 705 | installUpstreamRulesForVlans(fwd, output, innerPair, outerPair, noneValueVlanStatus); |
| 706 | } |
| 707 | } |
| 708 | |
| 709 | private void installUpstreamRulesForVlans(ForwardingObjective fwd, Instruction output, |
| 710 | Pair<Instruction, Instruction> innerPair, |
| 711 | Pair<Instruction, Instruction> outerPair, Boolean noneValueVlanStatus) { |
| 712 | |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 713 | List<Instruction> setVlanPcps = findL2Instructions(L2ModificationInstruction.L2SubType.VLAN_PCP, |
| 714 | fwd.treatment().allInstructions()); |
| 715 | |
| 716 | Instruction innerPbitSet = null; |
| 717 | Instruction outerPbitSet = null; |
| 718 | |
| 719 | if (setVlanPcps != null && !setVlanPcps.isEmpty()) { |
| 720 | innerPbitSet = setVlanPcps.get(0); |
| 721 | outerPbitSet = setVlanPcps.get(1); |
| 722 | } |
| 723 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 724 | TrafficTreatment innerTreatment; |
| 725 | if (noneValueVlanStatus) { |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 726 | innerTreatment = buildTreatment(innerPair.getLeft(), innerPair.getRight(), fetchMeter(fwd), |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 727 | fetchWriteMetadata(fwd), innerPbitSet, |
| 728 | Instructions.transition(QQ_TABLE)); |
Jonathan Hart | 3dc474c | 2018-08-15 18:15:45 -0700 | [diff] [blame] | 729 | } else { |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 730 | innerTreatment = buildTreatment(innerPair.getRight(), fetchMeter(fwd), fetchWriteMetadata(fwd), |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 731 | innerPbitSet, Instructions.transition(QQ_TABLE)); |
Jonathan Hart | 3dc474c | 2018-08-15 18:15:45 -0700 | [diff] [blame] | 732 | } |
| 733 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 734 | //match: in port, vlanId (0 or None) |
| 735 | //action: |
| 736 | //if vlanId None, push & set c-tag go to table 1 |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 737 | //if vlanId 0 or any specific vlan, set c-tag, write metadata, meter and go to table 1 |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 738 | FlowRule.Builder inner = DefaultFlowRule.builder() |
alshabib | 8336447 | 2016-03-25 09:59:55 -0700 | [diff] [blame] | 739 | .fromApp(fwd.appId()) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 740 | .forDevice(deviceId) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 741 | .makePermanent() |
| 742 | .withPriority(fwd.priority()) |
| 743 | .withSelector(fwd.selector()) |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 744 | .withTreatment(innerTreatment); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 745 | |
| 746 | PortCriterion inPort = (PortCriterion) |
| 747 | fwd.selector().getCriterion(Criterion.Type.IN_PORT); |
| 748 | |
| 749 | VlanId cVlanId = ((L2ModificationInstruction.ModVlanIdInstruction) |
| 750 | innerPair.getRight()).vlanId(); |
| 751 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 752 | //match: in port, c-tag |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 753 | //action: immediate: push s-tag, write metadata, meter and output |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 754 | FlowRule.Builder outer = DefaultFlowRule.builder() |
alshabib | 8336447 | 2016-03-25 09:59:55 -0700 | [diff] [blame] | 755 | .fromApp(fwd.appId()) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 756 | .forDevice(deviceId) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 757 | .forTable(QQ_TABLE) |
| 758 | .makePermanent() |
| 759 | .withPriority(fwd.priority()) |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 760 | .withTreatment(buildTreatment(outerPair.getLeft(), outerPair.getRight(), |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 761 | fetchMeter(fwd), writeMetadataIncludingOnlyTp(fwd), |
| 762 | outerPbitSet, output)); |
| 763 | |
| 764 | if (innerPbitSet != null) { |
| 765 | byte innerPbit = ((L2ModificationInstruction.ModVlanPcpInstruction) |
| 766 | innerPbitSet).vlanPcp(); |
| 767 | outer.withSelector(buildSelector(inPort, Criteria.matchVlanId(cVlanId), Criteria.matchVlanPcp(innerPbit))); |
| 768 | } else { |
| 769 | outer.withSelector(buildSelector(inPort, Criteria.matchVlanId(cVlanId))); |
| 770 | } |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 771 | |
| 772 | applyRules(fwd, inner, outer); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 773 | } |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 774 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 775 | private void installUpstreamRulesForAnyVlan(ForwardingObjective fwd, Instruction output, |
| 776 | Pair<Instruction, Instruction> outerPair) { |
| 777 | |
| 778 | log.debug("Installing upstream rules for any value vlan"); |
| 779 | |
| 780 | //match: in port and any-vlan (coming from OLT app.) |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 781 | //action: write metadata, go to table 1 and meter |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 782 | FlowRule.Builder inner = DefaultFlowRule.builder() |
| 783 | .fromApp(fwd.appId()) |
| 784 | .forDevice(deviceId) |
| 785 | .makePermanent() |
| 786 | .withPriority(fwd.priority()) |
| 787 | .withSelector(fwd.selector()) |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 788 | .withTreatment(buildTreatment(Instructions.transition(QQ_TABLE), fetchMeter(fwd), |
| 789 | fetchWriteMetadata(fwd))); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 790 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 791 | //match: in port and any-vlan (coming from OLT app.) |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 792 | //action: immediate: push:QinQ, vlanId (s-tag), write metadata, meter and output |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 793 | FlowRule.Builder outer = DefaultFlowRule.builder() |
| 794 | .fromApp(fwd.appId()) |
| 795 | .forDevice(deviceId) |
| 796 | .forTable(QQ_TABLE) |
| 797 | .makePermanent() |
| 798 | .withPriority(fwd.priority()) |
| 799 | .withSelector(fwd.selector()) |
Andrea Campanella | bee52b9 | 2020-01-29 14:41:42 +0100 | [diff] [blame] | 800 | .withTreatment(buildTreatment(outerPair.getLeft(), outerPair.getRight(), |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 801 | fetchMeter(fwd), writeMetadataIncludingOnlyTp(fwd), output)); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 802 | |
Andrea Campanella | bee52b9 | 2020-01-29 14:41:42 +0100 | [diff] [blame] | 803 | applyRules(fwd, inner, outer); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | private boolean checkNoneVlanCriteria(ForwardingObjective fwd) { |
| 807 | // Add the VLAN_PUSH treatment if we're matching on VlanId.NONE |
| 808 | Criterion vlanMatchCriterion = filterForCriterion(fwd.selector().criteria(), Criterion.Type.VLAN_VID); |
| 809 | boolean noneValueVlanStatus = false; |
| 810 | if (vlanMatchCriterion != null) { |
| 811 | noneValueVlanStatus = ((VlanIdCriterion) vlanMatchCriterion).vlanId().equals(VlanId.NONE); |
| 812 | } |
| 813 | return noneValueVlanStatus; |
| 814 | } |
| 815 | |
| 816 | private boolean checkAnyVlanMatchCriteria(ForwardingObjective fwd) { |
| 817 | Criterion anyValueVlanCriterion = fwd.selector().criteria().stream() |
| 818 | .filter(c -> c.type().equals(Criterion.Type.VLAN_VID)) |
| 819 | .filter(vc -> ((VlanIdCriterion) vc).vlanId().toShort() == VlanId.ANY_VALUE) |
| 820 | .findAny().orElse(null); |
| 821 | |
| 822 | if (anyValueVlanCriterion == null) { |
Andrea Campanella | bee52b9 | 2020-01-29 14:41:42 +0100 | [diff] [blame] | 823 | log.debug("Any value vlan match criteria is not found, criteria {}", |
| 824 | fwd.selector().criteria()); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 825 | return false; |
| 826 | } |
| 827 | |
| 828 | return true; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | private Instruction fetchOutput(ForwardingObjective fwd, String direction) { |
| 832 | Instruction output = fwd.treatment().allInstructions().stream() |
| 833 | .filter(i -> i.type() == Instruction.Type.OUTPUT) |
| 834 | .findFirst().orElse(null); |
| 835 | |
| 836 | if (output == null) { |
| 837 | log.error("OLT {} rule has no output", direction); |
| 838 | fail(fwd, ObjectiveError.BADPARAMS); |
| 839 | return null; |
| 840 | } |
| 841 | return output; |
| 842 | } |
| 843 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 844 | private Instruction fetchMeter(ForwardingObjective fwd) { |
| 845 | Instruction meter = fwd.treatment().metered(); |
| 846 | |
| 847 | if (meter == null) { |
| 848 | log.debug("Meter instruction is not found for the forwarding objective {}", fwd); |
| 849 | return null; |
| 850 | } |
| 851 | |
| 852 | log.debug("Meter instruction is found."); |
| 853 | return meter; |
| 854 | } |
| 855 | |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 856 | private Instructions.MetadataInstruction fetchWriteMetadata(ForwardingObjective fwd) { |
| 857 | Instructions.MetadataInstruction writeMetadata = fwd.treatment().writeMetadata(); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 858 | |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 859 | if (writeMetadata == null) { |
| 860 | log.warn("Write metadata is not found for the forwarding obj"); |
| 861 | fail(fwd, ObjectiveError.BADPARAMS); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 862 | return null; |
| 863 | } |
| 864 | |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 865 | log.debug("Write metadata is found {}", writeMetadata); |
| 866 | return writeMetadata; |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 867 | } |
| 868 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 869 | private List<Pair<Instruction, Instruction>> vlanOps(ForwardingObjective fwd, |
| 870 | L2ModificationInstruction.L2SubType type) { |
| 871 | |
| 872 | List<Pair<Instruction, Instruction>> vlanOps = findVlanOps( |
| 873 | fwd.treatment().allInstructions(), type); |
| 874 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 875 | if (vlanOps == null || vlanOps.isEmpty()) { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 876 | String direction = type == L2ModificationInstruction.L2SubType.VLAN_POP |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 877 | ? DOWNSTREAM : UPSTREAM; |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 878 | log.error("Missing vlan operations in {} forwarding: {}", direction, fwd); |
| 879 | fail(fwd, ObjectiveError.BADPARAMS); |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 880 | return ImmutableList.of(); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 881 | } |
| 882 | return vlanOps; |
| 883 | } |
| 884 | |
| 885 | |
| 886 | private List<Pair<Instruction, Instruction>> findVlanOps(List<Instruction> instructions, |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 887 | L2ModificationInstruction.L2SubType type) { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 888 | |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 889 | List<Instruction> vlanOperations = findL2Instructions( |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 890 | type, |
| 891 | instructions); |
| 892 | List<Instruction> vlanSets = findL2Instructions( |
| 893 | L2ModificationInstruction.L2SubType.VLAN_ID, |
| 894 | instructions); |
| 895 | |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 896 | if (vlanOperations.size() != vlanSets.size()) { |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 897 | return ImmutableList.of(); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | List<Pair<Instruction, Instruction>> pairs = Lists.newArrayList(); |
| 901 | |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 902 | for (int i = 0; i < vlanOperations.size(); i++) { |
| 903 | pairs.add(new ImmutablePair<>(vlanOperations.get(i), vlanSets.get(i))); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 904 | } |
| 905 | return pairs; |
| 906 | } |
| 907 | |
| 908 | private List<Instruction> findL2Instructions(L2ModificationInstruction.L2SubType subType, |
| 909 | List<Instruction> actions) { |
| 910 | return actions.stream() |
| 911 | .filter(i -> i.type() == Instruction.Type.L2MODIFICATION) |
| 912 | .filter(i -> ((L2ModificationInstruction) i).subtype() == subType) |
| 913 | .collect(Collectors.toList()); |
| 914 | } |
| 915 | |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 916 | private void provisionEthTypeBasedFilter(FilteringObjective filter, |
| 917 | EthTypeCriterion ethType, |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 918 | Instructions.OutputInstruction output, |
| 919 | L2ModificationInstruction vlanId, |
| 920 | L2ModificationInstruction vlanPush) { |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 921 | |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 922 | Instruction meter = filter.meta().metered(); |
| 923 | Instruction writeMetadata = filter.meta().writeMetadata(); |
| 924 | |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 925 | TrafficSelector selector = buildSelector(filter.key(), ethType); |
| 926 | TrafficTreatment treatment; |
Gamze Abaka | f57ef60 | 2019-03-11 06:52:48 +0000 | [diff] [blame] | 927 | |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 928 | if (vlanPush == null || vlanId == null) { |
| 929 | treatment = buildTreatment(output, meter, writeMetadata); |
| 930 | } else { |
| 931 | // we need to push the vlan because it came untagged (ATT) |
| 932 | treatment = buildTreatment(output, meter, vlanPush, vlanId, writeMetadata); |
| 933 | } |
| 934 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 935 | buildAndApplyRule(filter, selector, treatment); |
| 936 | |
| 937 | } |
| 938 | |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 939 | private void provisionIgmp(FilteringObjective filter, EthTypeCriterion ethType, |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 940 | IPProtocolCriterion ipProto, |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 941 | Instructions.OutputInstruction output, |
Andrea Campanella | 0956dba | 2020-09-21 14:34:00 +0200 | [diff] [blame] | 942 | Instruction vlan, Instruction pcp) { |
Gamze Abaka | 7c070c8 | 2019-02-21 14:40:18 +0000 | [diff] [blame] | 943 | |
| 944 | Instruction meter = filter.meta().metered(); |
| 945 | Instruction writeMetadata = filter.meta().writeMetadata(); |
| 946 | |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 947 | // uniTagMatch |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 948 | VlanIdCriterion vlanId = (VlanIdCriterion) filterForCriterion(filter.conditions(), |
| 949 | Criterion.Type.VLAN_VID); |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 950 | |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 951 | TrafficSelector selector = buildSelector(filter.key(), ethType, ipProto, vlanId); |
| 952 | TrafficTreatment treatment = buildTreatment(output, vlan, pcp, meter, writeMetadata); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 953 | buildAndApplyRule(filter, selector, treatment); |
| 954 | } |
| 955 | |
Amit Ghosh | cbaf867 | 2016-12-23 21:36:19 +0000 | [diff] [blame] | 956 | private void provisionDhcp(FilteringObjective filter, EthTypeCriterion ethType, |
| 957 | IPProtocolCriterion ipProto, |
| 958 | UdpPortCriterion udpSrcPort, |
| 959 | UdpPortCriterion udpDstPort, |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 960 | Instruction vlanIdInstruction, |
| 961 | Instruction vlanPcpInstruction, |
Amit Ghosh | cbaf867 | 2016-12-23 21:36:19 +0000 | [diff] [blame] | 962 | Instructions.OutputInstruction output) { |
Gamze Abaka | 7c070c8 | 2019-02-21 14:40:18 +0000 | [diff] [blame] | 963 | |
| 964 | Instruction meter = filter.meta().metered(); |
| 965 | Instruction writeMetadata = filter.meta().writeMetadata(); |
| 966 | |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 967 | VlanIdCriterion matchVlanId = (VlanIdCriterion) |
Gamze Abaka | 61269f8 | 2019-12-02 06:42:39 +0000 | [diff] [blame] | 968 | filterForCriterion(filter.conditions(), Criterion.Type.VLAN_VID); |
| 969 | |
Andrea Campanella | befc294 | 2020-06-11 16:09:39 +0200 | [diff] [blame] | 970 | TrafficSelector selector; |
| 971 | TrafficTreatment treatment; |
| 972 | |
| 973 | if (matchVlanId != null) { |
| 974 | log.debug("Building selector with match VLAN, {}", matchVlanId); |
| 975 | // in case of TT upstream the packet comes tagged and the vlan is swapped. |
| 976 | selector = buildSelector(filter.key(), ethType, ipProto, udpSrcPort, |
| 977 | udpDstPort, matchVlanId); |
| 978 | treatment = buildTreatment(output, meter, writeMetadata, |
| 979 | vlanIdInstruction, vlanPcpInstruction); |
| 980 | } else { |
| 981 | log.debug("Building selector with no VLAN"); |
| 982 | // in case of ATT upstream the packet comes in untagged and we need to push the vlan |
| 983 | selector = buildSelector(filter.key(), ethType, ipProto, udpSrcPort, udpDstPort); |
| 984 | treatment = buildTreatment(output, meter, vlanIdInstruction, writeMetadata); |
| 985 | } |
| 986 | //In case of downstream there will be no match on the VLAN, which is null, |
| 987 | // so it will just be output, meter, writeMetadata |
| 988 | |
Amit Ghosh | cbaf867 | 2016-12-23 21:36:19 +0000 | [diff] [blame] | 989 | buildAndApplyRule(filter, selector, treatment); |
| 990 | } |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 991 | |
Gustavo Silva | 197fd40 | 2021-02-12 08:35:16 -0300 | [diff] [blame^] | 992 | private void provisionPPPoED(FilteringObjective filter, EthTypeCriterion ethType, |
| 993 | Instruction vlanIdInstruction, |
| 994 | Instruction vlanPcpInstruction, |
| 995 | Instructions.OutputInstruction output) { |
| 996 | Instruction meter = filter.meta().metered(); |
| 997 | Instruction writeMetadata = filter.meta().writeMetadata(); |
| 998 | |
| 999 | VlanIdCriterion matchVlanId = (VlanIdCriterion) |
| 1000 | filterForCriterion(filter.conditions(), Criterion.Type.VLAN_VID); |
| 1001 | |
| 1002 | TrafficSelector selector; |
| 1003 | TrafficTreatment treatment; |
| 1004 | |
| 1005 | if (matchVlanId != null) { |
| 1006 | log.debug("Building pppoed selector with match VLAN {}.", matchVlanId); |
| 1007 | } else { |
| 1008 | log.debug("Building pppoed selector without match VLAN."); |
| 1009 | } |
| 1010 | |
| 1011 | selector = buildSelector(filter.key(), ethType, matchVlanId); |
| 1012 | treatment = buildTreatment(output, meter, writeMetadata, vlanIdInstruction, vlanPcpInstruction); |
| 1013 | buildAndApplyRule(filter, selector, treatment); |
| 1014 | } |
| 1015 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1016 | private void buildAndApplyRule(FilteringObjective filter, TrafficSelector selector, |
| 1017 | TrafficTreatment treatment) { |
| 1018 | FlowRule rule = DefaultFlowRule.builder() |
alshabib | 8336447 | 2016-03-25 09:59:55 -0700 | [diff] [blame] | 1019 | .fromApp(filter.appId()) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1020 | .forDevice(deviceId) |
| 1021 | .forTable(0) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1022 | .makePermanent() |
| 1023 | .withSelector(selector) |
| 1024 | .withTreatment(treatment) |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 1025 | .withPriority(filter.priority()) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1026 | .build(); |
| 1027 | |
| 1028 | FlowRuleOperations.Builder opsBuilder = FlowRuleOperations.builder(); |
| 1029 | |
| 1030 | switch (filter.type()) { |
| 1031 | case PERMIT: |
| 1032 | opsBuilder.add(rule); |
| 1033 | break; |
| 1034 | case DENY: |
| 1035 | opsBuilder.remove(rule); |
| 1036 | break; |
| 1037 | default: |
| 1038 | log.warn("Unknown filter type : {}", filter.type()); |
| 1039 | fail(filter, ObjectiveError.UNSUPPORTED); |
| 1040 | } |
| 1041 | |
| 1042 | applyFlowRules(opsBuilder, filter); |
| 1043 | } |
| 1044 | |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 1045 | private void applyRules(ForwardingObjective fwd, FlowRule.Builder... fwdBuilders) { |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 1046 | FlowRuleOperations.Builder builder = FlowRuleOperations.builder(); |
| 1047 | switch (fwd.op()) { |
| 1048 | case ADD: |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 1049 | for (FlowRule.Builder fwdBuilder : fwdBuilders) { |
| 1050 | builder.add(fwdBuilder.build()); |
| 1051 | } |
Amit Ghosh | f1f2275 | 2018-08-14 07:28:01 +0100 | [diff] [blame] | 1052 | break; |
| 1053 | case REMOVE: |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 1054 | for (FlowRule.Builder fwdBuilder : fwdBuilders) { |
| 1055 | builder.remove(fwdBuilder.build()); |
| 1056 | } |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1057 | break; |
| 1058 | case ADD_TO_EXISTING: |
| 1059 | break; |
| 1060 | case REMOVE_FROM_EXISTING: |
| 1061 | break; |
| 1062 | default: |
| 1063 | log.warn("Unknown forwarding operation: {}", fwd.op()); |
| 1064 | } |
| 1065 | |
| 1066 | applyFlowRules(builder, fwd); |
| 1067 | } |
| 1068 | |
| 1069 | private void applyFlowRules(FlowRuleOperations.Builder builder, |
| 1070 | Objective objective) { |
| 1071 | flowRuleService.apply(builder.build(new FlowRuleOperationsContext() { |
| 1072 | @Override |
| 1073 | public void onSuccess(FlowRuleOperations ops) { |
| 1074 | pass(objective); |
| 1075 | } |
| 1076 | |
| 1077 | @Override |
| 1078 | public void onError(FlowRuleOperations ops) { |
| 1079 | fail(objective, ObjectiveError.FLOWINSTALLATIONFAILED); |
| 1080 | } |
| 1081 | })); |
| 1082 | } |
| 1083 | |
| 1084 | private Criterion filterForCriterion(Collection<Criterion> criteria, Criterion.Type type) { |
| 1085 | return criteria.stream() |
alshabib | bb42423 | 2016-01-15 12:20:25 -0800 | [diff] [blame] | 1086 | .filter(c -> c.type().equals(type)) |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1087 | .limit(1) |
| 1088 | .findFirst().orElse(null); |
| 1089 | } |
| 1090 | |
| 1091 | private TrafficSelector buildSelector(Criterion... criteria) { |
| 1092 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1093 | TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder(); |
| 1094 | |
Gamze Abaka | f57ef60 | 2019-03-11 06:52:48 +0000 | [diff] [blame] | 1095 | Arrays.stream(criteria).filter(Objects::nonNull).forEach(sBuilder::add); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1096 | |
| 1097 | return sBuilder.build(); |
| 1098 | } |
| 1099 | |
| 1100 | private TrafficTreatment buildTreatment(Instruction... instructions) { |
| 1101 | |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1102 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); |
| 1103 | |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 1104 | Arrays.stream(instructions).filter(Objects::nonNull).forEach(tBuilder::add); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1105 | |
| 1106 | return tBuilder.build(); |
| 1107 | } |
| 1108 | |
Gamze Abaka | 6c8a71b | 2018-12-24 13:17:12 +0000 | [diff] [blame] | 1109 | private Instruction writeMetadataIncludingOnlyTp(ForwardingObjective fwd) { |
| 1110 | |
| 1111 | return Instructions.writeMetadata( |
| 1112 | fetchWriteMetadata(fwd).metadata() & 0xFFFF00000000L, 0L); |
| 1113 | } |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1114 | |
| 1115 | private void fail(Objective obj, ObjectiveError error) { |
Sho SHIMIZU | ef7e290 | 2016-02-12 18:38:29 -0800 | [diff] [blame] | 1116 | obj.context().ifPresent(context -> context.onError(obj, error)); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1117 | } |
| 1118 | |
| 1119 | private void pass(Objective obj) { |
Sho SHIMIZU | ef7e290 | 2016-02-12 18:38:29 -0800 | [diff] [blame] | 1120 | obj.context().ifPresent(context -> context.onSuccess(obj)); |
alshabib | fd430b6 | 2015-12-16 18:56:38 -0800 | [diff] [blame] | 1121 | } |
| 1122 | |
alshabib | 2cc73cb | 2015-06-30 20:26:56 -0700 | [diff] [blame] | 1123 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 1124 | private class InnerGroupListener implements GroupListener { |
alshabib | 2cc73cb | 2015-06-30 20:26:56 -0700 | [diff] [blame] | 1125 | @Override |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 1126 | public void event(GroupEvent event) { |
Andrea Campanella | 63b17dc | 2020-05-06 16:09:10 +0200 | [diff] [blame] | 1127 | GroupKey key = event.subject().appCookie(); |
| 1128 | NextObjective obj = pendingGroups.getIfPresent(key); |
| 1129 | if (obj == null) { |
| 1130 | log.debug("No pending group for {}, moving on", key); |
| 1131 | return; |
| 1132 | } |
| 1133 | log.trace("Event {} for group {}, handling pending" + |
| 1134 | "NextGroup {}", event.type(), key, obj.id()); |
ke han | f508667 | 2016-08-12 11:09:17 +0800 | [diff] [blame] | 1135 | if (event.type() == GroupEvent.Type.GROUP_ADDED || |
Gamze Abaka | dadae72 | 2018-09-12 10:55:35 +0000 | [diff] [blame] | 1136 | event.type() == GroupEvent.Type.GROUP_UPDATED) { |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 1137 | flowObjectiveStore.putNextGroup(obj.id(), new OLTPipelineGroup(key)); |
| 1138 | pass(obj); |
| 1139 | pendingGroups.invalidate(key); |
Andrea Campanella | 63b17dc | 2020-05-06 16:09:10 +0200 | [diff] [blame] | 1140 | } else if (event.type() == GroupEvent.Type.GROUP_REMOVED) { |
| 1141 | flowObjectiveStore.removeNextGroup(obj.id()); |
| 1142 | pass(obj); |
| 1143 | pendingGroups.invalidate(key); |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 1144 | } |
alshabib | 2cc73cb | 2015-06-30 20:26:56 -0700 | [diff] [blame] | 1145 | } |
| 1146 | } |
| 1147 | |
alshabib | d61b77b | 2016-02-01 23:30:53 -0800 | [diff] [blame] | 1148 | private static class OLTPipelineGroup implements NextGroup { |
| 1149 | |
| 1150 | private final GroupKey key; |
| 1151 | |
| 1152 | public OLTPipelineGroup(GroupKey key) { |
| 1153 | this.key = key; |
| 1154 | } |
| 1155 | |
| 1156 | public GroupKey key() { |
| 1157 | return key; |
| 1158 | } |
| 1159 | |
| 1160 | @Override |
| 1161 | public byte[] data() { |
| 1162 | return appKryo.serialize(key); |
| 1163 | } |
| 1164 | |
| 1165 | } |
Saurav Das | 2443119 | 2016-03-07 19:13:00 -0800 | [diff] [blame] | 1166 | |
| 1167 | @Override |
| 1168 | public List<String> getNextMappings(NextGroup nextGroup) { |
| 1169 | // TODO Implementation deferred to vendor |
| 1170 | return null; |
| 1171 | } |
alshabib | 0ccde6d | 2015-05-30 18:22:36 -0700 | [diff] [blame] | 1172 | } |