use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.
the class ExternalRoutersListener method buildNaptPfibFlowEntity.
public FlowEntity buildNaptPfibFlowEntity(BigInteger dpId, long segmentId) {
LOG.debug("buildNaptPfibFlowEntity : called for dpId {}, segmentId {}", dpId, segmentId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(segmentId), MetaDataUtil.METADATA_MASK_VRFID));
ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
listActionInfo.add(new ActionNxLoadInPort(BigInteger.ZERO));
listActionInfo.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
instructionInfo.add(new InstructionApplyActions(listActionInfo));
String flowRef = getFlowRefTs(dpId, NwConstants.NAPT_PFIB_TABLE, segmentId);
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.NAPT_PFIB_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, instructionInfo);
LOG.debug("buildNaptPfibFlowEntity : Returning NaptPFib Flow Entity {}", flowEntity);
return flowEntity;
}
use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.
the class ExternalRoutersListener method buildNaptPfibFlowEntityWithUpdatedVpnId.
public FlowEntity buildNaptPfibFlowEntityWithUpdatedVpnId(BigInteger dpId, long segmentId, long changedVpnId) {
LOG.debug("buildNaptPfibFlowEntityWithUpdatedVpnId : called for dpId {}, " + "segmentId {}, BGP VPN ID {}", dpId, segmentId, changedVpnId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(changedVpnId), MetaDataUtil.METADATA_MASK_VRFID));
ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
listActionInfo.add(new ActionNxLoadInPort(BigInteger.ZERO));
listActionInfo.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
instructionInfo.add(new InstructionApplyActions(listActionInfo));
String flowRef = getFlowRefTs(dpId, NwConstants.NAPT_PFIB_TABLE, segmentId);
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.NAPT_PFIB_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, instructionInfo);
LOG.debug("buildNaptPfibFlowEntityWithUpdatedVpnId : Returning NaptPFib Flow Entity {}", flowEntity);
return flowEntity;
}
use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.
the class NatUtil method buildDefaultNATFlowEntityForExternalSubnet.
static FlowEntity buildDefaultNATFlowEntityForExternalSubnet(BigInteger dpId, long vpnId, String subnetId, IdManagerService idManager) {
InetAddress defaultIP = null;
try {
defaultIP = InetAddress.getByName("0.0.0.0");
} catch (UnknownHostException e) {
LOG.error("buildDefaultNATFlowEntityForExternalSubnet : Failed to build FIB Table Flow for " + "Default Route to NAT.", e);
return null;
}
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
// add match for vrfid
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfo = new ArrayList<>();
long groupId = createGroupId(NatUtil.getGroupIdKey(subnetId), idManager);
actionsInfo.add(new ActionGroup(groupId));
String flowRef = getFlowRef(dpId, NwConstants.L3_FIB_TABLE, defaultIP, vpnId);
instructions.add(new InstructionApplyActions(actionsInfo));
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_FIB_TABLE, flowRef, NatConstants.DEFAULT_DNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_DNAT_TABLE, matches, instructions);
return flowEntity;
}
use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.
the class FloatingIPListener method buildDNATFlowEntity.
private FlowEntity buildDNATFlowEntity(BigInteger dpId, InternalToExternalPortMap mapping, long routerId, long associatedVpn) {
String externalIp = mapping.getExternalIp();
LOG.info("buildDNATFlowEntity : Bulding DNAT Flow entity for ip {} ", externalIp);
long segmentId = associatedVpn == NatConstants.INVALID_ID ? routerId : associatedVpn;
LOG.debug("buildDNATFlowEntity : Segment id {} in build DNAT", segmentId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(segmentId), MetaDataUtil.METADATA_MASK_VRFID));
matches.add(MatchEthernetType.IPV4);
String internalIp = mapping.getInternalIp();
matches.add(new MatchIpv4Destination(internalIp, "32"));
List<ActionInfo> actionsInfos = new ArrayList<>();
// actionsInfos.add(new ActionSetDestinationIp(internalIp, "32"));
List<InstructionInfo> instructions = new ArrayList<>();
// instructions.add(new InstructionWriteMetadata(BigInteger.valueOf
// (routerId), MetaDataUtil.METADATA_MASK_VRFID));
actionsInfos.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
instructions.add(new InstructionApplyActions(actionsInfos));
// instructions.add(new InstructionGotoTable(NatConstants.L3_FIB_TABLE));
String flowRef = NatUtil.getFlowRef(dpId, NwConstants.DNAT_TABLE, routerId, internalIp);
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.DNAT_TABLE, flowRef, NatConstants.DEFAULT_DNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_DNAT_TABLE, matches, instructions);
return flowEntity;
}
use of org.opendaylight.genius.mdsalutil.matches.MatchMetadata in project netvirt by opendaylight.
the class NaptEventHandler method buildAndGetMatchInfo.
private static List<MatchInfo> buildAndGetMatchInfo(String ip, int port, short tableId, NAPTEntryEvent.Protocol protocol, long segmentId) {
MatchInfo ipMatchInfo = null;
MatchInfo portMatchInfo = null;
MatchInfo protocolMatchInfo = null;
InetAddress ipAddress = null;
String ipAddressAsString = null;
try {
ipAddress = InetAddress.getByName(ip);
ipAddressAsString = ipAddress.getHostAddress();
} catch (UnknownHostException e) {
LOG.error("buildAndGetMatchInfo : UnknowHostException in buildAndGetMatchInfo." + "Failed to build NAPT Flow for ip {}", ip, e);
return null;
}
MatchInfo metaDataMatchInfo = null;
if (tableId == NwConstants.OUTBOUND_NAPT_TABLE) {
ipMatchInfo = new MatchIpv4Source(ipAddressAsString, "32");
if (protocol == NAPTEntryEvent.Protocol.TCP) {
protocolMatchInfo = MatchIpProtocol.TCP;
portMatchInfo = new MatchTcpSourcePort(port);
} else if (protocol == NAPTEntryEvent.Protocol.UDP) {
protocolMatchInfo = MatchIpProtocol.UDP;
portMatchInfo = new MatchUdpSourcePort(port);
}
metaDataMatchInfo = new MatchMetadata(MetaDataUtil.getVpnIdMetadata(segmentId), MetaDataUtil.METADATA_MASK_VRFID);
} else {
ipMatchInfo = new MatchIpv4Destination(ipAddressAsString, "32");
if (protocol == NAPTEntryEvent.Protocol.TCP) {
protocolMatchInfo = MatchIpProtocol.TCP;
portMatchInfo = new MatchTcpDestinationPort(port);
} else if (protocol == NAPTEntryEvent.Protocol.UDP) {
protocolMatchInfo = MatchIpProtocol.UDP;
portMatchInfo = new MatchUdpDestinationPort(port);
}
// metaDataMatchInfo = new MatchMetadata(BigInteger.valueOf(vpnId), MetaDataUtil.METADATA_MASK_VRFID);
}
ArrayList<MatchInfo> matchInfo = new ArrayList<>();
matchInfo.add(MatchEthernetType.IPV4);
matchInfo.add(ipMatchInfo);
matchInfo.add(protocolMatchInfo);
matchInfo.add(portMatchInfo);
if (tableId == NwConstants.OUTBOUND_NAPT_TABLE) {
matchInfo.add(metaDataMatchInfo);
}
return matchInfo;
}
Aggregations