From 5d5e0d1a499019be75ffd13d13f34162217ad191 Mon Sep 17 00:00:00 2001 From: Milos Fabian Date: Wed, 17 Jun 2015 17:55:07 +0200 Subject: [PATCH] Bug-2802: BGP Update message serialization bug 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 (cherry picked from commit 7505f0031b58a178994ed90e12d0a7bb111ae8e1) --- .../opendaylight/protocol/bgp/rib/impl/BGPPeer.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java index 85518cf955..35bc75e6d3 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java @@ -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 * -- 2.36.6