use of org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState in project netvirt by opendaylight.
the class AclServiceOFFlowBuilder method addLPortTagMatches.
/**
* Adds LPort matches to the flow.
* @param lportTag lport tag
* @param conntrackState conntrack state to be used with matches
* @param conntrackMask conntrack mask to be used with matches
* @param serviceMode ingress or egress service
* @return list of matches
*/
public static List<MatchInfoBase> addLPortTagMatches(int lportTag, int conntrackState, int conntrackMask, Class<? extends ServiceModeBase> serviceMode) {
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode));
matches.add(new NxMatchCtState(conntrackState, conntrackMask));
return matches;
}
use of org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState in project netvirt by opendaylight.
the class AclNodeDefaultFlowsTxBuilder method addEgressConntrackDummyLookup.
private void addEgressConntrackDummyLookup() {
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new NxMatchCtState(AclConstants.TRACKED_CT_STATE, AclConstants.TRACKED_CT_STATE_MASK));
int elanTag = dummyTag;
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
actionsInfos.add(new ActionNxConntrack(2, 0, 0, elanTag, NwConstants.EGRESS_ACL_ANTI_SPOOFING_TABLE));
instructions.add(new InstructionApplyActions(actionsInfos));
String flowName = "Egress_Fixed_Dummy_Table_Ipv4_" + this.dpId;
addFlowToTx(NwConstants.EGRESS_ACL_DUMMY_TABLE, flowName, AclConstants.ACL_DEFAULT_PRIORITY, matches, instructions);
matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV6);
matches.add(new NxMatchCtState(AclConstants.TRACKED_CT_STATE, AclConstants.TRACKED_CT_STATE_MASK));
flowName = "Egress_Fixed_Dummy_Table_Ipv6_" + this.dpId;
addFlowToTx(NwConstants.EGRESS_ACL_DUMMY_TABLE, flowName, AclConstants.ACL_DEFAULT_PRIORITY, matches, instructions);
}
use of org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState in project netvirt by opendaylight.
the class VxlanGreConntrackBasedSnatService method createOutboundTblEntryForVxlanGre.
protected void createOutboundTblEntryForVxlanGre(BigInteger dpnId, long routerId, Long extNetVpnId, List<ExternalIps> externalIps, int elanId, int addOrRemove) {
LOG.info("createOutboundTblEntryForVxlanGre: Install Outbound table flow on dpId {} for routerId {}", dpnId, routerId);
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new NxMatchCtState(TRACKED_NEW_CT_STATE, TRACKED_NEW_CT_MASK));
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
if (externalIps.isEmpty()) {
LOG.error("createOutboundTblEntryForVxlanGre: No externalIP present for routerId {}", routerId);
return;
}
// The logic now handle only one external IP per router, others if present will be ignored.
String externalIp = externalIps.get(0).getIpAddress();
List<ActionInfo> actionsInfos = new ArrayList<>();
if (addOrRemove == NwConstants.ADD_FLOW) {
ActionSetFieldMeta actionSetFieldMeta = new ActionSetFieldMeta(MetaDataUtil.getVpnIdMetadata(extNetVpnId));
actionsInfos.add(actionSetFieldMeta);
}
List<ActionNxConntrack.NxCtAction> ctActionsListCommit = new ArrayList<>();
int rangePresent = NxActionNatRangePresent.NXNATRANGEIPV4MIN.getIntValue();
int flags = NxActionNatFlags.NXNATFSRC.getIntValue();
ActionNxConntrack.NxCtAction nxCtActionCommit = new ActionNxConntrack.NxNat(0, flags, rangePresent, new IpPrefixOrAddress(externalIp.toCharArray()).getIpAddress(), null, 0, 0);
ctActionsListCommit.add(nxCtActionCommit);
int ctCommitFlag = 1;
ActionNxConntrack actionNxConntrackSubmit = new ActionNxConntrack(ctCommitFlag, 0, elanId, NwConstants.NAPT_PFIB_TABLE, ctActionsListCommit);
actionsInfos.add(actionNxConntrackSubmit);
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfos));
String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId);
syncFlow(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef, NatConstants.SNAT_NEW_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
use of org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState in project netvirt by opendaylight.
the class ConntrackBasedSnatService method installNaptPfibFlow.
protected void installNaptPfibFlow(Routers routers, BigInteger dpnId, long routerId, long extSubnetId, int addOrRemove) {
Long extNetId = NatUtil.getVpnId(getDataBroker(), routers.getNetworkId().getValue());
LOG.info("installNaptPfibFlow : dpId {}, extNetId {}", dpnId, extNetId);
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));
List<ActionInfo> listActionInfo = new ArrayList<>();
if (addOrRemove == NwConstants.ADD_FLOW) {
if (extSubnetId == NatConstants.INVALID_ID) {
LOG.error("installNaptPfibFlow : external subnet id is invalid.");
return;
}
ActionNxLoadMetadata actionLoadMeta = new ActionNxLoadMetadata(MetaDataUtil.getVpnIdMetadata(extSubnetId), LOAD_START, LOAD_END);
listActionInfo.add(actionLoadMeta);
}
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, routerId);
flowRef = flowRef + "OUTBOUND";
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.nxmatches.NxMatchCtState in project netvirt by opendaylight.
the class ConntrackBasedSnatService method createOutboundTblTrackEntry.
protected void createOutboundTblTrackEntry(BigInteger dpnId, Long routerId, String extGwMacAddress, int addOrRemove) {
LOG.info("createOutboundTblTrackEntry : called for switch {}, 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) {
listActionInfo.add(new ActionSetFieldEthernetSource(new MacAddress(extGwMacAddress)));
}
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);
}
Aggregations