use of org.opendaylight.genius.mdsalutil.actions.ActionGroup in project netvirt by opendaylight.
the class ExternalRoutersListener method buildSnatFlowEntity.
private FlowEntity buildSnatFlowEntity(BigInteger dpId, String routerName, long routerId, long groupId) {
LOG.debug("buildSnatFlowEntity : called for dpId {}, routerName {} and groupId {}", dpId, routerName, groupId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
List<ActionInfo> actionsInfo = new ArrayList<>();
long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId, routerName);
actionsInfo.add(new ActionSetFieldTunnelId(BigInteger.valueOf(tunnelId)));
LOG.debug("buildSnatFlowEntity : Setting the tunnel to the list of action infos {}", actionsInfo);
actionsInfo.add(new ActionGroup(groupId));
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfo));
String flowRef = getFlowRefSnat(dpId, NwConstants.PSNAT_TABLE, routerName);
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
LOG.debug("buildSnatFlowEntity : Returning SNAT Flow Entity {}", flowEntity);
return flowEntity;
}
use of org.opendaylight.genius.mdsalutil.actions.ActionGroup in project netvirt by opendaylight.
the class NexthopManager method getBucketsForLocalNexthop.
private List<BucketInfo> getBucketsForLocalNexthop(Long vpnId, BigInteger dpnId, VrfEntry vrfEntry, Routes routes) {
List<BucketInfo> listBucketInfo = new CopyOnWriteArrayList<>();
routes.getNexthopIpList().parallelStream().forEach(nextHopIp -> {
String localNextHopIP;
if (isIpv4Address(nextHopIp)) {
localNextHopIP = nextHopIp + NwConstants.IPV4PREFIX;
} else {
localNextHopIP = nextHopIp + NwConstants.IPV6PREFIX;
}
Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, localNextHopIP);
if (localNextHopInfo != null) {
long groupId = getLocalNextHopGroup(vpnId, localNextHopIP);
if (groupId == FibConstants.INVALID_GROUP_ID) {
LOG.error("Unable to allocate groupId for vpnId {} , prefix {} , interface {}", vpnId, vrfEntry.getDestPrefix(), localNextHopInfo.getVpnInterfaceName());
return;
}
List<ActionInfo> actionsInfos = Collections.singletonList(new ActionGroup(groupId));
BucketInfo bucket = new BucketInfo(actionsInfos);
bucket.setWeight(1);
listBucketInfo.add(bucket);
}
});
LOG.trace("LOCAL: listbucket {}, vpnId {}, dpnId {}, routes {}", listBucketInfo, vpnId, dpnId, routes);
return listBucketInfo;
}
use of org.opendaylight.genius.mdsalutil.actions.ActionGroup in project netvirt by opendaylight.
the class VrfEntryListener method checkCreateLocalFibEntry.
private BigInteger checkCreateLocalFibEntry(Prefixes localNextHopInfo, String localNextHopIP, final Long vpnId, final String rd, final VrfEntry vrfEntry, Long parentVpnId, Routes routes, List<Routes> vpnExtraRoutes) {
String vpnName = fibUtil.getVpnNameFromId(vpnId);
if (localNextHopInfo != null) {
long groupId;
long localGroupId;
final BigInteger dpnId = localNextHopInfo.getDpnId();
if (Prefixes.PrefixCue.Nat.equals(localNextHopInfo.getPrefixCue())) {
LOG.debug("checkCreateLocalFibEntry: NAT Prefix {} with vpnId {} rd {}. Skip local dpn {}" + " FIB processing", vrfEntry.getDestPrefix(), vpnId, rd, dpnId);
return dpnId;
}
if (Prefixes.PrefixCue.PhysNetFunc.equals(localNextHopInfo.getPrefixCue())) {
LOG.debug("checkCreateLocalFibEntry: PNF Prefix {} with vpnId {} rd {}. Skip local dpn {}" + " FIB processing", vrfEntry.getDestPrefix(), vpnId, rd, dpnId);
return dpnId;
}
String jobKey = FibUtil.getCreateLocalNextHopJobKey(vpnId, dpnId, vrfEntry.getDestPrefix());
String interfaceName = localNextHopInfo.getVpnInterfaceName();
String prefix = vrfEntry.getDestPrefix();
String gwMacAddress = vrfEntry.getGatewayMacAddress();
// to avoid loadbalancing the discovered routes
if (vpnExtraRoutes != null) {
if (isIpv4Address(routes.getNexthopIpList().get(0))) {
localNextHopIP = routes.getNexthopIpList().get(0) + NwConstants.IPV4PREFIX;
} else {
localNextHopIP = routes.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
}
if (vpnExtraRoutes.size() > 1) {
groupId = nextHopManager.createNextHopGroups(parentVpnId, rd, dpnId, vrfEntry, routes, vpnExtraRoutes);
localGroupId = nextHopManager.getLocalNextHopGroup(parentVpnId, localNextHopIP);
} else if (routes.getNexthopIpList().size() > 1) {
groupId = nextHopManager.createNextHopGroups(parentVpnId, rd, dpnId, vrfEntry, routes, vpnExtraRoutes);
localGroupId = groupId;
} else {
groupId = nextHopManager.getLocalNextHopGroup(parentVpnId, localNextHopIP);
localGroupId = groupId;
}
} else {
groupId = nextHopManager.createLocalNextHop(parentVpnId, dpnId, interfaceName, localNextHopIP, prefix, gwMacAddress, jobKey);
localGroupId = groupId;
}
if (groupId == FibConstants.INVALID_GROUP_ID) {
LOG.error("Unable to create Group for local prefix {} on rd {} for vpninterface {} on Node {}", prefix, rd, interfaceName, dpnId.toString());
return BigInteger.ZERO;
}
final List<InstructionInfo> instructions = Collections.singletonList(new InstructionApplyActions(Collections.singletonList(new ActionGroup(groupId))));
final List<InstructionInfo> lfibinstructions = Collections.singletonList(new InstructionApplyActions(Arrays.asList(new ActionPopMpls(), new ActionGroup(groupId))));
java.util.Optional<Long> optLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
jobCoordinator.enqueueJob(jobKey, () -> {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx, null);
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 " + "{}, rd {}, prefix {}, nexthop {}", dpnId, localNextHopInfo.getVpnInterfaceName(), optLabel, rd, vrfEntry.getDestPrefix(), nextHopAddressList);
makeLFibTableEntry(dpnId, label, lfibinstructions, DEFAULT_FIB_FLOW_PRIORITY, NwConstants.ADD_FLOW, tx);
// then it should be pointing to one of the local group in order to avoid looping.
if (vrfEntry.getRoutePaths().size() == 1) {
makeTunnelTableEntry(dpnId, label, groupId, tx);
} else {
makeTunnelTableEntry(dpnId, label, localGroupId, tx);
}
} else {
LOG.debug("Route with rd {} prefix {} label {} nexthop {} for vpn {} is an imported " + "route. LFib and Terminating table entries will not be created.", rd, vrfEntry.getDestPrefix(), optLabel, nextHopAddressList, vpnId);
}
});
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(tx.submit());
return futures;
});
return dpnId;
}
LOG.error("localNextHopInfo received is null for prefix {} on rd {} on vpn {}", vrfEntry.getDestPrefix(), rd, vpnName);
return BigInteger.ZERO;
}
use of org.opendaylight.genius.mdsalutil.actions.ActionGroup in project netvirt by opendaylight.
the class VrfEntryListener method makeTunnelTableEntry.
void makeTunnelTableEntry(BigInteger dpId, long label, long groupId, /*String egressInterfaceName*/
WriteTransaction tx) {
List<ActionInfo> actionsInfos = Collections.singletonList(new ActionGroup(groupId));
createTerminatingServiceActions(dpId, (int) label, actionsInfos, tx);
LOG.debug("Terminating service Entry for dpID {} : label : {} egress : {} installed successfully", dpId, label, groupId);
}
use of org.opendaylight.genius.mdsalutil.actions.ActionGroup in project netvirt by opendaylight.
the class EvpnVrfEntryHandler method checkCreateLocalEvpnFlows.
private BigInteger checkCreateLocalEvpnFlows(Prefixes localNextHopInfo, String localNextHopIP, final Long vpnId, final String rd, final VrfEntry vrfEntry) {
final BigInteger dpnId = localNextHopInfo.getDpnId();
String jobKey = "FIB-" + vpnId.toString() + "-" + dpnId.toString() + "-" + vrfEntry.getDestPrefix();
final long groupId = nexthopManager.createLocalNextHop(vpnId, dpnId, localNextHopInfo.getVpnInterfaceName(), localNextHopIP, vrfEntry.getDestPrefix(), vrfEntry.getGatewayMacAddress(), jobKey);
LOG.debug("LocalNextHopGroup {} created/reused for prefix {} rd {} evi {} route-paths {}", groupId, vrfEntry.getDestPrefix(), rd, vrfEntry.getL3vni(), vrfEntry.getRoutePaths());
final List<InstructionInfo> instructions = Collections.singletonList(new InstructionApplyActions(Collections.singletonList(new ActionGroup(groupId))));
jobCoordinator.enqueueJob("FIB-" + vpnId.toString() + "-" + dpnId.toString() + "-" + vrfEntry.getDestPrefix(), () -> {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx, null);
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(tx.submit());
return futures;
});
return dpnId;
}
Aggregations