Committed by
Gerrit Code Review
ONOS-958: Add a Group action to TrafficTreatment subsystem.
Change-Id: I2a377508b9721ee96a5a52b0bb2ed3a960c982ce
Showing
5 changed files
with
89 additions
and
13 deletions
| ... | @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList; | ... | @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList; |
| 20 | import org.onlab.packet.IpAddress; | 20 | import org.onlab.packet.IpAddress; |
| 21 | import org.onlab.packet.MacAddress; | 21 | import org.onlab.packet.MacAddress; |
| 22 | import org.onlab.packet.VlanId; | 22 | import org.onlab.packet.VlanId; |
| 23 | +import org.onosproject.core.GroupId; | ||
| 23 | import org.onosproject.net.PortNumber; | 24 | import org.onosproject.net.PortNumber; |
| 24 | import org.onosproject.net.flow.instructions.Instruction; | 25 | import org.onosproject.net.flow.instructions.Instruction; |
| 25 | import org.onosproject.net.flow.instructions.Instructions; | 26 | import org.onosproject.net.flow.instructions.Instructions; |
| ... | @@ -241,6 +242,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -241,6 +242,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
| 241 | } | 242 | } |
| 242 | 243 | ||
| 243 | @Override | 244 | @Override |
| 245 | + public Builder group(GroupId groupId) { | ||
| 246 | + return add(Instructions.createGroup(groupId)); | ||
| 247 | + } | ||
| 248 | + | ||
| 249 | + @Override | ||
| 244 | public TrafficTreatment build() { | 250 | public TrafficTreatment build() { |
| 245 | 251 | ||
| 246 | //If we are dropping should we just return an empty list? | 252 | //If we are dropping should we just return an empty list? | ... | ... |
| ... | @@ -17,6 +17,7 @@ package org.onosproject.net.flow; | ... | @@ -17,6 +17,7 @@ package org.onosproject.net.flow; |
| 17 | 17 | ||
| 18 | import java.util.List; | 18 | import java.util.List; |
| 19 | 19 | ||
| 20 | +import org.onosproject.core.GroupId; | ||
| 20 | import org.onosproject.net.PortNumber; | 21 | import org.onosproject.net.PortNumber; |
| 21 | import org.onosproject.net.flow.instructions.Instruction; | 22 | import org.onosproject.net.flow.instructions.Instruction; |
| 22 | import org.onlab.packet.IpAddress; | 23 | import org.onlab.packet.IpAddress; |
| ... | @@ -185,6 +186,14 @@ public interface TrafficTreatment { | ... | @@ -185,6 +186,14 @@ public interface TrafficTreatment { |
| 185 | public Builder setLambda(short lambda); | 186 | public Builder setLambda(short lambda); |
| 186 | 187 | ||
| 187 | /** | 188 | /** |
| 189 | + * Sets the group ID. | ||
| 190 | + * | ||
| 191 | + * @param groupId group ID | ||
| 192 | + * @return a treatment builder | ||
| 193 | + */ | ||
| 194 | + public Builder group(GroupId groupId); | ||
| 195 | + | ||
| 196 | + /** | ||
| 188 | * Builds an immutable traffic treatment descriptor. | 197 | * Builds an immutable traffic treatment descriptor. |
| 189 | * | 198 | * |
| 190 | * @return traffic treatment | 199 | * @return traffic treatment | ... | ... |
| ... | @@ -21,6 +21,7 @@ import static org.onosproject.net.flow.instructions.L2ModificationInstruction.*; | ... | @@ -21,6 +21,7 @@ import static org.onosproject.net.flow.instructions.L2ModificationInstruction.*; |
| 21 | 21 | ||
| 22 | import java.util.Objects; | 22 | import java.util.Objects; |
| 23 | 23 | ||
| 24 | +import org.onosproject.core.GroupId; | ||
| 24 | import org.onosproject.net.PortNumber; | 25 | import org.onosproject.net.PortNumber; |
| 25 | import org.onosproject.net.flow.instructions.L0ModificationInstruction.L0SubType; | 26 | import org.onosproject.net.flow.instructions.L0ModificationInstruction.L0SubType; |
| 26 | import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction; | 27 | import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction; |
| ... | @@ -65,6 +66,17 @@ public final class Instructions { | ... | @@ -65,6 +66,17 @@ public final class Instructions { |
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | /** | 68 | /** |
| 69 | + * Creates a group instruction. | ||
| 70 | + * | ||
| 71 | + * @param groupId Group Id | ||
| 72 | + * @return group instruction | ||
| 73 | + */ | ||
| 74 | + public static GroupInstruction createGroup(final GroupId groupId) { | ||
| 75 | + checkNotNull(groupId, "GroupId cannot be null"); | ||
| 76 | + return new GroupInstruction(groupId); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + /** | ||
| 68 | * Creates a l0 modification. | 80 | * Creates a l0 modification. |
| 69 | * @param lambda the lambda to modify to. | 81 | * @param lambda the lambda to modify to. |
| 70 | * @return a l0 modification | 82 | * @return a l0 modification |
| ... | @@ -207,7 +219,7 @@ public final class Instructions { | ... | @@ -207,7 +219,7 @@ public final class Instructions { |
| 207 | } | 219 | } |
| 208 | 220 | ||
| 209 | /* | 221 | /* |
| 210 | - * Output instructions | 222 | + * Drop instructions |
| 211 | */ | 223 | */ |
| 212 | 224 | ||
| 213 | public static final class DropInstruction implements Instruction { | 225 | public static final class DropInstruction implements Instruction { |
| ... | @@ -241,6 +253,9 @@ public final class Instructions { | ... | @@ -241,6 +253,9 @@ public final class Instructions { |
| 241 | } | 253 | } |
| 242 | } | 254 | } |
| 243 | 255 | ||
| 256 | + /* | ||
| 257 | + * Output Instruction | ||
| 258 | + */ | ||
| 244 | 259 | ||
| 245 | public static final class OutputInstruction implements Instruction { | 260 | public static final class OutputInstruction implements Instruction { |
| 246 | private final PortNumber port; | 261 | private final PortNumber port; |
| ... | @@ -282,6 +297,50 @@ public final class Instructions { | ... | @@ -282,6 +297,50 @@ public final class Instructions { |
| 282 | } | 297 | } |
| 283 | } | 298 | } |
| 284 | 299 | ||
| 300 | + /* | ||
| 301 | + * Group Instruction | ||
| 302 | + */ | ||
| 303 | + | ||
| 304 | + public static final class GroupInstruction implements Instruction { | ||
| 305 | + private final GroupId groupId; | ||
| 306 | + | ||
| 307 | + private GroupInstruction(GroupId groupId) { | ||
| 308 | + this.groupId = groupId; | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + public GroupId groupId() { | ||
| 312 | + return groupId; | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + @Override | ||
| 316 | + public Type type() { | ||
| 317 | + return Type.GROUP; | ||
| 318 | + } | ||
| 319 | + @Override | ||
| 320 | + public String toString() { | ||
| 321 | + return toStringHelper(type().toString()) | ||
| 322 | + .add("group ID", groupId.id()).toString(); | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + @Override | ||
| 326 | + public int hashCode() { | ||
| 327 | + return Objects.hash(type(), groupId); | ||
| 328 | + } | ||
| 329 | + | ||
| 330 | + @Override | ||
| 331 | + public boolean equals(Object obj) { | ||
| 332 | + if (this == obj) { | ||
| 333 | + return true; | ||
| 334 | + } | ||
| 335 | + if (obj instanceof GroupInstruction) { | ||
| 336 | + GroupInstruction that = (GroupInstruction) obj; | ||
| 337 | + return Objects.equals(groupId, that.groupId); | ||
| 338 | + | ||
| 339 | + } | ||
| 340 | + return false; | ||
| 341 | + } | ||
| 342 | + } | ||
| 343 | + | ||
| 285 | } | 344 | } |
| 286 | 345 | ||
| 287 | 346 | ... | ... |
| ... | @@ -22,6 +22,7 @@ import org.onlab.packet.Ip6Address; | ... | @@ -22,6 +22,7 @@ import org.onlab.packet.Ip6Address; |
| 22 | import org.onlab.packet.Ip6Prefix; | 22 | import org.onlab.packet.Ip6Prefix; |
| 23 | import org.onlab.packet.MacAddress; | 23 | import org.onlab.packet.MacAddress; |
| 24 | import org.onlab.packet.VlanId; | 24 | import org.onlab.packet.VlanId; |
| 25 | +import org.onosproject.core.DefaultGroupId; | ||
| 25 | import org.onosproject.net.DeviceId; | 26 | import org.onosproject.net.DeviceId; |
| 26 | import org.onosproject.net.PortNumber; | 27 | import org.onosproject.net.PortNumber; |
| 27 | import org.onosproject.net.flow.DefaultFlowEntry; | 28 | import org.onosproject.net.flow.DefaultFlowEntry; |
| ... | @@ -39,14 +40,10 @@ import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; | ... | @@ -39,14 +40,10 @@ import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; |
| 39 | import org.projectfloodlight.openflow.protocol.OFInstructionType; | 40 | import org.projectfloodlight.openflow.protocol.OFInstructionType; |
| 40 | import org.projectfloodlight.openflow.protocol.action.OFAction; | 41 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
| 41 | import org.projectfloodlight.openflow.protocol.action.OFActionCircuit; | 42 | import org.projectfloodlight.openflow.protocol.action.OFActionCircuit; |
| 42 | -import org.projectfloodlight.openflow.protocol.action.OFActionCopyTtlIn; | ||
| 43 | -import org.projectfloodlight.openflow.protocol.action.OFActionCopyTtlOut; | ||
| 44 | -import org.projectfloodlight.openflow.protocol.action.OFActionDecMplsTtl; | ||
| 45 | -import org.projectfloodlight.openflow.protocol.action.OFActionDecNwTtl; | ||
| 46 | import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter; | 43 | import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter; |
| 44 | +import org.projectfloodlight.openflow.protocol.action.OFActionGroup; | ||
| 47 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; | 45 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; |
| 48 | import org.projectfloodlight.openflow.protocol.action.OFActionPopMpls; | 46 | import org.projectfloodlight.openflow.protocol.action.OFActionPopMpls; |
| 49 | -import org.projectfloodlight.openflow.protocol.action.OFActionPushMpls; | ||
| 50 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst; | 47 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst; |
| 51 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc; | 48 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc; |
| 52 | import org.projectfloodlight.openflow.protocol.action.OFActionSetField; | 49 | import org.projectfloodlight.openflow.protocol.action.OFActionSetField; |
| ... | @@ -207,25 +204,24 @@ public class FlowEntryBuilder { | ... | @@ -207,25 +204,24 @@ public class FlowEntryBuilder { |
| 207 | builder.popMpls((short) popMpls.getEthertype().getValue()); | 204 | builder.popMpls((short) popMpls.getEthertype().getValue()); |
| 208 | break; | 205 | break; |
| 209 | case PUSH_MPLS: | 206 | case PUSH_MPLS: |
| 210 | - OFActionPushMpls pushMpls = (OFActionPushMpls) act; | ||
| 211 | builder.pushMpls(); | 207 | builder.pushMpls(); |
| 212 | break; | 208 | break; |
| 213 | case COPY_TTL_IN: | 209 | case COPY_TTL_IN: |
| 214 | - OFActionCopyTtlIn copyTtlIn = (OFActionCopyTtlIn) act; | ||
| 215 | builder.copyTtlIn(); | 210 | builder.copyTtlIn(); |
| 216 | break; | 211 | break; |
| 217 | case COPY_TTL_OUT: | 212 | case COPY_TTL_OUT: |
| 218 | - OFActionCopyTtlOut copyTtlOut = (OFActionCopyTtlOut) act; | ||
| 219 | builder.copyTtlOut(); | 213 | builder.copyTtlOut(); |
| 220 | break; | 214 | break; |
| 221 | case DEC_MPLS_TTL: | 215 | case DEC_MPLS_TTL: |
| 222 | - OFActionDecMplsTtl decMplsTtl = (OFActionDecMplsTtl) act; | ||
| 223 | builder.decMplsTtl(); | 216 | builder.decMplsTtl(); |
| 224 | break; | 217 | break; |
| 225 | case DEC_NW_TTL: | 218 | case DEC_NW_TTL: |
| 226 | - OFActionDecNwTtl decNwTtl = (OFActionDecNwTtl) act; | ||
| 227 | builder.decNwTtl(); | 219 | builder.decNwTtl(); |
| 228 | break; | 220 | break; |
| 221 | + case GROUP: | ||
| 222 | + OFActionGroup group = (OFActionGroup) act; | ||
| 223 | + builder.group(new DefaultGroupId(group.getGroup().getGroupNumber())); | ||
| 224 | + break; | ||
| 229 | case SET_TP_DST: | 225 | case SET_TP_DST: |
| 230 | case SET_TP_SRC: | 226 | case SET_TP_SRC: |
| 231 | case POP_PBB: | 227 | case POP_PBB: |
| ... | @@ -241,8 +237,6 @@ public class FlowEntryBuilder { | ... | @@ -241,8 +237,6 @@ public class FlowEntryBuilder { |
| 241 | case SET_QUEUE: | 237 | case SET_QUEUE: |
| 242 | case STRIP_VLAN: | 238 | case STRIP_VLAN: |
| 243 | case ENQUEUE: | 239 | case ENQUEUE: |
| 244 | - | ||
| 245 | - case GROUP: | ||
| 246 | default: | 240 | default: |
| 247 | log.warn("Action type {} not yet implemented.", act.getType()); | 241 | log.warn("Action type {} not yet implemented.", act.getType()); |
| 248 | } | 242 | } | ... | ... |
providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
| ... | @@ -21,6 +21,7 @@ import org.onosproject.net.flow.FlowRule; | ... | @@ -21,6 +21,7 @@ import org.onosproject.net.flow.FlowRule; |
| 21 | import org.onosproject.net.flow.TrafficTreatment; | 21 | import org.onosproject.net.flow.TrafficTreatment; |
| 22 | import org.onosproject.net.flow.instructions.Instruction; | 22 | import org.onosproject.net.flow.instructions.Instruction; |
| 23 | import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; | 23 | import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; |
| 24 | +import org.onosproject.net.flow.instructions.Instructions.GroupInstruction; | ||
| 24 | import org.onosproject.net.flow.instructions.L0ModificationInstruction; | 25 | import org.onosproject.net.flow.instructions.L0ModificationInstruction; |
| 25 | import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction; | 26 | import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction; |
| 26 | import org.onosproject.net.flow.instructions.L2ModificationInstruction; | 27 | import org.onosproject.net.flow.instructions.L2ModificationInstruction; |
| ... | @@ -37,6 +38,7 @@ import org.projectfloodlight.openflow.protocol.OFFlowDelete; | ... | @@ -37,6 +38,7 @@ import org.projectfloodlight.openflow.protocol.OFFlowDelete; |
| 37 | import org.projectfloodlight.openflow.protocol.OFFlowMod; | 38 | import org.projectfloodlight.openflow.protocol.OFFlowMod; |
| 38 | import org.projectfloodlight.openflow.protocol.OFFlowModFlags; | 39 | import org.projectfloodlight.openflow.protocol.OFFlowModFlags; |
| 39 | import org.projectfloodlight.openflow.protocol.action.OFAction; | 40 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
| 41 | +import org.projectfloodlight.openflow.protocol.action.OFActionGroup; | ||
| 40 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; | 42 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; |
| 41 | import org.projectfloodlight.openflow.protocol.match.Match; | 43 | import org.projectfloodlight.openflow.protocol.match.Match; |
| 42 | import org.projectfloodlight.openflow.protocol.oxm.OFOxm; | 44 | import org.projectfloodlight.openflow.protocol.oxm.OFOxm; |
| ... | @@ -45,6 +47,7 @@ import org.projectfloodlight.openflow.types.EthType; | ... | @@ -45,6 +47,7 @@ import org.projectfloodlight.openflow.types.EthType; |
| 45 | import org.projectfloodlight.openflow.types.IPv4Address; | 47 | import org.projectfloodlight.openflow.types.IPv4Address; |
| 46 | import org.projectfloodlight.openflow.types.MacAddress; | 48 | import org.projectfloodlight.openflow.types.MacAddress; |
| 47 | import org.projectfloodlight.openflow.types.OFBufferId; | 49 | import org.projectfloodlight.openflow.types.OFBufferId; |
| 50 | +import org.projectfloodlight.openflow.types.OFGroup; | ||
| 48 | import org.projectfloodlight.openflow.types.OFPort; | 51 | import org.projectfloodlight.openflow.types.OFPort; |
| 49 | import org.projectfloodlight.openflow.types.OFVlanVidMatch; | 52 | import org.projectfloodlight.openflow.types.OFVlanVidMatch; |
| 50 | import org.projectfloodlight.openflow.types.U32; | 53 | import org.projectfloodlight.openflow.types.U32; |
| ... | @@ -183,6 +186,11 @@ public class FlowModBuilderVer13 extends FlowModBuilder { | ... | @@ -183,6 +186,11 @@ public class FlowModBuilderVer13 extends FlowModBuilder { |
| 183 | actions.add(action.build()); | 186 | actions.add(action.build()); |
| 184 | break; | 187 | break; |
| 185 | case GROUP: | 188 | case GROUP: |
| 189 | + GroupInstruction group = (GroupInstruction) i; | ||
| 190 | + OFActionGroup.Builder groupBuilder = factory().actions().buildGroup() | ||
| 191 | + .setGroup(OFGroup.of(group.groupId().id())); | ||
| 192 | + actions.add(groupBuilder.build()); | ||
| 193 | + break; | ||
| 186 | default: | 194 | default: |
| 187 | log.warn("Instruction type {} not yet implemented.", i.type()); | 195 | log.warn("Instruction type {} not yet implemented.", i.type()); |
| 188 | } | 196 | } | ... | ... |
-
Please register or login to post a comment