use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.
the class VpnToElanFallbackNodeListener method add.
@Override
protected void add(InstanceIdentifier<Node> identifier, Node add) {
BigInteger dpnId = getDpnIdFromNodeId(add.getNodeId());
if (dpnId == null) {
return;
}
LOG.debug("Installing L3VPN to ELAN default Fallback flow in LPortDispatcher table on Dpn {}", add.getNodeId());
List<MatchInfo> matches = Collections.singletonList(new MatchMetadata(MetaDataUtil.getServiceIndexMetaData(ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX)), MetaDataUtil.METADATA_MASK_SERVICE_INDEX));
BigInteger metadataToWrite = MetaDataUtil.getServiceIndexMetaData(ServiceIndex.getIndex(NwConstants.ELAN_SERVICE_NAME, NwConstants.ELAN_SERVICE_INDEX));
int instructionKey = 0;
List<Instruction> instructions = Arrays.asList(MDSALUtil.buildAndGetWriteMetadaInstruction(metadataToWrite, MetaDataUtil.METADATA_MASK_SERVICE_INDEX, ++instructionKey), MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.L3_INTERFACE_TABLE, ++instructionKey));
Flow flow = MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, L3_TO_L2_DEFAULT_FLOW_REF, NwConstants.TABLE_MISS_PRIORITY, L3_TO_L2_DEFAULT_FLOW_REF, 0, 0, CloudServiceChainConstants.COOKIE_L3_BASE, matches, instructions);
mdsalMgr.installFlow(dpnId, flow);
}
use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.
the class ElanServiceChainUtils method programExternalTunnelTable.
/**
* This flow is in charge of receiving packets from the TOR and sending
* them to the SCF Pipeline by setting the LportTag of ElanPseudoPort.
* Note that ELAN already has a flow in this table that redirects packets
* to the ELAN Pipeline. However, the flow for the SCF Pipeline will have
* higher priority, and will only be present when there is a ServiceChain
* using this ElanPseudoPort.
* <ul>
* <li> Matches on the VNI
* <li> Sets SI=1 and ElanPseudoPort tag in the Metadata and sends to
* LPortDispatcher via table 80.
* </ul>
* @param dpnId Dpn Id where the flow must be installed
* @param elanLportTag the Elan Pseudo Lport Id to be used in the Dataplane
* @param vni the VNI to which the Elan is related
* @param elanTag the Elan Id to be used in the Dataplane
* @param addOrRemove States if the flow must be added or removed
*/
public static void programExternalTunnelTable(IMdsalApiManager mdsalManager, BigInteger dpnId, int elanLportTag, long vni, int elanTag, int addOrRemove) {
LOG.info("L2-ServiceChaining: programExternalTunnelTable dpId={} vni={} elanLportTag={} addOrRemove={} ", dpnId, vni, elanLportTag, addOrRemove);
String flowRef = buildExtTunnelTblToLportDispFlowRef(vni, elanLportTag);
if (addOrRemove == NwConstants.ADD_FLOW) {
List<MatchInfo> matches = Collections.singletonList(new MatchTunnelId(BigInteger.valueOf(vni)));
List<Instruction> instructions = buildSetLportTagAndGotoLportDispInstructions(elanLportTag);
Flow flow = MDSALUtil.buildFlowNew(NwConstants.EXTERNAL_TUNNEL_TABLE, flowRef, CloudServiceChainConstants.DEFAULT_SCF_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.TUNNEL_TABLE_COOKIE.add(BigInteger.valueOf(elanTag)), matches, instructions);
mdsalManager.installFlow(dpnId, flow);
} else {
Flow flow = new FlowBuilder().setTableId(NwConstants.EXTERNAL_TUNNEL_TABLE).setId(new FlowId(flowRef)).build();
mdsalManager.removeFlow(dpnId, flow);
}
}
use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.
the class VpnServiceChainUtils method buildLportFlowDispForVpnToScf.
/**
* Creates the flow that sends the packet from the VPN to the SCF pipeline.
* This usually happens when there is an ScHop whose ingressPort is a
* VpnPseudoPort.
* <ul>
* <li>Matches: lportTag = vpnPseudoLPortTag, SI = 1
* <li>Actions: setMetadata(scfTag), Go to: UpSubFilter table
* </ul>
*/
public static FlowEntity buildLportFlowDispForVpnToScf(BigInteger dpId, int lportTag, long scfTag, short gotoTableId) {
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
actionsInfos.add(new ActionRegLoad(NxmNxReg2.class, 0, 31, scfTag));
instructions.add(new InstructionApplyActions(actionsInfos));
instructions.add(new InstructionGotoTable(gotoTableId));
String flowRef = getL3VpnToScfLportDispatcherFlowRef(lportTag);
List<MatchInfo> matches = buildMatchOnLportTagAndSI(lportTag, ServiceIndex.getIndex(NwConstants.SCF_SERVICE_NAME, NwConstants.SCF_SERVICE_INDEX));
return MDSALUtil.buildFlowEntity(dpId, NwConstants.LPORT_DISPATCHER_TABLE, flowRef, CloudServiceChainConstants.DEFAULT_SCF_FLOW_PRIORITY, flowRef, 0, 0, getCookieSCHop(scfTag), matches, instructions);
}
use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.
the class NatUtil method makePreDnatToSnatTableEntry.
public static void makePreDnatToSnatTableEntry(IMdsalApiManager mdsalManager, BigInteger naptDpnId, short tableId, WriteTransaction writeFlowTx) {
LOG.debug("makePreDnatToSnatTableEntry : Create Pre-DNAT table {} --> table {} flow on NAPT DpnId {} ", NwConstants.PDNAT_TABLE, tableId, naptDpnId);
List<Instruction> preDnatToSnatInstructions = new ArrayList<>();
preDnatToSnatInstructions.add(new InstructionGotoTable(tableId).buildInstruction(0));
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
String flowRef = getFlowRefPreDnatToSnat(naptDpnId, NwConstants.PDNAT_TABLE, "PreDNATToSNAT");
Flow preDnatToSnatTableFlowEntity = MDSALUtil.buildFlowNew(NwConstants.PDNAT_TABLE, flowRef, 5, flowRef, 0, 0, NwConstants.COOKIE_DNAT_TABLE, matches, preDnatToSnatInstructions);
mdsalManager.addFlowToTx(naptDpnId, preDnatToSnatTableFlowEntity, writeFlowTx);
LOG.debug("makePreDnatToSnatTableEntry : Successfully installed Pre-DNAT flow {} on NAPT DpnId {} ", preDnatToSnatTableFlowEntity, naptDpnId);
}
use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.
the class FloatingIPListener method buildPreDNATFlowEntity.
private FlowEntity buildPreDNATFlowEntity(BigInteger dpId, InternalToExternalPortMap mapping, long routerId, long associatedVpn) {
String externalIp = mapping.getExternalIp();
Uuid floatingIpId = mapping.getExternalId();
// Get the FIP MAC address for DNAT
String floatingIpPortMacAddress = NatUtil.getFloatingIpPortMacFromFloatingIpId(dataBroker, floatingIpId);
if (floatingIpPortMacAddress == null) {
LOG.error("buildPreDNATFlowEntity : Unable to retrieve floatingIpPortMacAddress from floating IP UUID {} " + "for floating IP {}", floatingIpId, externalIp);
return null;
}
LOG.debug("buildPreDNATFlowEntity : Bulding DNAT Flow entity for ip {} ", externalIp);
long segmentId = associatedVpn == NatConstants.INVALID_ID ? routerId : associatedVpn;
LOG.debug("buildPreDNATFlowEntity : Segment id {} in build preDNAT Flow", segmentId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new MatchIpv4Destination(externalIp, "32"));
// Match Destination Floating IP MAC Address on table = 25 (PDNAT_TABLE)
matches.add(new MatchEthernetDestination(new MacAddress(floatingIpPortMacAddress)));
// matches.add(new MatchMetadata(
// BigInteger.valueOf(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
List<ActionInfo> actionsInfos = new ArrayList<>();
String internalIp = mapping.getInternalIp();
actionsInfos.add(new ActionSetDestinationIp(internalIp, "32"));
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionWriteMetadata(MetaDataUtil.getVpnIdMetadata(segmentId), MetaDataUtil.METADATA_MASK_VRFID));
instructions.add(new InstructionApplyActions(actionsInfos));
instructions.add(new InstructionGotoTable(NwConstants.DNAT_TABLE));
String flowRef = NatUtil.getFlowRef(dpId, NwConstants.PDNAT_TABLE, routerId, externalIp);
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.PDNAT_TABLE, flowRef, NatConstants.DEFAULT_DNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_DNAT_TABLE, matches, instructions);
return flowEntity;
}
Aggregations