use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.
the class OpenVSwitchPipeline method processSpecific.
private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
log.debug("Processing specific forwarding objective");
TrafficSelector selector = fwd.selector();
TrafficTreatment tb = fwd.treatment();
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority()).forDevice(deviceId).withSelector(selector).withTreatment(tb).makeTemporary(TIME_OUT);
ruleBuilder.withPriority(fwd.priority());
if (fwd.permanent()) {
ruleBuilder.makePermanent();
}
Integer transition = null;
Integer forTable = null;
// MAC table flow rules
if (selector.getCriterion(Type.TUNNEL_ID) != null && (selector.getCriterion(Type.ETH_DST) != null || selector.getCriterion(Type.ETH_SRC) != null)) {
forTable = MAC_TABLE;
return reassemblyFlowRule(ruleBuilder, tb, transition, forTable);
}
// CLASSIFIER table flow rules
if (selector.getCriterion(Type.IN_PORT) != null) {
forTable = CLASSIFIER_TABLE;
if (selector.getCriterion(Type.ETH_SRC) != null && selector.getCriterion(Type.ETH_DST) != null) {
transition = L3FWD_TABLE;
} else if (selector.getCriterion(Type.ETH_SRC) != null || selector.getCriterion(Type.TUNNEL_ID) != null) {
transition = MAC_TABLE;
} else if (selector.getCriterion(Type.IPV4_DST) != null) {
transition = DNAT_TABLE;
} else if (selector.getCriterion(Type.ETH_TYPE) != null && selector.getCriterion(Type.ETH_TYPE).equals(Criteria.matchEthType(EtherType.ARP.ethType().toShort()))) {
transition = ARP_TABLE;
}
return reassemblyFlowRule(ruleBuilder, tb, transition, forTable);
}
// ARP table flow rules
if (selector.getCriterion(Type.ETH_TYPE) != null && selector.getCriterion(Type.ETH_TYPE).equals(Criteria.matchEthType(EtherType.ARP.ethType().toShort()))) {
// CLASSIFIER table arp flow rules
if (selector.getCriterion(Type.TUNNEL_ID) == null) {
if (selector.getCriterion(Type.ARP_OP) != null) {
forTable = CLASSIFIER_TABLE;
return reassemblyFlowRule(ruleBuilder, tb, null, forTable);
}
transition = ARP_TABLE;
forTable = CLASSIFIER_TABLE;
return reassemblyFlowRule(ruleBuilder, tb, transition, forTable);
}
forTable = ARP_TABLE;
return reassemblyFlowRule(ruleBuilder, tb, transition, forTable);
}
// SNAT table flow rules
if (selector.getCriterion(Type.TUNNEL_ID) != null && selector.getCriterion(Type.IPV4_SRC) != null) {
transition = MAC_TABLE;
forTable = SNAT_TABLE;
return reassemblyFlowRule(ruleBuilder, tb, transition, forTable);
}
// L3FWD table flow rules
if (selector.getCriterion(Type.TUNNEL_ID) != null && selector.getCriterion(Type.IPV4_DST) != null) {
transition = MAC_TABLE;
forTable = L3FWD_TABLE;
return reassemblyFlowRule(ruleBuilder, tb, transition, forTable);
}
// DNAT table flow rules
if (selector.getCriterion(Type.IPV4_DST) != null) {
IPCriterion ipCriterion = (IPCriterion) selector.getCriterion(Type.IPV4_DST);
IpPrefix ipPrefix = ipCriterion.ip();
// specific CLASSIFIER table flow rules for userdata
if (ipPrefix.address().equals(IpAddress.valueOf(USERDATA_IP))) {
forTable = CLASSIFIER_TABLE;
transition = MAC_TABLE;
return reassemblyFlowRule(ruleBuilder, tb, transition, forTable);
}
transition = L3FWD_TABLE;
forTable = DNAT_TABLE;
return reassemblyFlowRule(ruleBuilder, tb, transition, forTable);
}
return Collections.singletonList(ruleBuilder.build());
}
use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.
the class OpenVSwitchPipeline method processVersatile.
private Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
log.debug("Processing versatile forwarding objective");
TrafficSelector selector = fwd.selector();
TrafficTreatment tb = fwd.treatment();
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority()).forDevice(deviceId).withSelector(selector).withTreatment(tb).makeTemporary(TIME_OUT);
ruleBuilder.withPriority(fwd.priority());
if (fwd.priority() == 100) {
ruleBuilder.forTable(ENCAP_OUTPUT_TABLE);
} else if (fwd.priority() == 200) {
ruleBuilder.forTable(TUN_SEND_TABLE);
} else {
ruleBuilder.forTable(CLASSIFIER_TABLE);
}
if (fwd.permanent()) {
ruleBuilder.makePermanent();
}
return Collections.singletonList(ruleBuilder.build());
}
use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.
the class PicaPipeline method processSpecific.
private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
log.debug("Processing specific forwarding objective");
TrafficSelector selector = fwd.selector();
EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) {
fail(fwd, ObjectiveError.UNSUPPORTED);
return Collections.emptySet();
}
List<FlowRule> ipflows = new ArrayList<FlowRule>();
for (Filter f : filters) {
TrafficSelector filteredSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(((IPCriterion) selector.getCriterion(Criterion.Type.IPV4_DST)).ip()).matchEthDst(f.mac()).matchVlanId(f.vlanId()).build();
TrafficTreatment tt = null;
if (fwd.nextId() != null) {
NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
if (next == null) {
log.error("next-id {} does not exist in store", fwd.nextId());
return Collections.emptySet();
}
tt = appKryo.deserialize(next.data());
if (tt == null) {
log.error("Error in deserializing next-id {}", fwd.nextId());
return Collections.emptySet();
}
}
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority()).forDevice(deviceId).withSelector(filteredSelector).withTreatment(tt);
if (fwd.permanent()) {
ruleBuilder.makePermanent();
} else {
ruleBuilder.makeTemporary(fwd.timeout());
}
ruleBuilder.forTable(IP_UNICAST_TABLE);
ipflows.add(ruleBuilder.build());
}
return ipflows;
}
use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.
the class SpringOpenTTP method processEthTypeSpecificObjective.
protected Collection<FlowRule> processEthTypeSpecificObjective(ForwardingObjective fwd) {
TrafficSelector selector = fwd.selector();
EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
TrafficSelector.Builder filteredSelectorBuilder = DefaultTrafficSelector.builder();
int forTableId = -1;
if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) {
filteredSelectorBuilder = filteredSelectorBuilder.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(((IPCriterion) selector.getCriterion(Criterion.Type.IPV4_DST)).ip());
forTableId = ipv4UnicastTableId;
log.debug("processing IPv4 specific forwarding objective:{} in dev:{}", fwd.id(), deviceId);
} else {
filteredSelectorBuilder = filteredSelectorBuilder.matchEthType(Ethernet.MPLS_UNICAST).matchMplsLabel(((MplsCriterion) selector.getCriterion(Criterion.Type.MPLS_LABEL)).label());
if (selector.getCriterion(Criterion.Type.MPLS_BOS) != null) {
filteredSelectorBuilder.matchMplsBos(((MplsBosCriterion) selector.getCriterion(Type.MPLS_BOS)).mplsBos());
}
forTableId = mplsTableId;
log.debug("processing MPLS specific forwarding objective:{} in dev:{}", fwd.id(), deviceId);
}
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
if (fwd.treatment() != null) {
for (Instruction i : fwd.treatment().allInstructions()) {
treatmentBuilder.add(i);
}
}
if (fwd.nextId() != null) {
NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
if (next != null) {
SpringOpenGroup soGroup = appKryo.deserialize(next.data());
if (soGroup.dummy) {
log.debug("Adding {} flow-actions for fwd. obj. {} -> next:{} " + "in dev: {}", soGroup.treatment.allInstructions().size(), fwd.id(), fwd.nextId(), deviceId);
for (Instruction ins : soGroup.treatment.allInstructions()) {
treatmentBuilder.add(ins);
}
} else {
GroupKey key = soGroup.key;
Group group = groupService.getGroup(deviceId, key);
if (group == null) {
log.warn("The group left!");
fail(fwd, ObjectiveError.GROUPMISSING);
return Collections.emptySet();
}
treatmentBuilder.deferred().group(group.id());
log.debug("Adding OUTGROUP action to group:{} for fwd. obj. {} " + "for next:{} in dev: {}", group.id(), fwd.id(), fwd.nextId(), deviceId);
}
} else {
log.warn("processSpecific: No associated next objective object");
fail(fwd, ObjectiveError.GROUPMISSING);
return Collections.emptySet();
}
}
TrafficSelector filteredSelector = filteredSelectorBuilder.build();
TrafficTreatment treatment = treatmentBuilder.transition(aclTableId).build();
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority()).forDevice(deviceId).withSelector(filteredSelector).withTreatment(treatment);
if (fwd.permanent()) {
ruleBuilder.makePermanent();
} else {
ruleBuilder.makeTemporary(fwd.timeout());
}
ruleBuilder.forTable(forTableId);
return Collections.singletonList(ruleBuilder.build());
}
use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.
the class SpringOpenTTP method isSupportedEthTypeObjective.
private boolean isSupportedEthTypeObjective(ForwardingObjective fwd) {
TrafficSelector selector = fwd.selector();
EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
if ((ethType == null) || ((ethType.ethType().toShort() != Ethernet.TYPE_IPV4) && (ethType.ethType().toShort() != Ethernet.MPLS_UNICAST))) {
return false;
}
return true;
}
Aggregations