Search in sources :

Example 81 with InstructionInfo

use of org.opendaylight.genius.mdsalutil.InstructionInfo in project netvirt by opendaylight.

the class AbstractSnatService method installDefaultFibRouteForSNAT.

protected void installDefaultFibRouteForSNAT(BigInteger dpnId, Long extNetId, int addOrRemove) {
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extNetId), MetaDataUtil.METADATA_MASK_VRFID));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionGotoTable(NwConstants.PSNAT_TABLE));
    String flowRef = getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, extNetId);
    syncFlow(dpnId, NwConstants.L3_FIB_TABLE, flowRef, NatConstants.DEFAULT_DNAT_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList)

Example 82 with InstructionInfo

use of org.opendaylight.genius.mdsalutil.InstructionInfo 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 83 with InstructionInfo

use of org.opendaylight.genius.mdsalutil.InstructionInfo 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)

Example 84 with InstructionInfo

use of org.opendaylight.genius.mdsalutil.InstructionInfo in project netvirt by opendaylight.

the class ConntrackBasedSnatService method installInboundEntry.

protected void installInboundEntry(BigInteger dpnId, long routerId, String externalIp, int elanId, long extSubnetId, int addOrRemove) {
    LOG.info("installInboundEntry : dpId {} and routerId {}", dpnId, routerId);
    List<MatchInfoBase> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchIpv4Destination(externalIp, "32"));
    if (addOrRemove == NwConstants.ADD_FLOW) {
        if (extSubnetId == NatConstants.INVALID_ID) {
            LOG.error("installInboundEntry : external subnet id is invalid.");
            return;
        }
        matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extSubnetId), MetaDataUtil.METADATA_MASK_VRFID));
    }
    List<ActionInfo> actionsInfos = new ArrayList<>();
    List<NxCtAction> ctActionsList = new ArrayList<>();
    NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0, null, null, 0, 0);
    ActionNxLoadMetadata actionLoadMeta = new ActionNxLoadMetadata(MetaDataUtil.getVpnIdMetadata(routerId), LOAD_START, LOAD_END);
    actionsInfos.add(actionLoadMeta);
    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);
    flowRef = flowRef + "OUTBOUND";
    syncFlow(dpnId, NwConstants.INBOUND_NAPT_TABLE, flowRef, NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) ArrayList(java.util.ArrayList) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionNxConntrack(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack) ActionNxLoadMetadata(org.opendaylight.genius.mdsalutil.actions.ActionNxLoadMetadata) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) NxCtAction(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 85 with InstructionInfo

use of org.opendaylight.genius.mdsalutil.InstructionInfo in project netvirt by opendaylight.

the class ExternalRoutersListener method buildSnatFlowEntityWithUpdatedVpnId.

public FlowEntity buildSnatFlowEntityWithUpdatedVpnId(BigInteger dpId, String routerName, long groupId, long changedVpnId) {
    LOG.debug("buildSnatFlowEntityWithUpdatedVpnId : called for dpId {}, routerName {} groupId {} " + "changed VPN ID {}", dpId, routerName, groupId, changedVpnId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(changedVpnId), MetaDataUtil.METADATA_MASK_VRFID));
    List<ActionInfo> actionsInfo = new ArrayList<>();
    long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, changedVpnId, routerName);
    actionsInfo.add(new ActionSetFieldTunnelId(BigInteger.valueOf(tunnelId)));
    LOG.debug("buildSnatFlowEntityWithUpdatedVpnId : Setting the tunnel to the list of action infos {}", actionsInfo);
    actionsInfo.add(new ActionGroup(groupId));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actionsInfo));
    String flowRef = getFlowRefSnat(dpId, NwConstants.PSNAT_TABLE, routerName);
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
    LOG.debug("buildSnatFlowEntityWithUpdatedVpnId : Returning SNAT Flow Entity {}", flowEntity);
    return flowEntity;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Aggregations

InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)120 ArrayList (java.util.ArrayList)113 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)74 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)74 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)63 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)52 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)41 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)34 BigInteger (java.math.BigInteger)33 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)33 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)27 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)17 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)16 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)13 ActionNxConntrack (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack)12 ActionPuntToController (org.opendaylight.genius.mdsalutil.actions.ActionPuntToController)11 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)10 NxCtAction (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction)10 MatchTunnelId (org.opendaylight.genius.mdsalutil.matches.MatchTunnelId)10 MatchIpv4Destination (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination)9