Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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.sfc.manager.impl; |
| 17 | |
Phaneendra Manda | 5c8257b | 2016-02-03 22:07:38 +0530 | [diff] [blame^] | 18 | import static org.slf4j.LoggerFactory.getLogger; |
| 19 | |
| 20 | import java.util.concurrent.ConcurrentHashMap; |
| 21 | import java.util.concurrent.ConcurrentMap; |
| 22 | |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 23 | import org.apache.felix.scr.annotations.Activate; |
| 24 | import org.apache.felix.scr.annotations.Component; |
| 25 | import org.apache.felix.scr.annotations.Deactivate; |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 26 | import org.apache.felix.scr.annotations.Reference; |
| 27 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 28 | import org.apache.felix.scr.annotations.Service; |
Phaneendra Manda | 5c8257b | 2016-02-03 22:07:38 +0530 | [diff] [blame^] | 29 | import org.onlab.packet.Ethernet; |
| 30 | import org.onlab.packet.IPv4; |
| 31 | import org.onlab.packet.IPv6; |
| 32 | import org.onlab.packet.IpAddress; |
| 33 | import org.onlab.packet.MacAddress; |
| 34 | import org.onlab.packet.VlanId; |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 35 | import org.onlab.util.ItemNotFoundException; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 36 | import org.onlab.util.KryoNamespace; |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 37 | import org.onosproject.core.ApplicationId; |
| 38 | import org.onosproject.core.CoreService; |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 39 | import org.onosproject.net.NshServicePathId; |
Phaneendra Manda | 5c8257b | 2016-02-03 22:07:38 +0530 | [diff] [blame^] | 40 | import org.onosproject.net.packet.PacketContext; |
| 41 | import org.onosproject.net.packet.PacketProcessor; |
| 42 | import org.onosproject.net.packet.PacketService; |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 43 | import org.onosproject.sfc.forwarder.ServiceFunctionForwarderService; |
| 44 | import org.onosproject.sfc.forwarder.impl.ServiceFunctionForwarderImpl; |
| 45 | import org.onosproject.sfc.installer.FlowClassifierInstallerService; |
| 46 | import org.onosproject.sfc.installer.impl.FlowClassifierInstallerImpl; |
| 47 | import org.onosproject.sfc.manager.NshSpiIdGenerators; |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 48 | import org.onosproject.sfc.manager.SfcService; |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 49 | import org.onosproject.vtnrsc.FlowClassifier; |
| 50 | import org.onosproject.vtnrsc.FlowClassifierId; |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 51 | import org.onosproject.vtnrsc.PortChain; |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 52 | import org.onosproject.vtnrsc.PortChainId; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 53 | import org.onosproject.vtnrsc.PortPair; |
| 54 | import org.onosproject.vtnrsc.PortPairGroup; |
| 55 | import org.onosproject.vtnrsc.PortPairGroupId; |
| 56 | import org.onosproject.vtnrsc.PortPairId; |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 57 | import org.onosproject.vtnrsc.TenantId; |
| 58 | import org.onosproject.vtnrsc.event.VtnRscEvent; |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 59 | import org.onosproject.vtnrsc.event.VtnRscEventFeedback; |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 60 | import org.onosproject.vtnrsc.event.VtnRscListener; |
| 61 | import org.onosproject.vtnrsc.service.VtnRscService; |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 62 | import org.slf4j.Logger; |
| 63 | |
| 64 | /** |
| 65 | * Provides implementation of SFC Service. |
| 66 | */ |
| 67 | @Component(immediate = true) |
| 68 | @Service |
| 69 | public class SfcManager implements SfcService { |
| 70 | |
| 71 | private final Logger log = getLogger(getClass()); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 72 | private static final String APP_ID = "org.onosproject.app.vtn"; |
Phaneendra Manda | 5c8257b | 2016-02-03 22:07:38 +0530 | [diff] [blame^] | 73 | private static final int SFC_PRIORITY = 1000; |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 74 | |
| 75 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 76 | protected VtnRscService vtnRscService; |
| 77 | |
| 78 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 79 | protected CoreService coreService; |
| 80 | |
Phaneendra Manda | 5c8257b | 2016-02-03 22:07:38 +0530 | [diff] [blame^] | 81 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 82 | protected PacketService packetService; |
| 83 | |
| 84 | private SfcPacketProcessor processor = new SfcPacketProcessor(); |
| 85 | |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 86 | protected ApplicationId appId; |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 87 | private ServiceFunctionForwarderService serviceFunctionForwarderService; |
| 88 | private FlowClassifierInstallerService flowClassifierInstallerService; |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 89 | |
| 90 | private final VtnRscListener vtnRscListener = new InnerVtnRscListener(); |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 91 | |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 92 | private ConcurrentMap<PortChainId, NshServicePathId> nshSpiPortChainMap = new ConcurrentHashMap<>(); |
| 93 | |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 94 | @Activate |
| 95 | public void activate() { |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 96 | appId = coreService.registerApplication(APP_ID); |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 97 | serviceFunctionForwarderService = new ServiceFunctionForwarderImpl(appId); |
| 98 | flowClassifierInstallerService = new FlowClassifierInstallerImpl(appId); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 99 | |
| 100 | vtnRscService.addListener(vtnRscListener); |
| 101 | |
| 102 | KryoNamespace.Builder serializer = KryoNamespace.newBuilder() |
| 103 | .register(TenantId.class) |
| 104 | .register(PortPairId.class) |
| 105 | .register(PortPairGroupId.class) |
| 106 | .register(FlowClassifierId.class) |
| 107 | .register(PortChainId.class); |
| 108 | |
Phaneendra Manda | 5c8257b | 2016-02-03 22:07:38 +0530 | [diff] [blame^] | 109 | packetService.addProcessor(processor, PacketProcessor.director(SFC_PRIORITY)); |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 110 | log.info("Started"); |
| 111 | } |
| 112 | |
| 113 | @Deactivate |
| 114 | public void deactivate() { |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 115 | vtnRscService.removeListener(vtnRscListener); |
Phaneendra Manda | 5c8257b | 2016-02-03 22:07:38 +0530 | [diff] [blame^] | 116 | packetService.removeProcessor(processor); |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 117 | log.info("Stopped"); |
| 118 | } |
| 119 | |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 120 | /* |
| 121 | * Handle events. |
| 122 | */ |
| 123 | private class InnerVtnRscListener implements VtnRscListener { |
| 124 | @Override |
| 125 | public void event(VtnRscEvent event) { |
| 126 | |
| 127 | if (VtnRscEvent.Type.PORT_PAIR_PUT == event.type()) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 128 | PortPair portPair = ((VtnRscEventFeedback) event.subject()).portPair(); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 129 | onPortPairCreated(portPair); |
| 130 | } else if (VtnRscEvent.Type.PORT_PAIR_DELETE == event.type()) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 131 | PortPair portPair = ((VtnRscEventFeedback) event.subject()).portPair(); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 132 | onPortPairDeleted(portPair); |
| 133 | } else if (VtnRscEvent.Type.PORT_PAIR_UPDATE == event.type()) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 134 | PortPair portPair = ((VtnRscEventFeedback) event.subject()).portPair(); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 135 | onPortPairDeleted(portPair); |
| 136 | onPortPairCreated(portPair); |
| 137 | } else if (VtnRscEvent.Type.PORT_PAIR_GROUP_PUT == event.type()) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 138 | PortPairGroup portPairGroup = ((VtnRscEventFeedback) event.subject()).portPairGroup(); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 139 | onPortPairGroupCreated(portPairGroup); |
| 140 | } else if (VtnRscEvent.Type.PORT_PAIR_GROUP_DELETE == event.type()) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 141 | PortPairGroup portPairGroup = ((VtnRscEventFeedback) event.subject()).portPairGroup(); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 142 | onPortPairGroupDeleted(portPairGroup); |
| 143 | } else if (VtnRscEvent.Type.PORT_PAIR_GROUP_UPDATE == event.type()) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 144 | PortPairGroup portPairGroup = ((VtnRscEventFeedback) event.subject()).portPairGroup(); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 145 | onPortPairGroupDeleted(portPairGroup); |
| 146 | onPortPairGroupCreated(portPairGroup); |
| 147 | } else if (VtnRscEvent.Type.FLOW_CLASSIFIER_PUT == event.type()) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 148 | FlowClassifier flowClassifier = ((VtnRscEventFeedback) event.subject()).flowClassifier(); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 149 | onFlowClassifierCreated(flowClassifier); |
| 150 | } else if (VtnRscEvent.Type.FLOW_CLASSIFIER_DELETE == event.type()) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 151 | FlowClassifier flowClassifier = ((VtnRscEventFeedback) event.subject()).flowClassifier(); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 152 | onFlowClassifierDeleted(flowClassifier); |
| 153 | } else if (VtnRscEvent.Type.FLOW_CLASSIFIER_UPDATE == event.type()) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 154 | FlowClassifier flowClassifier = ((VtnRscEventFeedback) event.subject()).flowClassifier(); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 155 | onFlowClassifierDeleted(flowClassifier); |
| 156 | onFlowClassifierCreated(flowClassifier); |
| 157 | } else if (VtnRscEvent.Type.PORT_CHAIN_PUT == event.type()) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 158 | PortChain portChain = (PortChain) ((VtnRscEventFeedback) event.subject()).portChain(); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 159 | onPortChainCreated(portChain); |
| 160 | } else if (VtnRscEvent.Type.PORT_CHAIN_DELETE == event.type()) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 161 | PortChain portChain = (PortChain) ((VtnRscEventFeedback) event.subject()).portChain(); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 162 | onPortChainDeleted(portChain); |
| 163 | } else if (VtnRscEvent.Type.PORT_CHAIN_UPDATE == event.type()) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 164 | PortChain portChain = (PortChain) ((VtnRscEventFeedback) event.subject()).portChain(); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 165 | onPortChainDeleted(portChain); |
| 166 | onPortChainCreated(portChain); |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 171 | @Override |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 172 | public void onPortPairCreated(PortPair portPair) { |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 173 | log.debug("onPortPairCreated"); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 174 | // TODO: Modify forwarding rule on port-pair creation. |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | @Override |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 178 | public void onPortPairDeleted(PortPair portPair) { |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 179 | log.debug("onPortPairDeleted"); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 180 | // TODO: Modify forwarding rule on port-pair deletion. |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | @Override |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 184 | public void onPortPairGroupCreated(PortPairGroup portPairGroup) { |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 185 | log.debug("onPortPairGroupCreated"); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 186 | // TODO: Modify forwarding rule on port-pair-group creation. |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | @Override |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 190 | public void onPortPairGroupDeleted(PortPairGroup portPairGroup) { |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 191 | log.debug("onPortPairGroupDeleted"); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 192 | // TODO: Modify forwarding rule on port-pair-group deletion. |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | @Override |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 196 | public void onFlowClassifierCreated(FlowClassifier flowClassifier) { |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 197 | log.debug("onFlowClassifierCreated"); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 198 | // TODO: Modify forwarding rule on flow-classifier creation. |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | @Override |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 202 | public void onFlowClassifierDeleted(FlowClassifier flowClassifier) { |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 203 | log.debug("onFlowClassifierDeleted"); |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 204 | // TODO: Modify forwarding rule on flow-classifier deletion. |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | @Override |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 208 | public void onPortChainCreated(PortChain portChain) { |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 209 | NshServicePathId nshSpi; |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 210 | log.info("onPortChainCreated"); |
| 211 | if (nshSpiPortChainMap.containsKey(portChain.portChainId())) { |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 212 | nshSpi = nshSpiPortChainMap.get(portChain.portChainId()); |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 213 | } else { |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 214 | nshSpi = NshServicePathId.of(NshSpiIdGenerators.create()); |
| 215 | nshSpiPortChainMap.put(portChain.portChainId(), nshSpi); |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | // install in OVS. |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 219 | flowClassifierInstallerService.installFlowClassifier(portChain, nshSpi); |
| 220 | serviceFunctionForwarderService.installForwardingRule(portChain, nshSpi); |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | @Override |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 224 | public void onPortChainDeleted(PortChain portChain) { |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 225 | log.info("onPortChainDeleted"); |
| 226 | if (!nshSpiPortChainMap.containsKey(portChain.portChainId())) { |
| 227 | throw new ItemNotFoundException("Unable to find NSH SPI"); |
| 228 | } |
| 229 | |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 230 | NshServicePathId nshSpi = nshSpiPortChainMap.get(portChain.portChainId()); |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 231 | // uninstall from OVS. |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 232 | flowClassifierInstallerService.unInstallFlowClassifier(portChain, nshSpi); |
| 233 | serviceFunctionForwarderService.unInstallForwardingRule(portChain, nshSpi); |
Mahesh Poojary Huawei | 15092f6 | 2015-12-10 11:09:02 +0530 | [diff] [blame] | 234 | |
| 235 | // remove SPI. No longer it will be used. |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 236 | nshSpiPortChainMap.remove(nshSpi); |
Mahesh Poojary S | 335e7c3 | 2015-10-29 10:16:51 +0530 | [diff] [blame] | 237 | } |
Phaneendra Manda | 5c8257b | 2016-02-03 22:07:38 +0530 | [diff] [blame^] | 238 | |
| 239 | private class SfcPacketProcessor implements PacketProcessor { |
| 240 | |
| 241 | @Override |
| 242 | public void process(PacketContext context) { |
| 243 | Ethernet packet = context.inPacket().parsed(); |
| 244 | if (packet == null) { |
| 245 | return; |
| 246 | } |
| 247 | // get the five tupple parameters for the packet |
| 248 | short ethType = packet.getEtherType(); |
| 249 | VlanId vlanId = VlanId.vlanId(packet.getVlanID()); |
| 250 | MacAddress srcMac = packet.getSourceMAC(); |
| 251 | MacAddress dstMac = packet.getDestinationMAC(); |
| 252 | IpAddress ipSrc; |
| 253 | IpAddress ipDst; |
| 254 | |
| 255 | if (ethType == Ethernet.TYPE_IPV4) { |
| 256 | IPv4 ipv4Packet = (IPv4) packet.getPayload(); |
| 257 | ipSrc = IpAddress.valueOf(ipv4Packet.getSourceAddress()); |
| 258 | ipDst = IpAddress.valueOf(ipv4Packet.getDestinationAddress()); |
| 259 | } else if (ethType == Ethernet.TYPE_IPV6) { |
| 260 | IPv6 ipv6Packet = (IPv6) packet.getPayload(); |
| 261 | ipSrc = IpAddress.valueOf(ipv6Packet.getSourceAddress().toString()); |
| 262 | ipDst = IpAddress.valueOf(ipv6Packet.getDestinationAddress().toString()); |
| 263 | } |
| 264 | |
| 265 | //todo |
| 266 | //identify the port chain to which the packet belongs |
| 267 | } |
| 268 | } |
Mahesh Poojary S | c9c10f9 | 2015-11-30 17:18:05 +0530 | [diff] [blame] | 269 | } |