use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef in project netvirt by opendaylight.
the class FloatingIPListener method buildSNATFlowEntity.
private FlowEntity buildSNATFlowEntity(BigInteger dpId, InternalToExternalPortMap mapping, long vpnId, Uuid externalNetworkId) {
String internalIp = mapping.getInternalIp();
LOG.debug("buildSNATFlowEntity : Building SNAT Flow entity for ip {} ", internalIp);
ProviderTypes provType = NatUtil.getProviderTypefromNetworkId(dataBroker, externalNetworkId);
if (provType == null) {
LOG.error("buildSNATFlowEntity : Unable to get Network Provider Type for network {}", externalNetworkId);
return null;
}
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
matches.add(MatchEthernetType.IPV4);
String externalIp = mapping.getExternalIp();
matches.add(new MatchIpv4Source(externalIp, "32"));
List<ActionInfo> actionsInfo = new ArrayList<>();
Uuid floatingIpId = mapping.getExternalId();
String macAddress = NatUtil.getFloatingIpPortMacFromFloatingIpId(dataBroker, floatingIpId);
if (macAddress != null) {
actionsInfo.add(new ActionSetFieldEthernetSource(new MacAddress(macAddress)));
} else {
LOG.warn("buildSNATFlowEntity : No MAC address found for floating IP {}", externalIp);
}
LOG.trace("buildSNATFlowEntity : External Network Provider Type is {}, resubmit to FIB", provType.toString());
actionsInfo.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfo));
String flowRef = NatUtil.getFlowRef(dpId, NwConstants.SNAT_TABLE, vpnId, externalIp);
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.SNAT_TABLE, flowRef, NatConstants.DEFAULT_DNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_DNAT_TABLE, matches, instructions);
return flowEntity;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef in project netvirt by opendaylight.
the class ExternalRoutersListener method removeLFibTableEntry.
private void removeLFibTableEntry(BigInteger dpnId, long serviceId, WriteTransaction writeFlowInvTx) {
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.MPLS_UNICAST);
matches.add(new MatchMplsLabel(serviceId));
String flowRef = getFlowRef(dpnId, NwConstants.L3_LFIB_TABLE, serviceId, "");
LOG.debug("removeLFibTableEntry : with flow ref {}", flowRef);
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef, 10, flowRef, 0, 0, COOKIE_VM_LFIB_TABLE, matches, null);
mdsalManager.removeFlowToTx(dpnId, flowEntity, writeFlowInvTx);
LOG.debug("removeLFibTableEntry : dpID : {} label : {} removed successfully", dpnId, serviceId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef in project netvirt by opendaylight.
the class NatEvpnUtil method makeL3GwMacTableEntry.
static void makeL3GwMacTableEntry(final BigInteger dpnId, final long vpnId, String macAddress, List<Instruction> customInstructions, IMdsalApiManager mdsalManager, WriteTransaction writeFlowTx) {
List<MatchInfo> matchInfo = new ArrayList<>();
matchInfo.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
matchInfo.add(new MatchEthernetDestination(new MacAddress(macAddress)));
LOG.debug("makeL3GwMacTableEntry : Create flow table {} -> table {} for External Vpn Id = {} " + "and MacAddress = {} on DpnId = {}", NwConstants.L3_GW_MAC_TABLE, NwConstants.INBOUND_NAPT_TABLE, vpnId, macAddress, dpnId);
// Install the flow entry in L3_GW_MAC_TABLE
String flowRef = NatUtil.getFlowRef(dpnId, NwConstants.L3_GW_MAC_TABLE, vpnId, macAddress);
Flow l3GwMacTableFlowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_GW_MAC_TABLE, flowRef, 21, flowRef, 0, 0, NwConstants.COOKIE_L3_GW_MAC_TABLE, matchInfo, customInstructions);
mdsalManager.addFlowToTx(dpnId, l3GwMacTableFlowEntity, writeFlowTx);
LOG.debug("makeL3GwMacTableEntry : Successfully created flow entity {} on DPN = {}", l3GwMacTableFlowEntity, dpnId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef in project netvirt by opendaylight.
the class VpnFloatingIpHandler method removeLFibTableEntry.
private void removeLFibTableEntry(BigInteger dpnId, long serviceId, WriteTransaction removeFlowInvTx) {
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.MPLS_UNICAST);
matches.add(new MatchMplsLabel(serviceId));
String flowRef = getFlowRef(dpnId, NwConstants.L3_LFIB_TABLE, serviceId, "");
LOG.debug("removeLFibTableEntry : removing LFib entry with flow ref {}", flowRef);
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef, 10, flowRef, 0, 0, NwConstants.COOKIE_VM_LFIB_TABLE, matches, null);
mdsalManager.removeFlowToTx(dpnId, flowEntity, removeFlowInvTx);
LOG.debug("removeLFibTableEntry : LFIB Entry for dpID : {} label : {} removed successfully", dpnId, serviceId);
}
Aggregations