Committed by
Gerrit Code Review
ONOS-3529 Updating FlowEntryBuilder to avoid calling getTable on OF_1.0 messages
Change-Id: Id67a07855e0aed0cbd0612a28914c54d802af2cc
Showing
1 changed file
with
54 additions
and
44 deletions
| ... | @@ -49,6 +49,7 @@ import org.onosproject.openflow.controller.ExtensionTreatmentInterpreter; | ... | @@ -49,6 +49,7 @@ import org.onosproject.openflow.controller.ExtensionTreatmentInterpreter; |
| 49 | import org.projectfloodlight.openflow.protocol.OFFlowMod; | 49 | import org.projectfloodlight.openflow.protocol.OFFlowMod; |
| 50 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; | 50 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; |
| 51 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; | 51 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; |
| 52 | +import org.projectfloodlight.openflow.protocol.OFVersion; | ||
| 52 | import org.projectfloodlight.openflow.protocol.action.OFAction; | 53 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
| 53 | import org.projectfloodlight.openflow.protocol.action.OFActionCircuit; | 54 | import org.projectfloodlight.openflow.protocol.action.OFActionCircuit; |
| 54 | import org.projectfloodlight.openflow.protocol.action.OFActionEnqueue; | 55 | import org.projectfloodlight.openflow.protocol.action.OFActionEnqueue; |
| ... | @@ -157,50 +158,59 @@ public class FlowEntryBuilder { | ... | @@ -157,50 +158,59 @@ public class FlowEntryBuilder { |
| 157 | } | 158 | } |
| 158 | 159 | ||
| 159 | public FlowEntry build(FlowEntryState... state) { | 160 | public FlowEntry build(FlowEntryState... state) { |
| 160 | - FlowRule rule; | 161 | + FlowRule.Builder builder; |
| 161 | - switch (this.type) { | 162 | + try { |
| 162 | - case STAT: | 163 | + switch (this.type) { |
| 163 | - rule = DefaultFlowRule.builder() | 164 | + case STAT: |
| 164 | - .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) | 165 | + builder = DefaultFlowRule.builder() |
| 165 | - .withSelector(buildSelector()) | 166 | + .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) |
| 166 | - .withTreatment(buildTreatment()) | 167 | + .withSelector(buildSelector()) |
| 167 | - .withPriority(stat.getPriority()) | 168 | + .withTreatment(buildTreatment()) |
| 168 | - .makeTemporary(stat.getIdleTimeout()) | 169 | + .withPriority(stat.getPriority()) |
| 169 | - .withCookie(stat.getCookie().getValue()) | 170 | + .makeTemporary(stat.getIdleTimeout()) |
| 170 | - .forTable(stat.getTableId().getValue()) | 171 | + .withCookie(stat.getCookie().getValue()) |
| 171 | - .build(); | 172 | + .forTable(stat.getTableId().getValue()); |
| 172 | - | 173 | + |
| 173 | - return new DefaultFlowEntry(rule, FlowEntryState.ADDED, | 174 | + return new DefaultFlowEntry(builder.build(), FlowEntryState.ADDED, |
| 174 | - stat.getDurationSec(), stat.getPacketCount().getValue(), | 175 | + stat.getDurationSec(), |
| 175 | - stat.getByteCount().getValue()); | 176 | + stat.getPacketCount().getValue(), |
| 176 | - case REMOVED: | 177 | + stat.getByteCount().getValue()); |
| 177 | - rule = DefaultFlowRule.builder() | 178 | + case REMOVED: |
| 178 | - .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) | 179 | + builder = DefaultFlowRule.builder() |
| 179 | - .withSelector(buildSelector()) | 180 | + .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) |
| 180 | - .withPriority(removed.getPriority()) | 181 | + .withSelector(buildSelector()) |
| 181 | - .makeTemporary(removed.getIdleTimeout()) | 182 | + .withPriority(removed.getPriority()) |
| 182 | - .withCookie(removed.getCookie().getValue()) | 183 | + .makeTemporary(removed.getIdleTimeout()) |
| 183 | - .forTable(removed.getTableId().getValue()) | 184 | + .withCookie(removed.getCookie().getValue()); |
| 184 | - .build(); | 185 | + if (removed.getVersion() != OFVersion.OF_10) { |
| 185 | - | 186 | + builder.forTable(removed.getTableId().getValue()); |
| 186 | - return new DefaultFlowEntry(rule, FlowEntryState.REMOVED, removed.getDurationSec(), | 187 | + } |
| 187 | - removed.getPacketCount().getValue(), removed.getByteCount().getValue()); | 188 | + |
| 188 | - case MOD: | 189 | + return new DefaultFlowEntry(builder.build(), FlowEntryState.REMOVED, |
| 189 | - FlowEntryState flowState = state.length > 0 ? state[0] : FlowEntryState.FAILED; | 190 | + removed.getDurationSec(), |
| 190 | - rule = DefaultFlowRule.builder() | 191 | + removed.getPacketCount().getValue(), |
| 191 | - .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) | 192 | + removed.getByteCount().getValue()); |
| 192 | - .withSelector(buildSelector()) | 193 | + case MOD: |
| 193 | - .withTreatment(buildTreatment()) | 194 | + FlowEntryState flowState = state.length > 0 ? state[0] : FlowEntryState.FAILED; |
| 194 | - .withPriority(flowMod.getPriority()) | 195 | + builder = DefaultFlowRule.builder() |
| 195 | - .makeTemporary(flowMod.getIdleTimeout()) | 196 | + .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) |
| 196 | - .withCookie(flowMod.getCookie().getValue()) | 197 | + .withSelector(buildSelector()) |
| 197 | - .forTable(flowMod.getTableId().getValue()) | 198 | + .withTreatment(buildTreatment()) |
| 198 | - .build(); | 199 | + .withPriority(flowMod.getPriority()) |
| 199 | - | 200 | + .makeTemporary(flowMod.getIdleTimeout()) |
| 200 | - return new DefaultFlowEntry(rule, flowState, 0, 0, 0); | 201 | + .withCookie(flowMod.getCookie().getValue()); |
| 201 | - default: | 202 | + if (flowMod.getVersion() != OFVersion.OF_10) { |
| 202 | - log.error("Unknown flow type : {}", this.type); | 203 | + builder.forTable(flowMod.getTableId().getValue()); |
| 203 | - return null; | 204 | + } |
| 205 | + | ||
| 206 | + return new DefaultFlowEntry(builder.build(), flowState, 0, 0, 0); | ||
| 207 | + default: | ||
| 208 | + log.error("Unknown flow type : {}", this.type); | ||
| 209 | + return null; | ||
| 210 | + } | ||
| 211 | + } catch (UnsupportedOperationException e) { | ||
| 212 | + log.warn("Error building flow entry", e); | ||
| 213 | + return null; | ||
| 204 | } | 214 | } |
| 205 | 215 | ||
| 206 | } | 216 | } | ... | ... |
-
Please register or login to post a comment