Pavlin Radoslavov

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.

Change-Id: Iefe3e88f7b6257c18fd6f99c2740feabbe8eedc5
...@@ -36,6 +36,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -36,6 +36,7 @@ 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 /**
...@@ -46,6 +47,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -46,6 +47,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
46 * @param selector traffic match 47 * @param selector traffic match
47 * @param treatment action 48 * @param treatment action
48 * @param links traversed links 49 * @param links traversed links
50 + * @param ingressPoint ingress point
49 * @param egressPoint egress point 51 * @param egressPoint egress point
50 * @throws NullPointerException {@code path} is null 52 * @throws NullPointerException {@code path} is null
51 */ 53 */
...@@ -53,8 +55,10 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -53,8 +55,10 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
53 TrafficSelector selector, 55 TrafficSelector selector,
54 TrafficTreatment treatment, 56 TrafficTreatment treatment,
55 Set<Link> links, 57 Set<Link> links,
58 + ConnectPoint ingressPoint,
56 ConnectPoint egressPoint) { 59 ConnectPoint egressPoint) {
57 - this(appId, selector , treatment, links, egressPoint, Collections.emptyList()); 60 + this(appId, selector , treatment, links, ingressPoint, egressPoint,
61 + Collections.emptyList());
58 } 62 }
59 63
60 /** 64 /**
...@@ -66,6 +70,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -66,6 +70,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
66 * @param selector traffic match 70 * @param selector traffic match
67 * @param treatment action 71 * @param treatment action
68 * @param links traversed links 72 * @param links traversed links
73 + * @param ingressPoint ingress point
69 * @param egressPoint egress point 74 * @param egressPoint egress point
70 * @param constraints optional list of constraints 75 * @param constraints optional list of constraints
71 * @throws NullPointerException {@code path} is null 76 * @throws NullPointerException {@code path} is null
...@@ -74,10 +79,12 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -74,10 +79,12 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
74 TrafficSelector selector, 79 TrafficSelector selector,
75 TrafficTreatment treatment, 80 TrafficTreatment treatment,
76 Set<Link> links, 81 Set<Link> links,
82 + ConnectPoint ingressPoint,
77 ConnectPoint egressPoint, 83 ConnectPoint egressPoint,
78 List<Constraint> constraints) { 84 List<Constraint> constraints) {
79 super(appId, resources(links), selector, treatment, constraints); 85 super(appId, resources(links), selector, treatment, constraints);
80 this.links = links; 86 this.links = links;
87 + this.ingressPoints = ImmutableSet.of(ingressPoint);
81 this.egressPoints = ImmutableSet.of(egressPoint); 88 this.egressPoints = ImmutableSet.of(egressPoint);
82 } 89 }
83 90
...@@ -89,6 +96,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -89,6 +96,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
89 * @param selector traffic match 96 * @param selector traffic match
90 * @param treatment action 97 * @param treatment action
91 * @param links traversed links 98 * @param links traversed links
99 + * @param ingressPoints Set of ingress point
92 * @param egressPoints Set of egress point 100 * @param egressPoints Set of egress point
93 * @param constraints the constraints 101 * @param constraints the constraints
94 * @throws NullPointerException {@code path} is null 102 * @throws NullPointerException {@code path} is null
...@@ -97,11 +105,13 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -97,11 +105,13 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
97 TrafficSelector selector, 105 TrafficSelector selector,
98 TrafficTreatment treatment, 106 TrafficTreatment treatment,
99 Set<Link> links, 107 Set<Link> links,
108 + Set<ConnectPoint> ingressPoints,
100 Set<ConnectPoint> egressPoints, 109 Set<ConnectPoint> egressPoints,
101 List<Constraint> constraints) { 110 List<Constraint> constraints) {
102 super(appId, resources(links), selector, treatment); 111 super(appId, resources(links), selector, treatment);
103 112
104 this.links = links; 113 this.links = links;
114 + this.ingressPoints = ImmutableSet.copyOf(ingressPoints);
105 this.egressPoints = ImmutableSet.copyOf(egressPoints); 115 this.egressPoints = ImmutableSet.copyOf(egressPoints);
106 } 116 }
107 117
...@@ -111,6 +121,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -111,6 +121,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
111 protected LinkCollectionIntent() { 121 protected LinkCollectionIntent() {
112 super(); 122 super();
113 this.links = null; 123 this.links = null;
124 + this.ingressPoints = null;
114 this.egressPoints = null; 125 this.egressPoints = null;
115 } 126 }
116 127
...@@ -125,9 +136,18 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -125,9 +136,18 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
125 } 136 }
126 137
127 /** 138 /**
128 - * Returns the egress point of the intent. 139 + * Returns the ingress points of the intent.
129 * 140 *
130 - * @return the egress point 141 + * @return the ingress points
142 + */
143 + public Set<ConnectPoint> ingressPoints() {
144 + return ingressPoints;
145 + }
146 +
147 + /**
148 + * Returns the egress points of the intent.
149 + *
150 + * @return the egress points
131 */ 151 */
132 public Set<ConnectPoint> egressPoints() { 152 public Set<ConnectPoint> egressPoints() {
133 return egressPoints; 153 return egressPoints;
...@@ -146,6 +166,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { ...@@ -146,6 +166,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
146 .add("selector", selector()) 166 .add("selector", selector())
147 .add("treatment", treatment()) 167 .add("treatment", treatment())
148 .add("links", links()) 168 .add("links", links())
169 + .add("ingress", ingressPoints())
149 .add("egress", egressPoints()) 170 .add("egress", egressPoints())
150 .toString(); 171 .toString();
151 } 172 }
......
...@@ -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 }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.net.intent.impl; 16 package org.onosproject.net.intent.impl;
17 17
18 +import java.util.Collection;
18 import java.util.HashMap; 19 import java.util.HashMap;
19 import java.util.HashSet; 20 import java.util.HashSet;
20 import java.util.List; 21 import java.util.List;
...@@ -78,10 +79,16 @@ public class LinkCollectionIntentInstaller ...@@ -78,10 +79,16 @@ public class LinkCollectionIntentInstaller
78 79
79 @Override 80 @Override
80 public List<FlowRuleBatchOperation> install(LinkCollectionIntent intent) { 81 public List<FlowRuleBatchOperation> install(LinkCollectionIntent intent) {
82 + Map<DeviceId, Set<PortNumber>> inputMap = new HashMap<DeviceId, Set<PortNumber>>();
81 Map<DeviceId, Set<PortNumber>> outputMap = new HashMap<DeviceId, Set<PortNumber>>(); 83 Map<DeviceId, Set<PortNumber>> outputMap = new HashMap<DeviceId, Set<PortNumber>>();
82 List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); 84 List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
83 85
84 for (Link link : intent.links()) { 86 for (Link link : intent.links()) {
87 + if (inputMap.get(link.dst().deviceId()) == null) {
88 + inputMap.put(link.dst().deviceId(), new HashSet<PortNumber>());
89 + }
90 + inputMap.get(link.dst().deviceId()).add(link.dst().port());
91 +
85 if (outputMap.get(link.src().deviceId()) == null) { 92 if (outputMap.get(link.src().deviceId()) == null) {
86 outputMap.put(link.src().deviceId(), new HashSet<PortNumber>()); 93 outputMap.put(link.src().deviceId(), new HashSet<PortNumber>());
87 } 94 }
...@@ -89,6 +96,15 @@ public class LinkCollectionIntentInstaller ...@@ -89,6 +96,15 @@ public class LinkCollectionIntentInstaller
89 96
90 } 97 }
91 98
99 + for (ConnectPoint ingressPoint : intent.ingressPoints()) {
100 + if (inputMap.get(ingressPoint.deviceId()) == null) {
101 + inputMap
102 + .put(ingressPoint.deviceId(), new HashSet<PortNumber>());
103 + }
104 + inputMap.get(ingressPoint.deviceId()).add(ingressPoint.port());
105 +
106 + }
107 +
92 for (ConnectPoint egressPoint : intent.egressPoints()) { 108 for (ConnectPoint egressPoint : intent.egressPoints()) {
93 if (outputMap.get(egressPoint.deviceId()) == null) { 109 if (outputMap.get(egressPoint.deviceId()) == null) {
94 outputMap 110 outputMap
...@@ -99,8 +115,11 @@ public class LinkCollectionIntentInstaller ...@@ -99,8 +115,11 @@ public class LinkCollectionIntentInstaller
99 } 115 }
100 116
101 for (Entry<DeviceId, Set<PortNumber>> entry : outputMap.entrySet()) { 117 for (Entry<DeviceId, Set<PortNumber>> entry : outputMap.entrySet()) {
102 - rules.add(createBatchEntry(FlowRuleOperation.ADD, intent, 118 + Set<PortNumber> ingressPoints = inputMap.get(entry.getKey());
103 - entry.getKey(), entry.getValue())); 119 + rules.addAll(createBatchEntries(FlowRuleOperation.ADD, intent,
120 + entry.getKey(),
121 + ingressPoints,
122 + entry.getValue()));
104 } 123 }
105 124
106 return Lists.newArrayList(new FlowRuleBatchOperation(rules)); 125 return Lists.newArrayList(new FlowRuleBatchOperation(rules));
...@@ -108,16 +127,31 @@ public class LinkCollectionIntentInstaller ...@@ -108,16 +127,31 @@ public class LinkCollectionIntentInstaller
108 127
109 @Override 128 @Override
110 public List<FlowRuleBatchOperation> uninstall(LinkCollectionIntent intent) { 129 public List<FlowRuleBatchOperation> uninstall(LinkCollectionIntent intent) {
130 + Map<DeviceId, Set<PortNumber>> inputMap = new HashMap<DeviceId, Set<PortNumber>>();
111 Map<DeviceId, Set<PortNumber>> outputMap = new HashMap<DeviceId, Set<PortNumber>>(); 131 Map<DeviceId, Set<PortNumber>> outputMap = new HashMap<DeviceId, Set<PortNumber>>();
112 List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); 132 List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
113 133
114 for (Link link : intent.links()) { 134 for (Link link : intent.links()) {
135 + if (inputMap.get(link.dst().deviceId()) == null) {
136 + inputMap.put(link.dst().deviceId(), new HashSet<PortNumber>());
137 + }
138 + inputMap.get(link.dst().deviceId()).add(link.dst().port());
139 +
115 if (outputMap.get(link.src().deviceId()) == null) { 140 if (outputMap.get(link.src().deviceId()) == null) {
116 outputMap.put(link.src().deviceId(), new HashSet<PortNumber>()); 141 outputMap.put(link.src().deviceId(), new HashSet<PortNumber>());
117 } 142 }
118 outputMap.get(link.src().deviceId()).add(link.src().port()); 143 outputMap.get(link.src().deviceId()).add(link.src().port());
119 } 144 }
120 145
146 + for (ConnectPoint ingressPoint : intent.ingressPoints()) {
147 + if (inputMap.get(ingressPoint.deviceId()) == null) {
148 + inputMap
149 + .put(ingressPoint.deviceId(), new HashSet<PortNumber>());
150 + }
151 + inputMap.get(ingressPoint.deviceId()).add(ingressPoint.port());
152 +
153 + }
154 +
121 for (ConnectPoint egressPoint : intent.egressPoints()) { 155 for (ConnectPoint egressPoint : intent.egressPoints()) {
122 if (outputMap.get(egressPoint.deviceId()) == null) { 156 if (outputMap.get(egressPoint.deviceId()) == null) {
123 outputMap 157 outputMap
...@@ -127,8 +161,11 @@ public class LinkCollectionIntentInstaller ...@@ -127,8 +161,11 @@ public class LinkCollectionIntentInstaller
127 } 161 }
128 162
129 for (Entry<DeviceId, Set<PortNumber>> entry : outputMap.entrySet()) { 163 for (Entry<DeviceId, Set<PortNumber>> entry : outputMap.entrySet()) {
130 - rules.add(createBatchEntry(FlowRuleOperation.REMOVE, intent, 164 + Set<PortNumber> ingressPoints = inputMap.get(entry.getKey());
131 - entry.getKey(), entry.getValue())); 165 + rules.addAll(createBatchEntries(FlowRuleOperation.REMOVE, intent,
166 + entry.getKey(),
167 + ingressPoints,
168 + entry.getValue()));
132 } 169 }
133 170
134 return Lists.newArrayList(new FlowRuleBatchOperation(rules)); 171 return Lists.newArrayList(new FlowRuleBatchOperation(rules));
...@@ -144,34 +181,71 @@ public class LinkCollectionIntentInstaller ...@@ -144,34 +181,71 @@ public class LinkCollectionIntentInstaller
144 } 181 }
145 182
146 /** 183 /**
147 - * Creates a FlowRuleBatchEntry based on the provided parameters. 184 + * Creates a collection of FlowRuleBatchEntry based on the provided
185 + * parameters.
148 * 186 *
149 * @param operation the FlowRuleOperation to use 187 * @param operation the FlowRuleOperation to use
150 * @param intent the link collection intent 188 * @param intent the link collection intent
151 * @param deviceId the device ID for the flow rule 189 * @param deviceId the device ID for the flow rule
152 - * @param outPorts the output port of the flow rule 190 + * @param inPorts the logical input ports of the flow rule
153 - * @return the new flow rule batch entry 191 + * @param outPorts the output ports of the flow rule
192 + * @return a collection with the new flow rule batch entries
154 */ 193 */
155 - private FlowRuleBatchEntry createBatchEntry(FlowRuleOperation operation, 194 + private Collection<FlowRuleBatchEntry> createBatchEntries(
156 - LinkCollectionIntent intent, 195 + FlowRuleOperation operation,
157 - DeviceId deviceId, 196 + LinkCollectionIntent intent,
158 - Set<PortNumber> outPorts) { 197 + DeviceId deviceId,
159 - 198 + Set<PortNumber> inPorts,
160 - TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment 199 + Set<PortNumber> outPorts) {
161 - .builder(intent.treatment()); 200 + Collection<FlowRuleBatchEntry> result = Lists.newLinkedList();
201 + Set<PortNumber> ingressPorts = new HashSet<PortNumber>();
202 +
203 + //
204 + // Collect all ingress ports for this device.
205 + // The intent treatment is applied only on those ports.
206 + //
207 + for (ConnectPoint cp : intent.ingressPoints()) {
208 + if (cp.deviceId().equals(deviceId)) {
209 + ingressPorts.add(cp.port());
210 + }
211 + }
162 212
213 + //
214 + // Create two treatments: one for setting the output ports,
215 + // and a second one that applies the intent treatment and sets the
216 + // output ports.
217 + // NOTE: The second one is created only if there are ingress ports.
218 + //
219 + TrafficTreatment.Builder defaultTreatmentBuilder =
220 + DefaultTrafficTreatment.builder();
163 for (PortNumber outPort : outPorts) { 221 for (PortNumber outPort : outPorts) {
164 - treatmentBuilder.setOutput(outPort); 222 + defaultTreatmentBuilder.setOutput(outPort);
223 + }
224 + TrafficTreatment defaultTreatment = defaultTreatmentBuilder.build();
225 + TrafficTreatment intentTreatment = null;
226 + if (!ingressPorts.isEmpty()) {
227 + TrafficTreatment.Builder intentTreatmentBuilder =
228 + DefaultTrafficTreatment.builder(intent.treatment());
229 + for (PortNumber outPort : outPorts) {
230 + intentTreatmentBuilder.setOutput(outPort);
231 + }
232 + intentTreatment = intentTreatmentBuilder.build();
165 } 233 }
166 - TrafficTreatment treatment = treatmentBuilder.build();
167 -
168 - TrafficSelector selector = DefaultTrafficSelector
169 - .builder(intent.selector()).build();
170 234
171 - FlowRule rule = new DefaultFlowRule(deviceId, 235 + for (PortNumber inPort : inPorts) {
236 + TrafficSelector selector = DefaultTrafficSelector
237 + .builder(intent.selector()).matchInport(inPort).build();
238 + TrafficTreatment treatment = defaultTreatment;
239 + if (ingressPorts.contains(inPort)) {
240 + // Use the intent treatment if this is ingress port
241 + treatment = intentTreatment;
242 + }
243 + FlowRule rule = new DefaultFlowRule(deviceId,
172 selector, treatment, 123, 244 selector, treatment, 123,
173 appId, (short) (intent.id().fingerprint() & 0xffff), 0, true); 245 appId, (short) (intent.id().fingerprint() & 0xffff), 0, true);
246 + result.add(new FlowRuleBatchEntry(operation, rule));
247 + }
174 248
175 - return new FlowRuleBatchEntry(operation, rule); 249 + return result;
176 } 250 }
177 } 251 }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 package org.onosproject.net.intent.impl; 16 package org.onosproject.net.intent.impl;
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;
...@@ -39,6 +40,7 @@ import org.onosproject.net.intent.PointToPointIntent; ...@@ -39,6 +40,7 @@ import org.onosproject.net.intent.PointToPointIntent;
39 import org.onosproject.net.resource.LinkResourceAllocations; 40 import org.onosproject.net.resource.LinkResourceAllocations;
40 import org.onosproject.net.topology.PathService; 41 import org.onosproject.net.topology.PathService;
41 42
43 +import com.google.common.collect.ImmutableSet;
42 import com.google.common.collect.Sets; 44 import com.google.common.collect.Sets;
43 45
44 /** 46 /**
...@@ -75,8 +77,10 @@ public class MultiPointToSinglePointIntentCompiler ...@@ -75,8 +77,10 @@ public class MultiPointToSinglePointIntentCompiler
75 for (Link link : path.links()) { 77 for (Link link : path.links()) {
76 if (links.containsKey(link.src().deviceId())) { 78 if (links.containsKey(link.src().deviceId())) {
77 // We've already reached the existing tree with the first 79 // We've already reached the existing tree with the first
78 - // part of this path. Don't add the remainder of the path 80 + // part of this path. Add the merging point with differen
81 + // incoming port, but don't add the remainder of the path
79 // in case it differs from the path we already have. 82 // in case it differs from the path we already have.
83 + links.put(link.src().deviceId(), link);
80 break; 84 break;
81 } 85 }
82 86
...@@ -86,7 +90,10 @@ public class MultiPointToSinglePointIntentCompiler ...@@ -86,7 +90,10 @@ public class MultiPointToSinglePointIntentCompiler
86 90
87 Intent result = new LinkCollectionIntent(intent.appId(), 91 Intent result = new LinkCollectionIntent(intent.appId(),
88 intent.selector(), intent.treatment(), 92 intent.selector(), intent.treatment(),
89 - Sets.newHashSet(links.values()), intent.egressPoint()); 93 + Sets.newHashSet(links.values()),
94 + intent.ingressPoints(),
95 + ImmutableSet.of(intent.egressPoint()),
96 + Collections.emptyList());
90 return Arrays.asList(result); 97 return Arrays.asList(result);
91 } 98 }
92 99
......
...@@ -32,6 +32,8 @@ import org.onosproject.net.intent.SinglePointToMultiPointIntent; ...@@ -32,6 +32,8 @@ import org.onosproject.net.intent.SinglePointToMultiPointIntent;
32 import org.onosproject.net.provider.ProviderId; 32 import org.onosproject.net.provider.ProviderId;
33 import org.onosproject.net.resource.LinkResourceAllocations; 33 import org.onosproject.net.resource.LinkResourceAllocations;
34 34
35 +import com.google.common.collect.ImmutableSet;
36 +
35 @Component(immediate = true) 37 @Component(immediate = true)
36 public class SinglePointToMultiPointIntentCompiler 38 public class SinglePointToMultiPointIntentCompiler
37 extends ConnectivityIntentCompiler<SinglePointToMultiPointIntent> { 39 extends ConnectivityIntentCompiler<SinglePointToMultiPointIntent> {
...@@ -66,6 +68,7 @@ public class SinglePointToMultiPointIntentCompiler ...@@ -66,6 +68,7 @@ public class SinglePointToMultiPointIntentCompiler
66 Intent result = new LinkCollectionIntent(intent.appId(), 68 Intent result = new LinkCollectionIntent(intent.appId(),
67 intent.selector(), 69 intent.selector(),
68 intent.treatment(), links, 70 intent.treatment(), links,
71 + ImmutableSet.of(intent.ingressPoint()),
69 intent.egressPoints(), null); 72 intent.egressPoints(), null);
70 73
71 return Arrays.asList(result); 74 return Arrays.asList(result);
......