Committed by
Jonathan Hart
Added SpringOpenTTP switch driver (ONOS-822/ONOS-682).
Modified OpenFlpwRuleProvider to support FlowRule with multiple-table feature. Change-Id: If95284077b96213593c5c1e3ab12900001bf49a2
Showing
2 changed files
with
30 additions
and
0 deletions
This diff is collapsed. Click to expand it.
| ... | @@ -166,8 +166,13 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -166,8 +166,13 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
| 166 | 166 | ||
| 167 | private void applyRule(FlowRule flowRule) { | 167 | private void applyRule(FlowRule flowRule) { |
| 168 | OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri())); | 168 | OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri())); |
| 169 | + if (flowRule.type() == FlowRule.Type.DEFAULT) { | ||
| 169 | sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), | 170 | sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), |
| 170 | Optional.empty()).buildFlowAdd()); | 171 | Optional.empty()).buildFlowAdd()); |
| 172 | + } else { | ||
| 173 | + sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), | ||
| 174 | + Optional.empty()).buildFlowAdd(), getTableType(flowRule.type())); | ||
| 175 | + } | ||
| 171 | } | 176 | } |
| 172 | 177 | ||
| 173 | 178 | ||
| ... | @@ -181,8 +186,13 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -181,8 +186,13 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
| 181 | 186 | ||
| 182 | private void removeRule(FlowRule flowRule) { | 187 | private void removeRule(FlowRule flowRule) { |
| 183 | OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri())); | 188 | OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri())); |
| 189 | + if (flowRule.type() == FlowRule.Type.DEFAULT) { | ||
| 184 | sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), | 190 | sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), |
| 185 | Optional.empty()).buildFlowDel()); | 191 | Optional.empty()).buildFlowDel()); |
| 192 | + } else { | ||
| 193 | + sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), | ||
| 194 | + Optional.empty()).buildFlowDel(), getTableType(flowRule.type())); | ||
| 195 | + } | ||
| 186 | } | 196 | } |
| 187 | 197 | ||
| 188 | @Override | 198 | @Override |
| ... | @@ -195,11 +205,13 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -195,11 +205,13 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
| 195 | public Future<CompletedBatchOperation> executeBatch(BatchOperation<FlowRuleBatchEntry> batch) { | 205 | public Future<CompletedBatchOperation> executeBatch(BatchOperation<FlowRuleBatchEntry> batch) { |
| 196 | final Set<Dpid> sws = Sets.newConcurrentHashSet(); | 206 | final Set<Dpid> sws = Sets.newConcurrentHashSet(); |
| 197 | final Map<Long, FlowRuleBatchEntry> fmXids = new HashMap<>(); | 207 | final Map<Long, FlowRuleBatchEntry> fmXids = new HashMap<>(); |
| 208 | + | ||
| 198 | /* | 209 | /* |
| 199 | * Use identity hash map for reference equality as we could have equal | 210 | * Use identity hash map for reference equality as we could have equal |
| 200 | * flow mods for different switches. | 211 | * flow mods for different switches. |
| 201 | */ | 212 | */ |
| 202 | Map<OFFlowMod, OpenFlowSwitch> mods = Maps.newIdentityHashMap(); | 213 | Map<OFFlowMod, OpenFlowSwitch> mods = Maps.newIdentityHashMap(); |
| 214 | + Map<OFFlowMod, OpenFlowSwitch.TableType> modTypes = Maps.newIdentityHashMap(); | ||
| 203 | for (FlowRuleBatchEntry fbe : batch.getOperations()) { | 215 | for (FlowRuleBatchEntry fbe : batch.getOperations()) { |
| 204 | FlowRule flowRule = fbe.target(); | 216 | FlowRule flowRule = fbe.target(); |
| 205 | final Dpid dpid = Dpid.dpid(flowRule.deviceId().uri()); | 217 | final Dpid dpid = Dpid.dpid(flowRule.deviceId().uri()); |
| ... | @@ -235,6 +247,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -235,6 +247,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
| 235 | } | 247 | } |
| 236 | if (mod != null) { | 248 | if (mod != null) { |
| 237 | mods.put(mod, sw); | 249 | mods.put(mod, sw); |
| 250 | + modTypes.put(mod, getTableType(flowRule.type())); | ||
| 238 | fmXids.put(flowModXid, fbe); | 251 | fmXids.put(flowModXid, fbe); |
| 239 | } else { | 252 | } else { |
| 240 | log.error("Conversion of flowrule {} failed.", flowRule); | 253 | log.error("Conversion of flowrule {} failed.", flowRule); |
| ... | @@ -249,12 +262,29 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -249,12 +262,29 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
| 249 | for (Map.Entry<OFFlowMod, OpenFlowSwitch> entry : mods.entrySet()) { | 262 | for (Map.Entry<OFFlowMod, OpenFlowSwitch> entry : mods.entrySet()) { |
| 250 | OpenFlowSwitch sw = entry.getValue(); | 263 | OpenFlowSwitch sw = entry.getValue(); |
| 251 | OFFlowMod mod = entry.getKey(); | 264 | OFFlowMod mod = entry.getKey(); |
| 265 | + OpenFlowSwitch.TableType tableType = modTypes.get(mod); | ||
| 266 | + if (tableType == OpenFlowSwitch.TableType.NONE) { | ||
| 252 | sw.sendMsg(mod); | 267 | sw.sendMsg(mod); |
| 268 | + } else { | ||
| 269 | + sw.sendMsg(mod, tableType); | ||
| 270 | + } | ||
| 253 | } | 271 | } |
| 254 | installation.verify(); | 272 | installation.verify(); |
| 255 | return installation; | 273 | return installation; |
| 256 | } | 274 | } |
| 257 | 275 | ||
| 276 | + private OpenFlowSwitch.TableType getTableType(FlowRule.Type type) { | ||
| 277 | + switch (type) { | ||
| 278 | + case IP: | ||
| 279 | + return OpenFlowSwitch.TableType.IP; | ||
| 280 | + case MPLS: | ||
| 281 | + return OpenFlowSwitch.TableType.MPLS; | ||
| 282 | + case ACL: | ||
| 283 | + return OpenFlowSwitch.TableType.ACL; | ||
| 284 | + default: | ||
| 285 | + return OpenFlowSwitch.TableType.NONE; | ||
| 286 | + } | ||
| 287 | + } | ||
| 258 | 288 | ||
| 259 | private class InternalFlowProvider | 289 | private class InternalFlowProvider |
| 260 | implements OpenFlowSwitchListener, OpenFlowEventListener { | 290 | implements OpenFlowSwitchListener, OpenFlowEventListener { | ... | ... |
-
Please register or login to post a comment