use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.NextHop in project netvirt by opendaylight.
the class VrfEntryListener method deleteLocalFibEntry.
public List<BigInteger> deleteLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry) {
List<BigInteger> returnLocalDpnId = new ArrayList<>();
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());
if (usedRds.size() > 1) {
LOG.error("The extra route prefix {} is still present in some DPNs in vpn {} on rd {}", vrfEntry.getDestPrefix(), vpnName, rd);
return returnLocalDpnId;
}
// Is this fib route an extra route? If yes, get the nexthop which would be an adjacency
// in the vpn
Optional<Routes> extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, vpnName, rd, vrfEntry.getDestPrefix());
if (extraRouteOptional.isPresent()) {
isExtraroute = true;
Routes extraRoute = extraRouteOptional.get();
String ipPrefix;
if (isIpv4Address(extraRoute.getNexthopIpList().get(0))) {
ipPrefix = extraRoute.getNexthopIpList().get(0) + NwConstants.IPV4PREFIX;
} else {
ipPrefix = extraRoute.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
}
localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
if (localNextHopInfo != null) {
String localNextHopIP = localNextHopInfo.getIpAddress();
BigInteger dpnId = checkDeleteLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, isExtraroute, vpnId);
if (!dpnId.equals(BigInteger.ZERO)) {
LOG.trace("Deleting ECMP group for prefix {}, dpn {}", vrfEntry.getDestPrefix(), dpnId);
nextHopManager.setupLoadBalancingNextHop(vpnId, dpnId, vrfEntry.getDestPrefix(), /*listBucketInfo*/
Collections.emptyList(), /*remove*/
false);
returnLocalDpnId.add(dpnId);
}
} else {
LOG.error("localNextHopInfo unavailable while deleting prefix {} with rds {}, primary rd {} in " + "vpn {}", vrfEntry.getDestPrefix(), usedRds, rd, vpnName);
}
}
if (localNextHopInfo == null) {
/* Imported VRF entry */
java.util.Optional<Long> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
if (optionalLabel.isPresent()) {
Long label = optionalLabel.get();
List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
LabelRouteInfo lri = getLabelRouteInfo(label);
if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopAddressList, lri)) {
PrefixesBuilder prefixBuilder = new PrefixesBuilder();
prefixBuilder.setDpnId(lri.getDpnId());
BigInteger dpnId = checkDeleteLocalFibEntry(prefixBuilder.build(), nextHopAddressList.get(0), vpnId, rd, vrfEntry, isExtraroute, lri.getParentVpnid());
if (!dpnId.equals(BigInteger.ZERO)) {
returnLocalDpnId.add(dpnId);
}
}
}
}
} else {
LOG.debug("Obtained prefix to interface for rd {} prefix {}", rd, vrfEntry.getDestPrefix());
String localNextHopIP = localNextHopInfo.getIpAddress();
BigInteger dpnId = checkDeleteLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, isExtraroute, vpnId);
if (!dpnId.equals(BigInteger.ZERO)) {
returnLocalDpnId.add(dpnId);
}
}
return returnLocalDpnId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.NextHop in project netvirt by opendaylight.
the class VrfEntryListener method removeInterVPNLinkRouteFlows.
public void removeInterVPNLinkRouteFlows(final InterVpnLinkDataComposite interVpnLink, final String vpnName, final VrfEntry vrfEntry) {
Preconditions.checkArgument(vrfEntry.getRoutePaths() != null && vrfEntry.getRoutePaths().size() == 1);
String interVpnLinkName = interVpnLink.getInterVpnLinkName();
List<BigInteger> targetDpns = interVpnLink.getEndpointDpnsByVpnName(vpnName);
if (targetDpns.isEmpty()) {
LOG.warn("Could not find DPNs for VPN {} in InterVpnLink {}", vpnName, interVpnLinkName);
return;
}
java.util.Optional<String> optNextHop = FibUtil.getFirstNextHopAddress(vrfEntry);
java.util.Optional<Long> optLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
// delete from FIB
//
optNextHop.ifPresent(nextHop -> {
String flowRef = getInterVpnFibFlowRef(interVpnLinkName, vrfEntry.getDestPrefix(), nextHop);
FlowKey flowKey = new FlowKey(new FlowId(flowRef));
Flow flow = new FlowBuilder().setKey(flowKey).setId(new FlowId(flowRef)).setTableId(NwConstants.L3_FIB_TABLE).setFlowName(flowRef).build();
LOG.trace("Removing flow in FIB table for interVpnLink {} key {}", interVpnLinkName, flowRef);
for (BigInteger dpId : targetDpns) {
LOG.debug("Removing flow: VrfEntry=[prefix={} nexthop={}] dpn {} for InterVpnLink {} in FIB", vrfEntry.getDestPrefix(), nextHop, dpId, interVpnLinkName);
mdsalManager.removeFlow(dpId, flow);
}
});
// delete from LFIB
//
optLabel.ifPresent(label -> {
LOG.trace("Removing flow in FIB table for interVpnLink {}", interVpnLinkName);
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
for (BigInteger dpId : targetDpns) {
LOG.debug("Removing flow: VrfEntry=[prefix={} label={}] dpn {} for InterVpnLink {} in LFIB", vrfEntry.getDestPrefix(), label, dpId, interVpnLinkName);
makeLFibTableEntry(dpId, label, /*instructions*/
null, LFIB_INTERVPN_PRIORITY, NwConstants.DEL_FLOW, tx);
}
tx.submit();
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.NextHop in project netvirt by opendaylight.
the class BaseVrfEntryHandler method addTunnelInterfaceActions.
protected void addTunnelInterfaceActions(AdjacencyResult adjacencyResult, long vpnId, VrfEntry vrfEntry, List<ActionInfo> actionInfos, String rd) {
Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper.getTunnelType(nextHopManager.getInterfaceManager(), adjacencyResult.getInterfaceName());
if (tunnelType == null) {
LOG.debug("Tunnel type not found for vrfEntry {}", vrfEntry);
return;
}
// TODO - For now have added routePath into adjacencyResult so that we know for which
// routePath this result is built for. If this is not possible construct a map which does
// the same.
String nextHopIp = adjacencyResult.getNextHopIp();
java.util.Optional<Long> optionalLabel = FibUtil.getLabelForNextHop(vrfEntry, nextHopIp);
if (!optionalLabel.isPresent()) {
LOG.warn("NextHopIp {} not found in vrfEntry {}", nextHopIp, vrfEntry);
return;
}
long label = optionalLabel.get();
BigInteger tunnelId = null;
Prefixes prefixInfo = null;
// revisit
if (tunnelType.equals(TunnelTypeVxlan.class)) {
prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
// For extra route, the prefixInfo is fetched from the primary adjacency
if (prefixInfo == null) {
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())) {
if (vrfEntry.getL3vni() != null && vrfEntry.getL3vni() != 0) {
tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
}
} else {
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());
return;
}
tunnelId = BigInteger.valueOf(optionalVni.get());
} else {
tunnelId = BigInteger.valueOf(label);
}
}
} else {
tunnelId = BigInteger.valueOf(label);
}
LOG.debug("adding set tunnel id action for label {}", label);
actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
addRewriteDstMacAction(vpnId, vrfEntry, prefixInfo, actionInfos);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.NextHop in project netvirt by opendaylight.
the class EvpnVrfEntryHandler method createLocalEvpnFlows.
private List<BigInteger> createLocalEvpnFlows(long vpnId, String rd, VrfEntry vrfEntry, Prefixes localNextHopInfo) {
List<BigInteger> returnLocalDpnId = new ArrayList<>();
String localNextHopIP = vrfEntry.getDestPrefix();
if (localNextHopInfo == null) {
// Handle extra routes and imported routes
Routes extraRoute = getVpnToExtraroute(vpnId, rd, vrfEntry.getDestPrefix());
if (extraRoute != null) {
for (String nextHopIp : extraRoute.getNexthopIpList()) {
LOG.info("NextHop IP for destination {} is {}", vrfEntry.getDestPrefix(), nextHopIp);
if (nextHopIp != null) {
localNextHopInfo = getFibUtil().getPrefixToInterface(vpnId, nextHopIp + "/32");
if (localNextHopInfo != null) {
localNextHopIP = nextHopIp + "/32";
BigInteger dpnId = checkCreateLocalEvpnFlows(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry);
returnLocalDpnId.add(dpnId);
}
}
}
}
} else {
LOG.info("Creating local EVPN flows for prefix {} rd {} route-paths {} evi {}.", vrfEntry.getDestPrefix(), rd, vrfEntry.getRoutePaths(), vrfEntry.getL3vni());
BigInteger dpnId = checkCreateLocalEvpnFlows(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry);
returnLocalDpnId.add(dpnId);
}
return returnLocalDpnId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.NextHop in project netvirt by opendaylight.
the class VpnUtil method findVrfEntriesByNexthop.
public static List<VrfEntry> findVrfEntriesByNexthop(DataBroker broker, String rd, String nexthop) {
InstanceIdentifier<VrfTables> vpnVrfTableIid = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).build();
Optional<VrfTables> vrfTablesOpc = read(broker, LogicalDatastoreType.CONFIGURATION, vpnVrfTableIid);
List<VrfEntry> matches = new ArrayList<>();
if (vrfTablesOpc.isPresent()) {
VrfTables vrfTables = vrfTablesOpc.get();
for (VrfEntry vrfEntry : vrfTables.getVrfEntry()) {
vrfEntry.getRoutePaths().stream().filter(routePath -> routePath.getNexthopAddress() != null && routePath.getNexthopAddress().equals(nexthop)).findFirst().ifPresent(routePath -> matches.add(vrfEntry));
}
}
return matches;
}
Aggregations