Thomas Vachuska
Committed by Gerrit Code Review

Adding parametrization of the reactive forwarding app.

Change-Id: Ib54bd080f17ab8f755035ea3642bd385d9b5c35d
...@@ -80,9 +80,9 @@ public class ReactiveForwarding { ...@@ -80,9 +80,9 @@ public class ReactiveForwarding {
80 80
81 private ApplicationId appId; 81 private ApplicationId appId;
82 82
83 - @Property(name = "enabled", boolValue = true, 83 + @Property(name = "packetOutOnly", boolValue = false,
84 - label = "Enable forwarding; default is true") 84 + label = "Enable packet-out only forwarding; default is false")
85 - private boolean isEnabled = true; 85 + private boolean packetOutOnly = false;
86 86
87 @Activate 87 @Activate
88 public void activate() { 88 public void activate() {
...@@ -102,16 +102,13 @@ public class ReactiveForwarding { ...@@ -102,16 +102,13 @@ public class ReactiveForwarding {
102 @Modified 102 @Modified
103 public void modified(ComponentContext context) { 103 public void modified(ComponentContext context) {
104 Dictionary properties = context.getProperties(); 104 Dictionary properties = context.getProperties();
105 - String flag = (String) properties.get("enabled"); 105 + String flag = (String) properties.get("packetOutOnly");
106 if (flag != null) { 106 if (flag != null) {
107 boolean enabled = flag.equals("true"); 107 boolean enabled = flag.equals("true");
108 - if (isEnabled != enabled) { 108 + if (packetOutOnly != enabled) {
109 - isEnabled = enabled; 109 + packetOutOnly = enabled;
110 - if (!isEnabled) { 110 + log.info("Reconfigured. Packet-out only forwarding is {}",
111 - flowRuleService.removeFlowRulesById(appId); 111 + packetOutOnly ? "enabled" : "disabled");
112 - }
113 - log.info("Reconfigured. Forwarding is {}",
114 - isEnabled ? "enabled" : "disabled");
115 } 112 }
116 } 113 }
117 } 114 }
...@@ -125,7 +122,7 @@ public class ReactiveForwarding { ...@@ -125,7 +122,7 @@ public class ReactiveForwarding {
125 public void process(PacketContext context) { 122 public void process(PacketContext context) {
126 // Stop processing if the packet has been handled, since we 123 // Stop processing if the packet has been handled, since we
127 // can't do any more to it. 124 // can't do any more to it.
128 - if (!isEnabled || context.isHandled()) { 125 + if (context.isHandled()) {
129 return; 126 return;
130 } 127 }
131 128
...@@ -230,22 +227,23 @@ public class ReactiveForwarding { ...@@ -230,22 +227,23 @@ public class ReactiveForwarding {
230 private void installRule(PacketContext context, PortNumber portNumber) { 227 private void installRule(PacketContext context, PortNumber portNumber) {
231 // We don't yet support bufferids in the flowservice so packet out first. 228 // We don't yet support bufferids in the flowservice so packet out first.
232 packetOut(context, portNumber); 229 packetOut(context, portNumber);
233 - 230 + if (!packetOutOnly) {
234 - // Install the flow rule to handle this type of message from now on. 231 + // Install the flow rule to handle this type of message from now on.
235 - Ethernet inPkt = context.inPacket().parsed(); 232 + Ethernet inPkt = context.inPacket().parsed();
236 - TrafficSelector.Builder builder = DefaultTrafficSelector.builder(); 233 + TrafficSelector.Builder builder = DefaultTrafficSelector.builder();
237 - builder.matchEthType(inPkt.getEtherType()) 234 + builder.matchEthType(inPkt.getEtherType())
238 - .matchEthSrc(inPkt.getSourceMAC()) 235 + .matchEthSrc(inPkt.getSourceMAC())
239 - .matchEthDst(inPkt.getDestinationMAC()) 236 + .matchEthDst(inPkt.getDestinationMAC())
240 - .matchInport(context.inPacket().receivedFrom().port()); 237 + .matchInport(context.inPacket().receivedFrom().port());
241 - 238 +
242 - TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder(); 239 + TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
243 - treat.setOutput(portNumber); 240 + treat.setOutput(portNumber);
244 - 241 +
245 - FlowRule f = new DefaultFlowRule(context.inPacket().receivedFrom().deviceId(), 242 + FlowRule f = new DefaultFlowRule(context.inPacket().receivedFrom().deviceId(),
246 - builder.build(), treat.build(), PRIORITY, appId, TIMEOUT, false); 243 + builder.build(), treat.build(), PRIORITY, appId, TIMEOUT, false);
247 - 244 +
248 - flowRuleService.applyFlowRules(f); 245 + flowRuleService.applyFlowRules(f);
246 + }
249 } 247 }
250 248
251 } 249 }
......