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();
}
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()));
}
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);
}
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);
}
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();
}
Aggregations