Committed by
alshabib
BgpRouter app supports both OVSSwitch and Corsa HW switch.
Change-Id: Ic0174338af3dbb76e1195b0f94d53a13a60cc0e7
Showing
5 changed files
with
178 additions
and
11 deletions
| ... | @@ -453,7 +453,7 @@ public class BgpRouter { | ... | @@ -453,7 +453,7 @@ public class BgpRouter { |
| 453 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); | 453 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); |
| 454 | FlowRule rule; | 454 | FlowRule rule; |
| 455 | 455 | ||
| 456 | - selector.matchEthType(Ethernet.TYPE_VLAN); | 456 | + selector.matchVlanId(VlanId.ANY); |
| 457 | treatment.transition(FlowRule.Type.VLAN); | 457 | treatment.transition(FlowRule.Type.VLAN); |
| 458 | 458 | ||
| 459 | rule = new DefaultFlowRule(deviceId, selector.build(), | 459 | rule = new DefaultFlowRule(deviceId, selector.build(), | ... | ... |
| ... | @@ -60,7 +60,11 @@ public final class DriverManager implements OpenFlowSwitchDriverFactory { | ... | @@ -60,7 +60,11 @@ public final class DriverManager implements OpenFlowSwitchDriverFactory { |
| 60 | String hw = desc.getHwDesc(); | 60 | String hw = desc.getHwDesc(); |
| 61 | 61 | ||
| 62 | if (dpid.equals(corsaDpid)) { | 62 | if (dpid.equals(corsaDpid)) { |
| 63 | - return new OFCorsaSwitchDriver(dpid, desc); | 63 | + if (hw.startsWith("Open vSwitch")) { |
| 64 | + return new OFOVSSwitchCorsaTTP(dpid, desc); | ||
| 65 | + } else { | ||
| 66 | + return new OFCorsaSwitchDriver(dpid, desc); | ||
| 67 | + } | ||
| 64 | } | 68 | } |
| 65 | 69 | ||
| 66 | if (vendor.startsWith("Stanford University, Ericsson Research and CPqD Research") | 70 | if (vendor.startsWith("Stanford University, Ericsson Research and CPqD Research") | ... | ... |
| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | package org.onosproject.openflow.drivers; | 16 | package org.onosproject.openflow.drivers; |
| 17 | 17 | ||
| 18 | import com.google.common.collect.Lists; | 18 | import com.google.common.collect.Lists; |
| 19 | +import org.onlab.packet.Ethernet; | ||
| 19 | import org.onosproject.openflow.controller.Dpid; | 20 | import org.onosproject.openflow.controller.Dpid; |
| 20 | import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch; | 21 | import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch; |
| 21 | import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeAlreadyStarted; | 22 | import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeAlreadyStarted; |
| ... | @@ -24,11 +25,17 @@ import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotSta | ... | @@ -24,11 +25,17 @@ import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotSta |
| 24 | import org.projectfloodlight.openflow.protocol.OFBarrierRequest; | 25 | import org.projectfloodlight.openflow.protocol.OFBarrierRequest; |
| 25 | import org.projectfloodlight.openflow.protocol.OFDescStatsReply; | 26 | import org.projectfloodlight.openflow.protocol.OFDescStatsReply; |
| 26 | import org.projectfloodlight.openflow.protocol.OFFlowMod; | 27 | import org.projectfloodlight.openflow.protocol.OFFlowMod; |
| 28 | +import org.projectfloodlight.openflow.protocol.OFMatchV3; | ||
| 27 | import org.projectfloodlight.openflow.protocol.OFMessage; | 29 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 28 | import org.projectfloodlight.openflow.protocol.OFType; | 30 | import org.projectfloodlight.openflow.protocol.OFType; |
| 29 | import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; | 31 | import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; |
| 30 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; | 32 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; |
| 33 | +import org.projectfloodlight.openflow.protocol.match.Match; | ||
| 34 | +import org.projectfloodlight.openflow.protocol.match.MatchField; | ||
| 35 | +import org.projectfloodlight.openflow.protocol.oxm.OFOxm; | ||
| 36 | +import org.projectfloodlight.openflow.types.EthType; | ||
| 31 | import org.projectfloodlight.openflow.types.OFGroup; | 37 | import org.projectfloodlight.openflow.types.OFGroup; |
| 38 | +import org.projectfloodlight.openflow.types.OFVlanVidMatch; | ||
| 32 | import org.projectfloodlight.openflow.types.TableId; | 39 | import org.projectfloodlight.openflow.types.TableId; |
| 33 | 40 | ||
| 34 | import java.util.ArrayList; | 41 | import java.util.ArrayList; |
| ... | @@ -41,14 +48,15 @@ import java.util.concurrent.atomic.AtomicBoolean; | ... | @@ -41,14 +48,15 @@ import java.util.concurrent.atomic.AtomicBoolean; |
| 41 | */ | 48 | */ |
| 42 | public class OFCorsaSwitchDriver extends AbstractOpenFlowSwitch { | 49 | public class OFCorsaSwitchDriver extends AbstractOpenFlowSwitch { |
| 43 | 50 | ||
| 44 | - private static final int FIRST_TABLE = 0; | 51 | + protected static final int FIRST_TABLE = 0; |
| 45 | - private static final int VLAN_MPLS_TABLE = 1; | 52 | + protected static final int VLAN_MPLS_TABLE = 1; |
| 46 | - private static final int VLAN_TABLE = 2; | 53 | + protected static final int VLAN_TABLE = 2; |
| 47 | - private static final int MPLS_TABLE = 3; | 54 | + protected static final int MPLS_TABLE = 3; |
| 48 | - private static final int ETHER_TABLE = 4; | 55 | + protected static final int ETHER_TABLE = 4; |
| 49 | - private static final int COS_MAP_TABLE = 5; | 56 | + protected static final int COS_MAP_TABLE = 5; |
| 50 | - private static final int FIB_TABLE = 6; | 57 | + protected static final int FIB_TABLE = 6; |
| 51 | - private static final int LOCAL_TABLE = 9; | 58 | + protected static final int LOCAL_TABLE = 9; |
| 59 | + | ||
| 52 | 60 | ||
| 53 | private AtomicBoolean handShakeComplete = new AtomicBoolean(false); | 61 | private AtomicBoolean handShakeComplete = new AtomicBoolean(false); |
| 54 | 62 | ||
| ... | @@ -192,6 +200,17 @@ public class OFCorsaSwitchDriver extends AbstractOpenFlowSwitch { | ... | @@ -192,6 +200,17 @@ public class OFCorsaSwitchDriver extends AbstractOpenFlowSwitch { |
| 192 | log.warn("Unknown table type: {}", type); | 200 | log.warn("Unknown table type: {}", type); |
| 193 | } | 201 | } |
| 194 | builder.setInstructions(newInstructions); | 202 | builder.setInstructions(newInstructions); |
| 203 | + | ||
| 204 | + OFMatchV3 match = (OFMatchV3) flowMod.getMatch(); | ||
| 205 | + for (OFOxm oxm: match.getOxmList()) { | ||
| 206 | + if (oxm.getMatchField() == MatchField.VLAN_VID && | ||
| 207 | + oxm.getValue().equals(OFVlanVidMatch.PRESENT)) { | ||
| 208 | + Match.Builder mBuilder = factory().buildMatchV3(); | ||
| 209 | + mBuilder.setExact(MatchField.ETH_TYPE, EthType.of(Ethernet.TYPE_VLAN)); | ||
| 210 | + builder.setMatch(mBuilder.build()); | ||
| 211 | + } | ||
| 212 | + } | ||
| 213 | + | ||
| 195 | OFMessage msgnew = builder.build(); | 214 | OFMessage msgnew = builder.build(); |
| 196 | channel.write(Collections.singletonList(msgnew)); | 215 | channel.write(Collections.singletonList(msgnew)); |
| 197 | log.debug("Installed {}", msgnew); | 216 | log.debug("Installed {}", msgnew); | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.openflow.drivers; | ||
| 17 | + | ||
| 18 | +import com.google.common.collect.Lists; | ||
| 19 | +import org.onosproject.openflow.controller.Dpid; | ||
| 20 | +import org.projectfloodlight.openflow.protocol.OFDescStatsReply; | ||
| 21 | +import org.projectfloodlight.openflow.protocol.OFFlowMod; | ||
| 22 | +import org.projectfloodlight.openflow.protocol.OFMessage; | ||
| 23 | +import org.projectfloodlight.openflow.protocol.OFType; | ||
| 24 | +import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; | ||
| 25 | +import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; | ||
| 26 | +import org.projectfloodlight.openflow.types.TableId; | ||
| 27 | + | ||
| 28 | +import java.util.Collections; | ||
| 29 | +import java.util.List; | ||
| 30 | + | ||
| 31 | +public class OFOVSSwitchCorsaTTP extends OFCorsaSwitchDriver { | ||
| 32 | + | ||
| 33 | + OFOVSSwitchCorsaTTP(Dpid dpid, OFDescStatsReply desc) { | ||
| 34 | + super(dpid, desc); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public void transformAndSendMsg(OFMessage msg, TableType type) { | ||
| 39 | + log.trace("Trying to send {} of TableType {}", msg, type); | ||
| 40 | + if (msg.getType() == OFType.FLOW_MOD) { | ||
| 41 | + OFFlowMod flowMod = (OFFlowMod) msg; | ||
| 42 | + OFFlowMod.Builder builder = flowMod.createBuilder(); | ||
| 43 | + List<OFInstruction> instructions = flowMod.getInstructions(); | ||
| 44 | + List<OFInstruction> newInstructions = Lists.newArrayList(); | ||
| 45 | + for (OFInstruction i : instructions) { | ||
| 46 | + if (i instanceof OFInstructionGotoTable) { | ||
| 47 | + OFInstructionGotoTable gotoTable = (OFInstructionGotoTable) i; | ||
| 48 | + TableType tid = TableType.values()[gotoTable.getTableId().getValue()]; | ||
| 49 | + switch (tid) { | ||
| 50 | + case VLAN_MPLS: | ||
| 51 | + newInstructions.add( | ||
| 52 | + gotoTable.createBuilder() | ||
| 53 | + .setTableId(TableId.of(VLAN_MPLS_TABLE)).build()); | ||
| 54 | + break; | ||
| 55 | + case VLAN: | ||
| 56 | + newInstructions.add( | ||
| 57 | + gotoTable.createBuilder() | ||
| 58 | + .setTableId(TableId.of(VLAN_TABLE)).build()); | ||
| 59 | + break; | ||
| 60 | + case ETHER: | ||
| 61 | + newInstructions.add( | ||
| 62 | + gotoTable.createBuilder() | ||
| 63 | + .setTableId(TableId.of(ETHER_TABLE)).build()); | ||
| 64 | + break; | ||
| 65 | + case COS: | ||
| 66 | + newInstructions.add( | ||
| 67 | + gotoTable.createBuilder() | ||
| 68 | + .setTableId(TableId.of(COS_MAP_TABLE)).build()); | ||
| 69 | + break; | ||
| 70 | + case IP: | ||
| 71 | + newInstructions.add( | ||
| 72 | + gotoTable.createBuilder() | ||
| 73 | + .setTableId(TableId.of(FIB_TABLE)).build()); | ||
| 74 | + break; | ||
| 75 | + case MPLS: | ||
| 76 | + newInstructions.add( | ||
| 77 | + gotoTable.createBuilder() | ||
| 78 | + .setTableId(TableId.of(MPLS_TABLE)).build()); | ||
| 79 | + break; | ||
| 80 | + case ACL: | ||
| 81 | + newInstructions.add( | ||
| 82 | + gotoTable.createBuilder() | ||
| 83 | + .setTableId(TableId.of(LOCAL_TABLE)).build()); | ||
| 84 | + break; | ||
| 85 | + case NONE: | ||
| 86 | + log.error("Should never have to go to Table 0"); | ||
| 87 | + /*newInstructions.add( | ||
| 88 | + gotoTable.createBuilder() | ||
| 89 | + .setTableId(TableId.of(0)).build()); | ||
| 90 | + */ | ||
| 91 | + break; | ||
| 92 | + default: | ||
| 93 | + log.warn("Unknown table type: {}", tid); | ||
| 94 | + } | ||
| 95 | + } else { | ||
| 96 | + newInstructions.add(i); | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + switch (type) { | ||
| 100 | + case VLAN_MPLS: | ||
| 101 | + builder.setTableId(TableId.of(VLAN_MPLS_TABLE)); | ||
| 102 | + break; | ||
| 103 | + case VLAN: | ||
| 104 | + builder.setTableId(TableId.of(VLAN_TABLE)); | ||
| 105 | + break; | ||
| 106 | + case ETHER: | ||
| 107 | + builder.setTableId(TableId.of(ETHER_TABLE)); | ||
| 108 | + break; | ||
| 109 | + case COS: | ||
| 110 | + builder.setTableId(TableId.of(COS_MAP_TABLE)); | ||
| 111 | + break; | ||
| 112 | + case IP: | ||
| 113 | + builder.setTableId(TableId.of(FIB_TABLE)); | ||
| 114 | + break; | ||
| 115 | + case MPLS: | ||
| 116 | + builder.setTableId(TableId.of(MPLS_TABLE)); | ||
| 117 | + break; | ||
| 118 | + case ACL: | ||
| 119 | + builder.setTableId(TableId.of(LOCAL_TABLE)); | ||
| 120 | + break; | ||
| 121 | + case FIRST: | ||
| 122 | + builder.setTableId(TableId.of(FIRST_TABLE)); | ||
| 123 | + break; | ||
| 124 | + case NONE: | ||
| 125 | + builder.setTableId(TableId.of(LOCAL_TABLE)); | ||
| 126 | + break; | ||
| 127 | + default: | ||
| 128 | + log.warn("Unknown table type: {}", type); | ||
| 129 | + } | ||
| 130 | + builder.setInstructions(newInstructions); | ||
| 131 | + OFMessage msgnew = builder.build(); | ||
| 132 | + channel.write(Collections.singletonList(msgnew)); | ||
| 133 | + log.debug("Installed {}", msgnew); | ||
| 134 | + | ||
| 135 | + } else { | ||
| 136 | + channel.write(Collections.singletonList(msg)); | ||
| 137 | + } | ||
| 138 | + } | ||
| 139 | +} |
| ... | @@ -61,6 +61,7 @@ import org.projectfloodlight.openflow.protocol.match.MatchField; | ... | @@ -61,6 +61,7 @@ import org.projectfloodlight.openflow.protocol.match.MatchField; |
| 61 | import org.projectfloodlight.openflow.protocol.oxm.OFOxm; | 61 | import org.projectfloodlight.openflow.protocol.oxm.OFOxm; |
| 62 | import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic; | 62 | import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic; |
| 63 | import org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13; | 63 | import org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13; |
| 64 | +import org.projectfloodlight.openflow.types.EthType; | ||
| 64 | import org.projectfloodlight.openflow.types.IPv4Address; | 65 | import org.projectfloodlight.openflow.types.IPv4Address; |
| 65 | import org.projectfloodlight.openflow.types.IPv6Address; | 66 | import org.projectfloodlight.openflow.types.IPv6Address; |
| 66 | import org.projectfloodlight.openflow.types.Masked; | 67 | import org.projectfloodlight.openflow.types.Masked; |
| ... | @@ -466,7 +467,11 @@ public class FlowEntryBuilder { | ... | @@ -466,7 +467,11 @@ public class FlowEntryBuilder { |
| 466 | break; | 467 | break; |
| 467 | case ETH_TYPE: | 468 | case ETH_TYPE: |
| 468 | int ethType = match.get(MatchField.ETH_TYPE).getValue(); | 469 | int ethType = match.get(MatchField.ETH_TYPE).getValue(); |
| 469 | - builder.matchEthType((short) ethType); | 470 | + if (ethType == EthType.VLAN_FRAME.getValue()) { |
| 471 | + builder.matchVlanId(VlanId.ANY); | ||
| 472 | + } else { | ||
| 473 | + builder.matchEthType((short) ethType); | ||
| 474 | + } | ||
| 470 | break; | 475 | break; |
| 471 | case VLAN_VID: | 476 | case VLAN_VID: |
| 472 | VlanId vlanId = null; | 477 | VlanId vlanId = null; | ... | ... |
-
Please register or login to post a comment