Take our advertized tables into consideration in RibOut 94/80794/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 12 Mar 2019 11:27:55 +0000 (12:27 +0100)
committerRobert Varga <nite@hq.sk>
Tue, 12 Mar 2019 20:03:14 +0000 (20:03 +0000)
Asymmetric configuration of peers can end up with us receiving
tables which we do not advertize towards a peer (but still
process them internally).

In such a case we want to limit adj-rib-out to the intersection
of our advertized and peer-advertized tables.

JIRA: BGPCEP-865
Change-Id: I1b8c0a951c2be513841daf3901ef2b530ed87bf3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/PeerTrackerInformation.java

index 0318cb6158a819697f4e28ab43727bc7c3643ee7..3b9082cf1634d451e09dc8df06c579b5f22ccfa3 100644 (file)
@@ -112,7 +112,8 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener {
     private static final TablesKey IPV4_UCAST_TABLE_KEY = new TablesKey(Ipv4AddressFamily.class,
         UnicastSubsequentAddressFamily.class);
 
-    private Set<TablesKey> tables = Collections.emptySet();
+    private ImmutableSet<TablesKey> tables = ImmutableSet.of();
+    private ImmutableSet<TablesKey> advertizedTables = ImmutableSet.of();
     private final RIB rib;
     private final Map<TablesKey, AdjRibOutListener> adjRibOutListenerSet = new HashMap<>();
     private final List<RouteTarget> rtMemberships = new ArrayList<>();
@@ -339,7 +340,7 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener {
                 createEffRibInWriter();
                 this.effRibInWriter.init();
                 registerPrefixesCounters(this.effRibInWriter, this.effRibInWriter);
-                for (final TablesKey key : this.tables) {
+                for (final TablesKey key : this.advertizedTables) {
                     createAdjRibOutListener(key, true);
                 }
                 setLocalRestartingState(false);
@@ -372,6 +373,8 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener {
         final Set<TablesKey> setTables = advertizedTableTypes.stream().map(t -> new TablesKey(t.getAfi(), t.getSafi()))
                 .collect(Collectors.toSet());
         this.tables = ImmutableSet.copyOf(setTables);
+        this.advertizedTables = ImmutableSet.copyOf(Sets.intersection(tables, getAfiSafisAdvertized()));
+
         this.addPathTableMaps = mapTableTypesFamilies(addPathTablesType);
         final boolean restartingLocally = isLocalRestarting();
 
@@ -449,7 +452,7 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener {
 
         if (!restartingLocally) {
             addBgp4Support();
-            for (final TablesKey key : this.tables) {
+            for (final TablesKey key : this.advertizedTables) {
                 createAdjRibOutListener(key, true);
             }
         }
@@ -576,7 +579,7 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener {
         if (this.effRibInWriter != null) {
             this.effRibInWriter.close();
         }
-        this.tables = Collections.emptySet();
+        this.tables = ImmutableSet.of();
         this.addPathTableMaps = Collections.emptyMap();
         future = removePeer(this.peerPath);
         resetState();
@@ -632,7 +635,7 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener {
 
     @Override
     public boolean supportsTable(final TablesKey tableKey) {
-        return this.tables.contains(tableKey) && this.sessionUp;
+        return this.advertizedTables.contains(tableKey) && this.sessionUp;
     }
 
     @Override
index c838d09bfabb1452589032ef91278e6aaf44cc17..bfdf4485bf01c05f070e1d1583bbb72247506ade 100644 (file)
@@ -53,10 +53,11 @@ public interface PeerTrackerInformation {
     SendReceive getSupportedAddPathTables(@Nonnull TablesKey tableKey);
 
     /**
-     * Returns true if peer supports table.
+     * Returns true if peer supports table and we have advertized support for it, i.e. any prefix from this table should
+     * be subject to export towards the peer.
      *
      * @param tableKey table
-     * @return true if Additional Path is supported for defined table
+     * @return true if the table is supported by the peer and we have advertized support for it.
      */
     boolean supportsTable(@Nonnull TablesKey tableKey);