use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.
the class ElanUtils method buildDmacRedirectToDispatcherFlow.
public static FlowEntity buildDmacRedirectToDispatcherFlow(BigInteger dpId, String dstMacAddress, String displayName, long elanTag) {
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchMetadata(ElanHelper.getElanMetadataLabel(elanTag), MetaDataUtil.METADATA_MASK_SERVICE));
matches.add(new MatchEthernetDestination(new MacAddress(dstMacAddress)));
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actions = new ArrayList<>();
actions.add(new ActionNxResubmit(NwConstants.LPORT_DISPATCHER_TABLE));
instructions.add(new InstructionApplyActions(actions));
String flowId = getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, dpId, dstMacAddress, elanTag);
return MDSALUtil.buildFlowEntity(dpId, NwConstants.ELAN_DMAC_TABLE, flowId, 20, displayName, 0, 0, ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), matches, instructions);
}
use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.
the class ElanUtils method buildKnownSmacFlow.
public FlowEntity buildKnownSmacFlow(ElanInstance elanInfo, InterfaceInfo interfaceInfo, long macTimeout, String macAddress) {
int lportTag = interfaceInfo.getInterfaceTag();
// Matching metadata and eth_src fields
List<MatchInfo> mkMatches = new ArrayList<>();
mkMatches.add(new MatchMetadata(ElanHelper.getElanMetadataLabel(elanInfo.getElanTag(), lportTag), ElanHelper.getElanMetadataMask()));
mkMatches.add(new MatchEthernetSource(new MacAddress(macAddress)));
List<InstructionInfo> mkInstructions = new ArrayList<>();
mkInstructions.add(new InstructionGotoTable(NwConstants.ELAN_DMAC_TABLE));
BigInteger dpId = interfaceInfo.getDpId();
long elanTag = getElanTag(elanInfo, interfaceInfo);
return new FlowEntityBuilder().setDpnId(dpId).setTableId(NwConstants.ELAN_SMAC_TABLE).setFlowId(getKnownDynamicmacFlowRef(NwConstants.ELAN_SMAC_TABLE, dpId, lportTag, macAddress, elanTag)).setPriority(20).setFlowName(elanInfo.getDescription()).setIdleTimeOut((int) macTimeout).setHardTimeOut(0).setCookie(ElanConstants.COOKIE_ELAN_KNOWN_SMAC.add(BigInteger.valueOf(elanTag))).setMatchInfoList(mkMatches).setInstructionInfoList(mkInstructions).setStrictFlag(true).setSendFlowRemFlag(macTimeout != 0).build();
}
use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.
the class ElanUtils method buildRemoteDmacFlowEntry.
/**
* Builds a Flow to be programmed in a remote DPN's DMAC table. This flow
* consists in: Match: + elanTag in packet's metadata + packet going to a
* MAC known to be located in another DPN Actions: + set_tunnel_id
* + output ITM internal tunnel interface with the other DPN
*
* @param srcDpId
* the src Dpn Id
* @param destDpId
* dest Dp Id
* @param lportTagOrVni
* lportTag or network VNI
* @param elanTag
* elan Tag
* @param macAddress
* macAddress
* @param displayName
* display Name
* @param elanInstance
* elanInstance
* @return the flow remote Dmac
*/
@SuppressWarnings("checkstyle:IllegalCatch")
public Flow buildRemoteDmacFlowEntry(BigInteger srcDpId, BigInteger destDpId, long lportTagOrVni, long elanTag, String macAddress, String displayName, ElanInstance elanInstance) {
List<MatchInfo> mkMatches = new ArrayList<>();
mkMatches.add(new MatchMetadata(ElanHelper.getElanMetadataLabel(elanTag), MetaDataUtil.METADATA_MASK_SERVICE));
mkMatches.add(new MatchEthernetDestination(new MacAddress(macAddress)));
List<Instruction> mkInstructions = new ArrayList<>();
// List of Action for the provided Source and Destination DPIDs
try {
List<Action> actions = null;
if (isVlan(elanInstance) || isFlat(elanInstance)) {
String interfaceName = getExternalElanInterface(elanInstance.getElanInstanceName(), srcDpId);
if (null == interfaceName) {
LOG.info("buildRemoteDmacFlowEntry: Could not find interfaceName for {} {}", srcDpId, elanInstance);
}
actions = getEgressActionsForInterface(interfaceName, null);
} else if (isVxlanNetworkOrVxlanSegment(elanInstance)) {
actions = elanItmUtils.getInternalTunnelItmEgressAction(srcDpId, destDpId, lportTagOrVni);
}
mkInstructions.add(MDSALUtil.buildApplyActionsInstruction(actions));
} catch (Exception e) {
LOG.error("Could not get egress actions to add to flow for srcDpId {}, destDpId {}, lportTag/VNI {}", srcDpId, destDpId, lportTagOrVni, e);
}
Flow flow = MDSALUtil.buildFlowNew(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, srcDpId, destDpId, macAddress, elanTag), 20, /* prio */
displayName, 0, /* idleTimeout */
0, /* hardTimeout */
ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), mkMatches, mkInstructions);
return flow;
}
use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.
the class VpnUtil method buildL3vpnGatewayFlow.
public static FlowEntity buildL3vpnGatewayFlow(BigInteger dpId, String gwMacAddress, long vpnId, long subnetVpnId) {
List<MatchInfo> mkMatches = new ArrayList<>();
mkMatches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
mkMatches.add(new MatchEthernetDestination(new MacAddress(gwMacAddress)));
List<InstructionInfo> mkInstructions = new ArrayList<>();
mkInstructions.add(new InstructionGotoTable(NwConstants.L3_FIB_TABLE));
if (subnetVpnId != VpnConstants.INVALID_ID) {
BigInteger subnetIdMetaData = MetaDataUtil.getVpnIdMetadata(subnetVpnId);
mkInstructions.add(new InstructionWriteMetadata(subnetIdMetaData, MetaDataUtil.METADATA_MASK_VRFID));
}
String flowId = getL3VpnGatewayFlowRef(NwConstants.L3_GW_MAC_TABLE, dpId, vpnId, gwMacAddress);
return MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_GW_MAC_TABLE, flowId, 20, flowId, 0, 0, NwConstants.COOKIE_L3_GW_MAC_TABLE, mkMatches, mkInstructions);
}
use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.
the class ElanInterfaceManager method getMatchesForFilterEqualsLPortTag.
private List<MatchInfo> getMatchesForFilterEqualsLPortTag(int lportTag) {
List<MatchInfo> mkMatches = new ArrayList<>();
// Matching metadata
mkMatches.add(new MatchMetadata(MetaDataUtil.getLportTagMetaData(lportTag), MetaDataUtil.METADATA_MASK_LPORT_TAG));
mkMatches.add(new MatchTunnelId(BigInteger.valueOf(lportTag)));
return mkMatches;
}
Aggregations