summaryrefslogtreecommitdiffstats
path: root/routing/routing-impl/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'routing/routing-impl/src/main/java')
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizer.java10
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizer.java10
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactory.java59
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/base/BasicHopRequestFactory.java14
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/base/ClassifierContextHolder.java38
5 files changed, 65 insertions, 66 deletions
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizer.java
index 6252b8d3a..a1975a10c 100644
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizer.java
+++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizer.java
@@ -84,7 +84,8 @@ public class Ipv4RouteCustomizer extends FutureJVppCustomizer
SimpleHopRequestFactory.forContexts(classifierContextManager, interfaceContext, routingProtocolContext);
multipathHopRequestFactory = MultipathHopRequestFactory
.forContexts(classifierContextManager, interfaceContext, routingProtocolContext);
- specialNextHopRequestFactory = SpecialNextHopRequestFactory.forClassifierContext(classifierContextManager);
+ specialNextHopRequestFactory = SpecialNextHopRequestFactory.forContexts(classifierContextManager,
+ interfaceContext, routingProtocolContext);
routeNamesFactory = new Ipv4RouteNamesFactory(interfaceContext, routingProtocolContext);
}
@@ -141,7 +142,7 @@ public class Ipv4RouteCustomizer extends FutureJVppCustomizer
removeMappingForEachHop(routeName, writeContext, createdHops);
}
} else if (route.getNextHopOptions() instanceof SpecialNextHop) {
- writeSpecialHopRoute(identifier, route, writeContext, isAdd);
+ writeSpecialHopRoute(identifier, route, parentProtocolName, writeContext, isAdd);
} else {
throw new IllegalArgumentException("Unsupported next-hop type");
}
@@ -193,13 +194,14 @@ public class Ipv4RouteCustomizer extends FutureJVppCustomizer
private void writeSpecialHopRoute(final @Nonnull InstanceIdentifier<Route> identifier, final @Nonnull Route route,
- final @Nonnull WriteContext writeContext, final boolean isAdd)
+ final @Nonnull String parentProtocolName, final @Nonnull WriteContext writeContext,
+ final boolean isAdd)
throws WriteFailedException {
final SpecialNextHop hop = SpecialNextHop.class.cast(route.getNextHopOptions());
final MappingContext mappingContext = writeContext.getMappingContext();
final IpAddDelRoute request = specialNextHopRequestFactory
- .createIpv4SpecialHopRequest(isAdd, route, mappingContext, hop.getSpecialNextHop());
+ .createIpv4SpecialHopRequest(isAdd, parentProtocolName, route, mappingContext, hop.getSpecialNextHop());
writeRoute(request, identifier);
}
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizer.java
index aa7138624..4c4a6e7d6 100644
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizer.java
+++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizer.java
@@ -84,7 +84,8 @@ public class Ipv6RouteCustomizer extends FutureJVppCustomizer
SimpleHopRequestFactory.forContexts(classifierContextManager, interfaceContext, routingProtocolContext);
multipathHopRequestFactory = MultipathHopRequestFactory
.forContexts(classifierContextManager, interfaceContext, routingProtocolContext);
- specialNextHopRequestFactory = SpecialNextHopRequestFactory.forClassifierContext(classifierContextManager);
+ specialNextHopRequestFactory = SpecialNextHopRequestFactory.forContexts(classifierContextManager, interfaceContext,
+ routingProtocolContext);
namesFactory = new Ipv6RouteNamesFactory(interfaceContext, routingProtocolContext);
}
@@ -141,7 +142,7 @@ public class Ipv6RouteCustomizer extends FutureJVppCustomizer
removeMappingForEachHop(routeName, writeContext, createdHops);
}
} else if (route.getNextHopOptions() instanceof SpecialNextHop) {
- writeSpecialHopRoute(identifier, route, writeContext, isAdd);
+ writeSpecialHopRoute(identifier, route, parentProtocolName, writeContext, isAdd);
} else {
throw new IllegalArgumentException("Unsupported next-hop type");
}
@@ -177,13 +178,14 @@ public class Ipv6RouteCustomizer extends FutureJVppCustomizer
private void writeSpecialHopRoute(final @Nonnull InstanceIdentifier<Route> identifier, final @Nonnull Route route,
- final @Nonnull WriteContext writeContext, final boolean isAdd)
+ final @Nonnull String parentProtocolName, final @Nonnull WriteContext writeContext,
+ final boolean isAdd)
throws WriteFailedException {
final SpecialNextHop hop = SpecialNextHop.class.cast(route.getNextHopOptions());
final MappingContext mappingContext = writeContext.getMappingContext();
final IpAddDelRoute request = specialNextHopRequestFactory
- .createIpv6SpecialHopRequest(isAdd, route, mappingContext, hop.getSpecialNextHop());
+ .createIpv6SpecialHopRequest(isAdd, parentProtocolName, route, mappingContext, hop.getSpecialNextHop());
writeRoute(request, identifier);
}
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactory.java
index 2a5ab9821..e9c9c63ee 100644
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactory.java
+++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactory.java
@@ -16,31 +16,41 @@
package io.fd.hc2vpp.routing.write.factory;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import io.fd.hc2vpp.routing.write.factory.base.ClassifierContextHolder;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.routing.write.factory.base.BasicHopRequestFactory;
import io.fd.hc2vpp.routing.write.trait.RouteRequestProducer;
import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.vpp.jvpp.core.dto.IpAddDelRoute;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev161214.VniReference;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev161214.VppRouteAttributes;
+
+import javax.annotation.Nonnull;
+import java.util.Optional;
-public class SpecialNextHopRequestFactory extends ClassifierContextHolder
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class SpecialNextHopRequestFactory extends BasicHopRequestFactory
implements RouteRequestProducer {
- private SpecialNextHopRequestFactory(final VppClassifierContextManager classifierContextManager) {
- super(classifierContextManager);
+ private SpecialNextHopRequestFactory(final VppClassifierContextManager classifierContextManager,
+ final NamingContext interfaceContext,
+ final NamingContext routingProtocolContext) {
+ super(classifierContextManager,interfaceContext,routingProtocolContext);
}
- public static SpecialNextHopRequestFactory forClassifierContext(
- @Nonnull final VppClassifierContextManager classifierContextManager) {
- return new SpecialNextHopRequestFactory(classifierContextManager);
+ public static SpecialNextHopRequestFactory forContexts(
+ @Nonnull final VppClassifierContextManager classifierContextManager,
+ @Nonnull final NamingContext interfaceContext,
+ @Nonnull final NamingContext routingProtocolContext) {
+ return new SpecialNextHopRequestFactory(classifierContextManager, interfaceContext, routingProtocolContext);
}
public IpAddDelRoute createIpv4SpecialHopRequest(final boolean add,
+ @Nonnull final String parentProtocolName,
@Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route route,
@Nonnull final MappingContext mappingContext,
@Nonnull final SpecialNextHopGrouping.SpecialNextHop flagsVariant) {
@@ -48,10 +58,18 @@ public class SpecialNextHopRequestFactory extends ClassifierContextHolder
checkNotNull(mappingContext, "Mapping Context cannot be null");
checkNotNull(flagsVariant, "Flags variant cannot be null");
- return resolveFlags(getSpecialHopRequest(add, route.getDestinationPrefix()), flagsVariant);
+ final int parentProtocolTableId = getRoutingProtocolContext().getIndex(parentProtocolName,mappingContext);
+ final byte secondaryTableId = Optional.ofNullable(route.getVppIpv4Route())
+ .map(VppRouteAttributes::getSecondaryVrf)
+ .map(VniReference::getValue)
+ .map(Long::byteValue)
+ .orElse(DEFAULT_VNI);
+
+ return resolveFlags(getSpecialHopRequest(add, route.getDestinationPrefix(), (byte) parentProtocolTableId, secondaryTableId), flagsVariant);
}
public IpAddDelRoute createIpv6SpecialHopRequest(final boolean add,
+ @Nonnull final String parentProtocolName,
@Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route route,
@Nonnull final MappingContext mappingContext,
@Nonnull final SpecialNextHopGrouping.SpecialNextHop flagsVariant) {
@@ -60,20 +78,29 @@ public class SpecialNextHopRequestFactory extends ClassifierContextHolder
checkNotNull(mappingContext, "Mapping Context cannot be null");
checkNotNull(flagsVariant, "Flags variant cannot be null");
- return resolveFlags(getSpecialHopRequest(add, route.getDestinationPrefix()), flagsVariant);
+ final int parentProtocolTableId = getRoutingProtocolContext().getIndex(parentProtocolName,mappingContext);
+ final byte secondaryTableId = Optional.ofNullable(route.getVppIpv6Route())
+ .map(VppRouteAttributes::getSecondaryVrf)
+ .map(VniReference::getValue)
+ .map(Long::byteValue)
+ .orElse(DEFAULT_VNI);
+
+ return resolveFlags(getSpecialHopRequest(add, route.getDestinationPrefix(), (byte) parentProtocolTableId, secondaryTableId), flagsVariant);
}
- private IpAddDelRoute getSpecialHopRequest(final boolean isAdd, @Nonnull final Ipv6Prefix destinationAddress) {
+ private IpAddDelRoute getSpecialHopRequest(final boolean isAdd, @Nonnull final Ipv6Prefix destinationAddress,
+ final byte primaryTableId, final byte secondaryTableId) {
return flaglessAddDelRouteRequest(booleanToByte(isAdd), 0, null, DEFAULT_HOP_WEIGHT, BYTE_TRUE,
ipv6AddressPrefixToArray(destinationAddress), extractPrefix(destinationAddress.getValue()), BYTE_FALSE,
- DEFAULT_VNI, DEFAULT_VNI, DEFAULT_CLASSIFY_TABLE_INDEX, BYTE_FALSE);
+ primaryTableId, secondaryTableId, DEFAULT_CLASSIFY_TABLE_INDEX, BYTE_FALSE);
}
- private IpAddDelRoute getSpecialHopRequest(final boolean isAdd, @Nonnull final Ipv4Prefix destinationAddress) {
+ private IpAddDelRoute getSpecialHopRequest(final boolean isAdd, @Nonnull final Ipv4Prefix destinationAddress,
+ final byte primaryTableId, final byte secondaryTableId) {
return flaglessAddDelRouteRequest(booleanToByte(isAdd), 0, null, DEFAULT_HOP_WEIGHT, BYTE_FALSE,
ipv4AddressPrefixToArray(destinationAddress), extractPrefix(destinationAddress.getValue()), BYTE_FALSE,
- DEFAULT_VNI, DEFAULT_VNI, DEFAULT_CLASSIFY_TABLE_INDEX, BYTE_FALSE);
+ primaryTableId, secondaryTableId, DEFAULT_CLASSIFY_TABLE_INDEX, BYTE_FALSE);
}
private IpAddDelRoute resolveFlags(IpAddDelRoute request,
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/base/BasicHopRequestFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/base/BasicHopRequestFactory.java
index abaf0fa84..740c30c21 100644
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/base/BasicHopRequestFactory.java
+++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/base/BasicHopRequestFactory.java
@@ -16,17 +16,19 @@
package io.fd.hc2vpp.routing.write.factory.base;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
+
import javax.annotation.Nonnull;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* Extension to {@code ClassifierContextHolder} to hold also {@code NamingContext}
*/
-public abstract class BasicHopRequestFactory extends ClassifierContextHolder {
+public abstract class BasicHopRequestFactory {
+ private final VppClassifierContextManager classifierContextManager;
private final NamingContext interfaceNamingContext;
private final NamingContext routingProtocolContext;
@@ -34,11 +36,15 @@ public abstract class BasicHopRequestFactory extends ClassifierContextHolder {
@Nonnull final VppClassifierContextManager classifierContextManager,
@Nonnull final NamingContext interfaceContext,
@Nonnull final NamingContext routingProtocolContext) {
- super(classifierContextManager);
+ this.classifierContextManager = checkNotNull(classifierContextManager, "Classifier context cannot be null");
this.interfaceNamingContext = checkNotNull(interfaceContext, "Interface context cannot be null");
this.routingProtocolContext = checkNotNull(routingProtocolContext, "Routing protocol context cannot be null");
}
+ protected VppClassifierContextManager getVppClassifierContextManager() {
+ return this.classifierContextManager;
+ }
+
protected NamingContext getInterfaceNamingContext() {
return interfaceNamingContext;
}
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/base/ClassifierContextHolder.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/base/ClassifierContextHolder.java
deleted file mode 100644
index 0b11a9b3b..000000000
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/base/ClassifierContextHolder.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.hc2vpp.routing.write.factory.base;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
-import javax.annotation.Nonnull;
-
-/**
- * Holds reference for
- */
-public abstract class ClassifierContextHolder {
-
- private final VppClassifierContextManager classifierContextManager;
-
- protected ClassifierContextHolder(@Nonnull final VppClassifierContextManager classifierContextManager) {
- this.classifierContextManager = checkNotNull(classifierContextManager, "Classifier context cannot be null");
- }
-
- protected VppClassifierContextManager getVppClassifierContextManager() {
- return this.classifierContextManager;
- }
-}