Bugfix: handle link updated event

A direct link might be transiently marked as indirect if BDDP is received before LLDP.
SR needs to handle link updated event such that it can process when an indirect link becomes direct.

Change-Id: I2330d55e0a8265d5a6f50bd7700781d6e20ebcf8
diff --git a/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index 02623e2..9c5b37b 100644
--- a/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -737,8 +737,9 @@
     private class InternalLinkListener implements LinkListener {
         @Override
         public void event(LinkEvent event) {
-            if (event.type() == LinkEvent.Type.LINK_ADDED
-                    || event.type() == LinkEvent.Type.LINK_REMOVED) {
+            if (event.type() == LinkEvent.Type.LINK_ADDED ||
+                    event.type() == LinkEvent.Type.LINK_UPDATED ||
+                    event.type() == LinkEvent.Type.LINK_REMOVED) {
                 log.debug("Event {} received from Link Service", event.type());
                 scheduleEventHandlerIfNotScheduled(event);
             }
@@ -798,7 +799,8 @@
                             break;
                         }
                     }
-                    if (event.type() == LinkEvent.Type.LINK_ADDED) {
+                    if (event.type() == LinkEvent.Type.LINK_ADDED ||
+                            event.type() == LinkEvent.Type.LINK_UPDATED) {
                         processLinkAdded((Link) event.subject());
                     } else if (event.type() == LinkEvent.Type.LINK_REMOVED) {
                         Link linkRemoved = (Link) event.subject();
diff --git a/src/main/java/org/onosproject/segmentrouting/SegmentRoutingNeighbourHandler.java b/src/main/java/org/onosproject/segmentrouting/SegmentRoutingNeighbourHandler.java
index 0fa077b..129f893 100644
--- a/src/main/java/org/onosproject/segmentrouting/SegmentRoutingNeighbourHandler.java
+++ b/src/main/java/org/onosproject/segmentrouting/SegmentRoutingNeighbourHandler.java
@@ -87,7 +87,6 @@
             senderMacAddress = config.getDeviceMac(deviceId).toBytes();
             if (targetAddress.isIp4()) {
                 sender = config.getRouterIpAddressForASubnetHost(targetAddress.getIp4Address());
-
             } else {
                 sender = config.getRouterIpAddressForASubnetHost(targetAddress.getIp6Address());
             }
diff --git a/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java b/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
index aba822b..fe33f6c 100644
--- a/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
+++ b/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
@@ -190,12 +190,16 @@
     public void linkUp(Link newLink, boolean isMaster) {
 
         if (newLink.type() != Link.Type.DIRECT) {
-            log.warn("linkUp: unknown link type");
+            // NOTE: A DIRECT link might be transiently marked as INDIRECT
+            //       if BDDP is received before LLDP. We can safely ignore that
+            //       until the LLDP is received and the link is marked as DIRECT.
+            log.info("Ignore link {}->{}. Link type is {} instead of DIRECT.",
+                    newLink.src(), newLink.dst(), newLink.type());
             return;
         }
 
         if (!newLink.src().deviceId().equals(deviceId)) {
-            log.warn("linkUp: deviceId{} doesn't match with link src{}",
+            log.warn("linkUp: deviceId{} doesn't match with link src {}",
                      deviceId, newLink.src().deviceId());
             return;
         }