Bug 4731: Routes from BGP application peer not populated to example-ipv4-topology... 20/36720/3
authorMilos Fabian <milfabia@cisco.com>
Wed, 16 Mar 2016 17:50:48 +0000 (18:50 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Sat, 26 Mar 2016 10:56:40 +0000 (10:56 +0000)
Write routes into the eff-rib-in only in a case when
there are some routes in data change, so do not
overwrite empty routes table created before.

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

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

index 53ad8eb4c4d240fc77e37fd0112f5d4c169655c7..86cf3463c6055db97d88d145dd8373e5fba452ad 100644 (file)
@@ -164,12 +164,15 @@ final class EffectiveRibInWriter implements AutoCloseable {
         }
 
         private void writeRouteTables(final DataTreeCandidateNode child, final PathArgument childIdentifier, final DOMDataWriteTransaction tx, final RIBSupport ribSupport, final AbstractImportPolicy policy, final YangInstanceIdentifier childPath, final Optional<NormalizedNode<?, ?>> childDataAfter) {
-            tx.put(LogicalDatastoreType.OPERATIONAL, childPath, childDataAfter.get());
-            // Routes are special, as they may end up being filtered. The previous put conveniently
-            // ensured that we have them in at target, so a subsequent delete will not fail :)
             if (TABLE_ROUTES.equals(childIdentifier)) {
-                for (final DataTreeCandidateNode route : ribSupport.changedRoutes(child)) {
-                    processRoute(tx, ribSupport, policy, childPath, route);
+                final Collection<DataTreeCandidateNode> changedRoutes = ribSupport.changedRoutes(child);
+                if (!changedRoutes.isEmpty()) {
+                    tx.put(LogicalDatastoreType.OPERATIONAL, childPath, childDataAfter.get());
+                    // Routes are special, as they may end up being filtered. The previous put conveniently
+                    // ensured that we have them in at target, so a subsequent delete will not fail :)
+                    for (final DataTreeCandidateNode route : changedRoutes) {
+                        processRoute(tx, ribSupport, policy, childPath, route);
+                    }
                 }
             }
         }