Add missing policy database for new Internal Role defined.
Change-Id: Ifc7b29f7aa8417978db845d8544774e3b71ac8eb
Signed-off-by: Claudio D. Gasparini <cgaspari@cisco.com>
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.rib.impl;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+
+/**
+ * Invoked on routes which we get from our Internal peers. This is a special-case of
+ * FromInternalImportPolicy.
+ */
+final class FromInternalReflectorClientImportPolicy extends FromInternalImportPolicy {
+ FromInternalReflectorClientImportPolicy(final Ipv4Address bgpIdentifier, final ClusterIdentifier clusterIdentifier) {
+ super(bgpIdentifier, clusterIdentifier);
+ }
+
+ @Override
+ ContainerNode effectiveAttributes(final ContainerNode attributes) {
+ // TODO: (defensiveness) verify ORIGINATOR_ID (should have been set)
+
+ return super.effectiveAttributes(attributes);
+ }
+}
exportPolicies.put(PeerRole.Ebgp, new ToExternalExportPolicy(localAs));
exportPolicies.put(PeerRole.Ibgp, new ToInternalExportPolicy(bgpId, clusterId));
exportPolicies.put(PeerRole.RrClient, new ToReflectorClientExportPolicy(bgpId, clusterId));
+ exportPolicies.put(PeerRole.Internal, new ToInternalReflectorClientExportPolicy(bgpId, clusterId));
importPolicies.put(PeerRole.Ebgp, new FromExternalImportPolicy());
importPolicies.put(PeerRole.Ibgp, new FromInternalImportPolicy(bgpId, clusterId));
importPolicies.put(PeerRole.RrClient, new FromReflectorClientImportPolicy(bgpId, clusterId));
+ importPolicies.put(PeerRole.Internal, new FromInternalReflectorClientImportPolicy(bgpId, clusterId));
}
AbstractExportPolicy exportPolicyForRole(final PeerRole peerRole) {
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.rib.impl;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerRole;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+
+/**
+ * Invoked on routes which we send to our reflector peers. This is a special-case of
+ * FromInternalImportPolicy.
+ */
+final class ToInternalReflectorClientExportPolicy extends AbstractReflectingExportPolicy {
+
+ ToInternalReflectorClientExportPolicy(final Ipv4Address originatorId, final ClusterIdentifier clusterId) {
+ super(originatorId, clusterId);
+ }
+
+ @Override
+ ContainerNode effectiveAttributes(final PeerRole sourceRole, final ContainerNode attributes) {
+ switch (sourceRole) {
+ case Ebgp:
+ // eBGP -> Client iBGP, propagate
+ return attributes;
+ case Ibgp:
+ // Non-Client iBGP -> Client iBGP, reflect
+ return reflectedAttributes(attributes);
+ case RrClient:
+ // Client iBGP -> Client iBGP, reflect
+ return reflectedAttributes(attributes);
+ case Internal:
+ // Internal Client iBGP -> Client iBGP, reflect
+ return reflectedFromInternalAttributes(attributes);
+ default:
+ throw new IllegalArgumentException("Unhandled source role " + sourceRole);
+ }
+ }
+}
\ No newline at end of file
private static final long LOCAL_AS = 8;
private static final ToExternalExportPolicy EXT_POLICY = new ToExternalExportPolicy(LOCAL_AS);
private static final ToInternalExportPolicy INT_POLICY = new ToInternalExportPolicy(IPV4, CLUSTER);
+ private static final ToInternalReflectorClientExportPolicy INTERNAL_POLICY = new ToInternalReflectorClientExportPolicy(IPV4, CLUSTER);
@Test
public void testEbgpEffectiveAttributes() {
final ContainerNode clusterIn = createClusterInput();
final PeerRole peerRole = PeerRole.Ebgp;
assertEquals(clusterIn, REF_POLICY.effectiveAttributes(peerRole, clusterIn));
+ assertEquals(clusterIn, INTERNAL_POLICY.effectiveAttributes(peerRole, clusterIn));
assertEquals(clusterIn, INT_POLICY.effectiveAttributes(peerRole, clusterIn));
final ContainerNode asPathIn = createPathInput(null);
final ContainerNode clusterIn = createClusterInput();
final PeerRole peerRole = PeerRole.Ibgp;
assertEquals(createInputWithOriginator(), REF_POLICY.effectiveAttributes(peerRole, clusterIn));
+ assertEquals(createInputWithOriginator(), INTERNAL_POLICY.effectiveAttributes(peerRole, clusterIn));
assertEquals(null, INT_POLICY.effectiveAttributes(peerRole, clusterIn));
final ContainerNode asPathIn = createPathInput(null);
final ContainerNode clusterIn = createClusterInput();
final PeerRole peerRole = PeerRole.RrClient;
assertEquals(createInputWithOriginator(), REF_POLICY.effectiveAttributes(peerRole, clusterIn));
+ assertEquals(createInputWithOriginator(), INTERNAL_POLICY.effectiveAttributes(peerRole, clusterIn));
assertEquals(createInputWithOriginator(), INT_POLICY.effectiveAttributes(peerRole, clusterIn));
final ContainerNode asPathIn = createPathInput(null);
final ContainerNode clusterIn = createClusterInput();
final PeerRole peerRole = PeerRole.Internal;
assertEquals(createInternalOutput(), REF_POLICY.effectiveAttributes(peerRole, clusterIn));
+ assertEquals(createInternalOutput(), INTERNAL_POLICY.effectiveAttributes(peerRole, clusterIn));
assertEquals(createInternalOutput(), INT_POLICY.effectiveAttributes(peerRole, clusterIn));
final ContainerNode asPathIn = createPathInput(null);