From b009fc8a04c67b96818a624fdd13262e1c5c9ad5 Mon Sep 17 00:00:00 2001 From: "Claudio D. Gasparini" Date: Tue, 3 Apr 2018 12:47:45 +0200 Subject: [PATCH] BGPCEP-782: Fix peer-id by using the one send by peer. Change-Id: Ic18e7fac972b08dcd77a2dbaad7482295bdcd7ae Signed-off-by: Claudio D. Gasparini --- .../org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java | 6 +++--- .../bgp/rib/impl/SynchronizationAndExceptionTest.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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 8e45ad153a..146f52c2d9 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 @@ -119,7 +119,6 @@ public class BGPPeer extends BGPPeerStateImpl implements BGPRouteEntryImportPara .rev171207.bgp.rib.rib.Peer, PeerKey> peerIId; @GuardedBy("this") private AbstractRegistration trackerRegistration; - private final PeerId peerId; private final LoadingCache> tablesIId = CacheBuilder.newBuilder() .build(new CacheLoader>() { @@ -141,6 +140,7 @@ public class BGPPeer extends BGPPeerStateImpl implements BGPRouteEntryImportPara private EffectiveRibInWriter effRibInWriter; private RoutedRpcRegistration rpcRegistration; private Map addPathTableMaps = Collections.emptyMap(); + private PeerId peerId; public BGPPeer( final IpAddress neighborAddress, @@ -158,9 +158,8 @@ public class BGPPeer extends BGPPeerStateImpl implements BGPRouteEntryImportPara this.clusterId = clusterId; this.name = Ipv4Util.toStringIP(neighborAddress); this.rpcRegistry = rpcRegistry; - this.peerId = RouterIds.createPeerId(neighborAddress); this.peerIId = getInstanceIdentifier().child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns - .yang.bgp.rib.rev171207.bgp.rib.rib.Peer.class, new PeerKey(this.peerId)); + .yang.bgp.rib.rev171207.bgp.rib.rib.Peer.class, new PeerKey(RouterIds.createPeerId(neighborAddress))); this.peerRibOutIId = this.peerIId.child(AdjRibOut.class); this.chain = rib.createPeerDOMChain(this); } @@ -342,6 +341,7 @@ public class BGPPeer extends BGPPeerStateImpl implements BGPRouteEntryImportPara LOG.info("Session with peer {} went up with tables {} and Add Path tables {}", this.name, advertizedTableTypes, addPathTablesType); this.rawIdentifier = InetAddresses.forString(session.getBgpId().getValue()).getAddress(); + this.peerId = RouterIds.createPeerId(session.getBgpId()); final Set setTables = advertizedTableTypes.stream().map(t -> new TablesKey(t.getAfi(), t.getSafi())) .collect(Collectors.toSet()); this.tables = ImmutableSet.copyOf(setTables); diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SynchronizationAndExceptionTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SynchronizationAndExceptionTest.java index 596b4e3d83..890c40cf93 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SynchronizationAndExceptionTest.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SynchronizationAndExceptionTest.java @@ -111,7 +111,7 @@ public class SynchronizationAndExceptionTest extends AbstractAddPathTest { private static final YangInstanceIdentifier PEER_PATH = YangInstanceIdentifier.builder() .node(BgpRib.QNAME).node(Rib.QNAME) .nodeWithKey(Rib.QNAME, QName.create(Rib.QNAME, "id").intern(), RIB_ID) - .node(Peer.QNAME).nodeWithKey(Peer.QNAME, AdjRibInWriter.PEER_ID_QNAME, "bgp://1.1.1.4").build(); + .node(Peer.QNAME).nodeWithKey(Peer.QNAME, AdjRibInWriter.PEER_ID_QNAME, "bgp://1.1.1.2").build(); private static final YangInstanceIdentifier TABLE_PATH = PEER_PATH.node(AdjRibIn.QNAME).node(Tables.QNAME) .node(RibSupportUtils.toYangTablesKey(new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class))).node(Attributes.QNAME) -- 2.36.6