Bug-6001: Injecting route with missing next-hop value causes exception in reachabilit... 55/39855/1
authorAjay <ajayl.bro@gmail.com>
Sat, 4 Jun 2016 00:10:54 +0000 (00:10 +0000)
committerAjay <ajayl.bro@gmail.com>
Sat, 4 Jun 2016 00:12:07 +0000 (00:12 +0000)
- added check in reachability topology builder to handle scenario when next-hop value is null
- entry will be skipped from topology processing in such cases

Change-Id: I254666e1008f6f65e244e4cd93c3f77c8a7b58d7
Signed-off-by: Ajay <ajayl.bro@gmail.com>
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/AbstractReachabilityTopologyBuilder.java

index fd65369b90137f7bea9309dc45357d78eb0dcd5e..f19261d42d4d62058c89eb2eeffff4ec644f2ead 100644 (file)
@@ -68,7 +68,10 @@ abstract class AbstractReachabilityTopologyBuilder<T extends Route> extends Abst
 
     private NodeId advertizingNode(final Attributes attrs) {
         final CNextHop nh = attrs.getCNextHop();
-        if (nh instanceof Ipv4NextHopCase) {
+        if (nh == null) {
+            LOG.warn("Next hop value is null");
+            return null;
+        } else if (nh instanceof Ipv4NextHopCase) {
             final Ipv4NextHop ipv4 = ((Ipv4NextHopCase) nh).getIpv4NextHop();
 
             return new NodeId(ipv4.getGlobal().getValue());
@@ -122,6 +125,9 @@ abstract class AbstractReachabilityTopologyBuilder<T extends Route> extends Abst
     @Override
     protected final void createObject(final ReadWriteTransaction trans, final InstanceIdentifier<T> id, final T value) {
         final NodeId ni = advertizingNode(getAttributes(value));
+        if (ni == null) {
+            return;
+        }
         final InstanceIdentifier<IgpNodeAttributes> nii = ensureNodePresent(trans, ni);
 
         final IpPrefix prefix = getPrefix(value);
@@ -134,6 +140,9 @@ abstract class AbstractReachabilityTopologyBuilder<T extends Route> extends Abst
     @Override
     protected final void removeObject(final ReadWriteTransaction trans, final InstanceIdentifier<T> id, final T value) {
         final NodeId ni = advertizingNode(getAttributes(value));
+        if (ni == null) {
+            return;
+        }
         final NodeUsage present = this.nodes.get(ni);
         Preconditions.checkState(present != null, "Removing prefix from non-existent node %s", present);