BGPCEP-782: Fix peer-id 82/70282/3
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Tue, 3 Apr 2018 10:47:45 +0000 (12:47 +0200)
committerClaudio David Gasparini <claudio.gasparini@pantheon.tech>
Tue, 3 Apr 2018 15:57:51 +0000 (15:57 +0000)
by using the one send by peer.

Change-Id: Ic18e7fac972b08dcd77a2dbaad7482295bdcd7ae
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SynchronizationAndExceptionTest.java

index 8e45ad153a08e0d4a8bd455353383465bea39201..146f52c2d9a47a8bd4a603e85f7fed0825d5ca09 100644 (file)
@@ -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<TablesKey, KeyedInstanceIdentifier<Tables, TablesKey>> tablesIId
             = CacheBuilder.newBuilder()
             .build(new CacheLoader<TablesKey, KeyedInstanceIdentifier<Tables, TablesKey>>() {
@@ -141,6 +140,7 @@ public class BGPPeer extends BGPPeerStateImpl implements BGPRouteEntryImportPara
     private EffectiveRibInWriter effRibInWriter;
     private RoutedRpcRegistration<BgpPeerRpcService> rpcRegistration;
     private Map<TablesKey, SendReceive> 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<TablesKey> setTables = advertizedTableTypes.stream().map(t -> new TablesKey(t.getAfi(), t.getSafi()))
                 .collect(Collectors.toSet());
         this.tables = ImmutableSet.copyOf(setTables);
index 596b4e3d839b52c6067871dbbda09a7c1309de20..890c40cf93ee5b6273965e5e2a62840525e58463 100644 (file)
@@ -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)