Search in sources :

Example 21 with PiCriterion

use of org.onosproject.net.flow.criteria.PiCriterion in project fabric-tna by stratum.

the class FabricUpfTranslator method upfApplicationToFabricEntry.

public FlowRule upfApplicationToFabricEntry(UpfApplication appFilter, DeviceId deviceId, ApplicationId appId) throws UpfProgrammableException {
    PiCriterion match = buildApplicationCriterion(appFilter);
    PiAction action = PiAction.builder().withId(FABRIC_INGRESS_UPF_SET_APP_ID).withParameter(new PiActionParam(APP_ID, appFilter.appId())).build();
    return DefaultFlowRule.builder().forDevice(deviceId).fromApp(appId).makePermanent().forTable(FABRIC_INGRESS_UPF_APPLICATIONS).withSelector(DefaultTrafficSelector.builder().matchPi(match).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(action).build()).withPriority(appFilter.priority()).build();
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 22 with PiCriterion

use of org.onosproject.net.flow.criteria.PiCriterion in project fabric-tna by stratum.

the class FilteringObjectiveTranslator method ingressPortVlanRule.

private void ingressPortVlanRule(FilteringObjective obj, PortCriterion inPortCriterion, VlanIdCriterion outerVlanCriterion, VlanIdCriterion innerVlanCriterion, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    final boolean outerVlanValid = outerVlanCriterion != null && !outerVlanCriterion.vlanId().equals(VlanId.NONE);
    final boolean innerVlanValid = innerVlanCriterion != null && !innerVlanCriterion.vlanId().equals(VlanId.NONE);
    if (innerVlanValid && !capabilities.supportDoubleVlanTerm()) {
        throw new FabricPipelinerException("Found 2 VLAN IDs, but the pipeline does not support double VLAN termination", ObjectiveError.UNSUPPORTED);
    }
    final PiCriterion piCriterion = PiCriterion.builder().matchExact(P4InfoConstants.HDR_VLAN_IS_VALID, outerVlanValid ? ONE : ZERO).build();
    final TrafficSelector.Builder selector = DefaultTrafficSelector.builder().add(inPortCriterion).add(piCriterion);
    if (outerVlanValid) {
        selector.add(outerVlanCriterion);
    }
    if (innerVlanValid) {
        selector.add(innerVlanCriterion);
    }
    final TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
    if (obj.type().equals(FilteringObjective.Type.DENY)) {
        treatmentBuilder.piTableAction(DENY);
    } else {
        // FIXME SDFAB-52 to complete the work on metadata
        Byte portType = portType(obj);
        if (portType == null) {
            throw new FabricPipelinerException(format("Unsupported port_type configuration: metadata=%s", obj.meta()), ObjectiveError.BADPARAMS);
        }
        try {
            treatmentBuilder.piTableAction(mapFilteringTreatment(obj.meta(), P4InfoConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN, portType));
        } catch (PiInterpreterException ex) {
            throw new FabricPipelinerException(format("Unable to map treatment for table '%s': %s", P4InfoConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN, ex.getMessage()), ObjectiveError.UNSUPPORTED);
        }
        // the EgressDscpRewriter table.
        if (portType == PORT_TYPE_EDGE) {
            // We need to make sure that traffic exiting an edge port doesn't
            // carry the SD-Fabric DSCP field.
            resultBuilder.addFlowRule(buildEgressDscpRewriter(obj, inPortCriterion, true));
        } else if (portType == PORT_TYPE_INFRA) {
            // We need to make sure that traffic exiting an infra port carry
            // SD-Fabric DSCP field.
            resultBuilder.addFlowRule(buildEgressDscpRewriter(obj, inPortCriterion, false));
            resultBuilder.addFlowRule(buildTrustDscpEntry(obj, inPortCriterion));
        }
    }
    resultBuilder.addFlowRule(flowRule(obj, P4InfoConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN, selector.build(), treatmentBuilder.build()));
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) PiInterpreterException(org.onosproject.net.pi.model.PiPipelineInterpreter.PiInterpreterException) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 23 with PiCriterion

use of org.onosproject.net.flow.criteria.PiCriterion in project fabric-tna by stratum.

the class FabricUpfProgrammable method removeGtpTunnelPeer.

private void removeGtpTunnelPeer(UpfGtpTunnelPeer peer) throws UpfProgrammableException {
    PiCriterion match = PiCriterion.builder().matchExact(HDR_TUN_PEER_ID, peer.tunPeerId()).build();
    removeEntries(Lists.newArrayList(Pair.of(FABRIC_INGRESS_UPF_IG_TUNNEL_PEERS, match), Pair.of(FABRIC_EGRESS_UPF_EG_TUNNEL_PEERS, match)), false, DEFAULT_PRIORITY);
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion)

Example 24 with PiCriterion

use of org.onosproject.net.flow.criteria.PiCriterion in project fabric-tna by stratum.

the class FabricUpfProgrammable method removeSessionUplink.

private void removeSessionUplink(UpfSessionUplink ueSession) throws UpfProgrammableException {
    final PiCriterion match;
    match = PiCriterion.builder().matchExact(HDR_TEID, ueSession.teid()).matchExact(HDR_TUNNEL_IPV4_DST, ueSession.tunDstAddr().toOctets()).build();
    log.info("Removing {}", ueSession);
    removeEntry(match, FABRIC_INGRESS_UPF_UPLINK_SESSIONS, false);
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion)

Example 25 with PiCriterion

use of org.onosproject.net.flow.criteria.PiCriterion in project fabric-tna by stratum.

the class FabricIntProgrammableTest method buildCollectorWatchlistRule.

private FlowRule buildCollectorWatchlistRule(DeviceId deviceId) {
    final PiAction watchlistAction = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_INT_WATCHLIST_NO_REPORT_COLLECTOR).build();
    final TrafficTreatment watchlistTreatment = DefaultTrafficTreatment.builder().piTableAction(watchlistAction).build();
    final PiCriterion piCriterion = PiCriterion.builder().matchExact(P4InfoConstants.HDR_IPV4_VALID, 1).matchRange(P4InfoConstants.HDR_L4_DPORT, COLLECTOR_PORT.toInt(), COLLECTOR_PORT.toInt()).build();
    final TrafficSelector watchlistSelector = DefaultTrafficSelector.builder().matchIPDst(COLLECTOR_IP.toIpPrefix()).matchIPProtocol(IPv4.PROTOCOL_UDP).matchPi(piCriterion).build();
    return DefaultFlowRule.builder().forDevice(deviceId).withSelector(watchlistSelector).withTreatment(watchlistTreatment).withPriority(DEFAULT_PRIORITY + 10).forTable(P4InfoConstants.FABRIC_INGRESS_INT_WATCHLIST_WATCHLIST).fromApp(APP_ID).makePermanent().build();
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction)

Aggregations

PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)69 PiAction (org.onosproject.net.pi.runtime.PiAction)45 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)31 TrafficSelector (org.onosproject.net.flow.TrafficSelector)29 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)28 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)27 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)26 FlowRule (org.onosproject.net.flow.FlowRule)25 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)16 PiTableAction (org.onosproject.net.pi.runtime.PiTableAction)13 Test (org.junit.Test)8 UpfProgrammableException (org.onosproject.net.behaviour.upf.UpfProgrammableException)8 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)8 NextObjective (org.onosproject.net.flowobjective.NextObjective)8 PiActionId (org.onosproject.net.pi.model.PiActionId)7 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)6 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)6 GroupBucket (org.onosproject.net.group.GroupBucket)6 GroupBuckets (org.onosproject.net.group.GroupBuckets)6 GroupDescription (org.onosproject.net.group.GroupDescription)6