Fix exception in IPv6Service for non-neutron ports 54/43854/1
authorSridhar Gaddam <sgaddam@redhat.com>
Fri, 12 Aug 2016 12:56:35 +0000 (18:26 +0530)
committerSam Hague <shague@redhat.com>
Fri, 12 Aug 2016 13:26:01 +0000 (13:26 +0000)
This patch fixes the IllegalArgumentException for notifications
related to non-neutron ports.

Change-Id: I0824cafd5f7aa9edd8d8208b729cc1cf3e7416a3
Signed-off-by: Sridhar Gaddam <sgaddam@redhat.com>
vpnservice/ipv6service/impl/src/main/java/org/opendaylight/netvirt/ipv6service/Ipv6ServiceInterfaceEventListener.java

index 53cf56abed096bbd1074902a31e2ae4f6140460e..37d88262f534f3aa9a63cadcfe99dd4e976e9a85 100644 (file)
@@ -64,15 +64,23 @@ public class Ipv6ServiceInterfaceEventListener
         LOG.debug("Port updated...");
     }
 
+    private boolean isNeutronPort(String name) {
+        try {
+            Uuid portId = new Uuid(name);
+            return true;
+        } catch (IllegalArgumentException e) {
+            LOG.debug("Port {} is not a Neutron Port, skipping.", name);
+        }
+        return false;
+    }
+
     @Override
     protected void add(InstanceIdentifier<Interface> key, Interface add) {
         LOG.debug("Port added {}, {}", key, add);
         List<String> ofportIds = add.getLowerLayerIf();
-        // When a port is created, we receive two notifications.
-        // 1. where the interface name is dpnid:tapinterfaceName (f.e., 238412509713739:tapf662f5bf-9d)
-        // 2. neutron interface with name as UUID (f.e., f662f5bf-9d54-4dd7-8bcd-7a0a3a0bae4a)
-        // In ipv6service, we are interested only in notification-2, so we skip notification-1.
-        if (ofportIds == null || ofportIds.isEmpty() || add.getName().contains(":")) {
+        // When a port is created, we receive multiple notifications.
+        // In ipv6service, we are only interested in the notification for NeutronPort, so we skip other notifications
+        if (ofportIds == null || ofportIds.isEmpty() || !isNeutronPort(add.getName())) {
             return;
         }