Committed by
Ray Milkey
Changes related to the "LinkCollectionIntent" type of intents
(e.g., Multipoint-to-singlepoint and Singlepoint-to-multipoint) * Apply the Intent-defined traffic treatment only on the flowmods on the ingress switch with ingress inport for a flowmod. Previously, the traffic treatments were applied on each switch, and semantically it is not the correct (default) behavior. * Express the flowmods by explicitly specifying the expected inport in the matching conditions for each flowmod. Previously, the inport was not included in the matching conditions. [Merge from branch onos-1.0 - manually] Change-Id: Ic378b6e8be033a70b016f4ba5550d91fe08ddd9a
Showing
5 changed files
with
116 additions
and
42 deletions
... | @@ -36,16 +36,19 @@ public final class LinkCollectionIntent extends ConnectivityIntent { | ... | @@ -36,16 +36,19 @@ public final class LinkCollectionIntent extends ConnectivityIntent { |
36 | 36 | ||
37 | private final Set<Link> links; | 37 | private final Set<Link> links; |
38 | 38 | ||
39 | + private final Set<ConnectPoint> ingressPoints; | ||
39 | private final Set<ConnectPoint> egressPoints; | 40 | private final Set<ConnectPoint> egressPoints; |
40 | 41 | ||
41 | /** | 42 | /** |
42 | - * Creates a new actionable intent capable of funneling the selected traffic | 43 | + * Creates a new actionable intent capable of funneling the selected |
43 | - * along the specified convergent tree and out the given egress point. | 44 | + * traffic along the specified convergent tree and out the given egress |
45 | + * point. | ||
44 | * | 46 | * |
45 | * @param appId application identifier | 47 | * @param appId application identifier |
46 | * @param selector traffic match | 48 | * @param selector traffic match |
47 | * @param treatment action | 49 | * @param treatment action |
48 | * @param links traversed links | 50 | * @param links traversed links |
51 | + * @param ingressPoint ingress point | ||
49 | * @param egressPoint egress point | 52 | * @param egressPoint egress point |
50 | * @throws NullPointerException {@code path} is null | 53 | * @throws NullPointerException {@code path} is null |
51 | */ | 54 | */ |
... | @@ -53,19 +56,22 @@ public final class LinkCollectionIntent extends ConnectivityIntent { | ... | @@ -53,19 +56,22 @@ public final class LinkCollectionIntent extends ConnectivityIntent { |
53 | TrafficSelector selector, | 56 | TrafficSelector selector, |
54 | TrafficTreatment treatment, | 57 | TrafficTreatment treatment, |
55 | Set<Link> links, | 58 | Set<Link> links, |
59 | + ConnectPoint ingressPoint, | ||
56 | ConnectPoint egressPoint) { | 60 | ConnectPoint egressPoint) { |
57 | - this(appId, selector, treatment, links, egressPoint, Collections.emptyList()); | 61 | + this(appId, selector, treatment, links, ingressPoint, egressPoint, |
62 | + Collections.emptyList()); | ||
58 | } | 63 | } |
59 | 64 | ||
60 | /** | 65 | /** |
61 | * Creates a new actionable intent capable of funneling the selected | 66 | * Creates a new actionable intent capable of funneling the selected |
62 | - * traffic along the specified convergent tree and out the given egress point | 67 | + * traffic along the specified convergent tree and out the given egress |
63 | - * satisfying the specified constraints. | 68 | + * point satisfying the specified constraints. |
64 | * | 69 | * |
65 | * @param appId application identifier | 70 | * @param appId application identifier |
66 | * @param selector traffic match | 71 | * @param selector traffic match |
67 | * @param treatment action | 72 | * @param treatment action |
68 | * @param links traversed links | 73 | * @param links traversed links |
74 | + * @param ingressPoint ingress point | ||
69 | * @param egressPoint egress point | 75 | * @param egressPoint egress point |
70 | * @param constraints optional list of constraints | 76 | * @param constraints optional list of constraints |
71 | * @throws NullPointerException {@code path} is null | 77 | * @throws NullPointerException {@code path} is null |
... | @@ -74,22 +80,26 @@ public final class LinkCollectionIntent extends ConnectivityIntent { | ... | @@ -74,22 +80,26 @@ public final class LinkCollectionIntent extends ConnectivityIntent { |
74 | TrafficSelector selector, | 80 | TrafficSelector selector, |
75 | TrafficTreatment treatment, | 81 | TrafficTreatment treatment, |
76 | Set<Link> links, | 82 | Set<Link> links, |
83 | + ConnectPoint ingressPoint, | ||
77 | ConnectPoint egressPoint, | 84 | ConnectPoint egressPoint, |
78 | List<Constraint> constraints) { | 85 | List<Constraint> constraints) { |
79 | super(appId, resources(links), selector, treatment, constraints); | 86 | super(appId, resources(links), selector, treatment, constraints); |
80 | this.links = links; | 87 | this.links = links; |
88 | + this.ingressPoints = ImmutableSet.of(ingressPoint); | ||
81 | this.egressPoints = ImmutableSet.of(egressPoint); | 89 | this.egressPoints = ImmutableSet.of(egressPoint); |
82 | } | 90 | } |
83 | 91 | ||
84 | /** | 92 | /** |
85 | - * Creates a new actionable intent capable of funneling the selected traffic | 93 | + * Creates a new actionable intent capable of funneling the selected |
86 | - * along the specified convergent tree and out the given egress point. | 94 | + * traffic along the specified convergent tree and out the given egress |
95 | + * point. | ||
87 | * | 96 | * |
88 | * @param appId application identifier | 97 | * @param appId application identifier |
89 | * @param selector traffic match | 98 | * @param selector traffic match |
90 | * @param treatment action | 99 | * @param treatment action |
91 | * @param links traversed links | 100 | * @param links traversed links |
92 | - * @param egressPoints Set of egress point | 101 | + * @param ingressPoints Set of ingress points |
102 | + * @param egressPoints Set of egress points | ||
93 | * @param constraints the constraints | 103 | * @param constraints the constraints |
94 | * @throws NullPointerException {@code path} is null | 104 | * @throws NullPointerException {@code path} is null |
95 | */ | 105 | */ |
... | @@ -97,11 +107,13 @@ public final class LinkCollectionIntent extends ConnectivityIntent { | ... | @@ -97,11 +107,13 @@ public final class LinkCollectionIntent extends ConnectivityIntent { |
97 | TrafficSelector selector, | 107 | TrafficSelector selector, |
98 | TrafficTreatment treatment, | 108 | TrafficTreatment treatment, |
99 | Set<Link> links, | 109 | Set<Link> links, |
110 | + Set<ConnectPoint> ingressPoints, | ||
100 | Set<ConnectPoint> egressPoints, | 111 | Set<ConnectPoint> egressPoints, |
101 | List<Constraint> constraints) { | 112 | List<Constraint> constraints) { |
102 | super(appId, resources(links), selector, treatment, constraints); | 113 | super(appId, resources(links), selector, treatment, constraints); |
103 | 114 | ||
104 | this.links = links; | 115 | this.links = links; |
116 | + this.ingressPoints = ImmutableSet.copyOf(ingressPoints); | ||
105 | this.egressPoints = ImmutableSet.copyOf(egressPoints); | 117 | this.egressPoints = ImmutableSet.copyOf(egressPoints); |
106 | } | 118 | } |
107 | 119 | ||
... | @@ -111,6 +123,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { | ... | @@ -111,6 +123,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { |
111 | protected LinkCollectionIntent() { | 123 | protected LinkCollectionIntent() { |
112 | super(); | 124 | super(); |
113 | this.links = null; | 125 | this.links = null; |
126 | + this.ingressPoints = null; | ||
114 | this.egressPoints = null; | 127 | this.egressPoints = null; |
115 | } | 128 | } |
116 | 129 | ||
... | @@ -125,9 +138,18 @@ public final class LinkCollectionIntent extends ConnectivityIntent { | ... | @@ -125,9 +138,18 @@ public final class LinkCollectionIntent extends ConnectivityIntent { |
125 | } | 138 | } |
126 | 139 | ||
127 | /** | 140 | /** |
128 | - * Returns the egress point of the intent. | 141 | + * Returns the ingress points of the intent. |
142 | + * | ||
143 | + * @return the ingress points | ||
144 | + */ | ||
145 | + public Set<ConnectPoint> ingressPoints() { | ||
146 | + return ingressPoints; | ||
147 | + } | ||
148 | + | ||
149 | + /** | ||
150 | + * Returns the egress points of the intent. | ||
129 | * | 151 | * |
130 | - * @return the egress point | 152 | + * @return the egress points |
131 | */ | 153 | */ |
132 | public Set<ConnectPoint> egressPoints() { | 154 | public Set<ConnectPoint> egressPoints() { |
133 | return egressPoints; | 155 | return egressPoints; |
... | @@ -148,6 +170,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { | ... | @@ -148,6 +170,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { |
148 | .add("selector", selector()) | 170 | .add("selector", selector()) |
149 | .add("treatment", treatment()) | 171 | .add("treatment", treatment()) |
150 | .add("links", links()) | 172 | .add("links", links()) |
173 | + .add("ingress", ingressPoints()) | ||
151 | .add("egress", egressPoints()) | 174 | .add("egress", egressPoints()) |
152 | .toString(); | 175 | .toString(); |
153 | } | 176 | } | ... | ... |
... | @@ -45,6 +45,7 @@ import static org.onosproject.net.NetTestTools.link; | ... | @@ -45,6 +45,7 @@ import static org.onosproject.net.NetTestTools.link; |
45 | */ | 45 | */ |
46 | public class LinkCollectionIntentTest extends IntentTest { | 46 | public class LinkCollectionIntentTest extends IntentTest { |
47 | 47 | ||
48 | + final ConnectPoint ingress = NetTestTools.connectPoint("ingress", 2); | ||
48 | final ConnectPoint egress = NetTestTools.connectPoint("egress", 3); | 49 | final ConnectPoint egress = NetTestTools.connectPoint("egress", 3); |
49 | final TrafficSelector selector = new IntentTestsMocks.MockSelector(); | 50 | final TrafficSelector selector = new IntentTestsMocks.MockSelector(); |
50 | final IntentTestsMocks.MockTreatment treatment = new IntentTestsMocks.MockTreatment(); | 51 | final IntentTestsMocks.MockTreatment treatment = new IntentTestsMocks.MockTreatment(); |
... | @@ -70,6 +71,7 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -70,6 +71,7 @@ public class LinkCollectionIntentTest extends IntentTest { |
70 | selector, | 71 | selector, |
71 | treatment, | 72 | treatment, |
72 | links1, | 73 | links1, |
74 | + ingress, | ||
73 | egress); | 75 | egress); |
74 | 76 | ||
75 | final HashSet<Link> links2 = new HashSet<>(); | 77 | final HashSet<Link> links2 = new HashSet<>(); |
... | @@ -79,6 +81,7 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -79,6 +81,7 @@ public class LinkCollectionIntentTest extends IntentTest { |
79 | selector, | 81 | selector, |
80 | treatment, | 82 | treatment, |
81 | links2, | 83 | links2, |
84 | + ingress, | ||
82 | egress); | 85 | egress); |
83 | 86 | ||
84 | new EqualsTester() | 87 | new EqualsTester() |
... | @@ -99,6 +102,7 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -99,6 +102,7 @@ public class LinkCollectionIntentTest extends IntentTest { |
99 | selector, | 102 | selector, |
100 | treatment, | 103 | treatment, |
101 | links1, | 104 | links1, |
105 | + ingress, | ||
102 | egress); | 106 | egress); |
103 | 107 | ||
104 | final Set<Link> createdLinks = collectionIntent.links(); | 108 | final Set<Link> createdLinks = collectionIntent.links(); |
... | @@ -106,6 +110,7 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -106,6 +110,7 @@ public class LinkCollectionIntentTest extends IntentTest { |
106 | assertThat(collectionIntent.isInstallable(), is(true)); | 110 | assertThat(collectionIntent.isInstallable(), is(true)); |
107 | assertThat(collectionIntent.treatment(), is(treatment)); | 111 | assertThat(collectionIntent.treatment(), is(treatment)); |
108 | assertThat(collectionIntent.selector(), is(selector)); | 112 | assertThat(collectionIntent.selector(), is(selector)); |
113 | + assertThat(collectionIntent.ingressPoints(), is(ImmutableSet.of(ingress))); | ||
109 | assertThat(collectionIntent.egressPoints(), is(ImmutableSet.of(egress))); | 114 | assertThat(collectionIntent.egressPoints(), is(ImmutableSet.of(egress))); |
110 | assertThat(collectionIntent.resources(), hasSize(1)); | 115 | assertThat(collectionIntent.resources(), hasSize(1)); |
111 | final List<Constraint> createdConstraints = collectionIntent.constraints(); | 116 | final List<Constraint> createdConstraints = collectionIntent.constraints(); |
... | @@ -127,6 +132,7 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -127,6 +132,7 @@ public class LinkCollectionIntentTest extends IntentTest { |
127 | selector, | 132 | selector, |
128 | treatment, | 133 | treatment, |
129 | links1, | 134 | links1, |
135 | + ingress, | ||
130 | egress, | 136 | egress, |
131 | constraints); | 137 | constraints); |
132 | 138 | ||
... | @@ -135,6 +141,7 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -135,6 +141,7 @@ public class LinkCollectionIntentTest extends IntentTest { |
135 | assertThat(collectionIntent.isInstallable(), is(true)); | 141 | assertThat(collectionIntent.isInstallable(), is(true)); |
136 | assertThat(collectionIntent.treatment(), is(treatment)); | 142 | assertThat(collectionIntent.treatment(), is(treatment)); |
137 | assertThat(collectionIntent.selector(), is(selector)); | 143 | assertThat(collectionIntent.selector(), is(selector)); |
144 | + assertThat(collectionIntent.ingressPoints(), is(ImmutableSet.of(ingress))); | ||
138 | assertThat(collectionIntent.egressPoints(), is(ImmutableSet.of(egress))); | 145 | assertThat(collectionIntent.egressPoints(), is(ImmutableSet.of(egress))); |
139 | 146 | ||
140 | final List<Constraint> createdConstraints = collectionIntent.constraints(); | 147 | final List<Constraint> createdConstraints = collectionIntent.constraints(); |
... | @@ -156,6 +163,7 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -156,6 +163,7 @@ public class LinkCollectionIntentTest extends IntentTest { |
156 | assertThat(collectionIntent.isInstallable(), is(true)); | 163 | assertThat(collectionIntent.isInstallable(), is(true)); |
157 | assertThat(collectionIntent.treatment(), nullValue()); | 164 | assertThat(collectionIntent.treatment(), nullValue()); |
158 | assertThat(collectionIntent.selector(), nullValue()); | 165 | assertThat(collectionIntent.selector(), nullValue()); |
166 | + assertThat(collectionIntent.ingressPoints(), nullValue()); | ||
159 | assertThat(collectionIntent.egressPoints(), nullValue()); | 167 | assertThat(collectionIntent.egressPoints(), nullValue()); |
160 | 168 | ||
161 | final List<Constraint> createdConstraints = collectionIntent.constraints(); | 169 | final List<Constraint> createdConstraints = collectionIntent.constraints(); |
... | @@ -170,6 +178,7 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -170,6 +178,7 @@ public class LinkCollectionIntentTest extends IntentTest { |
170 | selector, | 178 | selector, |
171 | treatment, | 179 | treatment, |
172 | links1, | 180 | links1, |
181 | + ingress, | ||
173 | egress); | 182 | egress); |
174 | } | 183 | } |
175 | 184 | ||
... | @@ -181,6 +190,7 @@ public class LinkCollectionIntentTest extends IntentTest { | ... | @@ -181,6 +190,7 @@ public class LinkCollectionIntentTest extends IntentTest { |
181 | selector, | 190 | selector, |
182 | treatment, | 191 | treatment, |
183 | links2, | 192 | links2, |
193 | + ingress, | ||
184 | egress); | 194 | egress); |
185 | } | 195 | } |
186 | } | 196 | } | ... | ... |
... | @@ -43,9 +43,9 @@ import org.onosproject.net.intent.IntentInstaller; | ... | @@ -43,9 +43,9 @@ import org.onosproject.net.intent.IntentInstaller; |
43 | import org.onosproject.net.intent.LinkCollectionIntent; | 43 | import org.onosproject.net.intent.LinkCollectionIntent; |
44 | 44 | ||
45 | import java.util.Collection; | 45 | import java.util.Collection; |
46 | +import java.util.HashSet; | ||
46 | import java.util.List; | 47 | import java.util.List; |
47 | import java.util.Set; | 48 | import java.util.Set; |
48 | -import java.util.stream.Collectors; | ||
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Installer for {@link org.onosproject.net.intent.LinkCollectionIntent} path | 51 | * Installer for {@link org.onosproject.net.intent.LinkCollectionIntent} path |
... | @@ -88,35 +88,29 @@ public class LinkCollectionIntentInstaller | ... | @@ -88,35 +88,29 @@ public class LinkCollectionIntentInstaller |
88 | LinkCollectionIntent intent, FlowRuleOperation.Type operation) { | 88 | LinkCollectionIntent intent, FlowRuleOperation.Type operation) { |
89 | 89 | ||
90 | //TODO do we need a set here? | 90 | //TODO do we need a set here? |
91 | + SetMultimap<DeviceId, PortNumber> inputPorts = HashMultimap.create(); | ||
91 | SetMultimap<DeviceId, PortNumber> outputPorts = HashMultimap.create(); | 92 | SetMultimap<DeviceId, PortNumber> outputPorts = HashMultimap.create(); |
92 | 93 | ||
93 | for (Link link : intent.links()) { | 94 | for (Link link : intent.links()) { |
95 | + inputPorts.put(link.dst().deviceId(), link.dst().port()); | ||
94 | outputPorts.put(link.src().deviceId(), link.src().port()); | 96 | outputPorts.put(link.src().deviceId(), link.src().port()); |
95 | } | 97 | } |
96 | 98 | ||
97 | - for (ConnectPoint egressPoint : intent.egressPoints()) { | 99 | + for (ConnectPoint ingressPoint : intent.ingressPoints()) { |
98 | - outputPorts.put(egressPoint.deviceId(), egressPoint.port()); | 100 | + inputPorts.put(ingressPoint.deviceId(), ingressPoint.port()); |
99 | } | 101 | } |
100 | 102 | ||
101 | - //FIXME change to new api | 103 | + for (ConnectPoint egressPoint : intent.egressPoints()) { |
102 | - /* Fear of streams */ | 104 | + outputPorts.put(egressPoint.deviceId(), egressPoint.port()); |
103 | - /* | ||
104 | - Set<FlowRuleBatchEntry> rules = Sets.newHashSet(); | ||
105 | - for (DeviceId deviceId : outputPorts.keys()) { | ||
106 | - rules.add(createBatchEntry(operation, | ||
107 | - intent, deviceId, | ||
108 | - outputPorts.get(deviceId))); | ||
109 | } | 105 | } |
110 | - */ | ||
111 | 106 | ||
112 | - Set<FlowRuleOperation> rules = | 107 | + List<FlowRuleOperation> rules = Lists.newArrayList(); |
113 | - outputPorts | 108 | + outputPorts.keys().stream() |
114 | - .keys() | 109 | + .map(deviceId -> createBatchEntries(operation, |
115 | - .stream() | ||
116 | - .map(deviceId -> createBatchEntry(operation, | ||
117 | intent, deviceId, | 110 | intent, deviceId, |
111 | + inputPorts.get(deviceId), | ||
118 | outputPorts.get(deviceId))) | 112 | outputPorts.get(deviceId))) |
119 | - .collect(Collectors.toSet()); | 113 | + .forEach(rules::addAll); |
120 | 114 | ||
121 | return Lists.newArrayList(ImmutableSet.of(rules)); | 115 | return Lists.newArrayList(ImmutableSet.of(rules)); |
122 | } | 116 | } |
... | @@ -132,35 +126,72 @@ public class LinkCollectionIntentInstaller | ... | @@ -132,35 +126,72 @@ public class LinkCollectionIntentInstaller |
132 | } | 126 | } |
133 | 127 | ||
134 | /** | 128 | /** |
135 | - * Creates a FlowRuleBatchEntry based on the provided parameters. | 129 | + * Creates a collection of FlowRuleOperation based on the provided |
130 | + * parameters. | ||
136 | * | 131 | * |
137 | - * @param operation the FlowRuleOperation to use | 132 | + * @param operation the FlowRuleOperation type to use |
138 | * @param intent the link collection intent | 133 | * @param intent the link collection intent |
139 | * @param deviceId the device ID for the flow rule | 134 | * @param deviceId the device ID for the flow rule |
135 | + * @param inPorts the logical input ports of the flow rule | ||
140 | * @param outPorts the set of output ports for the flow rule | 136 | * @param outPorts the set of output ports for the flow rule |
141 | - * @return the new flow rule batch entry | 137 | + * @return a collection with the new flow rule batch entries |
142 | */ | 138 | */ |
143 | - private FlowRuleOperation createBatchEntry(FlowRuleOperation.Type operation, | 139 | + private Collection<FlowRuleOperation> createBatchEntries( |
140 | + FlowRuleOperation.Type operation, | ||
144 | LinkCollectionIntent intent, | 141 | LinkCollectionIntent intent, |
145 | DeviceId deviceId, | 142 | DeviceId deviceId, |
143 | + Set<PortNumber> inPorts, | ||
146 | Set<PortNumber> outPorts) { | 144 | Set<PortNumber> outPorts) { |
145 | + Collection<FlowRuleOperation> result = Lists.newLinkedList(); | ||
146 | + Set<PortNumber> ingressPorts = new HashSet<PortNumber>(); | ||
147 | + | ||
148 | + // | ||
149 | + // Collect all ingress ports for this device. | ||
150 | + // The intent treatment is applied only on those ports. | ||
151 | + // | ||
152 | + for (ConnectPoint cp : intent.ingressPoints()) { | ||
153 | + if (cp.deviceId().equals(deviceId)) { | ||
154 | + ingressPorts.add(cp.port()); | ||
155 | + } | ||
156 | + } | ||
147 | 157 | ||
148 | - TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment | 158 | + // |
149 | - .builder(intent.treatment()); | 159 | + // Create two treatments: one for setting the output ports, |
150 | - | 160 | + // and a second one that applies the intent treatment and sets the |
161 | + // output ports. | ||
162 | + // NOTE: The second one is created only if there are ingress ports. | ||
163 | + // | ||
164 | + TrafficTreatment.Builder defaultTreatmentBuilder = | ||
165 | + DefaultTrafficTreatment.builder(); | ||
166 | + for (PortNumber outPort : outPorts) { | ||
167 | + defaultTreatmentBuilder.setOutput(outPort); | ||
168 | + } | ||
169 | + TrafficTreatment defaultTreatment = defaultTreatmentBuilder.build(); | ||
170 | + TrafficTreatment intentTreatment = null; | ||
171 | + if (!ingressPorts.isEmpty()) { | ||
172 | + TrafficTreatment.Builder intentTreatmentBuilder = | ||
173 | + DefaultTrafficTreatment.builder(intent.treatment()); | ||
151 | for (PortNumber outPort : outPorts) { | 174 | for (PortNumber outPort : outPorts) { |
152 | - treatmentBuilder.setOutput(outPort); | 175 | + intentTreatmentBuilder.setOutput(outPort); |
176 | + } | ||
177 | + intentTreatment = intentTreatmentBuilder.build(); | ||
153 | } | 178 | } |
154 | - TrafficTreatment treatment = treatmentBuilder.build(); | ||
155 | 179 | ||
180 | + for (PortNumber inPort : inPorts) { | ||
156 | TrafficSelector selector = DefaultTrafficSelector | 181 | TrafficSelector selector = DefaultTrafficSelector |
157 | - .builder(intent.selector()).build(); | 182 | + .builder(intent.selector()).matchInPort(inPort).build(); |
158 | - | 183 | + TrafficTreatment treatment = defaultTreatment; |
184 | + if (ingressPorts.contains(inPort)) { | ||
185 | + // Use the intent treatment if this is ingress port | ||
186 | + treatment = intentTreatment; | ||
187 | + } | ||
159 | FlowRule rule = new DefaultFlowRule(deviceId, | 188 | FlowRule rule = new DefaultFlowRule(deviceId, |
160 | selector, treatment, 123, appId, | 189 | selector, treatment, 123, appId, |
161 | new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)), | 190 | new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)), |
162 | 0, true); | 191 | 0, true); |
192 | + result.add(new FlowRuleOperation(rule, operation)); | ||
193 | + } | ||
163 | 194 | ||
164 | - return new FlowRuleOperation(rule, operation); | 195 | + return result; |
165 | } | 196 | } |
166 | } | 197 | } | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onosproject.net.intent.impl.compiler; | 16 | package org.onosproject.net.intent.impl.compiler; |
17 | 17 | ||
18 | import java.util.Arrays; | 18 | import java.util.Arrays; |
19 | +import java.util.Collections; | ||
19 | import java.util.HashMap; | 20 | import java.util.HashMap; |
20 | import java.util.List; | 21 | import java.util.List; |
21 | import java.util.Map; | 22 | import java.util.Map; |
... | @@ -40,6 +41,7 @@ import org.onosproject.net.intent.impl.PathNotFoundException; | ... | @@ -40,6 +41,7 @@ import org.onosproject.net.intent.impl.PathNotFoundException; |
40 | import org.onosproject.net.resource.LinkResourceAllocations; | 41 | import org.onosproject.net.resource.LinkResourceAllocations; |
41 | import org.onosproject.net.topology.PathService; | 42 | import org.onosproject.net.topology.PathService; |
42 | 43 | ||
44 | +import com.google.common.collect.ImmutableSet; | ||
43 | import com.google.common.collect.Sets; | 45 | import com.google.common.collect.Sets; |
44 | 46 | ||
45 | /** | 47 | /** |
... | @@ -76,8 +78,10 @@ public class MultiPointToSinglePointIntentCompiler | ... | @@ -76,8 +78,10 @@ public class MultiPointToSinglePointIntentCompiler |
76 | for (Link link : path.links()) { | 78 | for (Link link : path.links()) { |
77 | if (links.containsKey(link.src().deviceId())) { | 79 | if (links.containsKey(link.src().deviceId())) { |
78 | // We've already reached the existing tree with the first | 80 | // We've already reached the existing tree with the first |
79 | - // part of this path. Don't add the remainder of the path | 81 | + // part of this path. Add the merging point with different |
82 | + // incoming port, but don't add the remainder of the path | ||
80 | // in case it differs from the path we already have. | 83 | // in case it differs from the path we already have. |
84 | + links.put(link.src().deviceId(), link); | ||
81 | break; | 85 | break; |
82 | } | 86 | } |
83 | 87 | ||
... | @@ -87,7 +91,10 @@ public class MultiPointToSinglePointIntentCompiler | ... | @@ -87,7 +91,10 @@ public class MultiPointToSinglePointIntentCompiler |
87 | 91 | ||
88 | Intent result = new LinkCollectionIntent(intent.appId(), | 92 | Intent result = new LinkCollectionIntent(intent.appId(), |
89 | intent.selector(), intent.treatment(), | 93 | intent.selector(), intent.treatment(), |
90 | - Sets.newHashSet(links.values()), intent.egressPoint()); | 94 | + Sets.newHashSet(links.values()), |
95 | + intent.ingressPoints(), | ||
96 | + ImmutableSet.of(intent.egressPoint()), | ||
97 | + Collections.emptyList()); | ||
91 | return Arrays.asList(result); | 98 | return Arrays.asList(result); |
92 | } | 99 | } |
93 | 100 | ... | ... |
... | @@ -33,6 +33,8 @@ import org.onosproject.net.intent.SinglePointToMultiPointIntent; | ... | @@ -33,6 +33,8 @@ import org.onosproject.net.intent.SinglePointToMultiPointIntent; |
33 | import org.onosproject.net.provider.ProviderId; | 33 | import org.onosproject.net.provider.ProviderId; |
34 | import org.onosproject.net.resource.LinkResourceAllocations; | 34 | import org.onosproject.net.resource.LinkResourceAllocations; |
35 | 35 | ||
36 | +import com.google.common.collect.ImmutableSet; | ||
37 | + | ||
36 | @Component(immediate = true) | 38 | @Component(immediate = true) |
37 | public class SinglePointToMultiPointIntentCompiler | 39 | public class SinglePointToMultiPointIntentCompiler |
38 | extends ConnectivityIntentCompiler<SinglePointToMultiPointIntent> { | 40 | extends ConnectivityIntentCompiler<SinglePointToMultiPointIntent> { |
... | @@ -67,6 +69,7 @@ public class SinglePointToMultiPointIntentCompiler | ... | @@ -67,6 +69,7 @@ public class SinglePointToMultiPointIntentCompiler |
67 | Intent result = new LinkCollectionIntent(intent.appId(), | 69 | Intent result = new LinkCollectionIntent(intent.appId(), |
68 | intent.selector(), | 70 | intent.selector(), |
69 | intent.treatment(), links, | 71 | intent.treatment(), links, |
72 | + ImmutableSet.of(intent.ingressPoint()), | ||
70 | intent.egressPoints(), Collections.emptyList()); | 73 | intent.egressPoints(), Collections.emptyList()); |
71 | 74 | ||
72 | return Arrays.asList(result); | 75 | return Arrays.asList(result); | ... | ... |
-
Please register or login to post a comment