private static final int DEFAULT_FIB_FLOW_PRIORITY = 10;
private final DataBroker dataBroker;
- final NexthopManager nextHopManager;
+ private final NexthopManager nextHopManager;
private final IMdsalApiManager mdsalManager;
+ private final FibUtil fibUtil;
@Inject
public BaseVrfEntryHandler(final DataBroker dataBroker,
final NexthopManager nexthopManager,
- final IMdsalApiManager mdsalManager) {
+ final IMdsalApiManager mdsalManager,
+ final FibUtil fibUtil) {
this.dataBroker = dataBroker;
this.nextHopManager = nexthopManager;
this.mdsalManager = mdsalManager;
+ this.fibUtil = fibUtil;
}
@Override
- public void close() throws Exception {
+ public void close() {
LOG.info("{} closed", getClass().getSimpleName());
}
+ protected FibUtil getFibUtil() {
+ return fibUtil;
+ }
+
+ protected NexthopManager getNextHopManager() {
+ return nextHopManager;
+ }
+
private void addAdjacencyResultToList(List<AdjacencyResult> adjacencyList, AdjacencyResult adjacencyResult) {
if (adjacencyResult != null && !adjacencyList.contains(adjacencyResult)) {
adjacencyList.add(adjacencyResult);
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
List<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker,
- FibUtil.getVpnNameFromId(dataBroker, vpnId), usedRds, vrfEntry.getDestPrefix());
+ fibUtil.getVpnNameFromId(vpnId), usedRds, vrfEntry.getDestPrefix());
if (vpnExtraRoutes.isEmpty()) {
- Prefixes prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, vrfEntry.getDestPrefix());
+ Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
// We don't want to provide an adjacencyList for an extra-route-prefix.
if (prefixInfo == null) {
LOG.debug("The extra route {} in rd {} for vpn {} has been removed from all the next hops",
return;
}
if (prefixInfo == null) {
- prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, vrfEntry.getDestPrefix());
+ prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
//Checking PrefixtoInterface again as it is populated later in some cases
if (prefixInfo == null) {
LOG.debug("No prefix info found for prefix {}", vrfEntry.getDestPrefix());
LOG.debug("Failed to get VPN interface for prefix {}", ipPrefix);
return;
}
- String macAddress = FibUtil.getMacAddressFromPrefix(dataBroker, ifName, ipPrefix);
+ String macAddress = fibUtil.getMacAddressFromPrefix(ifName, ipPrefix);
if (macAddress == null) {
LOG.warn("No MAC address found for VPN interface {} prefix {}", ifName, ipPrefix);
return;
// FIXME vxlan vni bit set is not working properly with OVS.need to
// revisit
if (tunnelType.equals(TunnelTypeVxlan.class)) {
- prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, vrfEntry.getDestPrefix());
+ prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
//For extra route, the prefixInfo is fetched from the primary adjacency
if (prefixInfo == null) {
- prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, adjacencyResult.getPrefix());
+ prefixInfo = fibUtil.getPrefixToInterface(vpnId, adjacencyResult.getPrefix());
}
// Internet VPN VNI will be used as tun_id for NAT use-cases
if (Prefixes.PrefixCue.Nat.equals(prefixInfo.getPrefixCue())) {
tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
}
} else {
- if (FibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(dataBroker, prefixInfo.getSubnetId(),
- vpnId, rd)) {
- java.util.Optional<Long> optionalVni = FibUtil.getVniForVxlanNetwork(dataBroker,
- prefixInfo.getSubnetId());
+ if (fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(prefixInfo.getSubnetId(), vpnId,
+ rd)) {
+ java.util.Optional<Long> optionalVni = fibUtil.getVniForVxlanNetwork(prefixInfo.getSubnetId());
if (!optionalVni.isPresent()) {
LOG.error("VNI not found for nexthop {} vrfEntry {} with subnetId {}", nextHopIp,
vrfEntry, prefixInfo.getSubnetId());
}
public Routes getVpnToExtraroute(Long vpnId, String vpnRd, String destPrefix) {
- String optVpnName = FibUtil.getVpnNameFromId(dataBroker, vpnId);
+ String optVpnName = fibUtil.getVpnNameFromId(vpnId);
if (optVpnName != null) {
InstanceIdentifier<Routes> vpnExtraRoutesId = getVpnToExtrarouteIdentifier(
optVpnName, vpnRd, destPrefix);
implements ResourceHandler, IVrfEntryHandler {
private static final Logger LOG = LoggerFactory.getLogger(BgpRouteVrfEntryHandler.class);
- private final DataBroker dataBroker;
-
private static final int BATCH_INTERVAL = 500;
private static final int BATCH_SIZE = 1000;
+
+ private final DataBroker dataBroker;
private final BlockingQueue<ActionableResource> vrfEntryBufferQ = new LinkedBlockingQueue<>();
private final ResourceBatchingManager resourceBatchingManager;
private final NexthopManager nexthopManager;
@Inject
public BgpRouteVrfEntryHandler(final DataBroker dataBroker,
- final NexthopManager nexthopManager) {
- super(dataBroker, nexthopManager, null);
+ final NexthopManager nexthopManager,
+ final FibUtil fibUtil) {
+ super(dataBroker, nexthopManager, null, fibUtil);
this.dataBroker = dataBroker;
this.nexthopManager = nexthopManager;
}
@Override
- public void close() throws Exception {
+ public void close() {
LOG.info("{} close", getClass().getSimpleName());
}
final VrfTablesKey vrfTableKey = vrfEntryIid.firstKeyOf(VrfTables.class);
final VpnInstanceOpDataEntry vpnInstance =
- FibUtil.getVpnInstance(dataBroker, vrfTableKey.getRouteDistinguisher());
+ getFibUtil().getVpnInstance(vrfTableKey.getRouteDistinguisher());
Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + vrfTableKey.getRouteDistinguisher());
Preconditions.checkNotNull(vpnInstance.getVpnId(), "Vpn Instance with rd " + vpnInstance.getVrfId()
+ " has null vpnId!");
final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
String rd = vrfTableKey.getRouteDistinguisher();
final VpnInstanceOpDataEntry vpnInstance =
- FibUtil.getVpnInstance(dataBroker, vrfTableKey.getRouteDistinguisher());
+ getFibUtil().getVpnInstance(vrfTableKey.getRouteDistinguisher());
if (vpnInstance == null) {
LOG.debug("VPN Instance for rd {} is not available from VPN Op Instance Datastore", rd);
return;
}
- String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnInstance.getVpnId());
+ String vpnName = getFibUtil().getVpnNameFromId(vpnInstance.getVpnId());
final Collection<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
if (vpnToDpnList != null) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker,
protected void addTunnelInterfaceActions(NexthopManager.AdjacencyResult adjacencyResult, long vpnId,
VrfEntry vrfEntry, List<ActionInfo> actionInfos, String rd) {
Class<? extends TunnelTypeBase> tunnelType =
- VpnExtraRouteHelper.getTunnelType(nextHopManager.getInterfaceManager(),
+ VpnExtraRouteHelper.getTunnelType(getNextHopManager().getInterfaceManager(),
adjacencyResult.getInterfaceName());
if (tunnelType == null) {
LOG.debug("Tunnel type not found for vrfEntry {}", vrfEntry);
import org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions;
import org.opendaylight.genius.utils.batching.SubTransaction;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elanmanager.api.IElanService;
import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
private final BgpRouteVrfEntryHandler bgpRouteVrfEntryHandler;
private final NexthopManager nexthopManager;
private final JobCoordinator jobCoordinator;
+ private final IElanService elanManager;
EvpnVrfEntryHandler(DataBroker broker, VrfEntryListener vrfEntryListener,
- BgpRouteVrfEntryHandler bgpRouteVrfEntryHandler,
- NexthopManager nexthopManager, JobCoordinator jobCoordinator) {
- super(broker, nexthopManager, null);
+ BgpRouteVrfEntryHandler bgpRouteVrfEntryHandler, NexthopManager nexthopManager,
+ JobCoordinator jobCoordinator, IElanService elanManager, FibUtil fibUtil) {
+ super(broker, nexthopManager, null, fibUtil);
this.dataBroker = broker;
this.vrfEntryListener = vrfEntryListener;
this.bgpRouteVrfEntryHandler = bgpRouteVrfEntryHandler;
this.nexthopManager = nexthopManager;
this.jobCoordinator = jobCoordinator;
+ this.elanManager = elanManager;
}
@Override
public void createFlows(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
LOG.info("Initiating creation of Evpn Flows");
final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
- final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstanceOpData(dataBroker,
+ final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstanceOpData(
vrfTableKey.getRouteDistinguisher()).get();
Long vpnId = vpnInstance.getVpnId();
Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + vrfTableKey.getRouteDistinguisher());
}
return;
}
- Prefixes localNextHopInfo = FibUtil.getPrefixToInterface(dataBroker, vpnInstance.getVpnId(),
- vrfEntry.getDestPrefix());
+ Prefixes localNextHopInfo = getFibUtil().getPrefixToInterface(vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
List<BigInteger> localDpnId = new ArrayList<>();
boolean isNatPrefix = false;
if (Prefixes.PrefixCue.Nat.equals(localNextHopInfo.getPrefixCue())) {
@Override
public void removeFlows(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
- final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstanceOpData(dataBroker,
+ final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstanceOpData(
vrfTableKey.getRouteDistinguisher()).get();
if (vpnInstance == null) {
LOG.error("VPN Instance for rd {} is not available from VPN Op Instance Datastore", rd);
for (String nextHopIp : extraRoute.getNexthopIpList()) {
LOG.info("NextHop IP for destination {} is {}", vrfEntry.getDestPrefix(), nextHopIp);
if (nextHopIp != null) {
- localNextHopInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, nextHopIp + "/32");
+ localNextHopInfo = getFibUtil().getPrefixToInterface(vpnId, nextHopIp + "/32");
if (localNextHopInfo != null) {
localNextHopIP = nextHopIp + "/32";
BigInteger dpnId = checkCreateLocalEvpnFlows(localNextHopInfo, localNextHopIP, vpnId,
List<ActionInfo> actionInfos = new ArrayList<>();
BigInteger tunnelId;
String prefix = adjacencyResult.getPrefix();
- Prefixes prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, prefix);
+ Prefixes prefixInfo = getFibUtil().getPrefixToInterface(vpnId, prefix);
String interfaceName = prefixInfo.getVpnInterfaceName();
if (vrfEntry.getOrigin().equals(RouteOrigin.BGP.getValue()) || isNatPrefix) {
tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
- } else if (VrfEntryListener.isOpenStackVniSemanticsEnforced) {
- tunnelId = BigInteger.valueOf(FibUtil.getVniForVxlanNetwork(dataBroker,
- prefixInfo.getSubnetId()).get());
+ } else if (elanManager.isOpenStackVniSemanticsEnforced()) {
+ tunnelId = BigInteger.valueOf(getFibUtil().getVniForVxlanNetwork(prefixInfo.getSubnetId()).get());
} else {
- Interface interfaceState = FibUtil.getInterfaceStateFromOperDS(dataBroker, interfaceName);
+ Interface interfaceState = getFibUtil().getInterfaceStateFromOperDS(interfaceName);
tunnelId = BigInteger.valueOf(interfaceState.getIfIndex());
}
LOG.debug("adding set tunnel id action for label {}", tunnelId);
String macAddress = null;
if (interfaceName != null) {
- macAddress = FibUtil.getMacAddressFromPrefix(dataBroker, interfaceName, prefix);
+ macAddress = getFibUtil().getMacAddressFromPrefix(interfaceName, prefix);
actionInfos.add(new ActionSetFieldEthernetDestination(new MacAddress(macAddress)));
}
actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
*/
package org.opendaylight.netvirt.fibmanager;
+import com.google.common.collect.ImmutableMap;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg1;
-public final class FibConstants {
- static final int DEFAULT_FIB_FLOW_PRIORITY = 10;
- static final int DEFAULT_PREFIX_LENGTH = 32;
- static final int DEFAULT_IPV6_PREFIX_LENGTH = 128;
- static final String PREFIX_SEPARATOR = "/";
- static final String FLOWID_PREFIX = "L3.";
- static final String VPN_IDPOOL_NAME = "vpnservices";
- static final String SEPARATOR = ".";
- static final String DEFAULT_NEXTHOP_IP = "0.0.0.0";
- public static final long INVALID_GROUP_ID = -1;
- public static final Map<Integer, Class<? extends NxmNxReg>> NXM_REG_MAPPING = new ConcurrentHashMap<>();
+public interface FibConstants {
+ int DEFAULT_FIB_FLOW_PRIORITY = 10;
+ int DEFAULT_PREFIX_LENGTH = 32;
+ int DEFAULT_IPV6_PREFIX_LENGTH = 128;
+ String PREFIX_SEPARATOR = "/";
+ String FLOWID_PREFIX = "L3.";
+ String VPN_IDPOOL_NAME = "vpnservices";
+ String SEPARATOR = ".";
+ String DEFAULT_NEXTHOP_IP = "0.0.0.0";
+ long INVALID_GROUP_ID = -1;
- static {
- NXM_REG_MAPPING.put(0, NxmNxReg0.class);
- NXM_REG_MAPPING.put(1, NxmNxReg1.class);
- }
+ Map<Integer, Class<? extends NxmNxReg>> NXM_REG_MAPPING = ImmutableMap.of(0, NxmNxReg0.class, 1, NxmNxReg1.class);
}
private final VrfEntryListener vrfEntryListener;
private IVpnManager vpnmanager;
private final DataBroker dataBroker;
+ private final FibUtil fibUtil;
@Inject
public FibManagerImpl(final DataBroker dataBroker,
final NexthopManager nexthopManager,
final VrfEntryListener vrfEntryListener,
- final BundleContext bundleContext) {
+ final BundleContext bundleContext,
+ final FibUtil fibUtil) {
this.dataBroker = dataBroker;
this.nexthopManager = nexthopManager;
this.vrfEntryListener = vrfEntryListener;
+ this.fibUtil = fibUtil;
GlobalEventExecutor.INSTANCE.execute(() -> {
final WaitingServiceTracker<IVpnManager> tracker = WaitingServiceTracker.create(
List<String> nextHopList, VrfEntry.EncapType encapType, long label,
long l3vni, String gwMacAddress, String parentVpnRd, RouteOrigin origin,
WriteTransaction writeConfigTxn) {
- FibUtil.addOrUpdateFibEntry(broker, rd, macAddress, prefix , nextHopList, encapType, label, l3vni,
- gwMacAddress, parentVpnRd, origin, writeConfigTxn);
+ fibUtil.addOrUpdateFibEntry(rd, macAddress, prefix, nextHopList , encapType, label, l3vni, gwMacAddress,
+ parentVpnRd, origin, writeConfigTxn);
}
@Override
public void addFibEntryForRouterInterface(DataBroker broker, String rd, String prefix,
RouterInterface routerInterface, long label,
WriteTransaction writeConfigTxn) {
- FibUtil.addFibEntryForRouterInterface(broker, rd, prefix, routerInterface, label, writeConfigTxn);
+ fibUtil.addFibEntryForRouterInterface(rd, prefix, routerInterface, label, writeConfigTxn);
}
@Override
public void removeOrUpdateFibEntry(DataBroker broker, String rd, String prefix,
String nextHopToRemove, WriteTransaction writeConfigTxn) {
- FibUtil.removeOrUpdateFibEntry(broker, rd, prefix, nextHopToRemove, writeConfigTxn);
+ fibUtil.removeOrUpdateFibEntry(rd, prefix, nextHopToRemove, writeConfigTxn);
}
@Override
public void removeFibEntry(DataBroker broker, String rd, String prefix, WriteTransaction writeConfigTxn) {
- FibUtil.removeFibEntry(broker, rd, prefix, writeConfigTxn);
+ fibUtil.removeFibEntry(rd, prefix, writeConfigTxn);
}
@Override
public void updateRoutePathForFibEntry(DataBroker broker, String rd, String prefix, String nextHop,
long label, boolean nextHopAdd, WriteTransaction writeConfigTxn) {
- FibUtil.updateRoutePathForFibEntry(broker, rd, prefix, nextHop, label, nextHopAdd, writeConfigTxn);
+ fibUtil.updateRoutePathForFibEntry(rd, prefix, nextHop, label, nextHopAdd, writeConfigTxn);
}
@Override
public void removeVrfTable(DataBroker broker, String rd, WriteTransaction writeConfigTxn) {
- FibUtil.removeVrfTable(broker, rd, writeConfigTxn);
+ fibUtil.removeVrfTable(rd, writeConfigTxn);
}
@Override
return;
}
InterVpnLinkDataComposite interVpnLink = optInterVpnLink.get();
- String vpnName = (isVpnFirstEndPoint) ? interVpnLink.getFirstEndpointVpnUuid().get()
+ String vpnName = isVpnFirstEndPoint ? interVpnLink.getFirstEndpointVpnUuid().get()
: interVpnLink.getSecondEndpointVpnUuid().get();
vrfEntryListener.removeInterVPNLinkRouteFlows(interVpnLink, vpnName, vrfEntry);
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
-import static org.opendaylight.netvirt.fibmanager.VrfEntryListener.isOpenStackVniSemanticsEnforced;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.net.InetAddresses;
-
import java.math.BigInteger;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-
+import javax.inject.Inject;
+import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.mdsalutil.BucketInfo;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
+import org.opendaylight.netvirt.elanmanager.api.IElanService;
import org.opendaylight.netvirt.fibmanager.NexthopManager.AdjacencyResult;
import org.opendaylight.netvirt.fibmanager.api.FibHelper;
import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class FibUtil {
+@Singleton
+public class FibUtil {
private static final Logger LOG = LoggerFactory.getLogger(FibUtil.class);
private static final String FLOWID_PREFIX = "L3.";
- private FibUtil() {
+ private final DataBroker dataBroker;
+ private final IElanService elanManager;
+ private final IdManagerService idManager;
+
+ @Inject
+ public FibUtil(DataBroker dataBroker, IElanService elanManager, IdManagerService idManager) {
+ this.dataBroker = dataBroker;
+ this.elanManager = elanManager;
+ this.idManager = idManager;
}
static InstanceIdentifier<Adjacency> getAdjacencyIdentifier(String vpnInterfaceName, String ipAddress) {
.child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(rd)).build();
}
- static Optional<VpnInstanceOpDataEntry> getVpnInstanceOpData(DataBroker broker, String rd) {
+ Optional<VpnInstanceOpDataEntry> getVpnInstanceOpData(String rd) {
InstanceIdentifier<VpnInstanceOpDataEntry> id = getVpnInstanceOpDataIdentifier(rd);
- return MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, id);
+ return MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
}
- static VpnInstanceOpDataEntry getVpnInstance(DataBroker dataBroker, String rd) {
+ VpnInstanceOpDataEntry getVpnInstance(String rd) {
InstanceIdentifier<VpnInstanceOpDataEntry> id =
InstanceIdentifier.create(VpnInstanceOpData.class)
.child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(rd));
return rd + FibConstants.SEPARATOR + prefix;
}
- static Prefixes getPrefixToInterface(DataBroker broker, Long vpnId, String ipPrefix) {
- Optional<Prefixes> localNextHopInfoData = MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL,
+ Prefixes getPrefixToInterface(Long vpnId, String ipPrefix) {
+ Optional<Prefixes> localNextHopInfoData = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL,
getPrefixToInterfaceIdentifier(vpnId, ipPrefix));
return localNextHopInfoData.isPresent() ? localNextHopInfoData.get() : null;
}
- static String getMacAddressFromPrefix(DataBroker broker, String ifName, String ipPrefix) {
- Optional<Adjacency> adjacencyData = MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL,
+ String getMacAddressFromPrefix(String ifName, String ipPrefix) {
+ Optional<Adjacency> adjacencyData = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL,
getAdjacencyIdentifier(ifName, ipPrefix));
return adjacencyData.isPresent() ? adjacencyData.get().getMacAddress() : null;
}
- static void releaseId(IdManagerService idManager, String poolName, String idKey) {
+ void releaseId(String poolName, String idKey) {
ReleaseIdInput idInput = new ReleaseIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
try {
Future<RpcResult<Void>> result = idManager.releaseId(idInput);
.VpnInstanceKey(vpnName)).build();
}
- public static long getVpnId(DataBroker broker, String vpnName) {
+ public long getVpnId(String vpnName) {
InstanceIdentifier<VpnInstance> id = getVpnInstanceToVpnIdIdentifier(vpnName);
- return MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id).toJavaUtil().map(
+ return MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id).toJavaUtil().map(
VpnInstance::getVpnId).orElse(-1L);
}
/**
* Retrieves the VpnInstance name (typically the VPN Uuid) out from the route-distinguisher.
- *
- * @param broker The DataBroker
* @param rd The route-distinguisher
+ *
* @return The vpn instance
*/
- public static Optional<String> getVpnNameFromRd(DataBroker broker, String rd) {
+ public Optional<String> getVpnNameFromRd(String rd) {
return Optional.fromJavaUtil(
- getVpnInstanceOpData(broker, rd).toJavaUtil().map(VpnInstanceOpDataEntry::getVpnInstanceName));
+ getVpnInstanceOpData(rd).toJavaUtil().map(VpnInstanceOpDataEntry::getVpnInstanceName));
}
- public static String getVpnNameFromId(DataBroker broker, long vpnId) {
+ public String getVpnNameFromId(long vpnId) {
InstanceIdentifier<VpnIds> id = getVpnIdToVpnInstanceIdentifier(vpnId);
- return MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id).toJavaUtil().map(
+ return MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id).toJavaUtil().map(
VpnIds::getVpnInstanceName).orElse(null);
}
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
- public static void addOrUpdateFibEntry(DataBroker broker, String rd, String macAddress, String prefix,
- List<String> nextHopList, VrfEntry.EncapType encapType, long label,
- long l3vni, String gwMacAddress, String parentVpnRd, RouteOrigin origin,
- WriteTransaction writeConfigTxn) {
+ public void addOrUpdateFibEntry(String rd, String macAddress, String prefix, List<String> nextHopList,
+ VrfEntry.EncapType encapType, long label, long l3vni, String gwMacAddress, String parentVpnRd,
+ RouteOrigin origin, WriteTransaction writeConfigTxn) {
if (rd == null || rd.isEmpty()) {
LOG.error("Prefix {} not associated with vpn", prefix);
return;
.child(VrfEntry.class, new VrfEntryKey(prefix)).build();
writeFibEntryToDs(vrfEntryId, prefix, nextHopList, label, l3vni, encapType, origin, macAddress,
- gwMacAddress, parentVpnRd, writeConfigTxn, broker);
+ gwMacAddress, parentVpnRd, writeConfigTxn);
LOG.debug("Created/Updated vrfEntry for {} nexthop {} label {}", prefix, nextHopList, label);
} catch (Exception e) {
LOG.error("addOrUpdateFibEntry: Prefix {} rd {} label {} error ", prefix, rd, label, e);
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
- public static void writeFibEntryToDs(InstanceIdentifier<VrfEntry> vrfEntryId, String prefix,
- List<String> nextHopList, long label, Long l3vni,
- VrfEntry.EncapType encapType, RouteOrigin origin, String macAddress,
- String gatewayMacAddress, String parentVpnRd,
- WriteTransaction writeConfigTxn, DataBroker broker) {
+ public void writeFibEntryToDs(InstanceIdentifier<VrfEntry> vrfEntryId, String prefix, List<String> nextHopList,
+ long label, Long l3vni, VrfEntry.EncapType encapType, RouteOrigin origin, String macAddress,
+ String gatewayMacAddress, String parentVpnRd, WriteTransaction writeConfigTxn) {
VrfEntryBuilder vrfEntryBuilder = new VrfEntryBuilder().setDestPrefix(prefix).setOrigin(origin.getValue());
if (parentVpnRd != null) {
vrfEntryBuilder.setParentVpnRd(parentVpnRd);
if (writeConfigTxn != null) {
writeConfigTxn.merge(LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntryBuilder.build(), true);
} else {
- MDSALUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntryBuilder.build());
+ MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntryBuilder.build());
}
}
@SuppressWarnings("checkstyle:IllegalCatch")
- public static void addFibEntryForRouterInterface(DataBroker broker,
- String rd,
- String prefix,
- RouterInterface routerInterface,
- long label,
- WriteTransaction writeConfigTxn) {
+ public void addFibEntryForRouterInterface(String rd, String prefix, RouterInterface routerInterface, long label,
+ WriteTransaction writeConfigTxn) {
if (rd == null || rd.isEmpty()) {
LOG.error("Prefix {} not associated with vpn", prefix);
return;
if (writeConfigTxn != null) {
writeConfigTxn.merge(LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry, true);
} else {
- MDSALUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry);
+ MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry);
}
LOG.debug("Created vrfEntry for router-interface-prefix {} rd {} label {}", prefix, rd, label);
} catch (Exception e) {
builder.setRoutePaths(routePaths);
}
- public static void removeFibEntry(DataBroker broker, String rd, String prefix, WriteTransaction writeConfigTxn) {
+ public void removeFibEntry(String rd, String prefix, WriteTransaction writeConfigTxn) {
if (rd == null || rd.isEmpty()) {
LOG.error("Prefix {} not associated with vpn", prefix);
if (writeConfigTxn != null) {
writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vrfEntryId);
} else {
- MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
+ MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
}
}
/**
* Removes a specific Nexthop from a VrfEntry. If Nexthop to remove is the
* last one in the VrfEntry, then the VrfEntry is removed too.
- *
- * @param broker dataBroker service reference
* @param rd Route-Distinguisher to which the VrfEntry belongs to
* @param prefix Destination of the route
* @param nextHopToRemove Specific nexthop within the Route to be removed.
* If null or empty, then the whole VrfEntry is removed
*/
- public static void removeOrUpdateFibEntry(DataBroker broker, String rd, String prefix, String nextHopToRemove,
- WriteTransaction writeConfigTxn) {
+ public void removeOrUpdateFibEntry(String rd, String prefix, String nextHopToRemove,
+ WriteTransaction writeConfigTxn) {
LOG.debug("Removing fib entry with destination prefix {} from vrf table for rd {}", prefix, rd);
InstanceIdentifier<VrfEntry> vrfEntryId =
InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd))
.child(VrfEntry.class, new VrfEntryKey(prefix)).build();
- Optional<VrfEntry> entry = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
+ Optional<VrfEntry> entry = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
if (entry.isPresent()) {
final List<RoutePaths> routePaths = entry.get().getRoutePaths();
if (routePaths == null || routePaths.isEmpty()) {
if (writeConfigTxn != null) {
writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vrfEntryId);
} else {
- MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
+ MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
}
LOG.info("Removed Fib Entry rd {} prefix {}", rd, prefix);
} else {
InstanceIdentifier<RoutePaths> routePathsId =
FibHelper.buildRoutePathId(rd, prefix, routePath.getNexthopAddress());
// Remove route
- MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, routePathsId);
+ MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routePathsId);
LOG.info("Removed Route Path rd {} prefix {}, nextHop {}, label {}", rd, prefix,
routePath.getNexthopAddress(), routePath.getLabel());
/**
* Adds or removes nextHop from routePath based on the flag nextHopAdd.
*/
- public static void updateRoutePathForFibEntry(DataBroker broker, String rd, String prefix, String nextHop,
- long label, boolean nextHopAdd, WriteTransaction writeConfigTxn) {
+ public void updateRoutePathForFibEntry(String rd, String prefix, String nextHop, long label,
+ boolean nextHopAdd, WriteTransaction writeConfigTxn) {
LOG.debug("Updating fib entry for prefix {} with nextHop {} for rd {}.", prefix, nextHop, rd);
writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, routePathId, routePaths,
WriteTransaction.CREATE_MISSING_PARENTS);
} else {
- MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, routePathId, routePaths);
+ MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routePathId, routePaths);
}
LOG.debug("Added routepath with nextHop {} for prefix {} and label {}.", nextHop, prefix, label);
} else {
- Optional<RoutePaths> routePath = MDSALUtil.read(broker,
+ Optional<RoutePaths> routePath = MDSALUtil.read(dataBroker,
LogicalDatastoreType.CONFIGURATION, routePathId);
if (!routePath.isPresent()) {
LOG.warn("Couldn't find RoutePath with rd {}, prefix {} and nh {} for deleting",
if (writeConfigTxn != null) {
writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, routePathId);
} else {
- MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, routePathId);
+ MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routePathId);
}
LOG.info("Removed routepath with nextHop {} for prefix {} and rd {}.", nextHop, prefix, rd);
}
}
}
- public static void removeVrfTable(DataBroker broker, String rd, WriteTransaction writeConfigTxn) {
+ public void removeVrfTable(String rd, WriteTransaction writeConfigTxn) {
LOG.debug("Removing vrf table for rd {}", rd);
InstanceIdentifier.InstanceIdentifierBuilder<VrfTables> idBuilder =
InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
if (writeConfigTxn != null) {
writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vrfTableId);
} else {
- Optional<VrfTables> ifStateOptional = MDSALUtil.read(broker,
+ Optional<VrfTables> ifStateOptional = MDSALUtil.read(dataBroker,
LogicalDatastoreType.CONFIGURATION, vrfTableId);
if (ifStateOptional.isPresent()) {
- MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, vrfTableId);
+ MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfTableId);
}
}
}
return id;
}
- public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces
- .state.Interface getInterfaceStateFromOperDS(DataBroker dataBroker, String interfaceName) {
+ public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces
+ .state.Interface getInterfaceStateFromOperDS(String interfaceName) {
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508
.interfaces.state.Interface> ifStateId = buildStateInterfaceId(interfaceName);
Optional<Interface> ifStateOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, ifStateId);
return "FIB-" + vpnId.toString() + "-" + dpnId.toString() ;
}
- public static void updateUsedRdAndVpnToExtraRoute(WriteTransaction writeOperTxn, DataBroker broker,
- String tunnelIpRemoved, String primaryRd, String prefix) {
- Optional<VpnInstanceOpDataEntry> optVpnInstance = getVpnInstanceOpData(broker, primaryRd);
+ public void updateUsedRdAndVpnToExtraRoute(WriteTransaction writeOperTxn, String tunnelIpRemoved, String primaryRd,
+ String prefix) {
+ Optional<VpnInstanceOpDataEntry> optVpnInstance = getVpnInstanceOpData(primaryRd);
if (!optVpnInstance.isPresent()) {
return;
}
VpnInstanceOpDataEntry vpnInstance = optVpnInstance.get();
String vpnName = vpnInstance.getVpnInstanceName();
long vpnId = vpnInstance.getVpnId();
- List<String> usedRds = VpnExtraRouteHelper.getUsedRds(broker, vpnId, prefix);
+ List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, prefix);
// To identify the rd to be removed, iterate through the allocated rds for the prefix and check
// which rd is allocated for the particular OVS.
for (String usedRd : usedRds) {
Optional<Routes> vpnExtraRoutes = VpnExtraRouteHelper
- .getVpnExtraroutes(broker, vpnName, usedRd, prefix);
+ .getVpnExtraroutes(dataBroker, vpnName, usedRd, prefix);
if (vpnExtraRoutes.isPresent()) {
// Since all the nexthops under one OVS will be present under one rd, only 1 nexthop is read
// to identify the OVS
String nextHopRemoved = vpnExtraRoutes.get().getNexthopIpList().get(0);
- Prefixes prefixToInterface = getPrefixToInterface(broker, vpnId, getIpPrefix(nextHopRemoved));
+ Prefixes prefixToInterface = getPrefixToInterface(vpnId, getIpPrefix(nextHopRemoved));
if (prefixToInterface != null && tunnelIpRemoved
- .equals(getEndpointIpAddressForDPN(broker, prefixToInterface.getDpnId()))) {
+ .equals(getEndpointIpAddressForDPN(prefixToInterface.getDpnId()))) {
InstanceIdentifier<Adjacency> adjId = getAdjacencyIdentifier(
prefixToInterface.getVpnInterfaceName(), prefix);
- Interface ifState = FibUtil.getInterfaceStateFromOperDS(
- broker, prefixToInterface.getVpnInterfaceName());
+ Interface ifState = getInterfaceStateFromOperDS(prefixToInterface.getVpnInterfaceName());
//Delete datastore only if extra route is deleted or VM interface is deleted/down
- if (!MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, adjId).isPresent()
+ if (!MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, adjId).isPresent()
|| ifState == null || ifState.getOperStatus() == OperStatus.Down) {
writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL,
getAdjacencyIdentifier(prefixToInterface.getVpnInterfaceName(), prefix));
}
}
- private static String getEndpointIpAddressForDPN(DataBroker broker, BigInteger dpnId) {
+ private String getEndpointIpAddressForDPN(BigInteger dpnId) {
//TODO: Move it to a common place for vpn and fib
String nextHopIp = null;
InstanceIdentifier<DPNTEPsInfo> tunnelInfoId =
InstanceIdentifier.builder(DpnEndpoints.class).child(DPNTEPsInfo.class, new DPNTEPsInfoKey(dpnId)).build();
- Optional<DPNTEPsInfo> tunnelInfo = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, tunnelInfoId);
+ Optional<DPNTEPsInfo> tunnelInfo = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, tunnelInfoId);
if (tunnelInfo.isPresent()) {
List<TunnelEndPoints> nexthopIpList = tunnelInfo.get().getTunnelEndPoints();
if (nexthopIpList != null && !nexthopIpList.isEmpty()) {
.child(VrfTables.class,new VrfTablesKey(rd)).child(VrfEntry.class,new VrfEntryKey(prefix)).build();
}
- public static List<String> getNextHopAddresses(DataBroker broker, String rd, String prefix) {
+ public List<String> getNextHopAddresses(String rd, String prefix) {
InstanceIdentifier<VrfEntry> vrfEntryId = getNextHopIdentifier(rd, prefix);
- Optional<VrfEntry> vrfEntry = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
+ Optional<VrfEntry> vrfEntry = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
if (vrfEntry.isPresent()) {
return FibHelper.getNextHopListFromRoutePaths(vrfEntry.get());
} else {
}
}
- public static Subnetmap getSubnetMap(DataBroker broker, Uuid subnetId) {
+ public Subnetmap getSubnetMap(Uuid subnetId) {
InstanceIdentifier<Subnetmap> subnetmapId = InstanceIdentifier.builder(Subnetmaps.class)
.child(Subnetmap.class, new SubnetmapKey(subnetId)).build();
- return MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, subnetmapId).orNull();
+ return MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetmapId).orNull();
}
public static String getGreLbGroupKey(List<String> availableDcGws) {
.setNexthopKey(Collections.singletonList(groupIdKey)).build();
}
- public static Optional<Nexthops> getNexthops(DataBroker dataBroker, String nextHopKey) {
+ public Optional<Nexthops> getNexthops(String nextHopKey) {
InstanceIdentifier<Nexthops> nextHopsId = InstanceIdentifier.builder(L3vpnLbNexthops.class)
.child(Nexthops.class, new NexthopsKey(nextHopKey)).build();
return MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, nextHopsId);
}
- public static Optional<DpnLbNexthops> getDpnLbNexthops(DataBroker dataBroker, BigInteger dpnId,
- String destinationIp) {
+ public Optional<DpnLbNexthops> getDpnLbNexthops(BigInteger dpnId, String destinationIp) {
InstanceIdentifier<DpnLbNexthops> id = InstanceIdentifier.builder(DpidL3vpnLbNexthops.class)
.child(DpnLbNexthops.class, new DpnLbNexthopsKey(destinationIp, dpnId))
.build();
return MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
}
- protected static boolean isVxlanNetworkAndInternalRouterVpn(DataBroker dataBroker, Uuid subnetId, String
+ boolean isVxlanNetworkAndInternalRouterVpn(Uuid subnetId, String
vpnInstanceName, String rd) {
if (rd.equals(vpnInstanceName)) {
- Subnetmap subnetmap = getSubnetMap(dataBroker, subnetId);
+ Subnetmap subnetmap = getSubnetMap(subnetId);
if (subnetmap != null) {
return subnetmap.getNetworkType() == NetworkAttributes.NetworkType.VXLAN;
}
return false;
}
- protected static java.util.Optional<Long> getVniForVxlanNetwork(DataBroker dataBroker, Uuid subnetId) {
- Subnetmap subnetmap = getSubnetMap(dataBroker, subnetId);
+ java.util.Optional<Long> getVniForVxlanNetwork(Uuid subnetId) {
+ Subnetmap subnetmap = getSubnetMap(subnetId);
if (subnetmap != null && subnetmap.getNetworkType() == NetworkAttributes.NetworkType.VXLAN) {
return java.util.Optional.of(subnetmap.getSegmentationId());
}
return java.util.Optional.empty();
}
- protected static boolean enforceVxlanDatapathSemanticsforInternalRouterVpn(DataBroker dataBroker, Uuid subnetId,
- long vpnId, String rd) {
- return isOpenStackVniSemanticsEnforced
- && isVxlanNetworkAndInternalRouterVpn(dataBroker, subnetId, getVpnNameFromId(dataBroker, vpnId), rd);
+ boolean enforceVxlanDatapathSemanticsforInternalRouterVpn(Uuid subnetId, long vpnId, String rd) {
+ return elanManager.isOpenStackVniSemanticsEnforced()
+ && isVxlanNetworkAndInternalRouterVpn(subnetId, getVpnNameFromId(vpnId), rd);
}
- protected static boolean enforceVxlanDatapathSemanticsforInternalRouterVpn(DataBroker dataBroker, Uuid subnetId,
- String vpnName, String rd) {
- return isOpenStackVniSemanticsEnforced
- && isVxlanNetworkAndInternalRouterVpn(dataBroker, subnetId, vpnName, rd);
+ boolean enforceVxlanDatapathSemanticsforInternalRouterVpn(Uuid subnetId, String vpnName, String rd) {
+ return elanManager.isOpenStackVniSemanticsEnforced()
+ && isVxlanNetworkAndInternalRouterVpn(subnetId, vpnName, rd);
}
static NodeRef buildNodeRef(BigInteger dpId) {
@Singleton
public class NexthopManager implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(NexthopManager.class);
+ private static final String NEXTHOP_ID_POOL_NAME = "nextHopPointerPool";
+ private static final long WAIT_TIME_FOR_SYNC_INSTALL = Long.getLong("wait.time.sync.install", 300L);
+
private final DataBroker dataBroker;
private final IMdsalApiManager mdsalApiManager;
private final OdlInterfaceRpcService interfaceManager;
private final IElanService elanService;
private final SalGroupService salGroupService;
private final JobCoordinator jobCoordinator;
- private static final String NEXTHOP_ID_POOL_NAME = "nextHopPointerPool";
- private static final long WAIT_TIME_FOR_SYNC_INSTALL = Long.getLong("wait.time.sync.install", 300L);
+ private final FibUtil fibUtil;
private L3VPNTransportTypes configuredTransportTypeL3VPN = L3VPNTransportTypes.Invalid;
/**
final ItmRpcService itmManager,
final IElanService elanService,
final SalGroupService salGroupService,
- final JobCoordinator jobCoordinator) {
+ final JobCoordinator jobCoordinator,
+ final FibUtil fibUtil) {
this.dataBroker = dataBroker;
this.mdsalApiManager = mdsalApiManager;
this.idManager = idManager;
this.elanService = elanService;
this.salGroupService = salGroupService;
this.jobCoordinator = jobCoordinator;
+ this.fibUtil = fibUtil;
createIdPool();
}
public long createLocalNextHop(long vpnId, BigInteger dpnId, String ifName,
String ipNextHopAddress, String ipPrefixAddress, String gwMacAddress, String jobKey) {
- String macAddress = FibUtil.getMacAddressFromPrefix(dataBroker, ifName, ipPrefixAddress);
+ String macAddress = fibUtil.getMacAddressFromPrefix(ifName, ipPrefixAddress);
String ipAddress = macAddress != null ? ipPrefixAddress : ipNextHopAddress;
long groupId = createNextHopPointer(getNextHopKey(vpnId, ipAddress));
ipAddress, ifName, dpnId);
if (nexthop == null) {
String encMacAddress = macAddress == null
- ? FibUtil.getMacAddressFromPrefix(dataBroker, ifName, ipAddress) : macAddress;
+ ? fibUtil.getMacAddressFromPrefix(ifName, ipAddress) : macAddress;
List<BucketInfo> listBucketInfo = new ArrayList<>();
List<ActionInfo> listActionInfo = new ArrayList<>();
int actionKey = 0;
private ElanInstance getElanInstanceForPrefix(long vpnId, String prefixIp) {
ElanInstance elanInstance = null;
- Prefixes prefix = FibUtil.getPrefixToInterface(dataBroker, vpnId, prefixIp);
+ Prefixes prefix = fibUtil.getPrefixToInterface(vpnId, prefixIp);
if (prefix != null) {
Uuid subnetId = prefix.getSubnetId();
if (subnetId != null) {
- Subnetmap subnetMap = FibUtil.getSubnetMap(dataBroker, subnetId);
+ Subnetmap subnetMap = fibUtil.getSubnetMap(subnetId);
if (subnetMap != null && subnetMap.getNetworkId() != null) {
elanInstance = elanService.getElanInstance(subnetMap.getNetworkId().getValue());
}
} else {
localNextHopIP = nextHopIp + NwConstants.IPV6PREFIX;
}
- Prefixes localNextHopInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, localNextHopIP);
+ Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, localNextHopIP);
if (localNextHopInfo != null) {
long groupId = getLocalNextHopGroup(vpnId, localNextHopIP);
if (groupId == FibConstants.INVALID_GROUP_ID) {
} else {
nextHopPrefixIp = nextHopIp + NwConstants.IPV6PREFIX;
}
- List<String> tepIpAddresses = FibUtil.getNextHopAddresses(dataBroker, rd, nextHopPrefixIp);
+ List<String> tepIpAddresses = fibUtil.getNextHopAddresses(rd, nextHopPrefixIp);
if (tepIpAddresses.isEmpty()) {
return;
}
Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper
.getTunnelType(interfaceManager,
egressInterface);
- Interface ifState = FibUtil.getInterfaceStateFromOperDS(dataBroker, egressInterface);
+ Interface ifState = fibUtil.getInterfaceStateFromOperDS(egressInterface);
if (ifState == null || ifState.getOperStatus() != OperStatus.Up) {
LOG.trace("Tunnel not up {}", egressInterface);
return;
return;
}
Long label = FibUtil.getLabelFromRoutePaths(vrfEntry).get();
- Prefixes prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, nextHopPrefixIp);
+ Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, nextHopPrefixIp);
BigInteger tunnelId;
- if (FibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(dataBroker, prefixInfo.getSubnetId(),
- vpnId, rd)) {
- java.util.Optional<Long> optionalVni = FibUtil.getVniForVxlanNetwork(dataBroker,
- prefixInfo.getSubnetId());
+ if (fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(prefixInfo.getSubnetId(), vpnId,
+ rd)) {
+ java.util.Optional<Long> optionalVni = fibUtil.getVniForVxlanNetwork(prefixInfo.getSubnetId());
if (!optionalVni.isPresent()) {
LOG.error("VNI not found for nexthop {} vrfEntry {} with subnetId {}", nextHopIp,
vrfEntry, prefixInfo.getSubnetId());
List<ActionInfo> actionInfos = new ArrayList<>();
actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
String ifName = prefixInfo.getVpnInterfaceName();
- String macAddress = FibUtil.getMacAddressFromPrefix(dataBroker, ifName, nextHopPrefixIp);
+ String macAddress = fibUtil.getMacAddressFromPrefix(ifName, nextHopPrefixIp);
actionInfos.add(new ActionSetFieldEthernetDestination(actionInfos.size(),
new MacAddress(macAddress)));
List<ActionInfo> egressActions;
}
// TODO : Place the logic to construct all possible DC-GW combination here.
int bucketId = availableDcGws.indexOf(destinationIp);
- Optional<DpnLbNexthops> dpnLbNextHops = FibUtil.getDpnLbNexthops(dataBroker, dpnId, destinationIp);
+ Optional<DpnLbNexthops> dpnLbNextHops = fibUtil.getDpnLbNexthops(dpnId, destinationIp);
if (!dpnLbNextHops.isPresent()) {
return;
}
List<String> nextHopKeys = dpnLbNextHops.get().getNexthopKey();
nextHopKeys.forEach(nextHopKey -> {
- Optional<Nexthops> optionalNextHops = FibUtil.getNexthops(dataBroker, nextHopKey);
+ Optional<Nexthops> optionalNextHops = fibUtil.getNexthops(nextHopKey);
if (!optionalNextHops.isPresent()) {
return;
}
WriteTransaction configTx = dataBroker.newWriteOnlyTransaction();
// TODO : Place the logic to construct all possible DC-GW combination here.
int bucketId = availableDcGws.indexOf(destinationIp);
- Optional<DpnLbNexthops> dpnLbNextHops = FibUtil.getDpnLbNexthops(dataBroker, dpnId, destinationIp);
+ Optional<DpnLbNexthops> dpnLbNextHops = fibUtil.getDpnLbNexthops(dpnId, destinationIp);
if (!dpnLbNextHops.isPresent()) {
return;
}
List<String> nextHopKeys = dpnLbNextHops.get().getNexthopKey();
nextHopKeys.forEach(nextHopKey -> {
- Optional<Nexthops> optionalNextHops = FibUtil.getNexthops(dataBroker, nextHopKey);
+ Optional<Nexthops> optionalNextHops = fibUtil.getNexthops(nextHopKey);
if (!optionalNextHops.isPresent()) {
return;
}
public class RouterInterfaceVrfEntryHandler extends BaseVrfEntryHandler implements IVrfEntryHandler {
private static final Logger LOG = LoggerFactory.getLogger(RouterInterfaceVrfEntryHandler.class);
- private final DataBroker dataBroker;
private final IMdsalApiManager mdsalManager;
private final IPv6Handler ipv6Handler;
@Inject
public RouterInterfaceVrfEntryHandler(final DataBroker dataBroker, final NexthopManager nexthopManager,
- final IMdsalApiManager mdsalManager, final IPv6Handler ipv6Handler) {
- super(dataBroker, nexthopManager, mdsalManager);
- this.dataBroker = dataBroker;
+ final IMdsalApiManager mdsalManager, final IPv6Handler ipv6Handler, final FibUtil fibUtil) {
+ super(dataBroker, nexthopManager, mdsalManager, fibUtil);
this.mdsalManager = mdsalManager;
this.ipv6Handler = ipv6Handler;
}
@Override
- public void close() throws Exception {
+ public void close() {
LOG.info("{} close", getClass().getSimpleName());
}
private Boolean installRouterFibEntries(VrfEntry vrfEntry, String rd, int addOrRemove,
RouterInterface routerInterface) {
- final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstance(dataBroker, rd);
+ final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstance(rd);
Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + rd);
Preconditions.checkNotNull(vpnInstance.getVpnId(),
"Vpn Instance with rd " + vpnInstance.getVrfId() + " has null vpnId!");
if (vrfEntry.getParentVpnRd() != null
&& FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
VpnInstanceOpDataEntry parentVpnInstance =
- FibUtil.getVpnInstance(dataBroker, vrfEntry.getParentVpnRd());
+ getFibUtil().getVpnInstance(vrfEntry.getParentVpnRd());
vpnToDpnList = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList()
: vpnInstance.getVpnToDpnList();
} else {
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries;
private final DataBroker dataBroker;
private final IMdsalApiManager mdsalManager;
private final NexthopManager nextHopManager;
- private final IdManagerService idManager;
private final BgpRouteVrfEntryHandler bgpRouteVrfEntryHandler;
private final BaseVrfEntryHandler baseVrfEntryHandler;
private final RouterInterfaceVrfEntryHandler routerInterfaceVrfEntryHandler;
private final JobCoordinator jobCoordinator;
+ private final IElanService elanManager;
+ private final FibUtil fibUtil;
private final List<AutoCloseable> closeables = new CopyOnWriteArrayList<>();
- // FXIME: This should not be a static here - will be fixed later
- @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
- static boolean isOpenStackVniSemanticsEnforced;
-
@Inject
public VrfEntryListener(final DataBroker dataBroker, final IMdsalApiManager mdsalApiManager,
- final NexthopManager nexthopManager, final IdManagerService idManager,
+ final NexthopManager nexthopManager,
final IElanService elanManager,
final BaseVrfEntryHandler vrfEntryHandler,
final BgpRouteVrfEntryHandler bgpRouteVrfEntryHandler,
final RouterInterfaceVrfEntryHandler routerInterfaceVrfEntryHandler,
- final JobCoordinator jobCoordinator) {
+ final JobCoordinator jobCoordinator,
+ final FibUtil fibUtil) {
super(VrfEntry.class, VrfEntryListener.class);
this.dataBroker = dataBroker;
this.mdsalManager = mdsalApiManager;
this.nextHopManager = nexthopManager;
- this.idManager = idManager;
+ this.elanManager = elanManager;
this.baseVrfEntryHandler = vrfEntryHandler;
this.bgpRouteVrfEntryHandler = bgpRouteVrfEntryHandler;
this.routerInterfaceVrfEntryHandler = routerInterfaceVrfEntryHandler;
this.jobCoordinator = jobCoordinator;
-
- isOpenStackVniSemanticsEnforced = elanManager.isOpenStackVniSemanticsEnforced();
+ this.fibUtil = fibUtil;
}
@Override
}
if (VrfEntry.EncapType.Vxlan.equals(vrfEntry.getEncapType())) {
LOG.info("EVPN flows need to be programmed.");
- EvpnVrfEntryHandler evpnVrfEntryHandler =
- new EvpnVrfEntryHandler(dataBroker, this, bgpRouteVrfEntryHandler, nextHopManager, jobCoordinator);
+ EvpnVrfEntryHandler evpnVrfEntryHandler = new EvpnVrfEntryHandler(dataBroker, this, bgpRouteVrfEntryHandler,
+ nextHopManager, jobCoordinator, elanManager, fibUtil);
evpnVrfEntryHandler.createFlows(identifier, vrfEntry, rd);
+ closeables.add(evpnVrfEntryHandler);
return;
}
RouterInterface routerInt = vrfEntry.getAugmentation(RouterInterface.class);
private void removeFibEntries(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
if (VrfEntry.EncapType.Vxlan.equals(vrfEntry.getEncapType())) {
LOG.info("EVPN flows to be deleted");
- EvpnVrfEntryHandler evpnVrfEntryHandler =
- new EvpnVrfEntryHandler(dataBroker, this, bgpRouteVrfEntryHandler, nextHopManager, jobCoordinator);
+ EvpnVrfEntryHandler evpnVrfEntryHandler = new EvpnVrfEntryHandler(dataBroker, this, bgpRouteVrfEntryHandler,
+ nextHopManager, jobCoordinator, elanManager, fibUtil);
evpnVrfEntryHandler.removeFlows(identifier, vrfEntry, rd);
closeables.add(evpnVrfEntryHandler);
return;
//Updates need to be handled for extraroute even if original vrf entry route path is null or
//updated vrf entry route path is null. This can happen during tunnel events.
- Optional<VpnInstanceOpDataEntry> optVpnInstance = FibUtil.getVpnInstanceOpData(dataBroker, rd);
+ Optional<VpnInstanceOpDataEntry> optVpnInstance = fibUtil.getVpnInstanceOpData(rd);
List<String> usedRds = new ArrayList<>();
if (optVpnInstance.isPresent()) {
usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker,optVpnInstance.get().getVpnId(),
nextHopsRemoved.removeAll(FibHelper.getNextHopListFromRoutePaths(update));
WriteTransaction writeOperTxn = dataBroker.newWriteOnlyTransaction();
nextHopsRemoved.parallelStream()
- .forEach(nextHopRemoved -> FibUtil.updateUsedRdAndVpnToExtraRoute(
- writeOperTxn, dataBroker, nextHopRemoved, rd,
- update.getDestPrefix()));
+ .forEach(nextHopRemoved -> fibUtil.updateUsedRdAndVpnToExtraRoute(
+ writeOperTxn, nextHopRemoved, rd, update.getDestPrefix()));
CheckedFuture<Void, TransactionCommitFailedException> operFuture = writeOperTxn.submit();
try {
operFuture.get();
final VrfTablesKey vrfTableKey = vrfEntryIid.firstKeyOf(VrfTables.class);
List<SubTransaction> txnObjects = new ArrayList<>();
final VpnInstanceOpDataEntry vpnInstance =
- FibUtil.getVpnInstance(dataBroker, vrfTableKey.getRouteDistinguisher());
+ fibUtil.getVpnInstance(vrfTableKey.getRouteDistinguisher());
Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + vrfTableKey.getRouteDistinguisher());
Preconditions.checkNotNull(vpnInstance.getVpnId(), "Vpn Instance with rd " + vpnInstance.getVrfId()
+ " has null vpnId!");
if (vrfEntry.getParentVpnRd() != null
&& FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
// This block MUST BE HIT only for PNF (Physical Network Function) FIB Entries.
- VpnInstanceOpDataEntry parentVpnInstance = FibUtil.getVpnInstance(dataBroker, vrfEntry.getParentVpnRd());
+ VpnInstanceOpDataEntry parentVpnInstance = fibUtil.getVpnInstance(vrfEntry.getParentVpnRd());
vpnToDpnList = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList() :
vpnInstance.getVpnToDpnList();
LOG.info("createFibEntries: Processing creation of PNF FIB entry with rd {} prefix {}",
}, DJC_MAX_RETRIES);
}
- Optional<String> optVpnUuid = FibUtil.getVpnNameFromRd(dataBroker, rd);
+ Optional<String> optVpnUuid = fibUtil.getVpnNameFromRd(rd);
if (optVpnUuid.isPresent()) {
String vpnUuid = optVpnUuid.get();
InterVpnLinkDataComposite interVpnLink = InterVpnLinkCache.getInterVpnLinkByVpnId(vpnUuid).orNull();
if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.SELF_IMPORTED) {
Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional =
- FibUtil.getVpnInstanceOpData(dataBroker, rd);
+ fibUtil.getVpnInstanceOpData(rd);
if (vpnInstanceOpDataEntryOptional.isPresent()) {
String vpnInstanceName = vpnInstanceOpDataEntryOptional.get().getVpnInstanceName();
if (!lri.getVpnInstanceList().contains(vpnInstanceName)) {
private List<BigInteger> createLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry) {
List<BigInteger> returnLocalDpnId = new ArrayList<>();
String localNextHopIP = vrfEntry.getDestPrefix();
- Prefixes localNextHopInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, localNextHopIP);
- String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnId);
+ Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, localNextHopIP);
+ String vpnName = fibUtil.getVpnNameFromId(vpnId);
if (localNextHopInfo == null) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, localNextHopIP);
List<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker,
} else {
ipPrefix = vpnExtraRoute.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
}
- Prefixes localNextHopInfoLocal = FibUtil.getPrefixToInterface(dataBroker,
- vpnId, ipPrefix);
+ Prefixes localNextHopInfoLocal = fibUtil.getPrefixToInterface(vpnId,
+ ipPrefix);
if (localNextHopInfoLocal != null) {
localNextHopSeen = true;
BigInteger dpnId =
LabelRouteInfo lri = getLabelRouteInfo(label);
if (isPrefixAndNextHopPresentInLri(localNextHopIP, nextHopAddressList, lri)) {
Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional =
- FibUtil.getVpnInstanceOpData(dataBroker, rd);
+ fibUtil.getVpnInstanceOpData(rd);
if (vpnInstanceOpDataEntryOptional.isPresent()) {
String vpnInstanceName = vpnInstanceOpDataEntryOptional.get().getVpnInstanceName();
if (lri.getVpnInstanceList().contains(vpnInstanceName)) {
final Long vpnId, final String rd,
final VrfEntry vrfEntry, Long parentVpnId,
Routes routes, List<Routes> vpnExtraRoutes) {
- String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnId);
+ String vpnName = fibUtil.getVpnNameFromId(vpnId);
if (localNextHopInfo != null) {
long groupId;
long localGroupId;
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions,
NwConstants.ADD_FLOW, tx, null);
- if (!FibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(dataBroker,
- localNextHopInfo.getSubnetId(), vpnName, rd)) {
+ if (!fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(localNextHopInfo.getSubnetId(),
+ vpnName, rd)) {
optLabel.ifPresent(label -> {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
LOG.debug("Installing LFIB and tunnel table entry on dpn {} for interface {} with label "
public List<BigInteger> deleteLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry) {
List<BigInteger> returnLocalDpnId = new ArrayList<>();
- Prefixes localNextHopInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, vrfEntry.getDestPrefix());
- String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnId);
+ Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
+ String vpnName = fibUtil.getVpnNameFromId(vpnId);
boolean isExtraroute = false;
if (localNextHopInfo == null) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
} else {
ipPrefix = extraRoute.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
}
- localNextHopInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, ipPrefix);
+ localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
if (localNextHopInfo != null) {
String localNextHopIP = localNextHopInfo.getIpAddress();
BigInteger dpnId = checkDeleteLocalFibEntry(localNextHopInfo, localNextHopIP,
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, null,
NwConstants.DEL_FLOW, tx, null);
- if (!FibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(dataBroker,
- localNextHopInfo.getSubnetId(), vpnId, rd)) {
+ if (!fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(localNextHopInfo.getSubnetId(),
+ vpnId, rd)) {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
FibUtil.getLabelFromRoutePaths(vrfEntry).ifPresent(label -> {
makeLFibTableEntry(dpnId, label, null /* instructions */, DEFAULT_FIB_FLOW_PRIORITY,
tx = dataBroker.newWriteOnlyTransaction();
}
- String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnId);
+ String vpnName = fibUtil.getVpnNameFromId(vpnId);
LOG.debug("createremotefibentry: adding route {} for rd {} on remoteDpnId {}",
vrfEntry.getDestPrefix(), rd, remoteDpnId);
java.util.Optional<Routes> routes = vpnExtraRoutes
.stream()
.filter(route -> {
- Prefixes prefixToInterface = FibUtil.getPrefixToInterface(dataBroker,
- vpnId, FibUtil.getIpPrefix(route.getNexthopIpList().get(0)));
+ Prefixes prefixToInterface = fibUtil.getPrefixToInterface(vpnId,
+ fibUtil.getIpPrefix(route.getNexthopIpList().get(0)));
if (prefixToInterface == null) {
return false;
}
- vpn interface op DS
*/
LOG.debug("Cleanup of prefix {} in VPN {}", vrfEntry.getDestPrefix(), vpnId);
- Prefixes prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, vrfEntry.getDestPrefix());
+ Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
if (prefixInfo == null) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
String usedRd = usedRds.isEmpty() ? primaryRd : usedRds.get(0);
} else {
ipPrefix = nextHopIp + NwConstants.IPV6PREFIX;
}
- prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, ipPrefix);
+ prefixInfo = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
checkCleanUpOpDataForFib(prefixInfo, vpnId, primaryRd, vrfEntry, extraRoute);
}
}
if (lri != null && lri.getPrefix().equals(vrfEntry.getDestPrefix())
&& nextHopAddressList.contains(lri.getNextHopIpList().get(0))) {
Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional =
- FibUtil.getVpnInstanceOpData(dataBroker, rd);
+ fibUtil.getVpnInstanceOpData(rd);
String vpnInstanceName = "";
if (vpnInstanceOpDataEntryOptional.isPresent()) {
vpnInstanceName = vpnInstanceOpDataEntryOptional.get().getVpnInstanceName();
boolean lriRemoved = deleteLabelRouteInfo(lri, vpnInstanceName, writeOperTxn);
if (lriRemoved) {
String parentRd = lri.getParentVpnRd();
- FibUtil.releaseId(idManager, FibConstants.VPN_IDPOOL_NAME,
- FibUtil.getNextHopLabelKey(parentRd, vrfEntry.getDestPrefix()));
+ fibUtil.releaseId(FibConstants.VPN_IDPOOL_NAME, FibUtil.getNextHopLabelKey(
+ parentRd, vrfEntry.getDestPrefix()));
}
} else {
- FibUtil.releaseId(idManager, FibConstants.VPN_IDPOOL_NAME,
- FibUtil.getNextHopLabelKey(rd, vrfEntry.getDestPrefix()));
+ fibUtil.releaseId(FibConstants.VPN_IDPOOL_NAME, FibUtil.getNextHopLabelKey(
+ rd, vrfEntry.getDestPrefix()));
}
}
});
if (Prefixes.PrefixCue.PhysNetFunc.equals(prefixInfo.getPrefixCue())) {
/*Get vpnId for rd = networkId since op vpnInterface will be pointing to rd = networkId
* */
- Optional<String> vpnName = FibUtil.getVpnNameFromRd(dataBroker, vrfEntry.getParentVpnRd());
+ Optional<String> vpnName = fibUtil.getVpnNameFromRd(vrfEntry.getParentVpnRd());
if (vpnName.isPresent()) {
- vpnId = FibUtil.getVpnId(dataBroker, vpnName.get());
+ vpnId = fibUtil.getVpnId(vpnName.get());
}
}
if (optvpnInterface.isPresent()) {
- long associatedVpnId = FibUtil.getVpnId(dataBroker, optvpnInterface.get().getVpnInstanceName());
+ long associatedVpnId = fibUtil.getVpnId(optvpnInterface.get().getVpnInstanceName());
if (vpnId != associatedVpnId) {
LOG.warn("Prefixes {} are associated with different vpn instance with id : {} rather than {}",
vrfEntry.getDestPrefix(), associatedVpnId, vpnId);
}
}
if (extraRoute != null) {
- Optional<String> optVpnName = FibUtil.getVpnNameFromRd(dataBroker, rd);
+ Optional<String> optVpnName = fibUtil.getVpnNameFromRd(rd);
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
//Only one used Rd present in case of removal event
String usedRd = usedRds.get(0);
private void deleteFibEntries(final InstanceIdentifier<VrfEntry> identifier, final VrfEntry vrfEntry) {
final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
final String rd = vrfTableKey.getRouteDistinguisher();
- final VpnInstanceOpDataEntry vpnInstance =
- FibUtil.getVpnInstance(dataBroker, vrfTableKey.getRouteDistinguisher());
+ final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(vrfTableKey.getRouteDistinguisher());
if (vpnInstance == null) {
LOG.error("VPN Instance for rd {} is not available from VPN Op Instance Datastore", rd);
return;
if (vrfEntry.getParentVpnRd() != null
&& FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
// This block MUST BE HIT only for PNF (Physical Network Function) FIB Entries.
- VpnInstanceOpDataEntry parentVpnInstance = FibUtil.getVpnInstance(dataBroker, vrfEntry.getParentVpnRd());
+ VpnInstanceOpDataEntry parentVpnInstance = fibUtil.getVpnInstance(vrfEntry.getParentVpnRd());
vpnToDpnList = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList() :
vpnInstance.getVpnToDpnList();
LOG.info("deleteFibEntries: Processing deletion of PNF FIB entry with rd {} prefix {}",
SubnetRoute subnetRoute = vrfEntry.getAugmentation(SubnetRoute.class);
final java.util.Optional<Long> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
- String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnInstance.getVpnId());
+ String vpnName = fibUtil.getVpnNameFromId(vpnInstance.getVpnId());
if (subnetRoute != null) {
long elanTag = subnetRoute.getElantag();
LOG.trace("SUBNETROUTE: deleteFibEntries: SubnetRoute augmented vrfentry found for rd {} prefix {}"
LabelRouteInfo lri = getLabelRouteInfo(label);
if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopAddressList, lri)) {
Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional =
- FibUtil.getVpnInstanceOpData(dataBroker, rd);
+ fibUtil.getVpnInstanceOpData(rd);
String vpnInstanceName = "";
if (vpnInstanceOpDataEntryOptional.isPresent()) {
vpnInstanceName = vpnInstanceOpDataEntryOptional.get().getVpnInstanceName();
boolean lriRemoved = this.deleteLabelRouteInfo(lri, vpnInstanceName, null);
if (lriRemoved) {
String parentRd = lri.getParentVpnRd();
- FibUtil.releaseId(idManager, FibConstants.VPN_IDPOOL_NAME,
- FibUtil.getNextHopLabelKey(parentRd, vrfEntry.getDestPrefix()));
+ fibUtil.releaseId(FibConstants.VPN_IDPOOL_NAME, FibUtil.getNextHopLabelKey(
+ parentRd, vrfEntry.getDestPrefix()));
LOG.trace("SUBNETROUTE: deleteFibEntries: Released subnetroute label {} for rd {} prefix {}"
+ " as labelRouteInfo cleared", label, rd, vrfEntry.getDestPrefix());
}
} else {
- FibUtil.releaseId(idManager, FibConstants.VPN_IDPOOL_NAME,
- FibUtil.getNextHopLabelKey(rd, vrfEntry.getDestPrefix()));
+ fibUtil.releaseId(FibConstants.VPN_IDPOOL_NAME, FibUtil.getNextHopLabelKey(
+ rd, vrfEntry.getDestPrefix()));
LOG.trace("SUBNETROUTE: deleteFibEntries: Released subnetroute label {} for rd {} prefix {}",
label, rd, vrfEntry.getDestPrefix());
}
// Remove all fib entries configured due to interVpnLink, when nexthop is the opposite endPoint
// of the interVpnLink.
- Optional<String> optVpnUuid = FibUtil.getVpnNameFromRd(this.dataBroker, rd);
+ Optional<String> optVpnUuid = fibUtil.getVpnNameFromRd(rd);
if (optVpnUuid.isPresent()) {
String vpnUuid = optVpnUuid.get();
FibUtil.getFirstNextHopAddress(vrfEntry).ifPresent(routeNexthop -> {
final FutureCallback<List<Void>> callback) {
LOG.trace("New dpn {} for vpn {} : populateFibOnNewDpn", dpnId, rd);
InstanceIdentifier<VrfTables> id = buildVrfId(rd);
- final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstance(dataBroker, rd);
+ final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
List<SubTransaction> txnObjects = new ArrayList<>();
if (!vrfTable.isPresent()) {
LOG.trace("populateExternalRoutesOnDpn : dpn {}, vpn {}, rd {}, localNexthopIp {} , remoteNextHopIp {} ",
dpnId, vpnId, rd, localNextHopIp, remoteNextHopIp);
InstanceIdentifier<VrfTables> id = buildVrfId(rd);
- final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstance(dataBroker, rd);
+ final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
List<SubTransaction> txnObjects = new ArrayList<>();
final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
if (vrfTable.isPresent()) {
final String destPrefix,
final String destTepIp,
final long label) {
- final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstance(dataBroker, rd);
+ final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
if (vpnInstance == null) {
LOG.error("VpnInstance for rd {} not present for prefix {}", rd, destPrefix);
Optional<Routes> extraRouteOptional = Optional.absent();
if (usedRds.size() != 0) {
extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker,
- FibUtil.getVpnNameFromId(dataBroker, vpnInstance.getVpnId()),
+ fibUtil.getVpnNameFromId(vpnInstance.getVpnId()),
usedRds.get(0), vrfEntry.getDestPrefix());
}
baseVrfEntryHandler.deleteRemoteRoute(null, localDpnId, vpnId, vrfTablesKey, modVrfEntry,
final FutureCallback<List<Void>> callback) {
LOG.trace("cleanUpDpnForVpn: Remove dpn {} for vpn {} : cleanUpDpnForVpn", dpnId, rd);
InstanceIdentifier<VrfTables> id = buildVrfId(rd);
- final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstance(dataBroker, rd);
+ final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
List<SubTransaction> txnObjects = new ArrayList<>();
final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, dpnId),
// to which prefix is attached at this point
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnInstance.getVpnId(),
vrfEntry.getDestPrefix());
- String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnInstance.getVpnId());
+ String vpnName = fibUtil.getVpnNameFromId(vpnInstance.getVpnId());
Optional<Routes> extraRouteOptional;
//Is this fib route an extra route? If yes, get the nexthop which would be
//an adjacency in the vpn
+ " localNexthopIp {} , remoteNexhtHopIp {}",
dpnId, vpnId, rd, localNextHopIp, remoteNextHopIp);
InstanceIdentifier<VrfTables> id = buildVrfId(rd);
- final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstance(dataBroker, rd);
+ final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
List<SubTransaction> txnObjects = new ArrayList<>();
final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
if (vrfTable.isPresent()) {
return true;
}
- Prefixes prefix = FibUtil.getPrefixToInterface(dataBroker, vpnId, vrfEntry.getDestPrefix());
+ Prefixes prefix = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
if (prefix != null) {
BigInteger prefixDpnId = prefix.getDpnId();
if (dpnId.equals(prefixDpnId)) {