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