Search in sources :

Example 11 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class FabricIntProgrammable method init.

@Override
public boolean init() {
    if (!setupBehaviour()) {
        return false;
    }
    // FIXME: create config class for INT to allow specifying arbitrary
    // switch IDs. The one for the GeneralDeviceProvider was temporary and
    // now has been removed. For now we use the chassis ID.
    // final GeneralProviderDeviceConfig cfg = cfgService.getConfig(
    // deviceId, GeneralProviderDeviceConfig.class);
    // if (cfg == null) {
    // log.warn("Missing GeneralProviderDevice config for {}", deviceId);
    // return false;
    // }
    // final String switchId = cfg.protocolsInfo().containsKey("int") ?
    // cfg.protocolsInfo().get("int").configValues().get("switchId")
    // : null;
    // if (switchId == null || switchId.isEmpty()) {
    // log.warn("Missing INT device config for {}", deviceId);
    // return false;
    // }
    PiActionParam transitIdParam = new PiActionParam(FabricConstants.SWITCH_ID, copyFrom(handler().get(DeviceService.class).getDevice(deviceId).chassisId().id()));
    PiAction transitAction = PiAction.builder().withId(FabricConstants.FABRIC_EGRESS_PROCESS_INT_MAIN_PROCESS_INT_TRANSIT_INIT_METADATA).withParameter(transitIdParam).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(transitAction).build();
    TrafficSelector selector = DefaultTrafficSelector.builder().matchPi(PiCriterion.builder().matchExact(FabricConstants.HDR_INT_IS_VALID, (byte) 0x01).build()).build();
    FlowRule transitFlowRule = DefaultFlowRule.builder().withSelector(selector).withTreatment(treatment).fromApp(appId).withPriority(DEFAULT_PRIORITY).makePermanent().forDevice(deviceId).forTable(FabricConstants.FABRIC_EGRESS_PROCESS_INT_MAIN_PROCESS_INT_TRANSIT_TB_INT_INSERT).build();
    flowRuleService.applyFlowRules(transitFlowRule);
    return true;
}
Also used : DeviceService(org.onosproject.net.device.DeviceService) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 12 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class IntProgrammableImpl method buildWatchlistEntry.

private FlowRule buildWatchlistEntry(IntObjective obj) {
    int instructionBitmap = buildInstructionBitmap(obj.metadataTypes());
    PiActionParam hopMetaLenParam = new PiActionParam(IntConstants.HOP_METADATA_LEN, ImmutableByteSequence.copyFrom(Integer.bitCount(instructionBitmap)));
    PiActionParam hopCntParam = new PiActionParam(IntConstants.REMAINING_HOP_CNT, ImmutableByteSequence.copyFrom(MAXHOP));
    PiActionParam inst0003Param = new PiActionParam(IntConstants.INS_MASK0003, ImmutableByteSequence.copyFrom((instructionBitmap >> 12) & 0xF));
    PiActionParam inst0407Param = new PiActionParam(IntConstants.INS_MASK0407, ImmutableByteSequence.copyFrom((instructionBitmap >> 8) & 0xF));
    PiAction intSourceAction = PiAction.builder().withId(IntConstants.INGRESS_PROCESS_INT_SOURCE_INT_SOURCE_DSCP).withParameter(hopMetaLenParam).withParameter(hopCntParam).withParameter(inst0003Param).withParameter(inst0407Param).build();
    TrafficTreatment instTreatment = DefaultTrafficTreatment.builder().piTableAction(intSourceAction).build();
    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
    for (Criterion criterion : obj.selector().criteria()) {
        switch(criterion.type()) {
            case IPV4_SRC:
                sBuilder.matchIPSrc(((IPCriterion) criterion).ip());
                break;
            case IPV4_DST:
                sBuilder.matchIPDst(((IPCriterion) criterion).ip());
                break;
            case TCP_SRC:
                sBuilder.matchPi(PiCriterion.builder().matchTernary(IntConstants.HDR_LOCAL_METADATA_L4_SRC_PORT, ((TcpPortCriterion) criterion).tcpPort().toInt(), PORTMASK).build());
                break;
            case UDP_SRC:
                sBuilder.matchPi(PiCriterion.builder().matchTernary(IntConstants.HDR_LOCAL_METADATA_L4_SRC_PORT, ((UdpPortCriterion) criterion).udpPort().toInt(), PORTMASK).build());
                break;
            case TCP_DST:
                sBuilder.matchPi(PiCriterion.builder().matchTernary(IntConstants.HDR_LOCAL_METADATA_L4_DST_PORT, ((TcpPortCriterion) criterion).tcpPort().toInt(), PORTMASK).build());
                break;
            case UDP_DST:
                sBuilder.matchPi(PiCriterion.builder().matchTernary(IntConstants.HDR_LOCAL_METADATA_L4_DST_PORT, ((UdpPortCriterion) criterion).udpPort().toInt(), PORTMASK).build());
                break;
            default:
                log.warn("Unsupported criterion type: {}", criterion.type());
        }
    }
    return DefaultFlowRule.builder().forDevice(this.data().deviceId()).withSelector(sBuilder.build()).withTreatment(instTreatment).withPriority(DEFAULT_PRIORITY).forTable(IntConstants.INGRESS_PROCESS_INT_SOURCE_TB_INT_SOURCE).fromApp(appId).withIdleTimeout(IDLE_TIMEOUT).build();
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 13 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class IntProgrammableImpl method buildReportEntry.

private FlowRule buildReportEntry(IntDeviceConfig cfg) {
    TrafficSelector selector = DefaultTrafficSelector.builder().matchPi(PiCriterion.builder().matchExact(IntConstants.HDR_INT_IS_VALID, (byte) 0x01).build()).build();
    PiActionParam srcMacParam = new PiActionParam(IntConstants.SRC_MAC, ImmutableByteSequence.copyFrom(cfg.sinkMac().toBytes()));
    PiActionParam nextHopMacParam = new PiActionParam(IntConstants.MON_MAC, ImmutableByteSequence.copyFrom(cfg.collectorNextHopMac().toBytes()));
    PiActionParam srcIpParam = new PiActionParam(IntConstants.SRC_IP, ImmutableByteSequence.copyFrom(cfg.sinkIp().toOctets()));
    PiActionParam monIpParam = new PiActionParam(IntConstants.MON_IP, ImmutableByteSequence.copyFrom(cfg.collectorIp().toOctets()));
    PiActionParam monPortParam = new PiActionParam(IntConstants.MON_PORT, ImmutableByteSequence.copyFrom(cfg.collectorPort().toInt()));
    PiAction reportAction = PiAction.builder().withId(IntConstants.EGRESS_PROCESS_INT_REPORT_DO_REPORT_ENCAPSULATION).withParameter(srcMacParam).withParameter(nextHopMacParam).withParameter(srcIpParam).withParameter(monIpParam).withParameter(monPortParam).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(reportAction).build();
    return DefaultFlowRule.builder().withSelector(selector).withTreatment(treatment).fromApp(appId).withPriority(DEFAULT_PRIORITY).makePermanent().forDevice(this.data().deviceId()).forTable(IntConstants.EGRESS_PROCESS_INT_REPORT_TB_GENERATE_REPORT).build();
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 14 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class FabricPipeliner method ingressVlanRule.

public FlowRule ingressVlanRule(long port, boolean vlanValid, int vlanId) {
    final TrafficSelector selector = DefaultTrafficSelector.builder().add(Criteria.matchInPort(PortNumber.portNumber(port))).add(PiCriterion.builder().matchExact(FabricConstants.HDR_VLAN_IS_VALID, vlanValid ? ONE : ZERO).build()).build();
    final TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(PiAction.builder().withId(vlanValid ? FabricConstants.FABRIC_INGRESS_FILTERING_PERMIT : FabricConstants.FABRIC_INGRESS_FILTERING_PERMIT_WITH_INTERNAL_VLAN).withParameter(new PiActionParam(FabricConstants.VLAN_ID, vlanId)).withParameter(new PiActionParam(FabricConstants.PORT_TYPE, PORT_TYPE_INTERNAL)).build()).build();
    return DefaultFlowRule.builder().withSelector(selector).withTreatment(treatment).forTable(FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN).makePermanent().withPriority(DEFAULT_FLOW_PRIORITY).forDevice(deviceId).fromApp(appId).build();
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam)

Example 15 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class FilteringObjectiveTranslatorTest method buildExpectedFwdClassifierRule.

private Collection<FlowRule> buildExpectedFwdClassifierRule(PortNumber inPort, MacAddress dstMac, MacAddress dstMacMask, short ethType, byte fwdClass) {
    PiActionParam classParam = new PiActionParam(FabricConstants.FWD_TYPE, ImmutableByteSequence.copyFrom(fwdClass));
    PiAction fwdClassifierAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_FILTERING_SET_FORWARDING_TYPE).withParameter(classParam).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(fwdClassifierAction).build();
    TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder().matchInPort(inPort);
    if (dstMacMask != null) {
        sbuilder.matchEthDstMasked(dstMac, dstMacMask);
    } else {
        sbuilder.matchEthDstMasked(dstMac, MacAddress.EXACT_MASK);
    }
    // Special case for MPLS UNICAST forwarding, need to build 2 rules for MPLS+IPv4 and MPLS+IPv6
    if (ethType == Ethernet.MPLS_UNICAST) {
        return buildExpectedFwdClassifierRulesMpls(fwdClassifierAction, treatment, sbuilder);
    }
    sbuilder.matchPi(PiCriterion.builder().matchExact(FabricConstants.HDR_IP_ETH_TYPE, ethType).build());
    TrafficSelector selector = sbuilder.build();
    return List.of(DefaultFlowRule.builder().withPriority(PRIORITY).withSelector(selector).withTreatment(treatment).fromApp(APP_ID).forDevice(DEVICE_ID).makePermanent().forTable(FabricConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER).build());
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction)

Aggregations

PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)102 PiAction (org.onosproject.net.pi.runtime.PiAction)90 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)50 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)50 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)39 TrafficSelector (org.onosproject.net.flow.TrafficSelector)39 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)39 Test (org.junit.Test)30 FlowRule (org.onosproject.net.flow.FlowRule)27 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)21 GroupDescription (org.onosproject.net.group.GroupDescription)11 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)10 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)8 NextObjective (org.onosproject.net.flowobjective.NextObjective)8 PortNumber (org.onosproject.net.PortNumber)7 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)7 GroupBucket (org.onosproject.net.group.GroupBucket)7 GroupBuckets (org.onosproject.net.group.GroupBuckets)7 PiActionProfileGroupId (org.onosproject.net.pi.runtime.PiActionProfileGroupId)7 PiGroupKey (org.onosproject.net.pi.runtime.PiGroupKey)6