}
}
+ grouping route-reflector-cluster-id-config {
+ leaf route-reflector-cluster-id {
+ type bgp-types:rr-cluster-id-type;
+ description
+ "Route-reflector cluster id to use when local router is
+ configured as a route reflector.";
+ }
+ }
+
augment /netinst:network-instances/netinst:network-instance/netinst:protocols/netinst:protocol {
ext:augment-identifier network-instance-protocol;
uses openconfig-bgp:bgp-top {
peer-group";
uses openconfig-bgp:bgp-neighbor-peer-group_config;
}
+ augment bgp/neighbors/neighbor/config {
+ ext:augment-identifier neighbor-cluster-id-config;
+ uses route-reflector-cluster-id-config;
+ }
augment bgp/global/config {
ext:augment-identifier global-config-augmentation;
- leaf route-reflector-cluster-id {
- type bgp-types:rr-cluster-id-type;
- description
- "Route-reflector cluster id to use when local router is
- configured as a route reflector.";
- }
+ uses route-reflector-cluster-id-config;
}
augment bgp/neighbors/neighbor/state {
ext:augment-identifier neighbor_state-augmentation;
ext:augment-identifier peer-group-transport-config;
uses transport-config;
}
+ augment bgp/peer-groups/peer-group/config {
+ ext:augment-identifier peer-group-cluster-id-config;
+ uses route-reflector-cluster-id-config;
+ }
}
}
final class BGPRibPolicyImpl implements BGPRibRoutingPolicy {
private static final InstanceIdentifier<RoutingPolicy> ROUTING_POLICY_IID
= InstanceIdentifier.create(RoutingPolicy.class);
- private static final List<String> EMPTY_POLICY = Collections.emptyList();
+ private static final List<String> DEFAULT_IMPORT_POLICY = Collections.singletonList("default-odl-import-policy");
+ private static final List<String> DEFAULT_EXPORT_POLICY = Collections.singletonList("default-odl-export-policy");
private final DefaultPolicyType defaultExportPolicy;
private final DefaultPolicyType defaultImportPolicy;
private final List<String> exportPolicy;
List<String> epolicy = policyConfig.getExportPolicy();
if (epolicy == null) {
- epolicy = EMPTY_POLICY;
+ epolicy = DEFAULT_EXPORT_POLICY;
}
List<String> ipolicy = policyConfig.getImportPolicy();
if (ipolicy == null) {
- ipolicy = EMPTY_POLICY;
+ ipolicy = DEFAULT_IMPORT_POLICY;
}
this.defaultExportPolicy = requireNonNull(policyConfig.getDefaultExportPolicy());
@Override
public Attributes applyImportAction(
final RouteEntryBaseAttributes routeEntryInfo,
- final BGPRouteEntryImportParameters routeEntryImportParameters,
+ final BGPRouteEntryImportParameters importParameters,
final Attributes attributes,
final SetClusterIdPrepend bgpActions) {
- return prependClusterId(attributes, routeEntryInfo.getClusterId());
+ final ClusterIdentifier clusterIdLocal = importParameters.getFromClusterId() == null
+ ? routeEntryInfo.getClusterId() : importParameters.getFromClusterId();
+ return prependClusterId(attributes, clusterIdLocal);
}
private Attributes prependClusterId(final Attributes attributes, final ClusterIdentifier clusterId) {
@Override
public Attributes applyExportAction(
final RouteEntryBaseAttributes routeEntryInfo,
- final BGPRouteEntryExportParameters routeEntryExportParameters,
+ final BGPRouteEntryExportParameters exportParameters,
final Attributes attributes,
final SetClusterIdPrepend bgpActions) {
- return prependClusterId(attributes, routeEntryInfo.getClusterId());
+ final ClusterIdentifier clusterIdLocal = exportParameters.getFromClusterId() == null
+ ? routeEntryInfo.getClusterId() : exportParameters.getFromClusterId();
+ return prependClusterId(attributes, clusterIdLocal);
}
}
@Override
public boolean matchImportCondition(
final RouteEntryBaseAttributes routeEntryInfo,
- final BGPRouteEntryImportParameters routeEntryImportParameters,
- final ClusterId clusterId,
+ final BGPRouteEntryImportParameters importParameters,
+ final ClusterId clusterIdAtt,
final MatchClusterIdSetCondition conditions) {
-
- return matchClusterIdCondition(routeEntryInfo.getClusterId(), clusterId,
+ final ClusterIdentifier clusterIdLocal = importParameters.getFromClusterId() == null
+ ? routeEntryInfo.getClusterId() : importParameters.getFromClusterId();
+ return matchClusterIdCondition(clusterIdLocal, clusterIdAtt,
conditions.getMatchClusterIdSetCondition());
}
@Override
public boolean matchExportCondition(
final RouteEntryBaseAttributes routeEntryInfo,
- final BGPRouteEntryExportParameters routeEntryExportParameters,
- final ClusterId clusterId,
+ final BGPRouteEntryExportParameters exportParameters,
+ final ClusterId clusterIdAtt,
final MatchClusterIdSetCondition conditions) {
- return matchClusterIdCondition(routeEntryInfo.getClusterId(), clusterId,
+ final ClusterIdentifier clusterIdLocal = exportParameters.getFromClusterId() == null
+ ? routeEntryInfo.getClusterId() : exportParameters.getFromClusterId();
+ return matchClusterIdCondition(clusterIdLocal, clusterIdAtt,
conditions.getMatchClusterIdSetCondition());
}
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
public final class BGPRouteEntryExportParametersImpl implements BGPRouteEntryExportParameters {
private final Peer fromPeer;
return this.fromPeer.getPeerId();
}
+ @Override
+ public ClusterIdentifier getFromClusterId() {
+ return this.fromPeer.getClusterId();
+ }
+
@Override
public PeerRole getToPeerRole() {
return this.toPeer.getRole();
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.peer.AdjRibOut;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
return PeerRole.Internal;
}
+ @Override
+ public ClusterIdentifier getClusterId() {
+ return null;
+ }
+
@Override
public KeyedInstanceIdentifier<Tables, TablesKey> getRibOutIId(final TablesKey tablesKey) {
return this.tablesIId.getUnchecked(tablesKey);
public PeerId getFromPeerId() {
return getPeerId();
}
+
+ @Override
+ public ClusterIdentifier getFromClusterId() {
+ return getClusterId();
+ }
}
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
+import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
public class BGPPeer extends BGPPeerStateImpl implements BGPRouteEntryImportParameters,
BGPSessionListener, Peer, TransactionChainListener {
private static final Logger LOG = LoggerFactory.getLogger(BGPPeer.class);
+ private final ClusterIdentifier clusterId;
private Set<TablesKey> tables = Collections.emptySet();
private final RIB rib;
final String peerGroupName,
final RIB rib,
final PeerRole role,
+ final ClusterIdentifier clusterId,
final RpcProviderRegistry rpcRegistry,
final Set<TablesKey> afiSafisAdvertized,
final Set<TablesKey> afiSafisGracefulAdvertized) {
afiSafisGracefulAdvertized);
this.peerRole = role;
this.rib = requireNonNull(rib);
+ this.clusterId = clusterId;
this.name = Ipv4Util.toStringIP(neighborAddress);
this.rpcRegistry = rpcRegistry;
this.peerId = RouterIds.createPeerId(neighborAddress);
this.chain = rib.createPeerDOMChain(this);
}
- public BGPPeer(
+ BGPPeer(
final IpAddress neighborAddress,
final RIB rib,
final PeerRole role,
final RpcProviderRegistry rpcRegistry,
final Set<TablesKey> afiSafisAdvertized,
final Set<TablesKey> afiSafisGracefulAdvertized) {
- this(neighborAddress, null, rib, role, rpcRegistry, afiSafisAdvertized,
+ this(neighborAddress, null, rib, role, null, rpcRegistry, afiSafisAdvertized,
afiSafisGracefulAdvertized);
}
return this.peerRole;
}
+ @Override
+ public ClusterIdentifier getClusterId() {
+ return this.clusterId;
+ }
+
@Override
public KeyedInstanceIdentifier<Tables, TablesKey> getRibOutIId(final TablesKey tablesKey) {
return this.tablesIId.getUnchecked(tablesKey);
public PeerId getFromPeerId() {
return getPeerId();
}
+
+ @Override
+ public ClusterIdentifier getFromClusterId() {
+ return getClusterId();
+ }
}
package org.opendaylight.protocol.bgp.rib.impl.config;
import static java.util.Objects.requireNonNull;
+import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getGlobalClusterIdentifier;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborPeerGroupConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.osgi.framework.ServiceRegistration;
import org.slf4j.Logger;
.toTableKey(afisSAfis.getAfiSafi(), tableTypeRegistry);
final PeerRole role = OpenConfigMappingUtil.toPeerRole(neighbor, peerGroup);
+ final ClusterIdentifier clusterId = OpenConfigMappingUtil
+ .getNeighborClusterIdentifier(neighbor.getConfig());
- this.bgpPeer = new BGPPeer(this.neighborAddress, peerGroupName, rib, role, BgpPeer.this.rpcRegistry,
- afiSafisAdvertized, Collections.emptySet());
+ this.bgpPeer = new BGPPeer(this.neighborAddress, peerGroupName, rib, role, clusterId,
+ BgpPeer.this.rpcRegistry, afiSafisAdvertized, Collections.emptySet());
final List<BgpParameters> bgpParameters = getBgpParameters(afisSAfis, rib, tableTypeRegistry);
final KeyMapping keyMapping = OpenConfigMappingUtil.getNeighborKey(neighbor);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAddPathsConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalConfigAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborClusterIdConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborPeerGroupConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupTransportConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.RouteReflectorClusterIdConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
return afiSafi;
}
- public static ClusterIdentifier getClusterIdentifier(final org.opendaylight.yang.gen.v1.http.openconfig.net.yang
- .bgp.rev151009.bgp.global.base.Config globalConfig) {
- final GlobalConfigAugmentation globalConfigAugmentation
+ public static ClusterIdentifier getGlobalClusterIdentifier(final org.opendaylight.yang.gen.v1.http.openconfig.net
+ .yang.bgp.rev151009.bgp.global.base.Config globalConfig) {
+ final RouteReflectorClusterIdConfig configAug
= globalConfig.getAugmentation(GlobalConfigAugmentation.class);
- if (globalConfigAugmentation != null && globalConfigAugmentation.getRouteReflectorClusterId() != null) {
- return new ClusterIdentifier(globalConfigAugmentation.getRouteReflectorClusterId().getIpv4Address());
+ if (configAug != null && configAug.getRouteReflectorClusterId() != null) {
+ return new ClusterIdentifier(configAug.getRouteReflectorClusterId().getIpv4Address());
}
return new ClusterIdentifier(globalConfig.getRouterId());
}
+ @Nullable
+ public static ClusterIdentifier getNeighborClusterIdentifier(@Nullable final org.opendaylight.yang.gen.v1.http
+ .openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Config config) {
+ if (config != null) {
+ final RouteReflectorClusterIdConfig configAug = config.getAugmentation(NeighborClusterIdConfig.class);
+ if (configAug != null && configAug.getRouteReflectorClusterId() != null) {
+ return new ClusterIdentifier(configAug.getRouteReflectorClusterId().getIpv4Address());
+ }
+ }
+ return null;
+ }
+
public static Map<BgpTableType, PathSelectionMode> toPathSelectionMode(final List<AfiSafi> afiSafis,
final BGPTableTypeRegistryConsumer tableTypeRegistry, final BGPPeerTracker peerTracker) {
final Map<BgpTableType, PathSelectionMode> pathSelectionModes = new HashMap<>();
package org.opendaylight.protocol.bgp.rib.impl.config;
import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getAfiSafiWithDefault;
-import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getClusterIdentifier;
+import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getGlobalClusterIdentifier;
import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.toTableTypes;
import com.google.common.base.Preconditions;
final Config globalConfig = global.getConfig();
final AsNumber globalAs = globalConfig.getAs();
final Ipv4Address globalRouterId = global.getConfig().getRouterId();
- final ClusterIdentifier globalClusterId = getClusterIdentifier(globalConfig);
+ final ClusterIdentifier globalClusterId = getGlobalClusterIdentifier(globalConfig);
return this.afiSafi.containsAll(globalAfiSafi) && globalAfiSafi.containsAll(this.afiSafi)
&& globalAs.equals(this.asNumber)
&& globalRouterId.getValue().equals(this.routerId.getValue())
final Config globalConfig = global.getConfig();
this.asNumber = globalConfig.getAs();
this.routerId = globalConfig.getRouterId();
- this.clusterId = getClusterIdentifier(globalConfig);
+ this.clusterId = getGlobalClusterIdentifier(globalConfig);
final BGPPeerTrackerImpl peerTracker = new BGPPeerTrackerImpl();
final Map<TablesKey, PathSelectionMode> pathSelectionModes = OpenConfigMappingUtil
.toPathSelectionMode(this.afiSafi, tableTypeRegistry, peerTracker).entrySet()
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalConfigAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborClusterIdConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborClusterIdConfigBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborPeerGroupConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborPeerGroupConfigBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportConfig;
}
@Test
- public void testGetClusterIdentifier() {
+ public void testGetGlobalClusterIdentifier() {
final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base
.ConfigBuilder configBuilder = new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009
.bgp.global.base.ConfigBuilder();
configBuilder.setRouterId(ROUTER_ID);
assertEquals(ROUTER_ID.getValue(),
- OpenConfigMappingUtil.getClusterIdentifier(configBuilder.build()).getValue());
+ OpenConfigMappingUtil.getGlobalClusterIdentifier(configBuilder.build()).getValue());
configBuilder.addAugmentation(GlobalConfigAugmentation.class, new GlobalConfigAugmentationBuilder()
.setRouteReflectorClusterId(new RrClusterIdType(CLUSTER_ID)).build()).build();
assertEquals(CLUSTER_ID.getValue(),
- OpenConfigMappingUtil.getClusterIdentifier(configBuilder.build()).getValue());
+ OpenConfigMappingUtil.getGlobalClusterIdentifier(configBuilder.build()).getValue());
+ }
+
+ @Test
+ public void testGetNeighborClusterIdentifier() {
+ assertNull(OpenConfigMappingUtil.getNeighborClusterIdentifier(null));
+
+ final ConfigBuilder configBuilder = new ConfigBuilder();
+ assertNull(OpenConfigMappingUtil.getNeighborClusterIdentifier(configBuilder.build()));
+
+ configBuilder.addAugmentation(NeighborClusterIdConfig.class, new NeighborClusterIdConfigBuilder()
+ .setRouteReflectorClusterId(new RrClusterIdType(CLUSTER_ID)).build()).build();
+ assertEquals(CLUSTER_ID.getValue(),
+ OpenConfigMappingUtil.getNeighborClusterIdentifier(configBuilder.build()).getValue());
}
@Test
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
/**
*/
@Nonnull
PeerRole getRole();
+
+ /**
+ * Returns Cluster Id.
+ *
+ * @return Cluster Id
+ */
+ @Nullable
+ ClusterIdentifier getClusterId();
}
package org.opendaylight.protocol.bgp.rib.spi.policy;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
/**
* Contains Peer destiny information for import route entry.
*/
@Nonnull
PeerId getFromPeerId();
+
+ /**
+ * Peer id of Peer route entry announcer.
+ *
+ * @return peer Id of announcer Peer
+ */
+ @Nullable
+ ClusterIdentifier getFromClusterId();
}