use of org.opendaylight.genius.mdsalutil.MatchInfoBase 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.MatchInfoBase in project netvirt by opendaylight.
the class AbstractAclServiceImpl method programForAceNotHavingRemoteAclId.
protected void programForAceNotHavingRemoteAclId(AclInterface port, String aclName, Ace ace, Map<String, List<MatchInfoBase>> flowMap, int addOrRemove) {
if (null == flowMap) {
return;
}
MatchInfoBase lportTagMatch = AclServiceUtils.buildLPortTagMatch(port.getLPortTag(), serviceMode);
List<InstructionInfo> instructions = AclServiceOFFlowBuilder.getGotoInstructionInfo(getAclCommitterTable());
Integer flowPriority = this.aclServiceUtils.getAceFlowPriority(aclName);
for (Entry<String, List<MatchInfoBase>> entry : flowMap.entrySet()) {
String flowName = entry.getKey();
List<MatchInfoBase> matches = entry.getValue();
matches.add(lportTagMatch);
String flowId = flowName + this.directionString + "_" + port.getDpId() + "_" + port.getLPortTag() + "_" + ace.getKey().getRuleName();
int operation = addOrRemove == NwConstants.MOD_FLOW ? NwConstants.DEL_FLOW : addOrRemove;
syncFlow(port.getDpId(), getAclFilterCumDispatcherTable(), flowId, flowPriority, "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, operation);
if (addOrRemove != NwConstants.DEL_FLOW) {
programAclForExistingTrafficTable(port, ace, addOrRemove, flowName, matches, flowPriority);
}
}
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase 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);
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class PolicyAceFlowProgrammer method getIngressInterfaceFlow.
private Optional<PolicyAceFlowWrapper> getIngressInterfaceFlow(IngressInterface ingressInterface) {
String interfaceName = ingressInterface.getName();
if (interfaceName == null) {
LOG.error("Invalid ingress interface augmentation. missing interface name");
return Optional.absent();
}
String flowName = "INGRESS_INTERFACE_" + interfaceName;
int flowPriority = PolicyServiceConstants.POLICY_ACL_TRUNK_INTERFACE_FLOW_PRIOPITY;
VlanId vlanId = ingressInterface.getVlanId();
if (vlanId != null) {
Optional<String> vlanMemberInterfaceOpt = policyServiceUtil.getVlanMemberInterface(interfaceName, vlanId);
if (!vlanMemberInterfaceOpt.isPresent()) {
LOG.debug("Vlan member {} missing for trunk {}", vlanId.getValue(), interfaceName);
return Optional.of(new PolicyAceFlowWrapper(flowName, PolicyAceFlowWrapper.PARTIAL));
}
interfaceName = vlanMemberInterfaceOpt.get();
flowPriority = PolicyServiceConstants.POLICY_ACL_VLAN_INTERFACE_FLOW_PRIOPITY;
}
List<MatchInfoBase> matches = policyFlowUtil.getIngressInterfaceMatches(interfaceName);
if (matches == null || matches.isEmpty()) {
LOG.debug("Failed to get ingress interface {} matches", interfaceName);
return Optional.of(new PolicyAceFlowWrapper(flowName, PolicyAceFlowWrapper.PARTIAL));
}
BigInteger dpId = interfaceManager.getDpnForInterface(interfaceName);
if (dpId == null) {
dpId = BigInteger.ZERO;
}
return Optional.of(new PolicyAceFlowWrapper(flowName, matches, flowPriority, dpId));
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project genius by opendaylight.
the class FlowBasedServicesUtils method getMatchInfoForEgressDispatcherTable.
public static List<MatchInfoBase> getMatchInfoForEgressDispatcherTable(int interfaceTag, short serviceIndex) {
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(new NxMatchRegister(NxmNxReg6.class, MetaDataUtil.getReg6ValueForLPortDispatcher(interfaceTag, serviceIndex)));
return matches;
}
Aggregations