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
27 additions
and
17 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,51 +158,60 @@ public class FlowEntryBuilder { | ... | @@ -157,51 +158,60 @@ 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; |
162 | + try { | ||
161 | switch (this.type) { | 163 | switch (this.type) { |
162 | case STAT: | 164 | case STAT: |
163 | - rule = DefaultFlowRule.builder() | 165 | + builder = DefaultFlowRule.builder() |
164 | .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) | 166 | .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) |
165 | .withSelector(buildSelector()) | 167 | .withSelector(buildSelector()) |
166 | .withTreatment(buildTreatment()) | 168 | .withTreatment(buildTreatment()) |
167 | .withPriority(stat.getPriority()) | 169 | .withPriority(stat.getPriority()) |
168 | .makeTemporary(stat.getIdleTimeout()) | 170 | .makeTemporary(stat.getIdleTimeout()) |
169 | .withCookie(stat.getCookie().getValue()) | 171 | .withCookie(stat.getCookie().getValue()) |
170 | - .forTable(stat.getTableId().getValue()) | 172 | + .forTable(stat.getTableId().getValue()); |
171 | - .build(); | ||
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(), |
176 | + stat.getPacketCount().getValue(), | ||
175 | stat.getByteCount().getValue()); | 177 | stat.getByteCount().getValue()); |
176 | case REMOVED: | 178 | case REMOVED: |
177 | - rule = DefaultFlowRule.builder() | 179 | + builder = DefaultFlowRule.builder() |
178 | .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) | 180 | .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) |
179 | .withSelector(buildSelector()) | 181 | .withSelector(buildSelector()) |
180 | .withPriority(removed.getPriority()) | 182 | .withPriority(removed.getPriority()) |
181 | .makeTemporary(removed.getIdleTimeout()) | 183 | .makeTemporary(removed.getIdleTimeout()) |
182 | - .withCookie(removed.getCookie().getValue()) | 184 | + .withCookie(removed.getCookie().getValue()); |
183 | - .forTable(removed.getTableId().getValue()) | 185 | + if (removed.getVersion() != OFVersion.OF_10) { |
184 | - .build(); | 186 | + builder.forTable(removed.getTableId().getValue()); |
187 | + } | ||
185 | 188 | ||
186 | - return new DefaultFlowEntry(rule, FlowEntryState.REMOVED, removed.getDurationSec(), | 189 | + return new DefaultFlowEntry(builder.build(), FlowEntryState.REMOVED, |
187 | - removed.getPacketCount().getValue(), removed.getByteCount().getValue()); | 190 | + removed.getDurationSec(), |
191 | + removed.getPacketCount().getValue(), | ||
192 | + removed.getByteCount().getValue()); | ||
188 | case MOD: | 193 | case MOD: |
189 | FlowEntryState flowState = state.length > 0 ? state[0] : FlowEntryState.FAILED; | 194 | FlowEntryState flowState = state.length > 0 ? state[0] : FlowEntryState.FAILED; |
190 | - rule = DefaultFlowRule.builder() | 195 | + builder = DefaultFlowRule.builder() |
191 | .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) | 196 | .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) |
192 | .withSelector(buildSelector()) | 197 | .withSelector(buildSelector()) |
193 | .withTreatment(buildTreatment()) | 198 | .withTreatment(buildTreatment()) |
194 | .withPriority(flowMod.getPriority()) | 199 | .withPriority(flowMod.getPriority()) |
195 | .makeTemporary(flowMod.getIdleTimeout()) | 200 | .makeTemporary(flowMod.getIdleTimeout()) |
196 | - .withCookie(flowMod.getCookie().getValue()) | 201 | + .withCookie(flowMod.getCookie().getValue()); |
197 | - .forTable(flowMod.getTableId().getValue()) | 202 | + if (flowMod.getVersion() != OFVersion.OF_10) { |
198 | - .build(); | 203 | + builder.forTable(flowMod.getTableId().getValue()); |
204 | + } | ||
199 | 205 | ||
200 | - return new DefaultFlowEntry(rule, flowState, 0, 0, 0); | 206 | + return new DefaultFlowEntry(builder.build(), flowState, 0, 0, 0); |
201 | default: | 207 | default: |
202 | log.error("Unknown flow type : {}", this.type); | 208 | log.error("Unknown flow type : {}", this.type); |
203 | return null; | 209 | return null; |
204 | } | 210 | } |
211 | + } catch (UnsupportedOperationException e) { | ||
212 | + log.warn("Error building flow entry", e); | ||
213 | + return null; | ||
214 | + } | ||
205 | 215 | ||
206 | } | 216 | } |
207 | 217 | ... | ... |
-
Please register or login to post a comment