Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [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.sfc.forwarder.impl; |
| 17 | |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| 19 | import static org.onosproject.net.flow.criteria.ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI; |
| 20 | import static org.slf4j.LoggerFactory.getLogger; |
| 21 | |
| 22 | import java.util.List; |
| 23 | import java.util.ListIterator; |
| 24 | |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 25 | import org.onlab.osgi.DefaultServiceDirectory; |
| 26 | import org.onlab.osgi.ServiceDirectory; |
| 27 | import org.onlab.packet.MacAddress; |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 28 | import org.onlab.packet.TpPort; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 29 | import org.onlab.packet.VlanId; |
| 30 | import org.onosproject.core.ApplicationId; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 31 | import org.onosproject.net.DeviceId; |
Mahesh Poojary S | e5cbab9 | 2015-12-10 10:52:04 +0530 | [diff] [blame] | 32 | import org.onosproject.net.Host; |
| 33 | import org.onosproject.net.HostId; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 34 | import org.onosproject.net.NshServicePathId; |
Mahesh Poojary S | e5cbab9 | 2015-12-10 10:52:04 +0530 | [diff] [blame] | 35 | import org.onosproject.net.PortNumber; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 36 | import org.onosproject.net.behaviour.ExtensionSelectorResolver; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 37 | import org.onosproject.net.driver.DriverHandler; |
| 38 | import org.onosproject.net.driver.DriverService; |
| 39 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 40 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 41 | import org.onosproject.net.flow.TrafficSelector; |
| 42 | import org.onosproject.net.flow.TrafficTreatment; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 43 | import org.onosproject.net.flow.criteria.ExtensionSelector; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 44 | import org.onosproject.net.flowobjective.DefaultForwardingObjective; |
| 45 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
| 46 | import org.onosproject.net.flowobjective.ForwardingObjective; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 47 | import org.onosproject.net.flowobjective.ForwardingObjective.Flag; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 48 | import org.onosproject.net.flowobjective.Objective; |
Mahesh Poojary S | e5cbab9 | 2015-12-10 10:52:04 +0530 | [diff] [blame] | 49 | import org.onosproject.net.host.HostService; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 50 | import org.onosproject.sfc.forwarder.ServiceFunctionForwarderService; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 51 | import org.onosproject.vtnrsc.PortChain; |
| 52 | import org.onosproject.vtnrsc.PortPair; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 53 | import org.onosproject.vtnrsc.PortPairId; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 54 | import org.onosproject.vtnrsc.VirtualPortId; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 55 | import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService; |
| 56 | import org.onosproject.vtnrsc.portchain.PortChainService; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 57 | import org.onosproject.vtnrsc.portpair.PortPairService; |
| 58 | import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; |
| 59 | import org.onosproject.vtnrsc.service.VtnRscService; |
| 60 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 61 | import org.slf4j.Logger; |
| 62 | |
| 63 | /** |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 64 | * Provides service function forwarder implementation. |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 65 | */ |
| 66 | public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderService { |
| 67 | |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 68 | private final Logger log = getLogger(getClass()); |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 69 | protected VirtualPortService virtualPortService; |
| 70 | protected VtnRscService vtnRscService; |
| 71 | protected PortPairService portPairService; |
| 72 | protected PortPairGroupService portPairGroupService; |
| 73 | protected FlowClassifierService flowClassifierService; |
| 74 | protected PortChainService portChainService; |
| 75 | protected DriverService driverService; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 76 | protected FlowObjectiveService flowObjectiveService; |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 77 | protected HostService hostService; |
| 78 | protected ApplicationId appId; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 79 | |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 80 | private static final String PATH_NOT_NULL = "Load balanced path cannot be null"; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 81 | private static final String APP_ID_NOT_NULL = "Application-Id cannot be null"; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 82 | |
| 83 | /** |
| 84 | * Default constructor. |
| 85 | */ |
| 86 | public ServiceFunctionForwarderImpl() { |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Explicit constructor. |
Bharat saraswal | 1adafb3 | 2015-12-11 01:29:44 +0530 | [diff] [blame] | 91 | * |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 92 | * @param appId application id |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 93 | */ |
| 94 | public ServiceFunctionForwarderImpl(ApplicationId appId) { |
| 95 | this.appId = checkNotNull(appId, APP_ID_NOT_NULL); |
| 96 | ServiceDirectory serviceDirectory = new DefaultServiceDirectory(); |
| 97 | this.flowObjectiveService = serviceDirectory.get(FlowObjectiveService.class); |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 98 | this.driverService = serviceDirectory.get(DriverService.class); |
| 99 | this.virtualPortService = serviceDirectory.get(VirtualPortService.class); |
| 100 | this.vtnRscService = serviceDirectory.get(VtnRscService.class); |
| 101 | this.portPairService = serviceDirectory.get(PortPairService.class); |
| 102 | this.portPairGroupService = serviceDirectory.get(PortPairGroupService.class); |
| 103 | this.flowClassifierService = serviceDirectory.get(FlowClassifierService.class); |
| 104 | this.hostService = serviceDirectory.get(HostService.class); |
| 105 | this.portChainService = serviceDirectory.get(PortChainService.class); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | @Override |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 109 | public void installForwardingRule(PortChain portChain, NshServicePathId nshSpi) { |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 110 | //TODO this method will be removed |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | @Override |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 114 | public void unInstallForwardingRule(PortChain portChain, NshServicePathId nshSpi) { |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 115 | //TODO this method will be removed |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | @Override |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 119 | public void installLoadBalancedForwardingRule(List<PortPairId> path, NshServicePathId nshSpi) { |
| 120 | checkNotNull(path, PATH_NOT_NULL); |
| 121 | processForwardingRule(path, nshSpi, Objective.Operation.ADD); |
| 122 | } |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 123 | |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 124 | @Override |
| 125 | public void unInstallLoadBalancedForwardingRule(List<PortPairId> path, NshServicePathId nshSpi) { |
| 126 | checkNotNull(path, PATH_NOT_NULL); |
| 127 | processForwardingRule(path, nshSpi, Objective.Operation.REMOVE); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | /** |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 131 | * Process the required forwarding rules for the given path. |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 132 | * |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 133 | * @param path list of port pair ids |
| 134 | * @param nshSpi service path index |
| 135 | * @param type operation type ADD/REMOVE |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 136 | */ |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 137 | private void processForwardingRule(List<PortPairId> path, NshServicePathId nshSpi, |
| 138 | Objective.Operation type) { |
| 139 | |
| 140 | // Get the first port pair |
| 141 | ListIterator<PortPairId> portPairListIterator = path.listIterator(); |
| 142 | PortPair currentPortPair = portPairService.getPortPair(portPairListIterator.next()); |
| 143 | |
| 144 | // Get destination port pair group |
| 145 | if (!portPairListIterator.hasNext()) { |
| 146 | log.debug("Path is empty"); |
| 147 | return; |
| 148 | } |
| 149 | PortPair nextPortPair = portPairService.getPortPair(portPairListIterator.next()); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 150 | DeviceId currentDeviceId = null; |
| 151 | DeviceId nextDeviceId = null; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 152 | |
| 153 | // Travel from SF to SF. |
| 154 | do { |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 155 | currentDeviceId = vtnRscService.getSfToSffMaping(VirtualPortId.portId(currentPortPair.egress())); |
| 156 | nextDeviceId = vtnRscService.getSfToSffMaping(VirtualPortId.portId(nextPortPair.ingress())); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 157 | // pack traffic selector |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 158 | TrafficSelector.Builder selector = packTrafficSelector(currentDeviceId, currentPortPair, nshSpi); |
| 159 | // Pack treatment |
| 160 | if (currentDeviceId.equals(nextDeviceId)) { |
| 161 | TrafficTreatment.Builder treatment = packTrafficTreatment(nextPortPair, true); |
| 162 | // Send SFF to SFF |
| 163 | sendServiceFunctionForwarder(selector, treatment, currentDeviceId, type); |
| 164 | } else { |
| 165 | TrafficTreatment.Builder treatment = packTrafficTreatment(nextPortPair, false); |
| 166 | // Send SFF to OVS |
| 167 | sendServiceFunctionForwarder(selector, treatment, currentDeviceId, type); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 168 | |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 169 | // At the other device get the packet from vlan and send to first port pair |
| 170 | TrafficSelector.Builder selectorDst = DefaultTrafficSelector.builder(); |
| 171 | selectorDst.matchVlanId((VlanId.vlanId(Short.parseShort((vtnRscService |
| 172 | .getL3vni(nextPortPair.tenantId()).toString()))))); |
| 173 | TrafficTreatment.Builder treatmentDst = DefaultTrafficTreatment.builder(); |
| 174 | MacAddress macAddr = virtualPortService.getPort(VirtualPortId.portId(nextPortPair.ingress())) |
| 175 | .macAddress(); |
| 176 | Host host = hostService.getHost(HostId.hostId(macAddr)); |
| 177 | PortNumber port = host.location().port(); |
| 178 | treatmentDst.setOutput(port); |
| 179 | // Send OVS to SFF |
| 180 | sendServiceFunctionForwarder(selectorDst, treatmentDst, nextDeviceId, type); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 181 | } |
| 182 | |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 183 | // Move to next service function |
| 184 | currentPortPair = nextPortPair; |
| 185 | if (!portPairListIterator.hasNext()) { |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 186 | break; |
| 187 | } |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 188 | nextPortPair = portPairService.getPortPair(portPairListIterator.next()); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 189 | } while (true); |
| 190 | } |
| 191 | |
| 192 | /** |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 193 | * Pack traffic selector. |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 194 | * |
| 195 | * @param deviceId device id |
Mahesh Poojary S | e5cbab9 | 2015-12-10 10:52:04 +0530 | [diff] [blame] | 196 | * @param portPair port-pair |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 197 | * @param nshSpi nsh service path index |
| 198 | * @return traffic selector |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 199 | */ |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 200 | public TrafficSelector.Builder packTrafficSelector(DeviceId deviceId, |
| 201 | PortPair portPair, NshServicePathId nshSpi) { |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 202 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 203 | |
Mahesh Poojary S | e5cbab9 | 2015-12-10 10:52:04 +0530 | [diff] [blame] | 204 | MacAddress dstMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.egress())).macAddress(); |
| 205 | Host host = hostService.getHost(HostId.hostId(dstMacAddress)); |
| 206 | PortNumber port = host.location().port(); |
| 207 | selector.matchInPort(port); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 208 | |
| 209 | DriverHandler handler = driverService.createHandler(deviceId); |
| 210 | ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class); |
| 211 | ExtensionSelector nspSpiSelector = resolver.getExtensionSelector(NICIRA_MATCH_NSH_SPI.type()); |
| 212 | |
| 213 | try { |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 214 | nspSpiSelector.setPropertyValue("nshSpi", nshSpi); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 215 | } catch (Exception e) { |
| 216 | log.error("Failed to get extension instruction to set Nsh Spi Id {}", deviceId); |
| 217 | } |
| 218 | |
| 219 | selector.extension(nspSpiSelector, deviceId); |
Mahesh Poojary S | e5cbab9 | 2015-12-10 10:52:04 +0530 | [diff] [blame] | 220 | |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 221 | return selector; |
| 222 | } |
| 223 | |
| 224 | /** |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 225 | * Pack traffic treatment. |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 226 | * |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 227 | * @param portPair port pair |
| 228 | * @param isSameOvs whether the next port pair is in the same ovs |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 229 | * @return traffic treatment |
| 230 | */ |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 231 | public TrafficTreatment.Builder packTrafficTreatment(PortPair portPair, boolean isSameOvs) { |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 232 | MacAddress srcMacAddress = null; |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 233 | |
| 234 | // Check the treatment whether destination SF is on same OVS or in |
| 235 | // different OVS. |
| 236 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 237 | if (isSameOvs) { |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 238 | srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())).macAddress(); |
Mahesh Poojary S | e5cbab9 | 2015-12-10 10:52:04 +0530 | [diff] [blame] | 239 | Host host = hostService.getHost(HostId.hostId(srcMacAddress)); |
| 240 | PortNumber port = host.location().port(); |
| 241 | treatment.setOutput(port); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 242 | } else { |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 243 | // Vxlan tunnel port for NSH header(Vxlan + NSH). |
| 244 | TpPort nshDstPort = TpPort.tpPort(6633); |
| 245 | // TODO check whether this logic is correct |
Mahesh Poojary S | e5cbab9 | 2015-12-10 10:52:04 +0530 | [diff] [blame] | 246 | VlanId vlanId = VlanId.vlanId(Short.parseShort((vtnRscService.getL3vni(portPair.tenantId()).toString()))); |
| 247 | treatment.setVlanId(vlanId); |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 248 | treatment.setUdpDst(nshDstPort); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | return treatment; |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Send service function forwarder to OVS. |
| 256 | * |
| 257 | * @param selector traffic selector |
| 258 | * @param treatment traffic treatment |
| 259 | * @param deviceId device id |
| 260 | * @param type operation type |
| 261 | */ |
| 262 | public void sendServiceFunctionForwarder(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment, |
Phaneendra Manda | b88b3f8 | 2016-02-12 21:51:30 +0530 | [diff] [blame] | 263 | DeviceId deviceId, Objective.Operation type) { |
| 264 | log.info("Sending flow to serfice-function-forwarder. Selector {}, Treatment {}", |
| 265 | selector.toString(), treatment.toString()); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 266 | ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build()) |
Mahesh Poojary S | e5cbab9 | 2015-12-10 10:52:04 +0530 | [diff] [blame] | 267 | .withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.VERSATILE); |
Mahesh Poojary S | 7e9a78f | 2015-12-04 01:55:57 +0530 | [diff] [blame] | 268 | if (type.equals(Objective.Operation.ADD)) { |
| 269 | log.debug("ADD"); |
| 270 | flowObjectiveService.forward(deviceId, objective.add()); |
| 271 | } else { |
| 272 | log.debug("REMOVE"); |
| 273 | flowObjectiveService.forward(deviceId, objective.remove()); |
| 274 | } |
| 275 | } |
| 276 | } |