[SDFAB-295] Inconsistent format of port number in host location
This patch updates fabric.p4 interpreter. Additionally, fixes also
the HostProbingProvider by adding a translation step also there.
Change-Id: I8d1f0f8b6827453e5bdc240ea902960f92ed7e14
diff --git a/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricInterpreter.java b/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricInterpreter.java
index 1a7b2ba..9f848ed 100644
--- a/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricInterpreter.java
+++ b/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricInterpreter.java
@@ -290,6 +290,9 @@
ImmutableByteSequence portByteSequence = packetMetadata.get().value();
short s = portByteSequence.asReadOnlyBuffer().getShort();
ConnectPoint receivedFrom = new ConnectPoint(deviceId, PortNumber.portNumber(s));
+ if (!receivedFrom.port().hasName()) {
+ receivedFrom = translateSwitchPort(receivedFrom);
+ }
ByteBuffer rawData = ByteBuffer.wrap(packetIn.data().asArray());
return new DefaultInboundPacket(receivedFrom, ethPkt, rawData);
} else {
@@ -311,4 +314,19 @@
}
return capabilities.cpuPort();
}
+
+ /* Connect point generated using sb metadata does not have port name
+ we use the device service as translation service */
+ private ConnectPoint translateSwitchPort(ConnectPoint connectPoint) {
+ final DeviceService deviceService = handler().get(DeviceService.class);
+ if (deviceService == null) {
+ log.warn("Unable to translate switch port due to DeviceService not available");
+ return connectPoint;
+ }
+ Port devicePort = deviceService.getPort(connectPoint);
+ if (devicePort != null) {
+ return new ConnectPoint(connectPoint.deviceId(), devicePort.number());
+ }
+ return connectPoint;
+ }
}