use of org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction in project netvirt by opendaylight.
the class AclServiceUtils method createCtMarkInstructionForNewState.
/**
* This method creates and returns the ct_mark instruction when a ACL rule removed from the
* instance. This instruction will reset the ct_mark value and stops the existing traffics.
*
* @param filterTable the filterTable
* @param elanId the Elan id
* @return list of instruction
*/
public static List<InstructionInfo> createCtMarkInstructionForNewState(Short filterTable, Long elanId) {
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
List<NxCtAction> ctActionsList = new ArrayList<>();
NxCtAction nxCtMarkClearAction = new ActionNxConntrack.NxCtMark(AclConstants.CT_MARK_NEW_STATE);
ctActionsList.add(nxCtMarkClearAction);
ActionNxConntrack actionNxConntrack = new ActionNxConntrack(2, 1, 0, elanId.intValue(), (short) 255, ctActionsList);
actionsInfos.add(actionNxConntrack);
instructions.add(new InstructionApplyActions(actionsInfos));
instructions.add(new InstructionGotoTable(filterTable));
return instructions;
}
use of org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction in project netvirt by opendaylight.
the class VxlanGreConntrackBasedSnatService method installInboundEntryForVxlanGre.
protected void installInboundEntryForVxlanGre(BigInteger dpnId, long routerId, Long extNeVpnId, List<ExternalIps> externalIps, int elanId, int addOrRemove) {
LOG.info("installInboundEntryForVxlanGre: Install Inbound table entry on dpId {} for routerId {}", dpnId, routerId);
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
if (externalIps.isEmpty()) {
LOG.error("installInboundEntryForVxlanGre : createInboundTblEntry no externalIP present for routerId {}", routerId);
return;
}
String externalIp = externalIps.get(0).getIpAddress();
matches.add(new MatchIpv4Destination(externalIp, "32"));
if (addOrRemove == NwConstants.ADD_FLOW) {
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extNeVpnId), MetaDataUtil.METADATA_MASK_VRFID));
}
List<ActionInfo> actionsInfos = new ArrayList<>();
List<ActionNxConntrack.NxCtAction> ctActionsList = new ArrayList<>();
ActionNxConntrack.NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0, null, null, 0, 0);
ActionSetFieldMeta actionSetFieldMeta = new ActionSetFieldMeta(MetaDataUtil.getVpnIdMetadata(routerId));
actionsInfos.add(actionSetFieldMeta);
ctActionsList.add(nxCtAction);
ActionNxConntrack actionNxConntrack = new ActionNxConntrack(0, 0, elanId, NwConstants.NAPT_PFIB_TABLE, ctActionsList);
actionsInfos.add(actionNxConntrack);
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfos));
String flowRef = getFlowRef(dpnId, NwConstants.INBOUND_NAPT_TABLE, routerId);
syncFlow(dpnId, NwConstants.INBOUND_NAPT_TABLE, flowRef, NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
use of org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction in project netvirt by opendaylight.
the class ConntrackBasedSnatService method installSnatMissEntryForPrimrySwch.
protected void installSnatMissEntryForPrimrySwch(BigInteger dpnId, Long routerId, int elanId, int addOrRemove) {
LOG.info("installSnatSpecificEntriesForNaptSwitch : called for the primary NAPT switch dpnId {}", dpnId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
List<NxCtAction> ctActionsList = new ArrayList<>();
NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0, null, null, 0, 0);
ctActionsList.add(nxCtAction);
ActionNxConntrack actionNxConntrack = new ActionNxConntrack(0, 0, elanId, NwConstants.OUTBOUND_NAPT_TABLE, ctActionsList);
actionsInfos.add(actionNxConntrack);
instructions.add(new InstructionApplyActions(actionsInfos));
String flowRef = getFlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
syncFlow(dpnId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
use of org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction in project netvirt by opendaylight.
the class ConntrackBasedSnatService method createOutboundTblEntry.
protected void createOutboundTblEntry(BigInteger dpnId, long routerId, String externalIp, int elanId, String extGwMacAddress, int addOrRemove) {
LOG.info("createOutboundTblEntry : dpId {} and 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));
List<ActionInfo> actionsInfos = new ArrayList<>();
if (addOrRemove == NwConstants.ADD_FLOW) {
actionsInfos.add(new ActionSetFieldEthernetSource(new MacAddress(extGwMacAddress)));
}
List<NxCtAction> ctActionsListCommit = new ArrayList<>();
int rangePresent = NxActionNatRangePresent.NXNATRANGEIPV4MIN.getIntValue();
int flags = NxActionNatFlags.NXNATFSRC.getIntValue();
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.actions.ActionNxConntrack.NxCtAction in project netvirt by opendaylight.
the class AbstractAclServiceImpl method programAclCommitRuleForConntrack.
/**
* Program acl commit rule for conntrack.
*
* @param dpId the dp id
* @param lportTag the lport tag
* @param portId the port id
* @param matchEtherType the match ether type
* @param addOrRemove the add or remove
*/
protected void programAclCommitRuleForConntrack(BigInteger dpId, int lportTag, String portId, MatchEthernetType matchEtherType, int addOrRemove) {
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(matchEtherType);
matches.addAll(AclServiceUtils.buildMatchesForLPortTagAndConntrackClassifierType(lportTag, AclConntrackClassifierType.CONNTRACK_SUPPORTED, serviceMode));
List<ActionInfo> actionsInfos = new ArrayList<>();
if (addOrRemove == NwConstants.ADD_FLOW) {
Long elanId = getElanIdFromAclInterface(portId);
if (elanId == null) {
LOG.error("ElanId not found for portId={}; Context: dpId={}, lportTag={}, addOrRemove={}", portId, dpId, lportTag, addOrRemove);
return;
}
List<NxCtAction> ctActionsList = Lists.newArrayList(new ActionNxConntrack.NxCtMark(AclConstants.CT_MARK_EST_STATE));
actionsInfos.add(new ActionNxConntrack(2, 1, 0, elanId.intValue(), (short) 255, ctActionsList));
}
List<InstructionInfo> instructions = getDispatcherTableResubmitInstructions(actionsInfos);
String flowName = directionString + "_Acl_Commit_Conntrack_" + dpId + "_" + lportTag + "_" + matchEtherType;
// Flow for conntrack traffic to commit and resubmit to dispatcher
syncFlow(dpId, getAclCommitterTable(), flowName, AclConstants.ACL_DEFAULT_PRIORITY, "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
}
Aggregations