use of org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions in project netvirt by opendaylight.
the class VxlanGreConntrackBasedSnatService method createOutboundTblTrackEntryForVxlanGre.
protected void createOutboundTblTrackEntryForVxlanGre(BigInteger dpnId, Long routerId, Long extNetVpnId, int addOrRemove) {
LOG.info("createOutboundTblTrackEntryForVxlanGre: Install Outbound tracking table flow on dpId {} for " + "routerId {}", dpnId, routerId);
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new NxMatchCtState(SNAT_CT_STATE, SNAT_CT_STATE_MASK));
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
if (addOrRemove == NwConstants.ADD_FLOW) {
ActionSetFieldMeta actionSetFieldMeta = new ActionSetFieldMeta(MetaDataUtil.getVpnIdMetadata(extNetVpnId));
listActionInfo.add(actionSetFieldMeta);
}
ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
listActionInfo.add(new ActionNxResubmit(NwConstants.NAPT_PFIB_TABLE));
instructionInfo.add(new InstructionApplyActions(listActionInfo));
String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId);
flowRef += "trkest";
syncFlow(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef, NatConstants.SNAT_TRK_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructionInfo, addOrRemove);
}
use of org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions in project netvirt by opendaylight.
the class VxlanGreConntrackBasedSnatService method installNaptPfibFlowForVxlanGre.
protected void installNaptPfibFlowForVxlanGre(Routers routers, BigInteger dpnId, Long extNetVpnId, int addOrRemove) {
LOG.info("installNaptPfibFlowForVxlanGre: Install Napt preFibFlow on dpId {} with matching extNetVpnId {} " + "for router {}", dpnId, extNetVpnId, routers.getRouterName());
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
if (addOrRemove == NwConstants.ADD_FLOW) {
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extNetVpnId), MetaDataUtil.METADATA_MASK_VRFID));
}
ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
ArrayList<InstructionInfo> instructions = new ArrayList<>();
listActionInfo.add(new ActionNxLoadInPort(BigInteger.ZERO));
listActionInfo.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
instructions.add(new InstructionApplyActions(listActionInfo));
String flowRef = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, extNetVpnId);
syncFlow(dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef, NatConstants.SNAT_TRK_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
use of org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions in project netvirt by opendaylight.
the class VxlanGreConntrackBasedSnatService method installTerminatingServiceTblEntryForVxlanGre.
protected void installTerminatingServiceTblEntryForVxlanGre(BigInteger dpnId, String routerName, Long routerId, int elanId, int addOrRemove) {
LOG.info("installTerminatingServiceTblEntryForVxlanGre : creating entry for" + "Terminating Service Table for switch {}, routerId {}", dpnId, routerId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
BigInteger tunnelId = BigInteger.valueOf(routerId);
if (elanManager.isOpenStackVniSemanticsEnforced()) {
tunnelId = NatOverVxlanUtil.getRouterVni(idManager, routerName, routerId);
}
matches.add(new MatchTunnelId(tunnelId));
List<ActionInfo> actionsInfos = new ArrayList<>();
List<NxCtAction> ctActionsList = new ArrayList<>();
NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0, null, null, 0, 0);
ctActionsList.add(nxCtAction);
ActionNxConntrack actionNxConntrack = new ActionNxConntrack(0, 0, elanId, NwConstants.OUTBOUND_NAPT_TABLE, ctActionsList);
ActionSetFieldMeta actionSetFieldMeta = new ActionSetFieldMeta(MetaDataUtil.getVpnIdMetadata(routerId.longValue()));
actionsInfos.add(actionSetFieldMeta);
actionsInfos.add(actionNxConntrack);
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfos));
String flowRef = getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId.longValue());
syncFlow(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef, NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
use of org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions in project netvirt by opendaylight.
the class Ipv6ServiceUtils method installIcmpv6NsPuntFlow.
public void installIcmpv6NsPuntFlow(short tableId, BigInteger dpId, Long elanTag, String ipv6Address, int addOrRemove) {
List<MatchInfo> neighborSolicitationMatch = getIcmpv6NSMatch(elanTag, ipv6Address);
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
actionsInfos.add(new ActionPuntToController());
instructions.add(new InstructionApplyActions(actionsInfos));
FlowEntity rsFlowEntity = MDSALUtil.buildFlowEntity(dpId, tableId, getIPv6FlowRef(dpId, elanTag, ipv6Address), Ipv6Constants.DEFAULT_FLOW_PRIORITY, "IPv6NS", 0, 0, NwConstants.COOKIE_IPV6_TABLE, neighborSolicitationMatch, instructions);
if (addOrRemove == Ipv6Constants.DEL_FLOW) {
LOG.trace("Removing IPv6 Neighbor Solicitation Flow DpId {}, elanTag {}", dpId, elanTag);
mdsalUtil.removeFlow(rsFlowEntity);
} else {
LOG.trace("Installing IPv6 Neighbor Solicitation Flow DpId {}, elanTag {}", dpId, elanTag);
mdsalUtil.installFlow(rsFlowEntity);
}
}
use of org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions 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;
}
Aggregations