use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.
the class SpringOpenTTP method isSupportedEthDstObjective.
private boolean isSupportedEthDstObjective(ForwardingObjective fwd) {
TrafficSelector selector = fwd.selector();
EthCriterion ethDst = (EthCriterion) selector.getCriterion(Criterion.Type.ETH_DST);
VlanIdCriterion vlanId = (VlanIdCriterion) selector.getCriterion(Criterion.Type.VLAN_VID);
if (ethDst == null && vlanId == null) {
return false;
}
return true;
}
use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.
the class AbstractCorsaPipeline method processFilter.
private void processFilter(FilteringObjective filt, boolean install, ApplicationId applicationId) {
// This driver only processes filtering criteria defined with switch
// ports as the key
PortCriterion port;
if (!filt.key().equals(Criteria.dummy()) && filt.key().type() == Criterion.Type.IN_PORT) {
port = (PortCriterion) filt.key();
} else {
log.warn("No key defined in filtering objective from app: {}. Not" + "processing filtering objective", applicationId);
fail(filt, ObjectiveError.UNKNOWN);
return;
}
// convert filtering conditions for switch-intfs into flowrules
FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
for (Criterion c : filt.conditions()) {
if (c.type() == Criterion.Type.ETH_DST) {
EthCriterion eth = (EthCriterion) c;
FlowRule.Builder rule = processEthFiler(filt, eth, port);
rule.forDevice(deviceId).fromApp(applicationId);
ops = install ? ops.add(rule.build()) : ops.remove(rule.build());
} else if (c.type() == Criterion.Type.VLAN_VID) {
VlanIdCriterion vlan = (VlanIdCriterion) c;
FlowRule.Builder rule = processVlanFiler(filt, vlan, port);
rule.forDevice(deviceId).fromApp(applicationId);
ops = install ? ops.add(rule.build()) : ops.remove(rule.build());
} else if (c.type() == Criterion.Type.IPV4_DST) {
IPCriterion ip = (IPCriterion) c;
FlowRule.Builder rule = processIpFilter(filt, ip, port);
rule.forDevice(deviceId).fromApp(applicationId);
ops = install ? ops.add(rule.build()) : ops.remove(rule.build());
} else {
log.warn("Driver does not currently process filtering condition" + " of type: {}", c.type());
fail(filt, ObjectiveError.UNSUPPORTED);
}
}
// apply filtering flow rules
flowRuleService.apply(ops.build(new FlowRuleOperationsContext() {
@Override
public void onSuccess(FlowRuleOperations ops) {
pass(filt);
log.info("Applied filtering rules");
}
@Override
public void onError(FlowRuleOperations ops) {
fail(filt, ObjectiveError.FLOWINSTALLATIONFAILED);
log.info("Failed to apply filtering rules");
}
}));
}
use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.
the class AbstractCorsaPipeline method processSpecific.
private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
log.debug("Processing specific forwarding objective");
TrafficSelector selector = fwd.selector();
EthTypeCriterion ethTypeCriterion = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
VlanIdCriterion vlanIdCriterion = (VlanIdCriterion) selector.getCriterion(Criterion.Type.VLAN_VID);
if (ethTypeCriterion != null) {
short et = ethTypeCriterion.ethType().toShort();
if (et == Ethernet.TYPE_IPV4) {
return processSpecificRoute(fwd);
} else if (et == Ethernet.TYPE_VLAN) {
/* The ForwardingObjective must specify VLAN ethtype in order to use the Transit Circuit */
return processSpecificSwitch(fwd);
}
} else if (vlanIdCriterion != null) {
return processSpecificSwitch(fwd);
}
fail(fwd, ObjectiveError.UNSUPPORTED);
return ImmutableSet.of();
}
use of org.onosproject.net.flow.criteria.VlanIdCriterion 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.criteria.VlanIdCriterion in project onos by opennetworkinglab.
the class FilteringObjectiveTranslator method doTranslate.
@Override
public ObjectiveTranslation doTranslate(FilteringObjective obj) throws FabricPipelinerException {
final ObjectiveTranslation.Builder resultBuilder = ObjectiveTranslation.builder();
if (obj.key() == null || obj.key().type() != Criterion.Type.IN_PORT) {
throw new FabricPipelinerException(format("Unsupported or missing filtering key: key=%s", obj.key()), ObjectiveError.BADPARAMS);
}
if (!isValidSrMetadata(obj)) {
throw new FabricPipelinerException(format("Unsupported metadata configuration: metadata=%s", obj.meta()), ObjectiveError.BADPARAMS);
}
final PortCriterion inPort = (PortCriterion) obj.key();
final VlanIdCriterion outerVlan = (VlanIdCriterion) criterion(obj.conditions(), Criterion.Type.VLAN_VID);
final VlanIdCriterion innerVlan = (VlanIdCriterion) criterion(obj.conditions(), Criterion.Type.INNER_VLAN_VID);
final EthCriterion ethDst = (EthCriterion) criterion(obj.conditions(), Criterion.Type.ETH_DST);
final EthCriterion ethDstMasked = (EthCriterion) criterion(obj.conditions(), Criterion.Type.ETH_DST_MASKED);
ingressPortVlanRule(obj, inPort, outerVlan, innerVlan, resultBuilder);
if (shouldModifyFwdClassifierTable(obj)) {
fwdClassifierRules(obj, inPort, ethDst, ethDstMasked, resultBuilder);
} else {
log.debug("Skipping fwd classifier rules for device {}.", deviceId);
}
return resultBuilder.build();
}
Aggregations