Search in sources :

Example 76 with ActionInfo

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

the class DhcpServiceUtils method setupDhcpDropAction.

public static void setupDhcpDropAction(BigInteger dpId, short tableId, String vmMacAddress, int addOrRemove, IMdsalApiManager mdsalUtil, WriteTransaction tx) {
    if (dpId == null || dpId.equals(DhcpMConstants.INVALID_DPID) || vmMacAddress == null) {
        return;
    }
    List<MatchInfo> matches = getDhcpMatch(vmMacAddress);
    List<ActionInfo> actionsInfos = new ArrayList<>();
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actionsInfos));
    // Drop Action
    actionsInfos.add(new ActionDrop());
    if (addOrRemove == NwConstants.DEL_FLOW) {
        FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, tableId, getDhcpFlowRef(dpId, tableId, vmMacAddress), DhcpMConstants.DEFAULT_DHCP_FLOW_PRIORITY, "DHCP", 0, 0, DhcpMConstants.COOKIE_DHCP_BASE, matches, null);
        LOG.trace("Removing DHCP Drop Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
        DhcpServiceCounters.remove_dhcp_drop_flow.inc();
        mdsalUtil.removeFlowToTx(flowEntity, tx);
    } else {
        FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, tableId, getDhcpFlowRef(dpId, tableId, vmMacAddress), DhcpMConstants.DEFAULT_DHCP_FLOW_PRIORITY, "DHCP", 0, 0, DhcpMConstants.COOKIE_DHCP_BASE, matches, instructions);
        LOG.trace("Installing DHCP Drop Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
        DhcpServiceCounters.install_dhcp_drop_flow.inc();
        mdsalUtil.addFlowToTx(flowEntity, tx);
    }
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 77 with ActionInfo

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

the class DhcpServiceUtils method setupDhcpFlowEntry.

public static void setupDhcpFlowEntry(@Nullable BigInteger dpId, short tableId, @Nullable String vmMacAddress, int addOrRemove, IMdsalApiManager mdsalUtil, WriteTransaction tx) {
    if (dpId == null || dpId.equals(DhcpMConstants.INVALID_DPID) || vmMacAddress == null) {
        return;
    }
    List<MatchInfo> matches = getDhcpMatch(vmMacAddress);
    List<InstructionInfo> instructions = new ArrayList<>();
    List<ActionInfo> actionsInfos = new ArrayList<>();
    // Punt to controller
    actionsInfos.add(new ActionPuntToController());
    instructions.add(new InstructionApplyActions(actionsInfos));
    if (addOrRemove == NwConstants.DEL_FLOW) {
        FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, tableId, getDhcpFlowRef(dpId, tableId, vmMacAddress), DhcpMConstants.DEFAULT_DHCP_FLOW_PRIORITY, "DHCP", 0, 0, DhcpMConstants.COOKIE_DHCP_BASE, matches, null);
        LOG.trace("Removing DHCP Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
        DhcpServiceCounters.remove_dhcp_flow.inc();
        mdsalUtil.removeFlowToTx(flowEntity, tx);
    } else {
        FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, tableId, getDhcpFlowRef(dpId, tableId, vmMacAddress), DhcpMConstants.DEFAULT_DHCP_FLOW_PRIORITY, "DHCP", 0, 0, DhcpMConstants.COOKIE_DHCP_BASE, matches, instructions);
        LOG.trace("Installing DHCP Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
        DhcpServiceCounters.install_dhcp_flow.inc();
        mdsalUtil.addFlowToTx(flowEntity, tx);
    }
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionPuntToController(org.opendaylight.genius.mdsalutil.actions.ActionPuntToController) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 78 with ActionInfo

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

the class ElanNodeListener method setupExternalL2vniTableMissFlow.

private void setupExternalL2vniTableMissFlow(BigInteger dpnId) {
    List<MatchInfo> matches = new ArrayList<>();
    List<ActionInfo> actionsInfos = Collections.singletonList(new ActionNxResubmit(NwConstants.LPORT_DISPATCHER_TABLE));
    List<InstructionInfo> instructions = Collections.singletonList(new InstructionApplyActions(actionsInfos));
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L2VNI_EXTERNAL_TUNNEL_DEMUX_TABLE, getTableMissFlowRef(NwConstants.L2VNI_EXTERNAL_TUNNEL_DEMUX_TABLE), 0, "External L2VNI Table Miss Flow", 0, 0, ElanConstants.COOKIE_L2VNI_DEMUX, matches, instructions);
    mdsalManager.installFlow(flowEntity);
}
Also used : 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) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 79 with ActionInfo

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

the class EgressCountersServiceImpl method syncCounterFlows.

@Override
public void syncCounterFlows(ElementCountersRequest ecr, int operation) {
    int lportTag = ecr.getLportTag();
    List<MatchInfoBase> flowMatches = CountersServiceUtils.getCounterFlowMatch(ecr, lportTag, ElementCountersDirection.EGRESS);
    List<ActionInfo> actionsInfos = new ArrayList<>();
    List<InstructionInfo> instructions = CountersServiceUtils.getDispatcherTableResubmitInstructions(actionsInfos, ElementCountersDirection.EGRESS);
    BigInteger dpn = ecr.getDpn();
    String flowName = createFlowName(ecr, lportTag, dpn);
    syncFlow(dpn, NwConstants.EGRESS_COUNTERS_TABLE, flowName, CountersServiceUtils.COUNTER_TABLE_COUNTER_FLOW_PRIORITY, CountersServiceUtils.COUNTER_FLOW_NAME, 0, 0, CountersServiceUtils.COOKIE_COUNTERS_BASE, flowMatches, instructions, operation);
}
Also used : InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 80 with ActionInfo

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

the class EgressCountersServiceImpl method installDefaultCounterRules.

@Override
public void installDefaultCounterRules(String interfaceId) {
    BigInteger dpn = interfaceManager.getDpnForInterface(interfaceId);
    String defaultFlowName = CountersServiceUtils.DEFAULT_EGRESS_COUNTER_FLOW_PREFIX + dpn + interfaceId;
    List<MatchInfoBase> defaultFlowMatches = new ArrayList<>();
    List<ActionInfo> actionsInfos = new ArrayList<>();
    List<InstructionInfo> instructions = CountersServiceUtils.getDispatcherTableResubmitInstructions(actionsInfos, ElementCountersDirection.EGRESS);
    syncFlow(dpn, NwConstants.EGRESS_COUNTERS_TABLE, defaultFlowName, CountersServiceUtils.COUNTER_TABLE_DEFAULT_FLOW_PRIORITY, CountersServiceUtils.COUNTER_FLOW_NAME, 0, 0, CountersServiceUtils.COOKIE_COUNTERS_BASE, defaultFlowMatches, instructions, NwConstants.ADD_FLOW);
}
Also used : InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Aggregations

ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)133 ArrayList (java.util.ArrayList)97 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)74 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)73 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)52 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)39 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)33 Test (org.junit.Test)32 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)32 BigInteger (java.math.BigInteger)26 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)20 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)17 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)16 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)15 BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)14 ActionNxConntrack (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack)12 ActionPuntToController (org.opendaylight.genius.mdsalutil.actions.ActionPuntToController)12 ActionSetFieldTunnelId (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)12 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)11 ActionDrop (org.opendaylight.genius.mdsalutil.actions.ActionDrop)9