Bug-6001: Injecting route with missing next-hop value causes exception in reachabilit... 72/39872/1
authorAjay <ajayl.bro@gmail.com>
Sat, 4 Jun 2016 00:10:54 +0000 (00:10 +0000)
committerMilos Fabian <milfabia@cisco.com>
Mon, 6 Jun 2016 07:49:54 +0000 (07:49 +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>
(cherry picked from commit b68719f08f2e414794aa1494a770f440850d48c2)

bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/AbstractReachabilityTopologyBuilder.java

index 5e1e0139ffa12ed59aa86a5e3a4154f0f043808b..fe47807a63adf35ff96ffed78d3df00fa8ff7628 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);