Refactored driver to use new FlowRule api.
Deprecated transition with table types and added api for transition with table ids. Change-Id: Ifcf2d87d16810666d992e4d9f5ddca3d0da460be
Showing
6 changed files
with
50 additions
and
67 deletions
| ... | @@ -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; | ... | ... |
This diff is collapsed. Click to expand it.
providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
| ... | @@ -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()) { | ... | ... |
-
Please register or login to post a comment