Thomas Vachuska

ONOS-537 Provided maxLen setting to make sure packet data is sent with packet-in…

… message. Also added support for TrafficTreatment.Builder.punt();

Change-Id: I9f5577cf83b4d25c79459e56492be747a245397c
...@@ -37,6 +37,7 @@ public final class PortNumber { ...@@ -37,6 +37,7 @@ public final class PortNumber {
37 public static final PortNumber FLOOD = new PortNumber(-5); 37 public static final PortNumber FLOOD = new PortNumber(-5);
38 public static final PortNumber ALL = new PortNumber(-4); 38 public static final PortNumber ALL = new PortNumber(-4);
39 public static final PortNumber LOCAL = new PortNumber(-2); 39 public static final PortNumber LOCAL = new PortNumber(-2);
40 + public static final PortNumber CONTROLLER = new PortNumber(-3);
40 41
41 private final long number; 42 private final long number;
42 43
......
...@@ -15,19 +15,18 @@ ...@@ -15,19 +15,18 @@
15 */ 15 */
16 package org.onosproject.net.flow; 16 package org.onosproject.net.flow;
17 17
18 -import java.util.LinkedList; 18 +import com.google.common.base.MoreObjects;
19 -import java.util.List; 19 +import com.google.common.collect.ImmutableList;
20 -import java.util.Objects;
21 -
22 -import org.onosproject.net.PortNumber;
23 -import org.onosproject.net.flow.instructions.Instruction;
24 -import org.onosproject.net.flow.instructions.Instructions;
25 import org.onlab.packet.IpAddress; 20 import org.onlab.packet.IpAddress;
26 import org.onlab.packet.MacAddress; 21 import org.onlab.packet.MacAddress;
27 import org.onlab.packet.VlanId; 22 import org.onlab.packet.VlanId;
23 +import org.onosproject.net.PortNumber;
24 +import org.onosproject.net.flow.instructions.Instruction;
25 +import org.onosproject.net.flow.instructions.Instructions;
28 26
29 -import com.google.common.base.MoreObjects; 27 +import java.util.LinkedList;
30 -import com.google.common.collect.ImmutableList; 28 +import java.util.List;
29 +import java.util.Objects;
31 30
32 /** 31 /**
33 * Default traffic treatment implementation. 32 * Default traffic treatment implementation.
...@@ -152,8 +151,13 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -152,8 +151,13 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
152 } 151 }
153 152
154 @Override 153 @Override
155 - public void drop() { 154 + public Builder drop() {
156 - add(Instructions.createDrop()); 155 + return add(Instructions.createDrop());
156 + }
157 +
158 + @Override
159 + public Builder punt() {
160 + return add(Instructions.createOutput(PortNumber.CONTROLLER));
157 } 161 }
158 162
159 @Override 163 @Override
......
...@@ -49,9 +49,18 @@ public interface TrafficTreatment { ...@@ -49,9 +49,18 @@ public interface TrafficTreatment {
49 Builder add(Instruction instruction); 49 Builder add(Instruction instruction);
50 50
51 /** 51 /**
52 - * Adds a drop instruction and does not return a builder. 52 + * Adds a drop instruction.
53 + *
54 + * @return a treatment builder
55 + */
56 + public Builder drop();
57 +
58 + /**
59 + * Adds a punt-to-controller instruction.
60 + *
61 + * @return a treatment builder
53 */ 62 */
54 - public void drop(); 63 + public Builder punt();
55 64
56 /** 65 /**
57 * Set the output port. 66 * Set the output port.
...@@ -111,18 +120,21 @@ public interface TrafficTreatment { ...@@ -111,18 +120,21 @@ public interface TrafficTreatment {
111 120
112 /** 121 /**
113 * Push MPLS ether type. 122 * Push MPLS ether type.
123 + *
114 * @return a treatment builder. 124 * @return a treatment builder.
115 */ 125 */
116 public Builder pushMpls(); 126 public Builder pushMpls();
117 127
118 /** 128 /**
119 * Pops MPLS ether type. 129 * Pops MPLS ether type.
130 + *
120 * @return a treatment builder. 131 * @return a treatment builder.
121 */ 132 */
122 public Builder popMpls(); 133 public Builder popMpls();
123 134
124 /** 135 /**
125 * Sets the mpls label. 136 * Sets the mpls label.
137 + *
126 * @param mplsLabel MPLS label. 138 * @param mplsLabel MPLS label.
127 * @return a treatment builder. 139 * @return a treatment builder.
128 */ 140 */
......
...@@ -15,11 +15,8 @@ ...@@ -15,11 +15,8 @@
15 */ 15 */
16 package org.onosproject.provider.of.flow.impl; 16 package org.onosproject.provider.of.flow.impl;
17 17
18 -import java.util.Collections; 18 +import org.onlab.packet.Ip4Address;
19 -import java.util.LinkedList; 19 +import org.onosproject.net.PortNumber;
20 -import java.util.List;
21 -import java.util.Optional;
22 -
23 import org.onosproject.net.flow.FlowRule; 20 import org.onosproject.net.flow.FlowRule;
24 import org.onosproject.net.flow.TrafficTreatment; 21 import org.onosproject.net.flow.TrafficTreatment;
25 import org.onosproject.net.flow.instructions.Instruction; 22 import org.onosproject.net.flow.instructions.Instruction;
...@@ -30,13 +27,13 @@ import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanId ...@@ -30,13 +27,13 @@ import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanId
30 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction; 27 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction;
31 import org.onosproject.net.flow.instructions.L3ModificationInstruction; 28 import org.onosproject.net.flow.instructions.L3ModificationInstruction;
32 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; 29 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
33 -import org.onlab.packet.Ip4Address;
34 import org.projectfloodlight.openflow.protocol.OFFactory; 30 import org.projectfloodlight.openflow.protocol.OFFactory;
35 import org.projectfloodlight.openflow.protocol.OFFlowAdd; 31 import org.projectfloodlight.openflow.protocol.OFFlowAdd;
36 import org.projectfloodlight.openflow.protocol.OFFlowDelete; 32 import org.projectfloodlight.openflow.protocol.OFFlowDelete;
37 import org.projectfloodlight.openflow.protocol.OFFlowMod; 33 import org.projectfloodlight.openflow.protocol.OFFlowMod;
38 import org.projectfloodlight.openflow.protocol.OFFlowModFlags; 34 import org.projectfloodlight.openflow.protocol.OFFlowModFlags;
39 import org.projectfloodlight.openflow.protocol.action.OFAction; 35 import org.projectfloodlight.openflow.protocol.action.OFAction;
36 +import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
40 import org.projectfloodlight.openflow.protocol.match.Match; 37 import org.projectfloodlight.openflow.protocol.match.Match;
41 import org.projectfloodlight.openflow.types.IPv4Address; 38 import org.projectfloodlight.openflow.types.IPv4Address;
42 import org.projectfloodlight.openflow.types.MacAddress; 39 import org.projectfloodlight.openflow.types.MacAddress;
...@@ -48,12 +45,18 @@ import org.projectfloodlight.openflow.types.VlanVid; ...@@ -48,12 +45,18 @@ import org.projectfloodlight.openflow.types.VlanVid;
48 import org.slf4j.Logger; 45 import org.slf4j.Logger;
49 import org.slf4j.LoggerFactory; 46 import org.slf4j.LoggerFactory;
50 47
48 +import java.util.Collections;
49 +import java.util.LinkedList;
50 +import java.util.List;
51 +import java.util.Optional;
52 +
51 /** 53 /**
52 * Flow mod builder for OpenFlow 1.0. 54 * Flow mod builder for OpenFlow 1.0.
53 */ 55 */
54 public class FlowModBuilderVer10 extends FlowModBuilder { 56 public class FlowModBuilderVer10 extends FlowModBuilder {
55 57
56 private static final Logger log = LoggerFactory.getLogger(FlowModBuilderVer10.class); 58 private static final Logger log = LoggerFactory.getLogger(FlowModBuilderVer10.class);
59 + private static final int OFPCML_NO_BUFFER = 0xffff;
57 60
58 private final TrafficTreatment treatment; 61 private final TrafficTreatment treatment;
59 62
...@@ -151,8 +154,12 @@ public class FlowModBuilderVer10 extends FlowModBuilder { ...@@ -151,8 +154,12 @@ public class FlowModBuilderVer10 extends FlowModBuilder {
151 break; 154 break;
152 case OUTPUT: 155 case OUTPUT:
153 OutputInstruction out = (OutputInstruction) i; 156 OutputInstruction out = (OutputInstruction) i;
154 - acts.add(factory().actions().buildOutput().setPort( 157 + OFActionOutput.Builder action = factory().actions().buildOutput()
155 - OFPort.of((int) out.port().toLong())).build()); 158 + .setPort(OFPort.of((int) out.port().toLong()));
159 + if (out.port().equals(PortNumber.CONTROLLER)) {
160 + action.setMaxLen(OFPCML_NO_BUFFER);
161 + }
162 + acts.add(action.build());
156 break; 163 break;
157 case L0MODIFICATION: 164 case L0MODIFICATION:
158 case GROUP: 165 case GROUP:
......