Skip to content

Commit cda74c8

Browse files
committed
Fix: do not handle non-smart NIC capable port at direct port provider
Change-Id: Ife763092da8d4ad8f361dbb7cfe5532c54c24ebe
1 parent 0a884ad commit cda74c8

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenStackSwitchingDirectPortProvider.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import static org.onosproject.openstacknetworking.api.Constants.UNSUPPORTED_VENDOR;
5959
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getIntfNameFromPciAddress;
6060
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.hasIntfAleadyInDevice;
61+
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.isSmartNicCapable;
6162
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE;
6263
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.CONTROLLER;
6364

@@ -148,6 +149,10 @@ private void processPortUpdate(OpenstackNetworkEvent event) {
148149
return;
149150
}
150151

152+
if (!isSmartNicCapable(event.port())) {
153+
return;
154+
}
155+
151156
if (event.port().getState() == State.DOWN) {
152157
removePort(event.port());
153158
} else {
@@ -160,6 +165,10 @@ private void processPortRemoval(OpenstackNetworkEvent event) {
160165
return;
161166
}
162167

168+
if (!isSmartNicCapable(event.port())) {
169+
return;
170+
}
171+
163172
removePort(event.port());
164173
}
165174

@@ -307,6 +316,7 @@ private void processComputeState(OpenstackNode node) {
307316
.filter(port -> port.getvNicType().equals(DIRECT))
308317
.filter(port -> !port.getVifType().equals(UNBOUND))
309318
.filter(port -> port.getHostId().equals(node.hostname()))
319+
.filter(OpenstackNetworkingUtil::isSmartNicCapable)
310320
.collect(Collectors.toList());
311321

312322
ports.forEach(port -> addIntfToDevice(node, port));
@@ -318,7 +328,7 @@ private void addIntfToDevice(OpenstackNode node, Port port) {
318328
log.error("Failed to retrieve interface name from a port {}", port.getId());
319329
} else if (intfName.equals(UNSUPPORTED_VENDOR)) {
320330
log.warn("Failed to retrieve interface name from a port {} " +
321-
"because of unsupported ovs-based sr-iov");
331+
"because of unsupported ovs-based sr-iov", port.getId());
322332
return;
323333
}
324334

apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
import static org.onlab.packet.Ip4Address.valueOf;
138138
import static org.onosproject.net.AnnotationKeys.PORT_NAME;
139139
import static org.onosproject.openstacknetworking.api.Constants.DEFAULT_GATEWAY_MAC_STR;
140+
import static org.onosproject.openstacknetworking.api.Constants.DIRECT;
140141
import static org.onosproject.openstacknetworking.api.Constants.FLOATING_IP_FORMAT;
141142
import static org.onosproject.openstacknetworking.api.Constants.NETWORK_FORMAT;
142143
import static org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_REST_PATH;
@@ -398,6 +399,24 @@ public static OSClient getConnectedClient(OpenstackNode osNode) {
398399
}
399400
}
400401

402+
/**
403+
* Checks whether the given openstack port is smart NIC capable.
404+
*
405+
* @param port openstack port
406+
* @return true if the given port is smart NIC capable, false otherwise
407+
*/
408+
public static boolean isSmartNicCapable(Port port) {
409+
if (port.getProfile() != null && port.getvNicType().equals(DIRECT)) {
410+
String vendorInfo = String.valueOf(port.getProfile().get(PCI_VENDOR_INFO));
411+
if (portNamePrefixMap().containsKey(vendorInfo)) {
412+
log.debug("Port {} is a Smart NIC capable port.", port.getId());
413+
return true;
414+
}
415+
return false;
416+
}
417+
return false;
418+
}
419+
401420
/**
402421
* Extract the interface name with the supplied port.
403422
*

0 commit comments

Comments
 (0)