alshabib

Refactored driver to use new FlowRule api.

Deprecated transition with table types and added api for transition with table ids.

Change-Id: Ifcf2d87d16810666d992e4d9f5ddca3d0da460be
...@@ -289,7 +289,7 @@ public class DefaultFlowRule implements FlowRule { ...@@ -289,7 +289,7 @@ public class DefaultFlowRule implements FlowRule {
289 return new Builder(); 289 return new Builder();
290 } 290 }
291 291
292 - private static final class Builder implements FlowRule.Builder { 292 + public static final class Builder implements FlowRule.Builder {
293 293
294 private FlowId flowId; 294 private FlowId flowId;
295 private Integer priority; 295 private Integer priority;
......
...@@ -328,7 +328,12 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -328,7 +328,12 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
328 328
329 @Override 329 @Override
330 public Builder transition(FlowRule.Type type) { 330 public Builder transition(FlowRule.Type type) {
331 - return add(Instructions.transition(type)); 331 + return add(Instructions.transition(type.ordinal()));
332 + }
333 +
334 + @Override
335 + public Builder transition(Integer tableId) {
336 + return add(Instructions.transition(tableId));
332 } 337 }
333 338
334 @Override 339 @Override
......
...@@ -230,9 +230,19 @@ public interface TrafficTreatment { ...@@ -230,9 +230,19 @@ public interface TrafficTreatment {
230 * @param type the table type 230 * @param type the table type
231 * @return a treatement builder 231 * @return a treatement builder
232 */ 232 */
233 + @Deprecated
233 public Builder transition(FlowRule.Type type); 234 public Builder transition(FlowRule.Type type);
234 235
235 /** 236 /**
237 + * Sets the next table id to transition to.
238 + *
239 + * @param tableId the table table
240 + * @return a treatement builder
241 + */
242 + public Builder transition(Integer tableId);
243 +
244 +
245 + /**
236 * Pops outermost VLAN tag. 246 * Pops outermost VLAN tag.
237 * 247 *
238 * @return a treatment builder. 248 * @return a treatment builder.
......
...@@ -22,11 +22,8 @@ import org.onlab.packet.MplsLabel; ...@@ -22,11 +22,8 @@ import org.onlab.packet.MplsLabel;
22 import org.onlab.packet.VlanId; 22 import org.onlab.packet.VlanId;
23 import org.onosproject.core.GroupId; 23 import org.onosproject.core.GroupId;
24 import org.onosproject.net.PortNumber; 24 import org.onosproject.net.PortNumber;
25 -import org.onosproject.net.flow.FlowRule;
26 import org.onosproject.net.flow.instructions.L0ModificationInstruction.L0SubType; 25 import org.onosproject.net.flow.instructions.L0ModificationInstruction.L0SubType;
27 import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction; 26 import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction;
28 -import org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType;
29 -import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
30 import org.onosproject.net.flow.instructions.L3ModificationInstruction.L3SubType; 27 import org.onosproject.net.flow.instructions.L3ModificationInstruction.L3SubType;
31 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; 28 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
32 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction; 29 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
...@@ -36,12 +33,6 @@ import java.util.Objects; ...@@ -36,12 +33,6 @@ import java.util.Objects;
36 33
37 import static com.google.common.base.MoreObjects.toStringHelper; 34 import static com.google.common.base.MoreObjects.toStringHelper;
38 import static com.google.common.base.Preconditions.checkNotNull; 35 import static com.google.common.base.Preconditions.checkNotNull;
39 -import static org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction;
40 -import static org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsTtlInstruction;
41 -import static org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
42 -import static org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction;
43 -import static org.onosproject.net.flow.instructions.L2ModificationInstruction.PopVlanInstruction;
44 -import static org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeaderInstructions;
45 36
46 /** 37 /**
47 * Factory class for creating various traffic treatment instructions. 38 * Factory class for creating various traffic treatment instructions.
...@@ -103,7 +94,8 @@ public final class Instructions { ...@@ -103,7 +94,8 @@ public final class Instructions {
103 */ 94 */
104 public static L2ModificationInstruction modL2Src(MacAddress addr) { 95 public static L2ModificationInstruction modL2Src(MacAddress addr) {
105 checkNotNull(addr, "Src l2 address cannot be null"); 96 checkNotNull(addr, "Src l2 address cannot be null");
106 - return new ModEtherInstruction(L2SubType.ETH_SRC, addr); 97 + return new L2ModificationInstruction.ModEtherInstruction(
98 + L2ModificationInstruction.L2SubType.ETH_SRC, addr);
107 } 99 }
108 100
109 /** 101 /**
...@@ -114,7 +106,8 @@ public final class Instructions { ...@@ -114,7 +106,8 @@ public final class Instructions {
114 */ 106 */
115 public static L2ModificationInstruction modL2Dst(MacAddress addr) { 107 public static L2ModificationInstruction modL2Dst(MacAddress addr) {
116 checkNotNull(addr, "Dst l2 address cannot be null"); 108 checkNotNull(addr, "Dst l2 address cannot be null");
117 - return new ModEtherInstruction(L2SubType.ETH_DST, addr); 109 + return new L2ModificationInstruction.ModEtherInstruction(
110 + L2ModificationInstruction.L2SubType.ETH_DST, addr);
118 } 111 }
119 112
120 /** 113 /**
...@@ -125,7 +118,7 @@ public final class Instructions { ...@@ -125,7 +118,7 @@ public final class Instructions {
125 */ 118 */
126 public static L2ModificationInstruction modVlanId(VlanId vlanId) { 119 public static L2ModificationInstruction modVlanId(VlanId vlanId) {
127 checkNotNull(vlanId, "VLAN id cannot be null"); 120 checkNotNull(vlanId, "VLAN id cannot be null");
128 - return new ModVlanIdInstruction(vlanId); 121 + return new L2ModificationInstruction.ModVlanIdInstruction(vlanId);
129 } 122 }
130 123
131 /** 124 /**
...@@ -136,7 +129,7 @@ public final class Instructions { ...@@ -136,7 +129,7 @@ public final class Instructions {
136 */ 129 */
137 public static L2ModificationInstruction modVlanPcp(Byte vlanPcp) { 130 public static L2ModificationInstruction modVlanPcp(Byte vlanPcp) {
138 checkNotNull(vlanPcp, "VLAN Pcp cannot be null"); 131 checkNotNull(vlanPcp, "VLAN Pcp cannot be null");
139 - return new ModVlanPcpInstruction(vlanPcp); 132 + return new L2ModificationInstruction.ModVlanPcpInstruction(vlanPcp);
140 } 133 }
141 134
142 /** 135 /**
...@@ -147,7 +140,7 @@ public final class Instructions { ...@@ -147,7 +140,7 @@ public final class Instructions {
147 */ 140 */
148 public static L2ModificationInstruction modMplsLabel(MplsLabel mplsLabel) { 141 public static L2ModificationInstruction modMplsLabel(MplsLabel mplsLabel) {
149 checkNotNull(mplsLabel, "MPLS label cannot be null"); 142 checkNotNull(mplsLabel, "MPLS label cannot be null");
150 - return new ModMplsLabelInstruction(mplsLabel); 143 + return new L2ModificationInstruction.ModMplsLabelInstruction(mplsLabel);
151 } 144 }
152 145
153 /** 146 /**
...@@ -156,7 +149,7 @@ public final class Instructions { ...@@ -156,7 +149,7 @@ public final class Instructions {
156 * @return a L2 Modification 149 * @return a L2 Modification
157 */ 150 */
158 public static L2ModificationInstruction decMplsTtl() { 151 public static L2ModificationInstruction decMplsTtl() {
159 - return new ModMplsTtlInstruction(); 152 + return new L2ModificationInstruction.ModMplsTtlInstruction();
160 } 153 }
161 154
162 /** 155 /**
...@@ -246,7 +239,8 @@ public final class Instructions { ...@@ -246,7 +239,8 @@ public final class Instructions {
246 * @return a L2 modification. 239 * @return a L2 modification.
247 */ 240 */
248 public static Instruction pushMpls() { 241 public static Instruction pushMpls() {
249 - return new PushHeaderInstructions(L2SubType.MPLS_PUSH, 242 + return new L2ModificationInstruction.PushHeaderInstructions(
243 + L2ModificationInstruction.L2SubType.MPLS_PUSH,
250 Ethernet.MPLS_UNICAST); 244 Ethernet.MPLS_UNICAST);
251 } 245 }
252 246
...@@ -256,7 +250,8 @@ public final class Instructions { ...@@ -256,7 +250,8 @@ public final class Instructions {
256 * @return a L2 modification. 250 * @return a L2 modification.
257 */ 251 */
258 public static Instruction popMpls() { 252 public static Instruction popMpls() {
259 - return new PushHeaderInstructions(L2SubType.MPLS_POP, 253 + return new L2ModificationInstruction.PushHeaderInstructions(
254 + L2ModificationInstruction.L2SubType.MPLS_POP,
260 Ethernet.MPLS_UNICAST); 255 Ethernet.MPLS_UNICAST);
261 } 256 }
262 257
...@@ -268,7 +263,8 @@ public final class Instructions { ...@@ -268,7 +263,8 @@ public final class Instructions {
268 */ 263 */
269 public static Instruction popMpls(Short etherType) { 264 public static Instruction popMpls(Short etherType) {
270 checkNotNull(etherType, "Ethernet type cannot be null"); 265 checkNotNull(etherType, "Ethernet type cannot be null");
271 - return new PushHeaderInstructions(L2SubType.MPLS_POP, etherType); 266 + return new L2ModificationInstruction.PushHeaderInstructions(
267 + L2ModificationInstruction.L2SubType.MPLS_POP, etherType);
272 } 268 }
273 269
274 /** 270 /**
...@@ -277,7 +273,8 @@ public final class Instructions { ...@@ -277,7 +273,8 @@ public final class Instructions {
277 * @return a L2 modification 273 * @return a L2 modification
278 */ 274 */
279 public static Instruction popVlan() { 275 public static Instruction popVlan() {
280 - return new PopVlanInstruction(L2SubType.VLAN_POP); 276 + return new L2ModificationInstruction.PopVlanInstruction(
277 + L2ModificationInstruction.L2SubType.VLAN_POP);
281 } 278 }
282 279
283 /** 280 /**
...@@ -286,18 +283,19 @@ public final class Instructions { ...@@ -286,18 +283,19 @@ public final class Instructions {
286 * @return a L2 modification 283 * @return a L2 modification
287 */ 284 */
288 public static Instruction pushVlan() { 285 public static Instruction pushVlan() {
289 - return new PushHeaderInstructions(L2SubType.VLAN_PUSH, Ethernet.TYPE_VLAN); 286 + return new L2ModificationInstruction.PushHeaderInstructions(
287 + L2ModificationInstruction.L2SubType.VLAN_PUSH, Ethernet.TYPE_VLAN);
290 } 288 }
291 289
292 /** 290 /**
293 - * Sends the packet to the table described in 'type'. 291 + * Sends the packet to the table id.
294 * 292 *
295 - * @param type flow rule table type 293 + * @param tableId flow rule table id
296 * @return table type transition instruction 294 * @return table type transition instruction
297 */ 295 */
298 - public static Instruction transition(FlowRule.Type type) { 296 + public static Instruction transition(Integer tableId) {
299 - checkNotNull(type, "Table type cannot be null"); 297 + checkNotNull(tableId, "Table id cannot be null");
300 - return new TableTypeTransition(type); 298 + return new TableTypeTransition(tableId);
301 } 299 }
302 300
303 /** 301 /**
...@@ -421,13 +419,12 @@ public final class Instructions { ...@@ -421,13 +419,12 @@ public final class Instructions {
421 } 419 }
422 } 420 }
423 421
424 - // FIXME: Temporary support for this. This should probably become it's own 422 +
425 - // type like other instructions.
426 public static class TableTypeTransition implements Instruction { 423 public static class TableTypeTransition implements Instruction {
427 - private final FlowRule.Type tableType; 424 + private final Integer tableId;
428 425
429 - TableTypeTransition(FlowRule.Type type) { 426 + TableTypeTransition(Integer tableId) {
430 - this.tableType = type; 427 + this.tableId = tableId;
431 } 428 }
432 429
433 @Override 430 @Override
...@@ -435,19 +432,19 @@ public final class Instructions { ...@@ -435,19 +432,19 @@ public final class Instructions {
435 return Type.TABLE; 432 return Type.TABLE;
436 } 433 }
437 434
438 - public FlowRule.Type tableType() { 435 + public Integer tableId() {
439 - return this.tableType; 436 + return this.tableId;
440 } 437 }
441 438
442 @Override 439 @Override
443 public String toString() { 440 public String toString() {
444 return toStringHelper(type().toString()) 441 return toStringHelper(type().toString())
445 - .add("tableType", this.tableType).toString(); 442 + .add("tableId", this.tableId).toString();
446 } 443 }
447 444
448 @Override 445 @Override
449 public int hashCode() { 446 public int hashCode() {
450 - return Objects.hash(type(), tableType); 447 + return Objects.hash(type(), tableId);
451 } 448 }
452 449
453 @Override 450 @Override
...@@ -457,7 +454,7 @@ public final class Instructions { ...@@ -457,7 +454,7 @@ public final class Instructions {
457 } 454 }
458 if (obj instanceof TableTypeTransition) { 455 if (obj instanceof TableTypeTransition) {
459 TableTypeTransition that = (TableTypeTransition) obj; 456 TableTypeTransition that = (TableTypeTransition) obj;
460 - return Objects.equals(tableType, that.tableType); 457 + return Objects.equals(tableId, that.tableId);
461 458
462 } 459 }
463 return false; 460 return false;
......
...@@ -77,6 +77,18 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -77,6 +77,18 @@ import static org.slf4j.LoggerFactory.getLogger;
77 */ 77 */
78 public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeliner { 78 public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeliner {
79 79
80 +
81 +
82 + protected static final int FIRST_TABLE = 0;
83 + protected static final int VLAN_MPLS_TABLE = 1;
84 + protected static final int VLAN_TABLE = 2;
85 + //protected static final int MPLS_TABLE = 3;
86 + protected static final int ETHER_TABLE = 4;
87 + protected static final int COS_MAP_TABLE = 5;
88 + protected static final int FIB_TABLE = 6;
89 + protected static final int LOCAL_TABLE = 9;
90 +
91 +
80 private static final int CONTROLLER_PRIORITY = 255; 92 private static final int CONTROLLER_PRIORITY = 255;
81 private static final int DROP_PRIORITY = 0; 93 private static final int DROP_PRIORITY = 0;
82 private static final int HIGHEST_PRIORITY = 0xffff; 94 private static final int HIGHEST_PRIORITY = 0xffff;
...@@ -266,10 +278,23 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -266,10 +278,23 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
266 .group(group.id()) 278 .group(group.id())
267 .build(); 279 .build();
268 280
269 - return Collections.singletonList( 281 + FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
270 - new DefaultFlowRule(deviceId, filteredSelector, treatment, 282 + .fromApp(fwd.appId())
271 - fwd.priority(), fwd.appId(), 0, fwd.permanent(), 283 + .withPriority(fwd.priority())
272 - FlowRule.Type.IP)); 284 + .forDevice(deviceId)
285 + .withSelector(filteredSelector)
286 + .withTreatment(treatment);
287 +
288 + if (fwd.permanent()) {
289 + ruleBuilder.makePermanent();
290 + } else {
291 + ruleBuilder.makeTemporary(fwd.timeout());
292 + }
293 +
294 + ruleBuilder.forTable(FIB_TABLE);
295 +
296 +
297 + return Collections.singletonList(ruleBuilder.build());
273 298
274 } 299 }
275 300
...@@ -296,11 +321,15 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -296,11 +321,15 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
296 TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); 321 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
297 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); 322 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
298 selector.matchEthDst(e.mac()); 323 selector.matchEthDst(e.mac());
299 - treatment.transition(FlowRule.Type.VLAN_MPLS); 324 + treatment.transition(VLAN_MPLS_TABLE);
300 - FlowRule rule = new DefaultFlowRule(deviceId, selector.build(), 325 + FlowRule rule = DefaultFlowRule.builder()
301 - treatment.build(), 326 + .forDevice(deviceId)
302 - CONTROLLER_PRIORITY, applicationId, 327 + .withSelector(selector.build())
303 - 0, true, FlowRule.Type.FIRST); 328 + .withTreatment(treatment.build())
329 + .withPriority(CONTROLLER_PRIORITY)
330 + .fromApp(applicationId)
331 + .makePermanent()
332 + .forTable(FIRST_TABLE).build();
304 ops = install ? ops.add(rule) : ops.remove(rule); 333 ops = install ? ops.add(rule) : ops.remove(rule);
305 } else if (c.type() == Criterion.Type.VLAN_VID) { 334 } else if (c.type() == Criterion.Type.VLAN_VID) {
306 Criteria.VlanIdCriterion v = (Criteria.VlanIdCriterion) c; 335 Criteria.VlanIdCriterion v = (Criteria.VlanIdCriterion) c;
...@@ -309,12 +338,16 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -309,12 +338,16 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
309 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); 338 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
310 selector.matchVlanId(v.vlanId()); 339 selector.matchVlanId(v.vlanId());
311 selector.matchInPort(p.port()); 340 selector.matchInPort(p.port());
312 - treatment.transition(FlowRule.Type.ETHER); 341 + treatment.transition(ETHER_TABLE);
313 treatment.deferred().popVlan(); 342 treatment.deferred().popVlan();
314 - FlowRule rule = new DefaultFlowRule(deviceId, selector.build(), 343 + FlowRule rule = DefaultFlowRule.builder()
315 - treatment.build(), 344 + .forDevice(deviceId)
316 - CONTROLLER_PRIORITY, applicationId, 345 + .withSelector(selector.build())
317 - 0, true, FlowRule.Type.VLAN); 346 + .withTreatment(treatment.build())
347 + .withPriority(CONTROLLER_PRIORITY)
348 + .fromApp(applicationId)
349 + .makePermanent()
350 + .forTable(VLAN_TABLE).build();
318 ops = install ? ops.add(rule) : ops.remove(rule); 351 ops = install ? ops.add(rule) : ops.remove(rule);
319 } else if (c.type() == Criterion.Type.IPV4_DST) { 352 } else if (c.type() == Criterion.Type.IPV4_DST) {
320 Criteria.IPCriterion ip = (Criteria.IPCriterion) c; 353 Criteria.IPCriterion ip = (Criteria.IPCriterion) c;
...@@ -323,10 +356,16 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -323,10 +356,16 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
323 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); 356 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
324 selector.matchEthType(Ethernet.TYPE_IPV4); 357 selector.matchEthType(Ethernet.TYPE_IPV4);
325 selector.matchIPDst(ip.ip()); 358 selector.matchIPDst(ip.ip());
326 - treatment.transition(FlowRule.Type.ACL); 359 + treatment.transition(LOCAL_TABLE);
327 - FlowRule rule = new DefaultFlowRule(deviceId, selector.build(), 360 + FlowRule rule = DefaultFlowRule.builder()
328 - treatment.build(), HIGHEST_PRIORITY, appId, 361 + .forDevice(deviceId)
329 - 0, true, FlowRule.Type.IP); 362 + .withSelector(selector.build())
363 + .withTreatment(treatment.build())
364 + .withPriority(HIGHEST_PRIORITY)
365 + .fromApp(applicationId)
366 + .makePermanent()
367 + .forTable(FIB_TABLE).build();
368 +
330 ops = install ? ops.add(rule) : ops.remove(rule); 369 ops = install ? ops.add(rule) : ops.remove(rule);
331 } else { 370 } else {
332 log.warn("Driver does not currently process filtering condition" 371 log.warn("Driver does not currently process filtering condition"
...@@ -381,12 +420,17 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -381,12 +420,17 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
381 treatment = DefaultTrafficTreatment.builder(); 420 treatment = DefaultTrafficTreatment.builder();
382 421
383 selector.matchEthDst(MacAddress.BROADCAST); 422 selector.matchEthDst(MacAddress.BROADCAST);
384 - treatment.transition(FlowRule.Type.VLAN_MPLS); 423 + treatment.transition(VLAN_MPLS_TABLE);
424 +
425 + FlowRule rule = DefaultFlowRule.builder()
426 + .forDevice(deviceId)
427 + .withSelector(selector.build())
428 + .withTreatment(treatment.build())
429 + .withPriority(CONTROLLER_PRIORITY)
430 + .fromApp(appId)
431 + .makePermanent()
432 + .forTable(FIRST_TABLE).build();
385 433
386 - FlowRule rule = new DefaultFlowRule(deviceId, selector.build(),
387 - treatment.build(),
388 - CONTROLLER_PRIORITY, appId, 0,
389 - true, FlowRule.Type.FIRST);
390 434
391 FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); 435 FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
392 436
...@@ -399,9 +443,15 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -399,9 +443,15 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
399 443
400 treatment.drop(); 444 treatment.drop();
401 445
402 - rule = new DefaultFlowRule(deviceId, selector.build(), 446 + rule = DefaultFlowRule.builder()
403 - treatment.build(), DROP_PRIORITY, appId, 447 + .forDevice(deviceId)
404 - 0, true, FlowRule.Type.FIRST); 448 + .withSelector(selector.build())
449 + .withTreatment(treatment.build())
450 + .withPriority(DROP_PRIORITY)
451 + .fromApp(appId)
452 + .makePermanent()
453 + .forTable(FIRST_TABLE).build();
454 +
405 455
406 ops = install ? ops.add(rule) : ops.remove(rule); 456 ops = install ? ops.add(rule) : ops.remove(rule);
407 457
...@@ -427,11 +477,17 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -427,11 +477,17 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
427 FlowRule rule; 477 FlowRule rule;
428 478
429 selector.matchVlanId(VlanId.ANY); 479 selector.matchVlanId(VlanId.ANY);
430 - treatment.transition(FlowRule.Type.VLAN); 480 + treatment.transition(VLAN_TABLE);
481 +
482 + rule = DefaultFlowRule.builder()
483 + .forDevice(deviceId)
484 + .withSelector(selector.build())
485 + .withTreatment(treatment.build())
486 + .withPriority(CONTROLLER_PRIORITY)
487 + .fromApp(appId)
488 + .makePermanent()
489 + .forTable(VLAN_MPLS_TABLE).build();
431 490
432 - rule = new DefaultFlowRule(deviceId, selector.build(),
433 - treatment.build(), CONTROLLER_PRIORITY,
434 - appId, 0, true, FlowRule.Type.VLAN_MPLS);
435 491
436 ops = install ? ops.add(rule) : ops.remove(rule); 492 ops = install ? ops.add(rule) : ops.remove(rule);
437 493
...@@ -463,9 +519,14 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -463,9 +519,14 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
463 519
464 treatment.drop(); 520 treatment.drop();
465 521
466 - rule = new DefaultFlowRule(deviceId, selector.build(), 522 + rule = DefaultFlowRule.builder()
467 - treatment.build(), DROP_PRIORITY, appId, 523 + .forDevice(deviceId)
468 - 0, true, FlowRule.Type.VLAN); 524 + .withSelector(selector.build())
525 + .withTreatment(treatment.build())
526 + .withPriority(DROP_PRIORITY)
527 + .fromApp(appId)
528 + .makePermanent()
529 + .forTable(VLAN_TABLE).build();
469 530
470 ops = install ? ops.add(rule) : ops.remove(rule); 531 ops = install ? ops.add(rule) : ops.remove(rule);
471 532
...@@ -492,9 +553,14 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -492,9 +553,14 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
492 selector.matchEthType(Ethernet.TYPE_ARP); 553 selector.matchEthType(Ethernet.TYPE_ARP);
493 treatment.punt(); 554 treatment.punt();
494 555
495 - rule = new DefaultFlowRule(deviceId, selector.build(), 556 + rule = DefaultFlowRule.builder()
496 - treatment.build(), CONTROLLER_PRIORITY, 557 + .forDevice(deviceId)
497 - appId, 0, true, FlowRule.Type.ETHER); 558 + .withSelector(selector.build())
559 + .withTreatment(treatment.build())
560 + .withPriority(CONTROLLER_PRIORITY)
561 + .fromApp(appId)
562 + .makePermanent()
563 + .forTable(ETHER_TABLE).build();
498 564
499 ops = install ? ops.add(rule) : ops.remove(rule); 565 ops = install ? ops.add(rule) : ops.remove(rule);
500 566
...@@ -502,11 +568,16 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -502,11 +568,16 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
502 treatment = DefaultTrafficTreatment.builder(); 568 treatment = DefaultTrafficTreatment.builder();
503 569
504 selector.matchEthType(Ethernet.TYPE_IPV4); 570 selector.matchEthType(Ethernet.TYPE_IPV4);
505 - treatment.transition(FlowRule.Type.COS); 571 + treatment.transition(COS_MAP_TABLE);
506 572
507 - rule = new DefaultFlowRule(deviceId, selector.build(), 573 + rule = DefaultFlowRule.builder()
508 - treatment.build(), CONTROLLER_PRIORITY, 574 + .forDevice(deviceId)
509 - appId, 0, true, FlowRule.Type.ETHER); 575 + .withPriority(CONTROLLER_PRIORITY)
576 + .withSelector(selector.build())
577 + .withTreatment(treatment.build())
578 + .fromApp(appId)
579 + .makePermanent()
580 + .forTable(ETHER_TABLE).build();
510 581
511 ops = install ? ops.add(rule) : ops.remove(rule); 582 ops = install ? ops.add(rule) : ops.remove(rule);
512 583
...@@ -516,9 +587,15 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -516,9 +587,15 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
516 587
517 treatment.drop(); 588 treatment.drop();
518 589
519 - rule = new DefaultFlowRule(deviceId, selector.build(), 590 + rule = DefaultFlowRule.builder()
520 - treatment.build(), DROP_PRIORITY, appId, 591 + .forDevice(deviceId)
521 - 0, true, FlowRule.Type.ETHER); 592 + .withSelector(selector.build())
593 + .withTreatment(treatment.build())
594 + .withPriority(DROP_PRIORITY)
595 + .fromApp(appId)
596 + .makePermanent()
597 + .forTable(ETHER_TABLE).build();
598 +
522 599
523 ops = install ? ops.add(rule) : ops.remove(rule); 600 ops = install ? ops.add(rule) : ops.remove(rule);
524 601
...@@ -543,11 +620,16 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -543,11 +620,16 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
543 FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); 620 FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
544 FlowRule rule; 621 FlowRule rule;
545 622
546 - treatment.transition(FlowRule.Type.IP); 623 + treatment.transition(FIB_TABLE);
547 624
548 - rule = new DefaultFlowRule(deviceId, selector.build(), 625 + rule = DefaultFlowRule.builder()
549 - treatment.build(), DROP_PRIORITY, appId, 626 + .forDevice(deviceId)
550 - 0, true, FlowRule.Type.COS); 627 + .withSelector(selector.build())
628 + .withTreatment(treatment.build())
629 + .withPriority(DROP_PRIORITY)
630 + .fromApp(appId)
631 + .makePermanent()
632 + .forTable(COS_MAP_TABLE).build();
551 633
552 ops = install ? ops.add(rule) : ops.remove(rule); 634 ops = install ? ops.add(rule) : ops.remove(rule);
553 635
...@@ -577,9 +659,14 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -577,9 +659,14 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
577 659
578 treatment.drop(); 660 treatment.drop();
579 661
580 - rule = new DefaultFlowRule(deviceId, selector.build(), 662 + rule = DefaultFlowRule.builder()
581 - treatment.build(), DROP_PRIORITY, appId, 663 + .forDevice(deviceId)
582 - 0, true, FlowRule.Type.IP); 664 + .withSelector(selector.build())
665 + .withTreatment(treatment.build())
666 + .withPriority(DROP_PRIORITY)
667 + .fromApp(appId)
668 + .makePermanent()
669 + .forTable(FIB_TABLE).build();
583 670
584 ops = install ? ops.add(rule) : ops.remove(rule); 671 ops = install ? ops.add(rule) : ops.remove(rule);
585 672
...@@ -605,9 +692,14 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli ...@@ -605,9 +692,14 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
605 692
606 treatment.punt(); 693 treatment.punt();
607 694
608 - rule = new DefaultFlowRule(deviceId, selector.build(), 695 + rule = DefaultFlowRule.builder()
609 - treatment.build(), CONTROLLER_PRIORITY, 696 + .forDevice(deviceId)
610 - appId, 0, true, FlowRule.Type.DEFAULT); 697 + .withSelector(selector.build())
698 + .withTreatment(treatment.build())
699 + .withPriority(CONTROLLER_PRIORITY)
700 + .fromApp(appId)
701 + .makePermanent()
702 + .forTable(LOCAL_TABLE).build();
611 703
612 ops = install ? ops.add(rule) : ops.remove(rule); 704 ops = install ? ops.add(rule) : ops.remove(rule);
613 705
......
...@@ -36,7 +36,6 @@ import org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeade ...@@ -36,7 +36,6 @@ import org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeade
36 import org.onosproject.net.flow.instructions.L3ModificationInstruction; 36 import org.onosproject.net.flow.instructions.L3ModificationInstruction;
37 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; 37 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
38 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction; 38 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
39 -import org.onosproject.openflow.controller.OpenFlowSwitch;
40 import org.projectfloodlight.openflow.protocol.OFFactory; 39 import org.projectfloodlight.openflow.protocol.OFFactory;
41 import org.projectfloodlight.openflow.protocol.OFFlowAdd; 40 import org.projectfloodlight.openflow.protocol.OFFlowAdd;
42 import org.projectfloodlight.openflow.protocol.OFFlowDelete; 41 import org.projectfloodlight.openflow.protocol.OFFlowDelete;
...@@ -238,38 +237,10 @@ public class FlowModBuilderVer13 extends FlowModBuilder { ...@@ -238,38 +237,10 @@ public class FlowModBuilderVer13 extends FlowModBuilder {
238 237
239 private OFInstruction buildTableGoto(Instructions.TableTypeTransition i) { 238 private OFInstruction buildTableGoto(Instructions.TableTypeTransition i) {
240 OFInstruction instruction = factory().instructions().gotoTable( 239 OFInstruction instruction = factory().instructions().gotoTable(
241 - TableId.of(getTableType(i.tableType()).ordinal())); 240 + TableId.of(i.tableId()));
242 return instruction; 241 return instruction;
243 } 242 }
244 243
245 - // FIXME: this has to go as well perhaps when we implement the SelectorService.
246 - private OpenFlowSwitch.TableType getTableType(FlowRule.Type type) {
247 - switch (type) {
248 -
249 - case DEFAULT:
250 - return OpenFlowSwitch.TableType.NONE;
251 - case IP:
252 - return OpenFlowSwitch.TableType.IP;
253 - case MPLS:
254 - return OpenFlowSwitch.TableType.MPLS;
255 - case ACL:
256 - return OpenFlowSwitch.TableType.ACL;
257 - case VLAN_MPLS:
258 - return OpenFlowSwitch.TableType.VLAN_MPLS;
259 - case VLAN:
260 - return OpenFlowSwitch.TableType.VLAN;
261 - case ETHER:
262 - return OpenFlowSwitch.TableType.ETHER;
263 - case COS:
264 - return OpenFlowSwitch.TableType.COS;
265 - case FIRST:
266 - return OpenFlowSwitch.TableType.FIRST;
267 - default:
268 - return OpenFlowSwitch.TableType.NONE;
269 - }
270 - }
271 -
272 -
273 private OFAction buildL0Modification(Instruction i) { 244 private OFAction buildL0Modification(Instruction i) {
274 L0ModificationInstruction l0m = (L0ModificationInstruction) i; 245 L0ModificationInstruction l0m = (L0ModificationInstruction) i;
275 switch (l0m.subtype()) { 246 switch (l0m.subtype()) {
......