Bug-2802: BGP Update message serialization bug 30/22830/2
authorMilos Fabian <milfabia@cisco.com>
Wed, 17 Jun 2015 15:55:07 +0000 (17:55 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 22 Jun 2015 19:42:44 +0000 (19:42 +0000)
The next-hop value from MP reach attribute is not stored in AdjRibIn,
thus next-hop is missing in output Update message.
Copy next-hop value from MP reach to next hop attribute to keep it in DS.

Change-Id: I866af30ecc2cd0baa0ca1ca2f763dc03176ac009
Signed-off-by: Milos Fabian <milfabia@cisco.com>
(cherry picked from commit 7505f0031b58a178994ed90e12d0a7bb111ae8e1)

bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java

index 85518cf955a0b3ef43c17ab14660530d4a5b77b7..35bc75e6d30c730ba21e40f26cfdd7889772390f 100644 (file)
@@ -41,6 +41,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AttributesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes2;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
@@ -119,7 +120,7 @@ public class BGPPeer implements ReusableBGPPeer, Peer, AutoCloseable, BGPPeerRun
             mpReach = attrs.getAugmentation(Attributes1.class).getMpReachNlri();
         }
         if (mpReach != null) {
-            this.ribWriter.updateRoutes(mpReach, attrs);
+            this.ribWriter.updateRoutes(mpReach, nextHopToAttribute(attrs, mpReach));
             return;
         }
         MpUnreachNlri mpUnreach = null;
@@ -133,6 +134,15 @@ public class BGPPeer implements ReusableBGPPeer, Peer, AutoCloseable, BGPPeerRun
         }
     }
 
+    private static Attributes nextHopToAttribute(final Attributes attrs, final MpReachNlri mpReach) {
+        if (attrs.getCNextHop() == null && mpReach.getCNextHop() != null) {
+            final AttributesBuilder attributesBuilder = new AttributesBuilder(attrs);
+            attributesBuilder.setCNextHop(mpReach.getCNextHop());
+            return attributesBuilder.build();
+        }
+        return attrs;
+    }
+
     /**
      * Creates MPReach for the prefixes to be handled in the same way as linkstate routes
      *