Search in sources :

Example 51 with InstructionApplyActions

use of org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions in project netvirt by opendaylight.

the class FloatingIPListener method buildPreSNATFlowEntity.

private FlowEntity buildPreSNATFlowEntity(BigInteger dpId, String internalIp, String externalIp, long vpnId, long routerId, long associatedVpn) {
    LOG.debug("buildPreSNATFlowEntity : Building PSNAT Flow entity for ip {} ", internalIp);
    long segmentId = associatedVpn == NatConstants.INVALID_ID ? routerId : associatedVpn;
    LOG.debug("buildPreSNATFlowEntity : Segment id {} in build preSNAT flow", segmentId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchIpv4Source(internalIp, "32"));
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(segmentId), MetaDataUtil.METADATA_MASK_VRFID));
    List<ActionInfo> actionsInfos = new ArrayList<>();
    actionsInfos.add(new ActionSetSourceIp(externalIp, "32"));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionWriteMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
    instructions.add(new InstructionApplyActions(actionsInfos));
    instructions.add(new InstructionGotoTable(NwConstants.SNAT_TABLE));
    String flowRef = NatUtil.getFlowRef(dpId, NwConstants.PSNAT_TABLE, routerId, internalIp);
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_DNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_DNAT_TABLE, matches, instructions);
    return flowEntity;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) ArrayList(java.util.ArrayList) ActionSetSourceIp(org.opendaylight.genius.mdsalutil.actions.ActionSetSourceIp) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) MatchIpv4Source(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Source) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 52 with InstructionApplyActions

use of org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions in project netvirt by opendaylight.

the class NaptEventHandler method buildAndGetSetActionInstructionInfo.

private static List<InstructionInfo> buildAndGetSetActionInstructionInfo(String ipAddress, int port, long segmentId, long vpnId, short tableId, NAPTEntryEvent.Protocol protocol, String extGwMacAddress) {
    ActionInfo ipActionInfo = null;
    ActionInfo macActionInfo = null;
    ActionInfo portActionInfo = null;
    ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
    ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
    switch(tableId) {
        case NwConstants.OUTBOUND_NAPT_TABLE:
            ipActionInfo = new ActionSetSourceIp(ipAddress);
            // Added External Gateway MAC Address
            macActionInfo = new ActionSetFieldEthernetSource(new MacAddress(extGwMacAddress));
            if (protocol == NAPTEntryEvent.Protocol.TCP) {
                portActionInfo = new ActionSetTcpSourcePort(port);
            } else if (protocol == NAPTEntryEvent.Protocol.UDP) {
                portActionInfo = new ActionSetUdpSourcePort(port);
            }
            // reset the split-horizon bit to allow traffic from tunnel to be sent back to the provider port
            instructionInfo.add(new InstructionWriteMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID.or(MetaDataUtil.METADATA_MASK_SH_FLAG)));
            break;
        case NwConstants.INBOUND_NAPT_TABLE:
            ipActionInfo = new ActionSetDestinationIp(ipAddress);
            if (protocol == NAPTEntryEvent.Protocol.TCP) {
                portActionInfo = new ActionSetTcpDestinationPort(port);
            } else if (protocol == NAPTEntryEvent.Protocol.UDP) {
                portActionInfo = new ActionSetUdpDestinationPort(port);
            }
            instructionInfo.add(new InstructionWriteMetadata(MetaDataUtil.getVpnIdMetadata(segmentId), MetaDataUtil.METADATA_MASK_VRFID));
            break;
        default:
            LOG.error("buildAndGetSetActionInstructionInfo : Neither OUTBOUND_NAPT_TABLE nor " + "INBOUND_NAPT_TABLE matches with input table id {}", tableId);
            return null;
    }
    listActionInfo.add(ipActionInfo);
    listActionInfo.add(portActionInfo);
    if (macActionInfo != null) {
        listActionInfo.add(macActionInfo);
        LOG.debug("buildAndGetSetActionInstructionInfo : External GW MAC Address {} is found  ", macActionInfo);
    }
    instructionInfo.add(new InstructionApplyActions(listActionInfo));
    instructionInfo.add(new InstructionGotoTable(NwConstants.NAPT_PFIB_TABLE));
    return instructionInfo;
}
Also used : ActionSetUdpSourcePort(org.opendaylight.genius.mdsalutil.actions.ActionSetUdpSourcePort) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) ArrayList(java.util.ArrayList) ActionSetSourceIp(org.opendaylight.genius.mdsalutil.actions.ActionSetSourceIp) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ActionSetTcpSourcePort(org.opendaylight.genius.mdsalutil.actions.ActionSetTcpSourcePort) ActionSetFieldEthernetSource(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionSetUdpDestinationPort(org.opendaylight.genius.mdsalutil.actions.ActionSetUdpDestinationPort) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) ActionSetDestinationIp(org.opendaylight.genius.mdsalutil.actions.ActionSetDestinationIp) ActionSetTcpDestinationPort(org.opendaylight.genius.mdsalutil.actions.ActionSetTcpDestinationPort) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 53 with InstructionApplyActions

use of org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions in project netvirt by opendaylight.

the class AbstractSnatService method installInboundTerminatingServiceTblEntry.

protected void installInboundTerminatingServiceTblEntry(BigInteger dpnId, Long routerId, long extSubnetId, int addOrRemove) {
    // Install the tunnel table entry in NAPT switch for inbound traffic to SNAP IP from a non a NAPT switch.
    LOG.info("installInboundTerminatingServiceTblEntry : creating entry for Terminating Service Table " + "for switch {}, routerId {}", dpnId, routerId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    List<ActionInfo> actionsInfos = new ArrayList<>();
    if (addOrRemove == NwConstants.ADD_FLOW) {
        if (extSubnetId == NatConstants.INVALID_ID) {
            LOG.error("installInboundTerminatingServiceTblEntry : external subnet id is invalid.");
            return;
        }
        matches.add(new MatchTunnelId(BigInteger.valueOf(extSubnetId)));
        ActionNxLoadMetadata actionLoadMeta = new ActionNxLoadMetadata(MetaDataUtil.getVpnIdMetadata(extSubnetId), LOAD_START, LOAD_END);
        actionsInfos.add(actionLoadMeta);
    }
    actionsInfos.add(new ActionNxResubmit(NwConstants.INBOUND_NAPT_TABLE));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actionsInfos));
    String flowRef = getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId.longValue());
    flowRef = flowRef + "INBOUND";
    syncFlow(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef, NatConstants.SNAT_FIB_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
Also used : ActionNxLoadMetadata(org.opendaylight.genius.mdsalutil.actions.ActionNxLoadMetadata) MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 54 with InstructionApplyActions

use of org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions in project netvirt by opendaylight.

the class ConntrackBasedSnatService method installNaptPfibEntry.

protected void installNaptPfibEntry(BigInteger dpnId, long routerId, int addOrRemove) {
    LOG.info("installNaptPfibEntry : called for dpnId {} and routerId {} ", dpnId, routerId);
    List<MatchInfoBase> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new NxMatchCtState(DNAT_CT_STATE, DNAT_CT_STATE_MASK));
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), 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 = getFlowRef(dpnId, NwConstants.NAPT_PFIB_TABLE, routerId);
    flowRef = flowRef + "INBOUND";
    syncFlow(dpnId, NwConstants.NAPT_PFIB_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructionInfo, addOrRemove);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) NxMatchCtState(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState) ActionNxLoadInPort(org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 55 with InstructionApplyActions

use of org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions in project netvirt by opendaylight.

the class ConntrackBasedSnatService method installTerminatingServiceTblEntry.

protected void installTerminatingServiceTblEntry(BigInteger dpnId, Long routerId, int elanId, int addOrRemove) {
    LOG.info("installTerminatingServiceTblEntry : creating entry for Terminating Service Table " + "for switch {}, routerId {}", dpnId, routerId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchTunnelId(BigInteger.valueOf(routerId)));
    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);
    ActionNxLoadMetadata actionLoadMeta = new ActionNxLoadMetadata(MetaDataUtil.getVpnIdMetadata(routerId.longValue()), LOAD_START, LOAD_END);
    actionsInfos.add(actionLoadMeta);
    actionsInfos.add(actionNxConntrack);
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actionsInfos));
    String flowRef = getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId.longValue());
    syncFlow(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef, NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
Also used : ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionNxConntrack(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack) ActionNxLoadMetadata(org.opendaylight.genius.mdsalutil.actions.ActionNxLoadMetadata) MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) NxCtAction(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Aggregations

InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)78 ArrayList (java.util.ArrayList)77 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)73 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)72 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)50 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)38 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)31 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)28 BigInteger (java.math.BigInteger)18 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)14 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)13 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)12 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)12 ActionNxConntrack (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack)11 ActionPuntToController (org.opendaylight.genius.mdsalutil.actions.ActionPuntToController)10 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)9 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)9 MatchIpv4Destination (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination)9 NxCtAction (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction)8 ActionPopMpls (org.opendaylight.genius.mdsalutil.actions.ActionPopMpls)8