use of org.onosproject.net.flow.FlowRule.Builder in project onos by opennetworkinglab.
the class CorsaPipelineV3 method processSpecificSwitch.
@Override
protected Collection<FlowRule> processSpecificSwitch(ForwardingObjective fwd) {
TrafficSelector filteredSelector = DefaultTrafficSelector.builder().matchInPort(((PortCriterion) fwd.selector().getCriterion(Criterion.Type.IN_PORT)).port()).matchVlanId(((VlanIdCriterion) fwd.selector().getCriterion(Criterion.Type.VLAN_VID)).vlanId()).build();
Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority()).forDevice(deviceId).withSelector(filteredSelector).forTable(VLAN_CIRCUIT_TABLE);
if (fwd.treatment() != null) {
ruleBuilder.withTreatment(fwd.treatment());
} else {
if (fwd.nextId() != null) {
NextObjective nextObjective = pendingNext.getIfPresent(fwd.nextId());
if (nextObjective != null) {
pendingNext.invalidate(fwd.nextId());
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setVlanPcp((byte) 0).setQueue(0).meter(defaultMeterId);
nextObjective.next().forEach(trafficTreatment -> {
trafficTreatment.allInstructions().forEach(instruction -> {
treatment.add(instruction);
});
});
ruleBuilder.withTreatment(treatment.build());
} else {
log.warn("The group left!");
fwd.context().ifPresent(c -> c.onError(fwd, ObjectiveError.GROUPMISSING));
return ImmutableSet.of();
}
} else {
log.warn("Missing NextObjective ID for ForwardingObjective {}", fwd.id());
fail(fwd, ObjectiveError.BADPARAMS);
return ImmutableSet.of();
}
}
if (fwd.permanent()) {
ruleBuilder.makePermanent();
} else {
ruleBuilder.makeTemporary(fwd.timeout());
}
return Collections.singletonList(ruleBuilder.build());
}
use of org.onosproject.net.flow.FlowRule.Builder in project onos by opennetworkinglab.
the class AbstractCorsaPipeline method processVersatile.
private Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
log.debug("Processing vesatile forwarding objective");
TrafficSelector selector = fwd.selector();
EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
if (ethType == null) {
log.error("Versatile forwarding objective must include ethType");
fail(fwd, ObjectiveError.UNKNOWN);
return ImmutableSet.of();
}
Builder rule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(fwd.selector()).withTreatment(fwd.treatment()).withPriority(fwd.priority()).fromApp(fwd.appId()).makePermanent();
if (ethType.ethType().toShort() == Ethernet.TYPE_ARP) {
return processArpTraffic(fwd, rule);
} else if (ethType.ethType().toShort() == Ethernet.TYPE_LLDP || ethType.ethType().toShort() == Ethernet.TYPE_BSN) {
return processLinkDiscovery(fwd, rule);
} else if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) {
return processIpTraffic(fwd, rule);
}
log.warn("Driver does not support given versatile forwarding objective");
fail(fwd, ObjectiveError.UNSUPPORTED);
return ImmutableSet.of();
}
use of org.onosproject.net.flow.FlowRule.Builder in project onos by opennetworkinglab.
the class AbstractCorsaPipeline method processSpecificRoute.
private Collection<FlowRule> processSpecificRoute(ForwardingObjective fwd) {
TrafficSelector filteredSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(((IPCriterion) fwd.selector().getCriterion(Criterion.Type.IPV4_DST)).ip()).build();
TrafficTreatment.Builder tb = processSpecificRoutingTreatment();
if (fwd.nextId() != null) {
NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
GroupKey key = appKryo.deserialize(next.data());
Group group = groupService.getGroup(deviceId, key);
if (group == null) {
log.warn("The group left!");
fail(fwd, ObjectiveError.GROUPMISSING);
return ImmutableSet.of();
}
tb.group(group.id());
} else {
log.error("Missing NextObjective ID for ForwardingObjective {}", fwd.id());
fail(fwd, ObjectiveError.BADPARAMS);
return ImmutableSet.of();
}
Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority()).forDevice(deviceId).withSelector(filteredSelector).withTreatment(tb.build());
ruleBuilder = processSpecificRoutingRule(ruleBuilder);
if (fwd.permanent()) {
ruleBuilder.makePermanent();
} else {
ruleBuilder.makeTemporary(fwd.timeout());
}
return Collections.singletonList(ruleBuilder.build());
}
use of org.onosproject.net.flow.FlowRule.Builder in project onos by opennetworkinglab.
the class CorsaPipelineV39 method processUntaggedPackets.
private void processUntaggedPackets(boolean install) {
deviceService.getPorts(deviceId).forEach(port -> {
if (!port.number().isLogical()) {
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().pushVlan().setVlanId(VlanId.vlanId(NATIVE_VLAN)).transition(VLAN_MAC_XLATE_TABLE);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder().matchVlanId(VlanId.NONE).matchInPort(port.number());
Builder rule = DefaultFlowRule.builder().forDevice(deviceId).withTreatment(treatment.build()).withSelector(selector.build()).withPriority(CONTROLLER_PRIORITY).fromApp(appId).makePermanent().forTable(VLAN_CHECK_TABLE);
processFlowRule(install, rule.build(), "Provisioned vlan untagged packet table");
}
});
}
Aggregations