Committed by
Mahesh Poojary Huawei
[ONOS-3120] Service function forwarder changes
Change-Id: Ic950348bcde25d3c1d78bbfb3eeaab6c5d1f7ca7
Showing
4 changed files
with
33 additions
and
18 deletions
... | @@ -20,6 +20,7 @@ | ... | @@ -20,6 +20,7 @@ |
20 | <description>${project.description}</description> | 20 | <description>${project.description}</description> |
21 | 21 | ||
22 | <artifact>mvn:${project.groupId}/onos-app-vtn-mgr/${project.version}</artifact> | 22 | <artifact>mvn:${project.groupId}/onos-app-vtn-mgr/${project.version}</artifact> |
23 | + <artifact>mvn:${project.groupId}/onos-app-sfc-mgr/${project.version}</artifact> | ||
23 | <artifact>mvn:${project.groupId}/onos-app-vtn-web/${project.version}</artifact> | 24 | <artifact>mvn:${project.groupId}/onos-app-vtn-web/${project.version}</artifact> |
24 | <artifact>mvn:${project.groupId}/onos-app-vtn-rsc/${project.version}</artifact> | 25 | <artifact>mvn:${project.groupId}/onos-app-vtn-rsc/${project.version}</artifact> |
25 | </app> | 26 | </app> | ... | ... |
... | @@ -20,6 +20,7 @@ | ... | @@ -20,6 +20,7 @@ |
20 | <feature>onos-api</feature> | 20 | <feature>onos-api</feature> |
21 | <feature>onos-drivers</feature> | 21 | <feature>onos-drivers</feature> |
22 | <bundle>mvn:${project.groupId}/onos-app-vtn-mgr/${project.version}</bundle> | 22 | <bundle>mvn:${project.groupId}/onos-app-vtn-mgr/${project.version}</bundle> |
23 | + <bundle>mvn:${project.groupId}/onos-app-sfc-mgr/${project.version}</bundle> | ||
23 | <bundle>mvn:${project.groupId}/onos-app-vtn-web/${project.version}</bundle> | 24 | <bundle>mvn:${project.groupId}/onos-app-vtn-web/${project.version}</bundle> |
24 | <bundle>mvn:${project.groupId}/onos-app-vtn-rsc/${project.version}</bundle> | 25 | <bundle>mvn:${project.groupId}/onos-app-vtn-rsc/${project.version}</bundle> |
25 | </feature> | 26 | </feature> | ... | ... |
... | @@ -39,6 +39,11 @@ | ... | @@ -39,6 +39,11 @@ |
39 | <artifactId>onos-app-vtn-mgr</artifactId> | 39 | <artifactId>onos-app-vtn-mgr</artifactId> |
40 | <version>${project.version}</version> | 40 | <version>${project.version}</version> |
41 | </dependency> | 41 | </dependency> |
42 | + <dependency> | ||
43 | + <groupId>org.onosproject</groupId> | ||
44 | + <artifactId>onos-app-sfc-mgr</artifactId> | ||
45 | + <version>${project.version}</version> | ||
46 | + </dependency> | ||
42 | </dependencies> | 47 | </dependencies> |
43 | 48 | ||
44 | </project> | 49 | </project> | ... | ... |
... | @@ -22,8 +22,11 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -22,8 +22,11 @@ import static com.google.common.base.Preconditions.checkNotNull; |
22 | import java.util.List; | 22 | import java.util.List; |
23 | import java.util.ListIterator; | 23 | import java.util.ListIterator; |
24 | 24 | ||
25 | +import org.apache.felix.scr.annotations.Component; | ||
25 | import org.apache.felix.scr.annotations.Reference; | 26 | import org.apache.felix.scr.annotations.Reference; |
26 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 27 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
28 | +import org.apache.felix.scr.annotations.Service; | ||
29 | + | ||
27 | import org.onlab.osgi.DefaultServiceDirectory; | 30 | import org.onlab.osgi.DefaultServiceDirectory; |
28 | import org.onlab.osgi.ServiceDirectory; | 31 | import org.onlab.osgi.ServiceDirectory; |
29 | import org.onlab.packet.MacAddress; | 32 | import org.onlab.packet.MacAddress; |
... | @@ -31,7 +34,10 @@ import org.onlab.packet.VlanId; | ... | @@ -31,7 +34,10 @@ import org.onlab.packet.VlanId; |
31 | import org.onosproject.core.ApplicationId; | 34 | import org.onosproject.core.ApplicationId; |
32 | import org.onosproject.net.behaviour.ExtensionSelectorResolver; | 35 | import org.onosproject.net.behaviour.ExtensionSelectorResolver; |
33 | import org.onosproject.net.DeviceId; | 36 | import org.onosproject.net.DeviceId; |
37 | +import org.onosproject.net.Host; | ||
38 | +import org.onosproject.net.HostId; | ||
34 | import org.onosproject.net.NshServicePathId; | 39 | import org.onosproject.net.NshServicePathId; |
40 | +import org.onosproject.net.PortNumber; | ||
35 | import org.onosproject.net.driver.DriverHandler; | 41 | import org.onosproject.net.driver.DriverHandler; |
36 | import org.onosproject.net.driver.DriverService; | 42 | import org.onosproject.net.driver.DriverService; |
37 | import org.onosproject.net.flow.DefaultTrafficSelector; | 43 | import org.onosproject.net.flow.DefaultTrafficSelector; |
... | @@ -43,6 +49,7 @@ import org.onosproject.net.flowobjective.DefaultForwardingObjective; | ... | @@ -43,6 +49,7 @@ import org.onosproject.net.flowobjective.DefaultForwardingObjective; |
43 | import org.onosproject.net.flowobjective.FlowObjectiveService; | 49 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
44 | import org.onosproject.net.flowobjective.ForwardingObjective; | 50 | import org.onosproject.net.flowobjective.ForwardingObjective; |
45 | import org.onosproject.net.flowobjective.Objective; | 51 | import org.onosproject.net.flowobjective.Objective; |
52 | +import org.onosproject.net.host.HostService; | ||
46 | import org.onosproject.net.flowobjective.ForwardingObjective.Flag; | 53 | import org.onosproject.net.flowobjective.ForwardingObjective.Flag; |
47 | import org.onosproject.vtnrsc.VirtualPortId; | 54 | import org.onosproject.vtnrsc.VirtualPortId; |
48 | import org.onosproject.vtnrsc.service.VtnRscService; | 55 | import org.onosproject.vtnrsc.service.VtnRscService; |
... | @@ -63,9 +70,13 @@ import org.slf4j.Logger; | ... | @@ -63,9 +70,13 @@ import org.slf4j.Logger; |
63 | /** | 70 | /** |
64 | * Provides Service Function Forwarder implementation. | 71 | * Provides Service Function Forwarder implementation. |
65 | */ | 72 | */ |
73 | +@Component(immediate = true) | ||
74 | +@Service | ||
66 | public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderService { | 75 | public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderService { |
67 | 76 | ||
68 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 77 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
78 | + protected HostService hostService; | ||
79 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
69 | protected DriverService driverService; | 80 | protected DriverService driverService; |
70 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 81 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
71 | protected VirtualPortService virtualPortService; | 82 | protected VirtualPortService virtualPortService; |
... | @@ -152,8 +163,6 @@ public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderSer | ... | @@ -152,8 +163,6 @@ public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderSer |
152 | */ | 163 | */ |
153 | public void pushServiceFunctionForwarder(PortPairGroup currentPortPairGroup, PortPairGroup nextPortPairGroup, | 164 | public void pushServiceFunctionForwarder(PortPairGroup currentPortPairGroup, PortPairGroup nextPortPairGroup, |
154 | ListIterator<PortPairGroupId> listGrpIterator, NshServicePathId nshSPI, Objective.Operation type) { | 165 | ListIterator<PortPairGroupId> listGrpIterator, NshServicePathId nshSPI, Objective.Operation type) { |
155 | - MacAddress srcMacAddress = null; | ||
156 | - MacAddress dstMacAddress = null; | ||
157 | DeviceId deviceId = null; | 166 | DeviceId deviceId = null; |
158 | DeviceId currentDeviceId = null; | 167 | DeviceId currentDeviceId = null; |
159 | DeviceId nextDeviceId = null; | 168 | DeviceId nextDeviceId = null; |
... | @@ -176,11 +185,9 @@ public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderSer | ... | @@ -176,11 +185,9 @@ public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderSer |
176 | if (deviceId == null) { | 185 | if (deviceId == null) { |
177 | deviceId = currentDeviceId; | 186 | deviceId = currentDeviceId; |
178 | } | 187 | } |
179 | - srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())).macAddress(); | ||
180 | - dstMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.egress())).macAddress(); | ||
181 | 188 | ||
182 | // pack traffic selector | 189 | // pack traffic selector |
183 | - TrafficSelector.Builder selector = packTrafficSelector(deviceId, srcMacAddress, dstMacAddress, nshSPI); | 190 | + TrafficSelector.Builder selector = packTrafficSelector(deviceId, portPair, nshSPI); |
184 | 191 | ||
185 | // Get the required information on port pairs from destination port | 192 | // Get the required information on port pairs from destination port |
186 | // pair group | 193 | // pair group |
... | @@ -216,16 +223,16 @@ public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderSer | ... | @@ -216,16 +223,16 @@ public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderSer |
216 | * Pack Traffic selector. | 223 | * Pack Traffic selector. |
217 | * | 224 | * |
218 | * @param deviceId device id | 225 | * @param deviceId device id |
219 | - * @param srcMacAddress source mac-address | 226 | + * @param portPair port-pair |
220 | - * @param dstMacAddress destination mac-address | ||
221 | * @param nshSPI nsh spi | 227 | * @param nshSPI nsh spi |
222 | * @return traffic treatment | 228 | * @return traffic treatment |
223 | */ | 229 | */ |
224 | - public TrafficSelector.Builder packTrafficSelector(DeviceId deviceId, MacAddress srcMacAddress, | 230 | + public TrafficSelector.Builder packTrafficSelector(DeviceId deviceId, PortPair portPair, NshServicePathId nshSPI) { |
225 | - MacAddress dstMacAddress, NshServicePathId nshSPI) { | ||
226 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | 231 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
227 | - selector.matchEthSrc(srcMacAddress); | 232 | + MacAddress dstMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.egress())).macAddress(); |
228 | - selector.matchEthDst(dstMacAddress); | 233 | + Host host = hostService.getHost(HostId.hostId(dstMacAddress)); |
234 | + PortNumber port = host.location().port(); | ||
235 | + selector.matchInPort(port); | ||
229 | 236 | ||
230 | DriverHandler handler = driverService.createHandler(deviceId); | 237 | DriverHandler handler = driverService.createHandler(deviceId); |
231 | ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class); | 238 | ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class); |
... | @@ -238,6 +245,7 @@ public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderSer | ... | @@ -238,6 +245,7 @@ public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderSer |
238 | } | 245 | } |
239 | 246 | ||
240 | selector.extension(nspSpiSelector, deviceId); | 247 | selector.extension(nspSpiSelector, deviceId); |
248 | + | ||
241 | return selector; | 249 | return selector; |
242 | } | 250 | } |
243 | 251 | ||
... | @@ -252,19 +260,19 @@ public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderSer | ... | @@ -252,19 +260,19 @@ public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderSer |
252 | public TrafficTreatment.Builder packTrafficTreatment(DeviceId currentDeviceId, DeviceId nextDeviceId, | 260 | public TrafficTreatment.Builder packTrafficTreatment(DeviceId currentDeviceId, DeviceId nextDeviceId, |
253 | PortPair portPair) { | 261 | PortPair portPair) { |
254 | MacAddress srcMacAddress = null; | 262 | MacAddress srcMacAddress = null; |
255 | - MacAddress dstMacAddress = null; | ||
256 | 263 | ||
257 | // Check the treatment whether destination SF is on same OVS or in | 264 | // Check the treatment whether destination SF is on same OVS or in |
258 | // different OVS. | 265 | // different OVS. |
259 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); | 266 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); |
260 | if (currentDeviceId.equals(nextDeviceId)) { | 267 | if (currentDeviceId.equals(nextDeviceId)) { |
261 | srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())).macAddress(); | 268 | srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())).macAddress(); |
262 | - dstMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.egress())).macAddress(); | 269 | + |
263 | - treatment.setEthSrc(srcMacAddress); | 270 | + Host host = hostService.getHost(HostId.hostId(srcMacAddress)); |
264 | - treatment.setEthDst(dstMacAddress); | 271 | + PortNumber port = host.location().port(); |
272 | + treatment.setOutput(port); | ||
265 | } else { | 273 | } else { |
266 | - treatment.setVlanId(VlanId.vlanId(Short.parseShort((vtnRscService.getL3vni(portPair | 274 | + VlanId vlanId = VlanId.vlanId(Short.parseShort((vtnRscService.getL3vni(portPair.tenantId()).toString()))); |
267 | - .tenantId()).toString())))); | 275 | + treatment.setVlanId(vlanId); |
268 | } | 276 | } |
269 | 277 | ||
270 | return treatment; | 278 | return treatment; |
... | @@ -281,7 +289,7 @@ public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderSer | ... | @@ -281,7 +289,7 @@ public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderSer |
281 | public void sendServiceFunctionForwarder(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment, | 289 | public void sendServiceFunctionForwarder(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment, |
282 | DeviceId deviceId, Objective.Operation type) { | 290 | DeviceId deviceId, Objective.Operation type) { |
283 | ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build()) | 291 | ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build()) |
284 | - .withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC); | 292 | + .withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.VERSATILE); |
285 | if (type.equals(Objective.Operation.ADD)) { | 293 | if (type.equals(Objective.Operation.ADD)) { |
286 | log.debug("ADD"); | 294 | log.debug("ADD"); |
287 | flowObjectiveService.forward(deviceId, objective.add()); | 295 | flowObjectiveService.forward(deviceId, objective.add()); | ... | ... |
-
Please register or login to post a comment