Fixed traffic selector builder to allow only one criterion.
Temporarily disabled flow rule time-out.
Showing
13 changed files
with
143 additions
and
98 deletions
| ... | @@ -184,13 +184,13 @@ public class ReactiveForwarding { | ... | @@ -184,13 +184,13 @@ public class ReactiveForwarding { |
| 184 | 184 | ||
| 185 | // Install the flow rule to handle this type of message from now on. | 185 | // Install the flow rule to handle this type of message from now on. |
| 186 | Ethernet inPkt = context.inPacket().parsed(); | 186 | Ethernet inPkt = context.inPacket().parsed(); |
| 187 | - TrafficSelector.Builder builder = new DefaultTrafficSelector.Builder(); | 187 | + TrafficSelector.Builder builder = DefaultTrafficSelector.builder(); |
| 188 | builder.matchEthType(inPkt.getEtherType()) | 188 | builder.matchEthType(inPkt.getEtherType()) |
| 189 | .matchEthSrc(inPkt.getSourceMAC()) | 189 | .matchEthSrc(inPkt.getSourceMAC()) |
| 190 | .matchEthDst(inPkt.getDestinationMAC()) | 190 | .matchEthDst(inPkt.getDestinationMAC()) |
| 191 | .matchInport(context.inPacket().receivedFrom().port()); | 191 | .matchInport(context.inPacket().receivedFrom().port()); |
| 192 | 192 | ||
| 193 | - TrafficTreatment.Builder treat = new DefaultTrafficTreatment.Builder(); | 193 | + TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder(); |
| 194 | treat.setOutput(portNumber); | 194 | treat.setOutput(portNumber); |
| 195 | 195 | ||
| 196 | FlowRule f = new DefaultFlowRule(context.inPacket().receivedFrom().deviceId(), | 196 | FlowRule f = new DefaultFlowRule(context.inPacket().receivedFrom().deviceId(), | ... | ... |
| ... | @@ -39,19 +39,15 @@ public class IntentInstallCommand extends AbstractShellCommand { | ... | @@ -39,19 +39,15 @@ public class IntentInstallCommand extends AbstractShellCommand { |
| 39 | HostId srcId = HostId.hostId(src); | 39 | HostId srcId = HostId.hostId(src); |
| 40 | HostId dstId = HostId.hostId(dst); | 40 | HostId dstId = HostId.hostId(dst); |
| 41 | 41 | ||
| 42 | - TrafficSelector.Builder builder = new DefaultTrafficSelector.Builder(); | 42 | + TrafficSelector.Builder builder = DefaultTrafficSelector.builder(); |
| 43 | - builder | 43 | + builder.matchEthSrc(hosts.getHost(srcId).mac()) |
| 44 | - .matchEthSrc(hosts.getHost(srcId).mac()) | 44 | + .matchEthDst(hosts.getHost(dstId).mac()); |
| 45 | - .matchEthDst(hosts.getHost(dstId).mac()); | 45 | + |
| 46 | - | 46 | + TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder(); |
| 47 | - TrafficTreatment.Builder treat = new DefaultTrafficTreatment.Builder(); | 47 | + |
| 48 | - | 48 | + HostToHostIntent intent = |
| 49 | - HostToHostIntent intent = new HostToHostIntent( | 49 | + new HostToHostIntent(new IntentId(id++), srcId, dstId, |
| 50 | - new IntentId(id++), | 50 | + builder.build(), treat.build()); |
| 51 | - srcId, | ||
| 52 | - dstId, | ||
| 53 | - builder.build(), | ||
| 54 | - treat.build()); | ||
| 55 | 51 | ||
| 56 | log.info("Adding intent {}", intent); | 52 | log.info("Adding intent {}", intent); |
| 57 | 53 | ... | ... |
| 1 | package org.onlab.onos.net.flow; | 1 | package org.onlab.onos.net.flow; |
| 2 | 2 | ||
| 3 | -import static org.slf4j.LoggerFactory.getLogger; | 3 | +import com.google.common.collect.ImmutableSet; |
| 4 | - | ||
| 5 | -import java.util.Collections; | ||
| 6 | -import java.util.HashSet; | ||
| 7 | -import java.util.Objects; | ||
| 8 | -import java.util.Set; | ||
| 9 | - | ||
| 10 | import org.onlab.onos.net.PortNumber; | 4 | import org.onlab.onos.net.PortNumber; |
| 11 | import org.onlab.onos.net.flow.criteria.Criteria; | 5 | import org.onlab.onos.net.flow.criteria.Criteria; |
| 12 | import org.onlab.onos.net.flow.criteria.Criterion; | 6 | import org.onlab.onos.net.flow.criteria.Criterion; |
| 13 | import org.onlab.packet.IpPrefix; | 7 | import org.onlab.packet.IpPrefix; |
| 14 | import org.onlab.packet.MacAddress; | 8 | import org.onlab.packet.MacAddress; |
| 15 | import org.onlab.packet.VlanId; | 9 | import org.onlab.packet.VlanId; |
| 16 | -import org.slf4j.Logger; | ||
| 17 | 10 | ||
| 11 | +import java.util.Collections; | ||
| 12 | +import java.util.HashMap; | ||
| 13 | +import java.util.Map; | ||
| 14 | +import java.util.Objects; | ||
| 15 | +import java.util.Set; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Default traffic selector implementation. | ||
| 19 | + */ | ||
| 18 | public final class DefaultTrafficSelector implements TrafficSelector { | 20 | public final class DefaultTrafficSelector implements TrafficSelector { |
| 19 | 21 | ||
| 20 | - private final Set<Criterion> selector; | 22 | + private final Set<Criterion> criteria; |
| 21 | 23 | ||
| 22 | - private DefaultTrafficSelector(Set<Criterion> selector) { | 24 | + /** |
| 23 | - this.selector = Collections.unmodifiableSet(selector); | 25 | + * Creates a new traffic selector with the specified criteria. |
| 26 | + * | ||
| 27 | + * @param criteria criteria | ||
| 28 | + */ | ||
| 29 | + private DefaultTrafficSelector(Set<Criterion> criteria) { | ||
| 30 | + this.criteria = Collections.unmodifiableSet(criteria); | ||
| 24 | } | 31 | } |
| 25 | 32 | ||
| 26 | @Override | 33 | @Override |
| 27 | public Set<Criterion> criteria() { | 34 | public Set<Criterion> criteria() { |
| 28 | - return selector; | 35 | + return criteria; |
| 29 | } | 36 | } |
| 30 | 37 | ||
| 31 | @Override | 38 | @Override |
| 32 | public int hashCode() { | 39 | public int hashCode() { |
| 33 | - return Objects.hash(selector); | 40 | + return Objects.hash(criteria); |
| 34 | } | 41 | } |
| 35 | 42 | ||
| 36 | @Override | 43 | @Override |
| ... | @@ -40,23 +47,50 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -40,23 +47,50 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
| 40 | } | 47 | } |
| 41 | if (obj instanceof DefaultTrafficSelector) { | 48 | if (obj instanceof DefaultTrafficSelector) { |
| 42 | DefaultTrafficSelector that = (DefaultTrafficSelector) obj; | 49 | DefaultTrafficSelector that = (DefaultTrafficSelector) obj; |
| 43 | - return Objects.equals(selector, that.selector); | 50 | + return Objects.equals(criteria, that.criteria); |
| 44 | 51 | ||
| 45 | } | 52 | } |
| 46 | return false; | 53 | return false; |
| 47 | } | 54 | } |
| 48 | 55 | ||
| 56 | + /** | ||
| 57 | + * Returns a new traffic selector builder. | ||
| 58 | + * | ||
| 59 | + * @return traffic selector builder | ||
| 60 | + */ | ||
| 61 | + public static TrafficSelector.Builder builder() { | ||
| 62 | + return new Builder(); | ||
| 63 | + } | ||
| 49 | 64 | ||
| 65 | + /** | ||
| 66 | + * Returns a new traffic selector builder primed to produce entities | ||
| 67 | + * patterned after the supplied selector. | ||
| 68 | + * | ||
| 69 | + * @return traffic selector builder | ||
| 70 | + */ | ||
| 71 | + public static TrafficSelector.Builder builder(TrafficSelector selector) { | ||
| 72 | + return new Builder(selector); | ||
| 73 | + } | ||
| 50 | 74 | ||
| 51 | - public static class Builder implements TrafficSelector.Builder { | 75 | + /** |
| 76 | + * Builder of traffic selector entities. | ||
| 77 | + */ | ||
| 78 | + public static final class Builder implements TrafficSelector.Builder { | ||
| 52 | 79 | ||
| 53 | - private final Logger log = getLogger(getClass()); | 80 | + private final Map<Criterion.Type, Criterion> selector = new HashMap<>(); |
| 54 | 81 | ||
| 55 | - private final Set<Criterion> selector = new HashSet<>(); | 82 | + private Builder() { |
| 83 | + } | ||
| 84 | + | ||
| 85 | + private Builder(TrafficSelector selector) { | ||
| 86 | + for (Criterion c : selector.criteria()) { | ||
| 87 | + add(c); | ||
| 88 | + } | ||
| 89 | + } | ||
| 56 | 90 | ||
| 57 | @Override | 91 | @Override |
| 58 | public Builder add(Criterion criterion) { | 92 | public Builder add(Criterion criterion) { |
| 59 | - selector.add(criterion); | 93 | + selector.put(criterion.type(), criterion); |
| 60 | return this; | 94 | return this; |
| 61 | } | 95 | } |
| 62 | 96 | ||
| ... | @@ -107,7 +141,7 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -107,7 +141,7 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
| 107 | 141 | ||
| 108 | @Override | 142 | @Override |
| 109 | public TrafficSelector build() { | 143 | public TrafficSelector build() { |
| 110 | - return new DefaultTrafficSelector(selector); | 144 | + return new DefaultTrafficSelector(ImmutableSet.copyOf(selector.values())); |
| 111 | } | 145 | } |
| 112 | 146 | ||
| 113 | } | 147 | } | ... | ... |
| 1 | package org.onlab.onos.net.flow; | 1 | package org.onlab.onos.net.flow; |
| 2 | 2 | ||
| 3 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 4 | - | ||
| 5 | -import java.util.Collections; | ||
| 6 | -import java.util.LinkedList; | ||
| 7 | -import java.util.List; | ||
| 8 | - | ||
| 9 | import org.onlab.onos.net.PortNumber; | 3 | import org.onlab.onos.net.PortNumber; |
| 10 | import org.onlab.onos.net.flow.instructions.Instruction; | 4 | import org.onlab.onos.net.flow.instructions.Instruction; |
| 11 | import org.onlab.onos.net.flow.instructions.Instructions; | 5 | import org.onlab.onos.net.flow.instructions.Instructions; |
| ... | @@ -14,10 +8,24 @@ import org.onlab.packet.MacAddress; | ... | @@ -14,10 +8,24 @@ import org.onlab.packet.MacAddress; |
| 14 | import org.onlab.packet.VlanId; | 8 | import org.onlab.packet.VlanId; |
| 15 | import org.slf4j.Logger; | 9 | import org.slf4j.Logger; |
| 16 | 10 | ||
| 11 | +import java.util.Collections; | ||
| 12 | +import java.util.LinkedList; | ||
| 13 | +import java.util.List; | ||
| 14 | + | ||
| 15 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Default traffic treatment implementation. | ||
| 19 | + */ | ||
| 17 | public final class DefaultTrafficTreatment implements TrafficTreatment { | 20 | public final class DefaultTrafficTreatment implements TrafficTreatment { |
| 18 | 21 | ||
| 19 | private final List<Instruction> instructions; | 22 | private final List<Instruction> instructions; |
| 20 | 23 | ||
| 24 | + /** | ||
| 25 | + * Creates a new traffic treatment from the specified list of instructions. | ||
| 26 | + * | ||
| 27 | + * @param instructions treatment instructions | ||
| 28 | + */ | ||
| 21 | private DefaultTrafficTreatment(List<Instruction> instructions) { | 29 | private DefaultTrafficTreatment(List<Instruction> instructions) { |
| 22 | this.instructions = Collections.unmodifiableList(instructions); | 30 | this.instructions = Collections.unmodifiableList(instructions); |
| 23 | } | 31 | } |
| ... | @@ -28,12 +36,19 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -28,12 +36,19 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
| 28 | } | 36 | } |
| 29 | 37 | ||
| 30 | /** | 38 | /** |
| 31 | - * Builds a list of treatments following the following order. | 39 | + * Returns a new traffic treatment builder. |
| 32 | - * Modifications -> Group -> Output (including drop) | ||
| 33 | * | 40 | * |
| 41 | + * @return traffic treatment builder | ||
| 34 | */ | 42 | */ |
| 43 | + public static TrafficTreatment.Builder builder() { | ||
| 44 | + return new Builder(); | ||
| 45 | + } | ||
| 35 | 46 | ||
| 36 | - public static class Builder implements TrafficTreatment.Builder { | 47 | + /** |
| 48 | + * Builds a list of treatments following the following order. | ||
| 49 | + * Modifications -> Group -> Output (including drop) | ||
| 50 | + */ | ||
| 51 | + public static final class Builder implements TrafficTreatment.Builder { | ||
| 37 | 52 | ||
| 38 | private final Logger log = getLogger(getClass()); | 53 | private final Logger log = getLogger(getClass()); |
| 39 | 54 | ||
| ... | @@ -47,27 +62,31 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -47,27 +62,31 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
| 47 | // TODO: should be a list of instructions based on modification objects | 62 | // TODO: should be a list of instructions based on modification objects |
| 48 | List<Instruction> modifications = new LinkedList<>(); | 63 | List<Instruction> modifications = new LinkedList<>(); |
| 49 | 64 | ||
| 65 | + // Creates a new builder | ||
| 66 | + private Builder() { | ||
| 67 | + } | ||
| 68 | + | ||
| 50 | public Builder add(Instruction instruction) { | 69 | public Builder add(Instruction instruction) { |
| 51 | if (drop) { | 70 | if (drop) { |
| 52 | return this; | 71 | return this; |
| 53 | } | 72 | } |
| 54 | switch (instruction.type()) { | 73 | switch (instruction.type()) { |
| 55 | - case DROP: | 74 | + case DROP: |
| 56 | - drop = true; | 75 | + drop = true; |
| 57 | - break; | 76 | + break; |
| 58 | - case OUTPUT: | 77 | + case OUTPUT: |
| 59 | - outputs.add(instruction); | 78 | + outputs.add(instruction); |
| 60 | - break; | 79 | + break; |
| 61 | - case L2MODIFICATION: | 80 | + case L2MODIFICATION: |
| 62 | - case L3MODIFICATION: | 81 | + case L3MODIFICATION: |
| 63 | - // TODO: enforce modification order if any | 82 | + // TODO: enforce modification order if any |
| 64 | - modifications.add(instruction); | 83 | + modifications.add(instruction); |
| 65 | - break; | 84 | + break; |
| 66 | - case GROUP: | 85 | + case GROUP: |
| 67 | - groups.add(instruction); | 86 | + groups.add(instruction); |
| 68 | - break; | 87 | + break; |
| 69 | - default: | 88 | + default: |
| 70 | - log.warn("Unknown instruction type {}", instruction.type()); | 89 | + log.warn("Unknown instruction type {}", instruction.type()); |
| 71 | } | 90 | } |
| 72 | return this; | 91 | return this; |
| 73 | } | 92 | } | ... | ... |
| ... | @@ -24,7 +24,7 @@ public abstract class DefaultPacketContext implements PacketContext { | ... | @@ -24,7 +24,7 @@ public abstract class DefaultPacketContext implements PacketContext { |
| 24 | this.inPkt = inPkt; | 24 | this.inPkt = inPkt; |
| 25 | this.outPkt = outPkt; | 25 | this.outPkt = outPkt; |
| 26 | this.block = new AtomicBoolean(block); | 26 | this.block = new AtomicBoolean(block); |
| 27 | - this.builder = new DefaultTrafficTreatment.Builder(); | 27 | + this.builder = DefaultTrafficTreatment.builder(); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | @Override | 30 | @Override | ... | ... |
| ... | @@ -16,8 +16,8 @@ import org.onlab.onos.net.flow.TrafficTreatment; | ... | @@ -16,8 +16,8 @@ import org.onlab.onos.net.flow.TrafficTreatment; |
| 16 | public abstract class ConnectivityIntentTest extends IntentTest { | 16 | public abstract class ConnectivityIntentTest extends IntentTest { |
| 17 | 17 | ||
| 18 | public static final IntentId IID = new IntentId(123); | 18 | public static final IntentId IID = new IntentId(123); |
| 19 | - public static final TrafficSelector MATCH = (new DefaultTrafficSelector.Builder()).build(); | 19 | + public static final TrafficSelector MATCH = DefaultTrafficSelector.builder().build(); |
| 20 | - public static final TrafficTreatment NOP = (new DefaultTrafficTreatment.Builder()).build(); | 20 | + public static final TrafficTreatment NOP = DefaultTrafficTreatment.builder().build(); |
| 21 | 21 | ||
| 22 | public static final ConnectPoint P1 = new ConnectPoint(DeviceId.deviceId("111"), PortNumber.portNumber(0x1)); | 22 | public static final ConnectPoint P1 = new ConnectPoint(DeviceId.deviceId("111"), PortNumber.portNumber(0x1)); |
| 23 | public static final ConnectPoint P2 = new ConnectPoint(DeviceId.deviceId("222"), PortNumber.portNumber(0x2)); | 23 | public static final ConnectPoint P2 = new ConnectPoint(DeviceId.deviceId("222"), PortNumber.portNumber(0x2)); | ... | ... |
| ... | @@ -242,15 +242,16 @@ implements FlowRuleService, FlowRuleProviderRegistry { | ... | @@ -242,15 +242,16 @@ implements FlowRuleService, FlowRuleProviderRegistry { |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | private boolean checkRuleLiveness(FlowRule swRule, FlowRule storedRule) { | 244 | private boolean checkRuleLiveness(FlowRule swRule, FlowRule storedRule) { |
| 245 | - int timeout = storedRule.timeout(); | 245 | + return true; |
| 246 | - if (storedRule.packets() != swRule.packets()) { | 246 | +// int timeout = storedRule.timeout(); |
| 247 | - deadRounds.get(swRule).set(0); | 247 | +// if (storedRule.packets() != swRule.packets()) { |
| 248 | - return true; | 248 | +// deadRounds.get(swRule).set(0); |
| 249 | - } | 249 | +// return true; |
| 250 | - | 250 | +// } |
| 251 | - return (deadRounds.get(swRule).getAndIncrement() * | 251 | +// |
| 252 | - FlowRuleProvider.POLL_INTERVAL) <= timeout; | 252 | +// return (deadRounds.get(swRule).getAndIncrement() * |
| 253 | - | 253 | +// FlowRuleProvider.POLL_INTERVAL) <= timeout; |
| 254 | +// | ||
| 254 | } | 255 | } |
| 255 | 256 | ||
| 256 | // Posts the specified event to the local event dispatcher. | 257 | // Posts the specified event to the local event dispatcher. | ... | ... |
| ... | @@ -150,7 +150,7 @@ public class HostMonitor implements TimerTask { | ... | @@ -150,7 +150,7 @@ public class HostMonitor implements TimerTask { |
| 150 | List<Instruction> instructions = new ArrayList<>(); | 150 | List<Instruction> instructions = new ArrayList<>(); |
| 151 | instructions.add(Instructions.createOutput(port.number())); | 151 | instructions.add(Instructions.createOutput(port.number())); |
| 152 | 152 | ||
| 153 | - TrafficTreatment treatment = new DefaultTrafficTreatment.Builder() | 153 | + TrafficTreatment treatment = DefaultTrafficTreatment.builder() |
| 154 | .setOutput(port.number()) | 154 | .setOutput(port.number()) |
| 155 | .build(); | 155 | .build(); |
| 156 | 156 | ... | ... |
| 1 | package org.onlab.onos.net.intent.impl; | 1 | package org.onlab.onos.net.intent.impl; |
| 2 | 2 | ||
| 3 | -import java.util.Iterator; | ||
| 4 | - | ||
| 5 | import org.apache.felix.scr.annotations.Activate; | 3 | import org.apache.felix.scr.annotations.Activate; |
| 6 | import org.apache.felix.scr.annotations.Component; | 4 | import org.apache.felix.scr.annotations.Component; |
| 7 | import org.apache.felix.scr.annotations.Deactivate; | 5 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -17,24 +15,25 @@ import org.onlab.onos.net.flow.FlowRule; | ... | @@ -17,24 +15,25 @@ import org.onlab.onos.net.flow.FlowRule; |
| 17 | import org.onlab.onos.net.flow.FlowRuleService; | 15 | import org.onlab.onos.net.flow.FlowRuleService; |
| 18 | import org.onlab.onos.net.flow.TrafficSelector; | 16 | import org.onlab.onos.net.flow.TrafficSelector; |
| 19 | import org.onlab.onos.net.flow.TrafficTreatment; | 17 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 20 | -import org.onlab.onos.net.flow.criteria.Criterion; | ||
| 21 | import org.onlab.onos.net.intent.IntentExtensionService; | 18 | import org.onlab.onos.net.intent.IntentExtensionService; |
| 22 | import org.onlab.onos.net.intent.IntentInstaller; | 19 | import org.onlab.onos.net.intent.IntentInstaller; |
| 23 | import org.onlab.onos.net.intent.PathIntent; | 20 | import org.onlab.onos.net.intent.PathIntent; |
| 24 | 21 | ||
| 22 | +import java.util.Iterator; | ||
| 23 | + | ||
| 25 | /** | 24 | /** |
| 26 | - * An intent installer for {@link PathIntent}. | 25 | + * Installer for {@link PathIntent path connectivity intents}. |
| 27 | */ | 26 | */ |
| 28 | @Component(immediate = true) | 27 | @Component(immediate = true) |
| 29 | -public class PathIntentInstaller | 28 | +public class PathIntentInstaller implements IntentInstaller<PathIntent> { |
| 30 | - implements IntentInstaller<PathIntent> { | 29 | + |
| 31 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 30 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 32 | protected IntentExtensionService intentManager; | 31 | protected IntentExtensionService intentManager; |
| 33 | 32 | ||
| 34 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 33 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 35 | - private FlowRuleService flowRuleService; | 34 | + protected FlowRuleService flowRuleService; |
| 36 | 35 | ||
| 37 | - private final ApplicationId appId = ApplicationId.valueOf(1); | 36 | + private final ApplicationId appId = ApplicationId.getAppId(); |
| 38 | 37 | ||
| 39 | @Activate | 38 | @Activate |
| 40 | public void activate() { | 39 | public void activate() { |
| ... | @@ -48,24 +47,21 @@ public class PathIntentInstaller | ... | @@ -48,24 +47,21 @@ public class PathIntentInstaller |
| 48 | 47 | ||
| 49 | @Override | 48 | @Override |
| 50 | public void install(PathIntent intent) { | 49 | public void install(PathIntent intent) { |
| 51 | - TrafficSelector.Builder builder = new DefaultTrafficSelector.Builder(); | 50 | + TrafficSelector.Builder builder = |
| 52 | - TrafficSelector selector = intent.getTrafficSelector(); | 51 | + DefaultTrafficSelector.builder(intent.getTrafficSelector()); |
| 53 | - for (Criterion c : selector.criteria()) { | ||
| 54 | - builder.add(c); | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | Iterator<Link> links = intent.getPath().links().iterator(); | 52 | Iterator<Link> links = intent.getPath().links().iterator(); |
| 58 | ConnectPoint prev = links.next().dst(); | 53 | ConnectPoint prev = links.next().dst(); |
| 59 | while (links.hasNext()) { | 54 | while (links.hasNext()) { |
| 60 | builder.matchInport(prev.port()); | 55 | builder.matchInport(prev.port()); |
| 61 | Link link = links.next(); | 56 | Link link = links.next(); |
| 62 | 57 | ||
| 63 | - TrafficTreatment.Builder treat = new DefaultTrafficTreatment.Builder(); | 58 | + TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder(); |
| 64 | treat.setOutput(link.src().port()); | 59 | treat.setOutput(link.src().port()); |
| 65 | 60 | ||
| 66 | - FlowRule f = new DefaultFlowRule(link.src().deviceId(), | 61 | + FlowRule rule = new DefaultFlowRule(link.src().deviceId(), |
| 67 | - builder.build(), treat.build(), 0, appId, 0); | 62 | + builder.build(), treat.build(), |
| 68 | - flowRuleService.applyFlowRules(f); | 63 | + 0, appId, 30); |
| 64 | + flowRuleService.applyFlowRules(rule); | ||
| 69 | 65 | ||
| 70 | prev = link.dst(); | 66 | prev = link.dst(); |
| 71 | } | 67 | } | ... | ... |
| ... | @@ -43,7 +43,6 @@ import com.google.common.collect.HashMultimap; | ... | @@ -43,7 +43,6 @@ import com.google.common.collect.HashMultimap; |
| 43 | import com.google.common.collect.Lists; | 43 | import com.google.common.collect.Lists; |
| 44 | import com.google.common.collect.Multimap; | 44 | import com.google.common.collect.Multimap; |
| 45 | 45 | ||
| 46 | - | ||
| 47 | @Component(immediate = true) | 46 | @Component(immediate = true) |
| 48 | @Service | 47 | @Service |
| 49 | public class ProxyArpManager implements ProxyArpService { | 48 | public class ProxyArpManager implements ProxyArpService { |
| ... | @@ -128,7 +127,7 @@ public class ProxyArpManager implements ProxyArpService { | ... | @@ -128,7 +127,7 @@ public class ProxyArpManager implements ProxyArpService { |
| 128 | 127 | ||
| 129 | Ethernet arpReply = buildArpReply(dst, eth); | 128 | Ethernet arpReply = buildArpReply(dst, eth); |
| 130 | // TODO: check send status with host service. | 129 | // TODO: check send status with host service. |
| 131 | - TrafficTreatment.Builder builder = new DefaultTrafficTreatment.Builder(); | 130 | + TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); |
| 132 | builder.setOutput(src.location().port()); | 131 | builder.setOutput(src.location().port()); |
| 133 | packetService.emit(new DefaultOutboundPacket(src.location().deviceId(), | 132 | packetService.emit(new DefaultOutboundPacket(src.location().deviceId(), |
| 134 | builder.build(), ByteBuffer.wrap(arpReply.serialize()))); | 133 | builder.build(), ByteBuffer.wrap(arpReply.serialize()))); |
| ... | @@ -148,7 +147,7 @@ public class ProxyArpManager implements ProxyArpService { | ... | @@ -148,7 +147,7 @@ public class ProxyArpManager implements ProxyArpService { |
| 148 | if (h == null) { | 147 | if (h == null) { |
| 149 | flood(eth); | 148 | flood(eth); |
| 150 | } else { | 149 | } else { |
| 151 | - TrafficTreatment.Builder builder = new DefaultTrafficTreatment.Builder(); | 150 | + TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); |
| 152 | builder.setOutput(h.location().port()); | 151 | builder.setOutput(h.location().port()); |
| 153 | packetService.emit(new DefaultOutboundPacket(h.location().deviceId(), | 152 | packetService.emit(new DefaultOutboundPacket(h.location().deviceId(), |
| 154 | builder.build(), ByteBuffer.wrap(eth.serialize()))); | 153 | builder.build(), ByteBuffer.wrap(eth.serialize()))); |
| ... | @@ -166,7 +165,7 @@ public class ProxyArpManager implements ProxyArpService { | ... | @@ -166,7 +165,7 @@ public class ProxyArpManager implements ProxyArpService { |
| 166 | 165 | ||
| 167 | synchronized (externalPorts) { | 166 | synchronized (externalPorts) { |
| 168 | for (Entry<Device, PortNumber> entry : externalPorts.entries()) { | 167 | for (Entry<Device, PortNumber> entry : externalPorts.entries()) { |
| 169 | - builder = new DefaultTrafficTreatment.Builder(); | 168 | + builder = DefaultTrafficTreatment.builder(); |
| 170 | builder.setOutput(entry.getValue()); | 169 | builder.setOutput(entry.getValue()); |
| 171 | packetService.emit(new DefaultOutboundPacket(entry.getKey().id(), | 170 | packetService.emit(new DefaultOutboundPacket(entry.getKey().id(), |
| 172 | builder.build(), buf)); | 171 | builder.build(), buf)); | ... | ... |
| ... | @@ -86,7 +86,7 @@ public class FlowRuleBuilder { | ... | @@ -86,7 +86,7 @@ public class FlowRuleBuilder { |
| 86 | 86 | ||
| 87 | 87 | ||
| 88 | private TrafficTreatment buildTreatment() { | 88 | private TrafficTreatment buildTreatment() { |
| 89 | - TrafficTreatment.Builder builder = new DefaultTrafficTreatment.Builder(); | 89 | + TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); |
| 90 | // If this is a drop rule | 90 | // If this is a drop rule |
| 91 | if (actions.size() == 0) { | 91 | if (actions.size() == 0) { |
| 92 | builder.drop(); | 92 | builder.drop(); |
| ... | @@ -171,7 +171,7 @@ public class FlowRuleBuilder { | ... | @@ -171,7 +171,7 @@ public class FlowRuleBuilder { |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | private TrafficSelector buildSelector() { | 173 | private TrafficSelector buildSelector() { |
| 174 | - TrafficSelector.Builder builder = new DefaultTrafficSelector.Builder(); | 174 | + TrafficSelector.Builder builder = DefaultTrafficSelector.builder(); |
| 175 | for (MatchField<?> field : match.getMatchFields()) { | 175 | for (MatchField<?> field : match.getMatchFields()) { |
| 176 | switch (field.id) { | 176 | switch (field.id) { |
| 177 | case IN_PORT: | 177 | case IN_PORT: | ... | ... |
| ... | @@ -181,7 +181,7 @@ public class OpenFlowPacketProviderTest { | ... | @@ -181,7 +181,7 @@ public class OpenFlowPacketProviderTest { |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | private static TrafficTreatment treatment(Instruction ... insts) { | 183 | private static TrafficTreatment treatment(Instruction ... insts) { |
| 184 | - TrafficTreatment.Builder builder = new DefaultTrafficTreatment.Builder(); | 184 | + TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); |
| 185 | for (Instruction i : insts) { | 185 | for (Instruction i : insts) { |
| 186 | builder.add(i); | 186 | builder.add(i); |
| 187 | } | 187 | } | ... | ... |
| ... | @@ -21,7 +21,7 @@ export PATH="$PATH:." | ... | @@ -21,7 +21,7 @@ export PATH="$PATH:." |
| 21 | # e.g. 'o api', 'o dev', 'o' | 21 | # e.g. 'o api', 'o dev', 'o' |
| 22 | function o { | 22 | function o { |
| 23 | cd $(find $ONOS_ROOT/ -type d | egrep -v '\.git|target' | \ | 23 | cd $(find $ONOS_ROOT/ -type d | egrep -v '\.git|target' | \ |
| 24 | - egrep "${1:-$ONOS_ROOT}" | head -n 1) | 24 | + egrep "${1:-$ONOS_ROOT}" | egrep -v "$ONOS_ROOT/.+/src/" | head -n 1) |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | # Short-hand for 'mvn clean install' for us lazy folk | 27 | # Short-hand for 'mvn clean install' for us lazy folk | ... | ... |
-
Please register or login to post a comment