Committed by
Gerrit Code Review
A set of fixes to ensure that the FlowRuleManager can correctly account for flows
from the dataplane in a multi-table pipeline scenario Change-Id: I9ca3ef9a77781f126a13538647c824b27f77101c
Showing
21 changed files
with
273 additions
and
87 deletions
... | @@ -557,7 +557,7 @@ public class BgpRouter { | ... | @@ -557,7 +557,7 @@ public class BgpRouter { |
557 | 557 | ||
558 | rule = new DefaultFlowRule(deviceId, selector.build(), | 558 | rule = new DefaultFlowRule(deviceId, selector.build(), |
559 | treatment.build(), CONTROLLER_PRIORITY, | 559 | treatment.build(), CONTROLLER_PRIORITY, |
560 | - appId, 0, true, FlowRule.Type.ACL); | 560 | + appId, 0, true, FlowRule.Type.DEFAULT); |
561 | 561 | ||
562 | ops = install ? ops.add(rule) : ops.remove(rule); | 562 | ops = install ? ops.add(rule) : ops.remove(rule); |
563 | 563 | ... | ... |
... | @@ -74,7 +74,7 @@ public class TunnellingConnectivityManager { | ... | @@ -74,7 +74,7 @@ public class TunnellingConnectivityManager { |
74 | selector.matchTcpSrc(BGP_PORT); | 74 | selector.matchTcpSrc(BGP_PORT); |
75 | 75 | ||
76 | packetService.requestPackets(selector.build(), PacketPriority.CONTROL, | 76 | packetService.requestPackets(selector.build(), PacketPriority.CONTROL, |
77 | - appId, FlowRule.Type.ACL); | 77 | + appId, FlowRule.Type.DEFAULT); |
78 | 78 | ||
79 | selector = DefaultTrafficSelector.builder(); | 79 | selector = DefaultTrafficSelector.builder(); |
80 | 80 | ||
... | @@ -84,7 +84,7 @@ public class TunnellingConnectivityManager { | ... | @@ -84,7 +84,7 @@ public class TunnellingConnectivityManager { |
84 | selector.matchTcpDst(BGP_PORT); | 84 | selector.matchTcpDst(BGP_PORT); |
85 | 85 | ||
86 | packetService.requestPackets(selector.build(), PacketPriority.CONTROL, | 86 | packetService.requestPackets(selector.build(), PacketPriority.CONTROL, |
87 | - appId, FlowRule.Type.ACL); | 87 | + appId, FlowRule.Type.DEFAULT); |
88 | } | 88 | } |
89 | 89 | ||
90 | public void stop() { | 90 | public void stop() { | ... | ... |
... | @@ -61,6 +61,23 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -61,6 +61,23 @@ public class DefaultFlowRule implements FlowRule { |
61 | } | 61 | } |
62 | 62 | ||
63 | public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, | 63 | public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, |
64 | + TrafficTreatment treatment, int priority, long flowId, | ||
65 | + int timeout, boolean permanent, Type tableType) { | ||
66 | + this.deviceId = deviceId; | ||
67 | + this.priority = priority; | ||
68 | + this.selector = selector; | ||
69 | + this.treatment = treatment; | ||
70 | + this.timeout = timeout; | ||
71 | + this.permanent = permanent; | ||
72 | + this.created = System.currentTimeMillis(); | ||
73 | + | ||
74 | + this.appId = (short) (flowId >>> 48); | ||
75 | + this.groupId = new DefaultGroupId((short) ((flowId >>> 32) & 0xFFFF)); | ||
76 | + this.id = FlowId.valueOf(flowId); | ||
77 | + this.type = tableType; | ||
78 | + } | ||
79 | + | ||
80 | + public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, | ||
64 | TrafficTreatment treatment, int priority, ApplicationId appId, | 81 | TrafficTreatment treatment, int priority, ApplicationId appId, |
65 | int timeout, boolean permanent) { | 82 | int timeout, boolean permanent) { |
66 | this(deviceId, selector, treatment, priority, appId, new DefaultGroupId(0), | 83 | this(deviceId, selector, treatment, priority, appId, new DefaultGroupId(0), | ... | ... |
... | @@ -355,8 +355,6 @@ public class FlowRuleManager | ... | @@ -355,8 +355,6 @@ public class FlowRuleManager |
355 | @Override | 355 | @Override |
356 | public void pushFlowMetrics(DeviceId deviceId, Iterable<FlowEntry> flowEntries) { | 356 | public void pushFlowMetrics(DeviceId deviceId, Iterable<FlowEntry> flowEntries) { |
357 | Set<FlowEntry> storedRules = Sets.newHashSet(store.getFlowEntries(deviceId)); | 357 | Set<FlowEntry> storedRules = Sets.newHashSet(store.getFlowEntries(deviceId)); |
358 | - | ||
359 | - | ||
360 | for (FlowEntry rule : flowEntries) { | 358 | for (FlowEntry rule : flowEntries) { |
361 | try { | 359 | try { |
362 | if (storedRules.remove(rule)) { | 360 | if (storedRules.remove(rule)) { | ... | ... |
... | @@ -20,6 +20,7 @@ import java.util.List; | ... | @@ -20,6 +20,7 @@ import java.util.List; |
20 | import org.projectfloodlight.openflow.protocol.OFFactory; | 20 | import org.projectfloodlight.openflow.protocol.OFFactory; |
21 | import org.projectfloodlight.openflow.protocol.OFMessage; | 21 | import org.projectfloodlight.openflow.protocol.OFMessage; |
22 | import org.projectfloodlight.openflow.protocol.OFPortDesc; | 22 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
23 | +import org.projectfloodlight.openflow.types.TableId; | ||
23 | 24 | ||
24 | /** | 25 | /** |
25 | * Represents to provider facing side of a switch. | 26 | * Represents to provider facing side of a switch. |
... | @@ -38,7 +39,7 @@ public interface OpenFlowSwitch { | ... | @@ -38,7 +39,7 @@ public interface OpenFlowSwitch { |
38 | /* VLAN table */ | 39 | /* VLAN table */ |
39 | VLAN, | 40 | VLAN, |
40 | 41 | ||
41 | - /* L2 table */ | 42 | + /* Ethertype table */ |
42 | ETHER, | 43 | ETHER, |
43 | 44 | ||
44 | /* Class of Service table */ | 45 | /* Class of Service table */ |
... | @@ -52,6 +53,8 @@ public interface OpenFlowSwitch { | ... | @@ -52,6 +53,8 @@ public interface OpenFlowSwitch { |
52 | ACL, | 53 | ACL, |
53 | /* Single table */ | 54 | /* Single table */ |
54 | NONE, | 55 | NONE, |
56 | + /* First table in multi-table */ | ||
57 | + FIRST, | ||
55 | 58 | ||
56 | 59 | ||
57 | } | 60 | } |
... | @@ -64,21 +67,22 @@ public interface OpenFlowSwitch { | ... | @@ -64,21 +67,22 @@ public interface OpenFlowSwitch { |
64 | public void sendMsg(OFMessage msg); | 67 | public void sendMsg(OFMessage msg); |
65 | 68 | ||
66 | /** | 69 | /** |
67 | - * Writes to the OFMessage list to the driver. | 70 | + * Writes the OFMessage list to the driver. |
68 | * | 71 | * |
69 | * @param msgs the messages to be written | 72 | * @param msgs the messages to be written |
70 | */ | 73 | */ |
71 | public void sendMsg(List<OFMessage> msgs); | 74 | public void sendMsg(List<OFMessage> msgs); |
72 | 75 | ||
73 | /** | 76 | /** |
74 | - * Writes to the OFMessage list to the driver. | 77 | + * Transforms FlowMod messages by setting the correct table-ids and sending |
75 | - * TableType is used to determine the table ID for the OFMessage. | 78 | + * them to the switch. TableType is used to determine the table ID for the OFMessage. |
76 | - * The switch driver that supports multi-table should implement the function. | 79 | + * Switch drivers that supports multi-table pipelines should implement this |
80 | + * method. | ||
77 | * | 81 | * |
78 | * @param msg the message to be written | 82 | * @param msg the message to be written |
79 | - * @param tableType the type of table in which the OFMessage needs to put | 83 | + * @param tableType the type of table in which the FlowMods need to be inserted |
80 | */ | 84 | */ |
81 | - public void sendMsg(OFMessage msg, TableType tableType); | 85 | + public void transformAndSendMsg(OFMessage msg, TableType tableType); |
82 | 86 | ||
83 | /** | 87 | /** |
84 | * Handle a message from the switch. | 88 | * Handle a message from the switch. |
... | @@ -189,4 +193,11 @@ public interface OpenFlowSwitch { | ... | @@ -189,4 +193,11 @@ public interface OpenFlowSwitch { |
189 | */ | 193 | */ |
190 | public String channelId(); | 194 | public String channelId(); |
191 | 195 | ||
196 | + /** | ||
197 | + * Returns the TableType corresponding to the TableId used to identify | ||
198 | + * a table in an OpenFlow switch. | ||
199 | + * @param tid identifies a table in an OpenFlow switch using TableId | ||
200 | + * @return TableType corresponding to 'tid' identifying the type of table | ||
201 | + */ | ||
202 | + public TableType getTableType(TableId tid); | ||
192 | } | 203 | } | ... | ... |
... | @@ -110,13 +110,6 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { | ... | @@ -110,13 +110,6 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { |
110 | } | 110 | } |
111 | 111 | ||
112 | @Override | 112 | @Override |
113 | - public void sendMsg(OFMessage msg, TableType tableType) { | ||
114 | - if (role == RoleState.MASTER) { | ||
115 | - this.write(msg); | ||
116 | - } | ||
117 | - } | ||
118 | - | ||
119 | - @Override | ||
120 | public abstract void write(OFMessage msg); | 113 | public abstract void write(OFMessage msg); |
121 | 114 | ||
122 | @Override | 115 | @Override | ... | ... |
... | @@ -23,6 +23,7 @@ import org.junit.After; | ... | @@ -23,6 +23,7 @@ import org.junit.After; |
23 | import org.junit.Before; | 23 | import org.junit.Before; |
24 | import org.junit.Test; | 24 | import org.junit.Test; |
25 | import org.onosproject.openflow.controller.RoleState; | 25 | import org.onosproject.openflow.controller.RoleState; |
26 | +import org.onosproject.openflow.controller.OpenFlowSwitch.TableType; | ||
26 | import org.onosproject.openflow.controller.driver.OpenFlowAgent; | 27 | import org.onosproject.openflow.controller.driver.OpenFlowAgent; |
27 | import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver; | 28 | import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver; |
28 | import org.onosproject.openflow.controller.driver.RoleHandler; | 29 | import org.onosproject.openflow.controller.driver.RoleHandler; |
... | @@ -38,6 +39,7 @@ import org.projectfloodlight.openflow.protocol.OFMessage; | ... | @@ -38,6 +39,7 @@ import org.projectfloodlight.openflow.protocol.OFMessage; |
38 | import org.projectfloodlight.openflow.protocol.OFPortDesc; | 39 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
39 | import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; | 40 | import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; |
40 | import org.projectfloodlight.openflow.protocol.OFVersion; | 41 | import org.projectfloodlight.openflow.protocol.OFVersion; |
42 | +import org.projectfloodlight.openflow.types.TableId; | ||
41 | import org.projectfloodlight.openflow.types.U64; | 43 | import org.projectfloodlight.openflow.types.U64; |
42 | 44 | ||
43 | import static org.junit.Assert.assertEquals; | 45 | import static org.junit.Assert.assertEquals; |
... | @@ -111,7 +113,7 @@ public class RoleManagerTest { | ... | @@ -111,7 +113,7 @@ public class RoleManagerTest { |
111 | } | 113 | } |
112 | 114 | ||
113 | @Override | 115 | @Override |
114 | - public void sendMsg(OFMessage msg, TableType tableType) { | 116 | + public void transformAndSendMsg(OFMessage msg, TableType tableType) { |
115 | } | 117 | } |
116 | 118 | ||
117 | @Override | 119 | @Override |
... | @@ -309,6 +311,10 @@ public class RoleManagerTest { | ... | @@ -309,6 +311,10 @@ public class RoleManagerTest { |
309 | return "1.2.3.4:1"; | 311 | return "1.2.3.4:1"; |
310 | } | 312 | } |
311 | 313 | ||
314 | + @Override | ||
315 | + public TableType getTableType(TableId tid) { | ||
316 | + return TableType.NONE; | ||
317 | + } | ||
312 | 318 | ||
313 | } | 319 | } |
314 | } | 320 | } | ... | ... |
... | @@ -29,6 +29,7 @@ import org.projectfloodlight.openflow.protocol.OFFlowAdd; | ... | @@ -29,6 +29,7 @@ import org.projectfloodlight.openflow.protocol.OFFlowAdd; |
29 | import org.projectfloodlight.openflow.protocol.OFMessage; | 29 | import org.projectfloodlight.openflow.protocol.OFMessage; |
30 | import org.projectfloodlight.openflow.protocol.OFPortDesc; | 30 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
31 | import org.projectfloodlight.openflow.protocol.OFVersion; | 31 | import org.projectfloodlight.openflow.protocol.OFVersion; |
32 | +import org.projectfloodlight.openflow.types.TableId; | ||
32 | import org.slf4j.Logger; | 33 | import org.slf4j.Logger; |
33 | import org.slf4j.LoggerFactory; | 34 | import org.slf4j.LoggerFactory; |
34 | 35 | ||
... | @@ -125,6 +126,17 @@ public final class DriverManager implements OpenFlowSwitchDriverFactory { | ... | @@ -125,6 +126,17 @@ public final class DriverManager implements OpenFlowSwitchDriverFactory { |
125 | return Collections.unmodifiableList(ports.getEntries()); | 126 | return Collections.unmodifiableList(ports.getEntries()); |
126 | } | 127 | } |
127 | } | 128 | } |
129 | + | ||
130 | + @Override | ||
131 | + public TableType getTableType(TableId tid) { | ||
132 | + return TableType.NONE; | ||
133 | + } | ||
134 | + | ||
135 | + @Override | ||
136 | + public void transformAndSendMsg(OFMessage msg, TableType tableType) { | ||
137 | + // TODO Auto-generated method stub | ||
138 | + | ||
139 | + } | ||
128 | }; | 140 | }; |
129 | } | 141 | } |
130 | 142 | ... | ... |
... | @@ -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 | + | ||
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.projectfloodlight.openflow.protocol.OFDescStatsReply; | 22 | import org.projectfloodlight.openflow.protocol.OFDescStatsReply; |
... | @@ -26,6 +27,7 @@ import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; | ... | @@ -26,6 +27,7 @@ import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; |
26 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; | 27 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; |
27 | import org.projectfloodlight.openflow.types.TableId; | 28 | import org.projectfloodlight.openflow.types.TableId; |
28 | 29 | ||
30 | +import java.util.ArrayList; | ||
29 | import java.util.Collections; | 31 | import java.util.Collections; |
30 | import java.util.List; | 32 | import java.util.List; |
31 | 33 | ||
... | @@ -33,7 +35,7 @@ import java.util.List; | ... | @@ -33,7 +35,7 @@ import java.util.List; |
33 | * Corsa switch driver for BGP Router deployment. | 35 | * Corsa switch driver for BGP Router deployment. |
34 | */ | 36 | */ |
35 | public class OFCorsaSwitchDriver extends AbstractOpenFlowSwitch { | 37 | public class OFCorsaSwitchDriver extends AbstractOpenFlowSwitch { |
36 | - | 38 | + private static final int FIRST_TABLE = 0; |
37 | private static final int VLAN_MPLS_TABLE = 1; | 39 | private static final int VLAN_MPLS_TABLE = 1; |
38 | private static final int VLAN_TABLE = 2; | 40 | private static final int VLAN_TABLE = 2; |
39 | private static final int MPLS_TABLE = 3; | 41 | private static final int MPLS_TABLE = 3; |
... | @@ -48,18 +50,45 @@ public class OFCorsaSwitchDriver extends AbstractOpenFlowSwitch { | ... | @@ -48,18 +50,45 @@ public class OFCorsaSwitchDriver extends AbstractOpenFlowSwitch { |
48 | setSwitchDescription(desc); | 50 | setSwitchDescription(desc); |
49 | } | 51 | } |
50 | 52 | ||
53 | + /** | ||
54 | + * Used by the default sendMsg to 'write' to the switch. | ||
55 | + * This method is indirectly used by generic onos services like proxyarp | ||
56 | + * to request packets from the default flow table. In a multi-table | ||
57 | + * pipeline, these requests are redirected to the correct table. | ||
58 | + * | ||
59 | + * For the Corsa switch, the equivalent table is the LOCAL TABLE | ||
60 | + * | ||
61 | + */ | ||
51 | @Override | 62 | @Override |
52 | public void write(OFMessage msg) { | 63 | public void write(OFMessage msg) { |
53 | - this.write(Collections.singletonList(msg)); | 64 | + if (msg.getType() == OFType.FLOW_MOD) { |
65 | + OFFlowMod flowMod = (OFFlowMod) msg; | ||
66 | + OFFlowMod.Builder builder = flowMod.createBuilder(); | ||
67 | + builder.setTableId(TableId.of(LOCAL_TABLE)); | ||
68 | + channel.write(Collections.singletonList(builder.build())); | ||
69 | + } else { | ||
70 | + channel.write(Collections.singletonList(msg)); | ||
71 | + } | ||
54 | } | 72 | } |
55 | 73 | ||
56 | @Override | 74 | @Override |
57 | public void write(List<OFMessage> msgs) { | 75 | public void write(List<OFMessage> msgs) { |
58 | - channel.write(msgs); | 76 | + List<OFMessage> newMsgs = new ArrayList<OFMessage>(); |
77 | + for (OFMessage msg : msgs) { | ||
78 | + if (msg.getType() == OFType.FLOW_MOD) { | ||
79 | + OFFlowMod flowMod = (OFFlowMod) msg; | ||
80 | + OFFlowMod.Builder builder = flowMod.createBuilder(); | ||
81 | + builder.setTableId(TableId.of(LOCAL_TABLE)); | ||
82 | + newMsgs.add(builder.build()); | ||
83 | + } else { | ||
84 | + newMsgs.add(msg); | ||
85 | + } | ||
86 | + } | ||
87 | + channel.write(newMsgs); | ||
59 | } | 88 | } |
60 | 89 | ||
61 | @Override | 90 | @Override |
62 | - public void sendMsg(OFMessage msg, TableType type) { | 91 | + public void transformAndSendMsg(OFMessage msg, TableType type) { |
63 | if (msg.getType() == OFType.FLOW_MOD) { | 92 | if (msg.getType() == OFType.FLOW_MOD) { |
64 | OFFlowMod flowMod = (OFFlowMod) msg; | 93 | OFFlowMod flowMod = (OFFlowMod) msg; |
65 | OFFlowMod.Builder builder = flowMod.createBuilder(); | 94 | OFFlowMod.Builder builder = flowMod.createBuilder(); |
... | @@ -142,19 +171,47 @@ public class OFCorsaSwitchDriver extends AbstractOpenFlowSwitch { | ... | @@ -142,19 +171,47 @@ public class OFCorsaSwitchDriver extends AbstractOpenFlowSwitch { |
142 | case ACL: | 171 | case ACL: |
143 | builder.setTableId(TableId.of(LOCAL_TABLE)); | 172 | builder.setTableId(TableId.of(LOCAL_TABLE)); |
144 | break; | 173 | break; |
174 | + case FIRST: | ||
175 | + builder.setTableId(TableId.of(FIRST_TABLE)); | ||
176 | + break; | ||
145 | case NONE: | 177 | case NONE: |
146 | - builder.setTableId(TableId.of(0)); | 178 | + builder.setTableId(TableId.of(LOCAL_TABLE)); |
147 | break; | 179 | break; |
148 | default: | 180 | default: |
149 | log.warn("Unknown table type: {}", type); | 181 | log.warn("Unknown table type: {}", type); |
150 | } | 182 | } |
151 | builder.setInstructions(newInstructions); | 183 | builder.setInstructions(newInstructions); |
152 | OFMessage msgnew = builder.build(); | 184 | OFMessage msgnew = builder.build(); |
153 | - this.write(msgnew); | 185 | + channel.write(Collections.singletonList(msgnew)); |
154 | log.debug("Installed {}", msgnew); | 186 | log.debug("Installed {}", msgnew); |
155 | 187 | ||
156 | } else { | 188 | } else { |
157 | - this.write(msg); | 189 | + channel.write(Collections.singletonList(msg)); |
190 | + } | ||
191 | + } | ||
192 | + | ||
193 | + @Override | ||
194 | + public TableType getTableType(TableId tid) { | ||
195 | + switch (tid.getValue()) { | ||
196 | + case VLAN_MPLS_TABLE: | ||
197 | + return TableType.VLAN_MPLS; | ||
198 | + case VLAN_TABLE: | ||
199 | + return TableType.VLAN; | ||
200 | + case ETHER_TABLE: | ||
201 | + return TableType.ETHER; | ||
202 | + case COS_MAP_TABLE: | ||
203 | + return TableType.COS; | ||
204 | + case FIB_TABLE: | ||
205 | + return TableType.IP; | ||
206 | + case MPLS_TABLE: | ||
207 | + return TableType.MPLS; | ||
208 | + case LOCAL_TABLE: | ||
209 | + return TableType.NONE; | ||
210 | + case FIRST_TABLE: | ||
211 | + return TableType.FIRST; | ||
212 | + default: | ||
213 | + log.warn("Unknown table type: {}", tid.getValue()); | ||
214 | + return TableType.NONE; | ||
158 | } | 215 | } |
159 | } | 216 | } |
160 | 217 | ... | ... |
... | @@ -30,6 +30,7 @@ import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; | ... | @@ -30,6 +30,7 @@ import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; |
30 | import org.projectfloodlight.openflow.protocol.OFPortOptical; | 30 | import org.projectfloodlight.openflow.protocol.OFPortOptical; |
31 | import org.projectfloodlight.openflow.protocol.OFStatsReply; | 31 | import org.projectfloodlight.openflow.protocol.OFStatsReply; |
32 | import org.projectfloodlight.openflow.protocol.OFStatsType; | 32 | import org.projectfloodlight.openflow.protocol.OFStatsType; |
33 | +import org.projectfloodlight.openflow.types.TableId; | ||
33 | 34 | ||
34 | import java.io.IOException; | 35 | import java.io.IOException; |
35 | import java.util.ArrayList; | 36 | import java.util.ArrayList; |
... | @@ -209,5 +210,15 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { | ... | @@ -209,5 +210,15 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { |
209 | return true; | 210 | return true; |
210 | } | 211 | } |
211 | 212 | ||
213 | + @Override | ||
214 | + public TableType getTableType(TableId tid) { | ||
215 | + return TableType.NONE; | ||
216 | + } | ||
217 | + | ||
218 | + @Override | ||
219 | + public void transformAndSendMsg(OFMessage msg, TableType tableType) { | ||
220 | + // TODO Auto-generated method stub | ||
221 | + | ||
222 | + } | ||
212 | 223 | ||
213 | } | 224 | } | ... | ... |
... | @@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicBoolean; | ... | @@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicBoolean; |
25 | 25 | ||
26 | import org.onosproject.openflow.controller.Dpid; | 26 | import org.onosproject.openflow.controller.Dpid; |
27 | import org.onosproject.openflow.controller.RoleState; | 27 | import org.onosproject.openflow.controller.RoleState; |
28 | +import org.onosproject.openflow.controller.OpenFlowSwitch.TableType; | ||
28 | import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch; | 29 | import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch; |
29 | import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeAlreadyStarted; | 30 | import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeAlreadyStarted; |
30 | import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeCompleted; | 31 | import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeCompleted; |
... | @@ -1216,4 +1217,15 @@ public class OFSwitchImplCPqD13 extends AbstractOpenFlowSwitch { | ... | @@ -1216,4 +1217,15 @@ public class OFSwitchImplCPqD13 extends AbstractOpenFlowSwitch { |
1216 | this.channel.write(msgs); | 1217 | this.channel.write(msgs); |
1217 | } | 1218 | } |
1218 | 1219 | ||
1220 | + | ||
1221 | + @Override | ||
1222 | + public TableType getTableType(TableId tid) { | ||
1223 | + return TableType.NONE; // XXX this needs to be fixed | ||
1224 | + } | ||
1225 | + | ||
1226 | + @Override | ||
1227 | + public void transformAndSendMsg(OFMessage msg, TableType tableType) { | ||
1228 | + // TODO Auto-generated method stub | ||
1229 | + | ||
1230 | + } | ||
1219 | } | 1231 | } | ... | ... |
... | @@ -24,6 +24,7 @@ import org.projectfloodlight.openflow.protocol.OFDescStatsReply; | ... | @@ -24,6 +24,7 @@ import org.projectfloodlight.openflow.protocol.OFDescStatsReply; |
24 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; | 24 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; |
25 | import org.projectfloodlight.openflow.protocol.OFMessage; | 25 | import org.projectfloodlight.openflow.protocol.OFMessage; |
26 | import org.projectfloodlight.openflow.protocol.OFPortDesc; | 26 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
27 | +import org.projectfloodlight.openflow.types.TableId; | ||
27 | 28 | ||
28 | /** | 29 | /** |
29 | * OFDescriptionStatistics Vendor (Manufacturer Desc.): Nicira, Inc. Make | 30 | * OFDescriptionStatistics Vendor (Manufacturer Desc.): Nicira, Inc. Make |
... | @@ -85,5 +86,15 @@ public class OFSwitchImplOVS10 extends AbstractOpenFlowSwitch { | ... | @@ -85,5 +86,15 @@ public class OFSwitchImplOVS10 extends AbstractOpenFlowSwitch { |
85 | return Collections.unmodifiableList(features.getPorts()); | 86 | return Collections.unmodifiableList(features.getPorts()); |
86 | } | 87 | } |
87 | 88 | ||
89 | + @Override | ||
90 | + public TableType getTableType(TableId tid) { | ||
91 | + return TableType.NONE; | ||
92 | + } | ||
93 | + | ||
94 | + @Override | ||
95 | + public void transformAndSendMsg(OFMessage msg, TableType tableType) { | ||
96 | + // TODO Auto-generated method stub | ||
97 | + | ||
98 | + } | ||
88 | 99 | ||
89 | } | 100 | } | ... | ... |
... | @@ -237,4 +237,15 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch { | ... | @@ -237,4 +237,15 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch { |
237 | write(tableMissEntry); | 237 | write(tableMissEntry); |
238 | } | 238 | } |
239 | 239 | ||
240 | + @Override | ||
241 | + public TableType getTableType(TableId tid) { | ||
242 | + return TableType.NONE; | ||
243 | + } | ||
244 | + | ||
245 | + @Override | ||
246 | + public void transformAndSendMsg(OFMessage msg, TableType tableType) { | ||
247 | + // TODO Auto-generated method stub | ||
248 | + | ||
249 | + } | ||
250 | + | ||
240 | } | 251 | } | ... | ... |
... | @@ -17,6 +17,7 @@ package org.onosproject.openflow.drivers; | ... | @@ -17,6 +17,7 @@ package org.onosproject.openflow.drivers; |
17 | 17 | ||
18 | import org.onosproject.openflow.controller.Dpid; | 18 | import org.onosproject.openflow.controller.Dpid; |
19 | import org.onosproject.openflow.controller.RoleState; | 19 | import org.onosproject.openflow.controller.RoleState; |
20 | +import org.onosproject.openflow.controller.OpenFlowSwitch.TableType; | ||
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; |
22 | import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeCompleted; | 23 | import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeCompleted; |
... | @@ -167,7 +168,7 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { | ... | @@ -167,7 +168,7 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { |
167 | } | 168 | } |
168 | 169 | ||
169 | @Override | 170 | @Override |
170 | - public void sendMsg(OFMessage m, TableType tableType) { | 171 | + public void transformAndSendMsg(OFMessage m, TableType tableType) { |
171 | 172 | ||
172 | if (m.getType() == OFType.FLOW_MOD) { | 173 | if (m.getType() == OFType.FLOW_MOD) { |
173 | OFFlowMod flowMod = (OFFlowMod) m; | 174 | OFFlowMod flowMod = (OFFlowMod) m; |
... | @@ -571,4 +572,10 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { | ... | @@ -571,4 +572,10 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { |
571 | .build(); | 572 | .build(); |
572 | write(br); | 573 | write(br); |
573 | } | 574 | } |
575 | + | ||
576 | + @Override | ||
577 | + public TableType getTableType(TableId tid) { | ||
578 | + return TableType.NONE; // XXX this needs to be fixed | ||
579 | + } | ||
580 | + | ||
574 | } | 581 | } | ... | ... |
... | @@ -49,6 +49,7 @@ import org.onosproject.openflow.controller.OpenFlowSwitch; | ... | @@ -49,6 +49,7 @@ import org.onosproject.openflow.controller.OpenFlowSwitch; |
49 | import org.onosproject.openflow.controller.OpenFlowSwitchListener; | 49 | import org.onosproject.openflow.controller.OpenFlowSwitchListener; |
50 | import org.onosproject.openflow.controller.PacketListener; | 50 | import org.onosproject.openflow.controller.PacketListener; |
51 | import org.onosproject.openflow.controller.RoleState; | 51 | import org.onosproject.openflow.controller.RoleState; |
52 | +import org.onosproject.openflow.controller.OpenFlowSwitch.TableType; | ||
52 | import org.projectfloodlight.openflow.protocol.OFFactory; | 53 | import org.projectfloodlight.openflow.protocol.OFFactory; |
53 | import org.projectfloodlight.openflow.protocol.OFMessage; | 54 | import org.projectfloodlight.openflow.protocol.OFMessage; |
54 | import org.projectfloodlight.openflow.protocol.OFPortDesc; | 55 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
... | @@ -56,6 +57,7 @@ import org.projectfloodlight.openflow.protocol.OFPortReason; | ... | @@ -56,6 +57,7 @@ import org.projectfloodlight.openflow.protocol.OFPortReason; |
56 | import org.projectfloodlight.openflow.protocol.OFPortStatus; | 57 | import org.projectfloodlight.openflow.protocol.OFPortStatus; |
57 | import org.projectfloodlight.openflow.protocol.ver10.OFFactoryVer10; | 58 | import org.projectfloodlight.openflow.protocol.ver10.OFFactoryVer10; |
58 | import org.projectfloodlight.openflow.types.OFPort; | 59 | import org.projectfloodlight.openflow.types.OFPort; |
60 | +import org.projectfloodlight.openflow.types.TableId; | ||
59 | 61 | ||
60 | import com.google.common.collect.HashMultimap; | 62 | import com.google.common.collect.HashMultimap; |
61 | import com.google.common.collect.Lists; | 63 | import com.google.common.collect.Lists; |
... | @@ -310,10 +312,6 @@ public class OpenFlowDeviceProviderTest { | ... | @@ -310,10 +312,6 @@ public class OpenFlowDeviceProviderTest { |
310 | } | 312 | } |
311 | 313 | ||
312 | @Override | 314 | @Override |
313 | - public void sendMsg(OFMessage msg, TableType tableType) { | ||
314 | - } | ||
315 | - | ||
316 | - @Override | ||
317 | public void handleMessage(OFMessage fromSwitch) { | 315 | public void handleMessage(OFMessage fromSwitch) { |
318 | } | 316 | } |
319 | 317 | ||
... | @@ -395,6 +393,17 @@ public class OpenFlowDeviceProviderTest { | ... | @@ -395,6 +393,17 @@ public class OpenFlowDeviceProviderTest { |
395 | return "1.2.3.4:1"; | 393 | return "1.2.3.4:1"; |
396 | } | 394 | } |
397 | 395 | ||
396 | + @Override | ||
397 | + public TableType getTableType(TableId tid) { | ||
398 | + return TableType.NONE; | ||
399 | + } | ||
400 | + | ||
401 | + @Override | ||
402 | + public void transformAndSendMsg(OFMessage msg, TableType tableType) { | ||
403 | + // TODO Auto-generated method stub | ||
404 | + } | ||
405 | + | ||
406 | + | ||
398 | } | 407 | } |
399 | 408 | ||
400 | } | 409 | } | ... | ... |
... | @@ -34,6 +34,7 @@ import org.onosproject.net.flow.DefaultTrafficTreatment; | ... | @@ -34,6 +34,7 @@ import org.onosproject.net.flow.DefaultTrafficTreatment; |
34 | import org.onosproject.net.flow.FlowEntry; | 34 | import org.onosproject.net.flow.FlowEntry; |
35 | import org.onosproject.net.flow.FlowEntry.FlowEntryState; | 35 | import org.onosproject.net.flow.FlowEntry.FlowEntryState; |
36 | import org.onosproject.net.flow.FlowRule; | 36 | import org.onosproject.net.flow.FlowRule; |
37 | +import org.onosproject.net.flow.FlowRule.Type; | ||
37 | import org.onosproject.net.flow.TrafficSelector; | 38 | import org.onosproject.net.flow.TrafficSelector; |
38 | import org.onosproject.net.flow.TrafficTreatment; | 39 | import org.onosproject.net.flow.TrafficTreatment; |
39 | import org.onosproject.openflow.controller.Dpid; | 40 | import org.onosproject.openflow.controller.Dpid; |
... | @@ -87,6 +88,7 @@ public class FlowEntryBuilder { | ... | @@ -87,6 +88,7 @@ public class FlowEntryBuilder { |
87 | public enum FlowType { STAT, REMOVED, MOD } | 88 | public enum FlowType { STAT, REMOVED, MOD } |
88 | 89 | ||
89 | private final FlowType type; | 90 | private final FlowType type; |
91 | + private Type tableType = FlowRule.Type.DEFAULT; | ||
90 | 92 | ||
91 | 93 | ||
92 | public FlowEntryBuilder(Dpid dpid, OFFlowStatsEntry entry) { | 94 | public FlowEntryBuilder(Dpid dpid, OFFlowStatsEntry entry) { |
... | @@ -99,6 +101,17 @@ public class FlowEntryBuilder { | ... | @@ -99,6 +101,17 @@ public class FlowEntryBuilder { |
99 | this.type = FlowType.STAT; | 101 | this.type = FlowType.STAT; |
100 | } | 102 | } |
101 | 103 | ||
104 | + public FlowEntryBuilder(Dpid dpid, OFFlowStatsEntry entry, Type tableType) { | ||
105 | + this.stat = entry; | ||
106 | + this.match = entry.getMatch(); | ||
107 | + this.actions = getActions(entry); | ||
108 | + this.dpid = dpid; | ||
109 | + this.removed = null; | ||
110 | + this.flowMod = null; | ||
111 | + this.type = FlowType.STAT; | ||
112 | + this.tableType = tableType; | ||
113 | + } | ||
114 | + | ||
102 | public FlowEntryBuilder(Dpid dpid, OFFlowRemoved removed) { | 115 | public FlowEntryBuilder(Dpid dpid, OFFlowRemoved removed) { |
103 | this.match = removed.getMatch(); | 116 | this.match = removed.getMatch(); |
104 | this.removed = removed; | 117 | this.removed = removed; |
... | @@ -127,7 +140,8 @@ public class FlowEntryBuilder { | ... | @@ -127,7 +140,8 @@ public class FlowEntryBuilder { |
127 | case STAT: | 140 | case STAT: |
128 | rule = new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)), | 141 | rule = new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)), |
129 | buildSelector(), buildTreatment(), stat.getPriority(), | 142 | buildSelector(), buildTreatment(), stat.getPriority(), |
130 | - stat.getCookie().getValue(), stat.getIdleTimeout(), false); | 143 | + stat.getCookie().getValue(), stat.getIdleTimeout(), false, |
144 | + tableType); | ||
131 | return new DefaultFlowEntry(rule, FlowEntryState.ADDED, | 145 | return new DefaultFlowEntry(rule, FlowEntryState.ADDED, |
132 | stat.getDurationSec(), stat.getPacketCount().getValue(), | 146 | stat.getDurationSec(), stat.getPacketCount().getValue(), |
133 | stat.getByteCount().getValue()); | 147 | stat.getByteCount().getValue()); | ... | ... |
providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
... | @@ -266,6 +266,8 @@ public class FlowModBuilderVer13 extends FlowModBuilder { | ... | @@ -266,6 +266,8 @@ public class FlowModBuilderVer13 extends FlowModBuilder { |
266 | return OpenFlowSwitch.TableType.ETHER; | 266 | return OpenFlowSwitch.TableType.ETHER; |
267 | case COS: | 267 | case COS: |
268 | return OpenFlowSwitch.TableType.COS; | 268 | return OpenFlowSwitch.TableType.COS; |
269 | + case FIRST: | ||
270 | + return OpenFlowSwitch.TableType.FIRST; | ||
269 | default: | 271 | default: |
270 | return OpenFlowSwitch.TableType.NONE; | 272 | return OpenFlowSwitch.TableType.NONE; |
271 | } | 273 | } | ... | ... |
... | @@ -45,26 +45,17 @@ import org.onosproject.openflow.controller.OpenFlowEventListener; | ... | @@ -45,26 +45,17 @@ import org.onosproject.openflow.controller.OpenFlowEventListener; |
45 | import org.onosproject.openflow.controller.OpenFlowSwitch; | 45 | import org.onosproject.openflow.controller.OpenFlowSwitch; |
46 | import org.onosproject.openflow.controller.OpenFlowSwitchListener; | 46 | import org.onosproject.openflow.controller.OpenFlowSwitchListener; |
47 | import org.onosproject.openflow.controller.RoleState; | 47 | import org.onosproject.openflow.controller.RoleState; |
48 | -import org.projectfloodlight.openflow.protocol.OFActionType; | ||
49 | import org.projectfloodlight.openflow.protocol.OFBarrierRequest; | 48 | import org.projectfloodlight.openflow.protocol.OFBarrierRequest; |
50 | import org.projectfloodlight.openflow.protocol.OFErrorMsg; | 49 | import org.projectfloodlight.openflow.protocol.OFErrorMsg; |
51 | import org.projectfloodlight.openflow.protocol.OFErrorType; | 50 | import org.projectfloodlight.openflow.protocol.OFErrorType; |
52 | import org.projectfloodlight.openflow.protocol.OFFlowMod; | 51 | import org.projectfloodlight.openflow.protocol.OFFlowMod; |
53 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; | 52 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; |
54 | -import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; | ||
55 | import org.projectfloodlight.openflow.protocol.OFFlowStatsReply; | 53 | import org.projectfloodlight.openflow.protocol.OFFlowStatsReply; |
56 | -import org.projectfloodlight.openflow.protocol.OFInstructionType; | ||
57 | import org.projectfloodlight.openflow.protocol.OFMessage; | 54 | import org.projectfloodlight.openflow.protocol.OFMessage; |
58 | import org.projectfloodlight.openflow.protocol.OFPortStatus; | 55 | import org.projectfloodlight.openflow.protocol.OFPortStatus; |
59 | import org.projectfloodlight.openflow.protocol.OFStatsReply; | 56 | import org.projectfloodlight.openflow.protocol.OFStatsReply; |
60 | import org.projectfloodlight.openflow.protocol.OFStatsType; | 57 | import org.projectfloodlight.openflow.protocol.OFStatsType; |
61 | -import org.projectfloodlight.openflow.protocol.OFVersion; | ||
62 | -import org.projectfloodlight.openflow.protocol.action.OFAction; | ||
63 | -import org.projectfloodlight.openflow.protocol.action.OFActionOutput; | ||
64 | import org.projectfloodlight.openflow.protocol.errormsg.OFFlowModFailedErrorMsg; | 58 | import org.projectfloodlight.openflow.protocol.errormsg.OFFlowModFailedErrorMsg; |
65 | -import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; | ||
66 | -import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; | ||
67 | -import org.projectfloodlight.openflow.types.OFPort; | ||
68 | import org.slf4j.Logger; | 59 | import org.slf4j.Logger; |
69 | 60 | ||
70 | import java.util.Collections; | 61 | import java.util.Collections; |
... | @@ -85,8 +76,6 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -85,8 +76,6 @@ import static org.slf4j.LoggerFactory.getLogger; |
85 | @Component(immediate = true) | 76 | @Component(immediate = true) |
86 | public class OpenFlowRuleProvider extends AbstractProvider implements FlowRuleProvider { | 77 | public class OpenFlowRuleProvider extends AbstractProvider implements FlowRuleProvider { |
87 | 78 | ||
88 | - private static final int LOWEST_PRIORITY = 0; | ||
89 | - | ||
90 | private final Logger log = getLogger(getClass()); | 79 | private final Logger log = getLogger(getClass()); |
91 | 80 | ||
92 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 81 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
... | @@ -160,7 +149,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -160,7 +149,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
160 | Optional.empty()).buildFlowAdd()); | 149 | Optional.empty()).buildFlowAdd()); |
161 | } else { | 150 | } else { |
162 | OpenFlowSwitch.TableType type = getTableType(flowRule.type()); | 151 | OpenFlowSwitch.TableType type = getTableType(flowRule.type()); |
163 | - sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), | 152 | + sw.transformAndSendMsg(FlowModBuilder.builder(flowRule, sw.factory(), |
164 | Optional.empty()).buildFlowAdd(), | 153 | Optional.empty()).buildFlowAdd(), |
165 | type); | 154 | type); |
166 | } | 155 | } |
... | @@ -181,7 +170,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -181,7 +170,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
181 | sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), | 170 | sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), |
182 | Optional.empty()).buildFlowDel()); | 171 | Optional.empty()).buildFlowDel()); |
183 | } else { | 172 | } else { |
184 | - sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), | 173 | + sw.transformAndSendMsg(FlowModBuilder.builder(flowRule, sw.factory(), |
185 | Optional.empty()).buildFlowDel(), getTableType(flowRule.type())); | 174 | Optional.empty()).buildFlowDel(), getTableType(flowRule.type())); |
186 | } | 175 | } |
187 | } | 176 | } |
... | @@ -225,7 +214,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -225,7 +214,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
225 | if (fbe.target().type() == FlowRule.Type.DEFAULT) { | 214 | if (fbe.target().type() == FlowRule.Type.DEFAULT) { |
226 | sw.sendMsg(mod); | 215 | sw.sendMsg(mod); |
227 | } else { | 216 | } else { |
228 | - sw.sendMsg(mod, getTableType(fbe.target().type())); | 217 | + sw.transformAndSendMsg(mod, getTableType(fbe.target().type())); |
229 | } | 218 | } |
230 | } | 219 | } |
231 | OFBarrierRequest.Builder builder = sw.factory() | 220 | OFBarrierRequest.Builder builder = sw.factory() |
... | @@ -253,12 +242,38 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -253,12 +242,38 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
253 | return OpenFlowSwitch.TableType.ETHER; | 242 | return OpenFlowSwitch.TableType.ETHER; |
254 | case COS: | 243 | case COS: |
255 | return OpenFlowSwitch.TableType.COS; | 244 | return OpenFlowSwitch.TableType.COS; |
245 | + case FIRST: | ||
246 | + return OpenFlowSwitch.TableType.FIRST; | ||
256 | default: | 247 | default: |
257 | return OpenFlowSwitch.TableType.NONE; | 248 | return OpenFlowSwitch.TableType.NONE; |
258 | } | 249 | } |
259 | } | 250 | } |
260 | 251 | ||
252 | + private FlowRule.Type getType(OpenFlowSwitch.TableType tableType) { | ||
253 | + switch (tableType) { | ||
261 | 254 | ||
255 | + case NONE: | ||
256 | + return FlowRule.Type.DEFAULT; | ||
257 | + case IP: | ||
258 | + return FlowRule.Type.IP; | ||
259 | + case MPLS: | ||
260 | + return FlowRule.Type.MPLS; | ||
261 | + case ACL: | ||
262 | + return FlowRule.Type.ACL; | ||
263 | + case VLAN_MPLS: | ||
264 | + return FlowRule.Type.VLAN_MPLS; | ||
265 | + case VLAN: | ||
266 | + return FlowRule.Type.VLAN; | ||
267 | + case ETHER: | ||
268 | + return FlowRule.Type.ETHER; | ||
269 | + case COS: | ||
270 | + return FlowRule.Type.COS; | ||
271 | + case FIRST: | ||
272 | + return FlowRule.Type.FIRST; | ||
273 | + default: | ||
274 | + return FlowRule.Type.DEFAULT; | ||
275 | + } | ||
276 | + } | ||
262 | 277 | ||
263 | 278 | ||
264 | private class InternalFlowProvider | 279 | private class InternalFlowProvider |
... | @@ -354,41 +369,18 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -354,41 +369,18 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
354 | private void pushFlowMetrics(Dpid dpid, OFFlowStatsReply replies) { | 369 | private void pushFlowMetrics(Dpid dpid, OFFlowStatsReply replies) { |
355 | 370 | ||
356 | DeviceId did = DeviceId.deviceId(Dpid.uri(dpid)); | 371 | DeviceId did = DeviceId.deviceId(Dpid.uri(dpid)); |
372 | + OpenFlowSwitch sw = controller.getSwitch(dpid); | ||
357 | 373 | ||
358 | List<FlowEntry> flowEntries = replies.getEntries().stream() | 374 | List<FlowEntry> flowEntries = replies.getEntries().stream() |
359 | - .filter(entry -> !tableMissRule(dpid, entry)) | 375 | + .map(entry -> new FlowEntryBuilder(dpid, entry, |
360 | - .map(entry -> new FlowEntryBuilder(dpid, entry).build()) | 376 | + getType(sw.getTableType(entry.getTableId()))) |
377 | + .build()) | ||
361 | .collect(Collectors.toList()); | 378 | .collect(Collectors.toList()); |
362 | 379 | ||
363 | providerService.pushFlowMetrics(did, flowEntries); | 380 | providerService.pushFlowMetrics(did, flowEntries); |
364 | 381 | ||
365 | } | 382 | } |
366 | 383 | ||
367 | - private boolean tableMissRule(Dpid dpid, OFFlowStatsEntry reply) { | ||
368 | - if (reply.getMatch().getMatchFields().iterator().hasNext()) { | ||
369 | - return false; | ||
370 | - } | ||
371 | - if (reply.getVersion().equals(OFVersion.OF_10)) { | ||
372 | - return reply.getPriority() == LOWEST_PRIORITY | ||
373 | - && reply.getActions().isEmpty(); | ||
374 | - } | ||
375 | - for (OFInstruction ins : reply.getInstructions()) { | ||
376 | - if (ins.getType() == OFInstructionType.APPLY_ACTIONS) { | ||
377 | - OFInstructionApplyActions apply = (OFInstructionApplyActions) ins; | ||
378 | - List<OFAction> acts = apply.getActions(); | ||
379 | - for (OFAction act : acts) { | ||
380 | - if (act.getType() == OFActionType.OUTPUT) { | ||
381 | - OFActionOutput out = (OFActionOutput) act; | ||
382 | - if (out.getPort() == OFPort.CONTROLLER) { | ||
383 | - return true; | ||
384 | - } | ||
385 | - } | ||
386 | - } | ||
387 | - } | ||
388 | - } | ||
389 | - return false; | ||
390 | - } | ||
391 | - | ||
392 | } | 384 | } |
393 | 385 | ||
394 | /** | 386 | /** | ... | ... |
1 | package org.onosproject.provider.of.group.impl; | 1 | package org.onosproject.provider.of.group.impl; |
2 | 2 | ||
3 | import com.google.common.collect.Lists; | 3 | import com.google.common.collect.Lists; |
4 | + | ||
4 | import org.junit.After; | 5 | import org.junit.After; |
5 | import org.junit.Before; | 6 | import org.junit.Before; |
6 | import org.junit.Test; | 7 | import org.junit.Test; |
... | @@ -41,6 +42,7 @@ import org.projectfloodlight.openflow.protocol.OFPortDesc; | ... | @@ -41,6 +42,7 @@ import org.projectfloodlight.openflow.protocol.OFPortDesc; |
41 | import org.projectfloodlight.openflow.protocol.OFVersion; | 42 | import org.projectfloodlight.openflow.protocol.OFVersion; |
42 | import org.projectfloodlight.openflow.protocol.errormsg.OFGroupModFailedErrorMsg; | 43 | import org.projectfloodlight.openflow.protocol.errormsg.OFGroupModFailedErrorMsg; |
43 | import org.projectfloodlight.openflow.types.OFGroup; | 44 | import org.projectfloodlight.openflow.types.OFGroup; |
45 | +import org.projectfloodlight.openflow.types.TableId; | ||
44 | 46 | ||
45 | import java.util.Collection; | 47 | import java.util.Collection; |
46 | import java.util.List; | 48 | import java.util.List; |
... | @@ -310,11 +312,6 @@ public class OpenFlowGroupProviderTest { | ... | @@ -310,11 +312,6 @@ public class OpenFlowGroupProviderTest { |
310 | } | 312 | } |
311 | 313 | ||
312 | @Override | 314 | @Override |
313 | - public void sendMsg(OFMessage msg, TableType tableType) { | ||
314 | - | ||
315 | - } | ||
316 | - | ||
317 | - @Override | ||
318 | public void handleMessage(OFMessage fromSwitch) { | 315 | public void handleMessage(OFMessage fromSwitch) { |
319 | 316 | ||
320 | } | 317 | } |
... | @@ -398,5 +395,15 @@ public class OpenFlowGroupProviderTest { | ... | @@ -398,5 +395,15 @@ public class OpenFlowGroupProviderTest { |
398 | public String channelId() { | 395 | public String channelId() { |
399 | return null; | 396 | return null; |
400 | } | 397 | } |
398 | + | ||
399 | + @Override | ||
400 | + public TableType getTableType(TableId tid) { | ||
401 | + return TableType.NONE; | ||
402 | + } | ||
403 | + | ||
404 | + @Override | ||
405 | + public void transformAndSendMsg(OFMessage msg, TableType tableType) { | ||
406 | + // TODO Auto-generated method stub | ||
407 | + } | ||
401 | } | 408 | } |
402 | } | 409 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -46,6 +46,7 @@ import org.onosproject.openflow.controller.OpenFlowSwitchListener; | ... | @@ -46,6 +46,7 @@ import org.onosproject.openflow.controller.OpenFlowSwitchListener; |
46 | import org.onosproject.openflow.controller.OpenflowControllerAdapter; | 46 | import org.onosproject.openflow.controller.OpenflowControllerAdapter; |
47 | import org.onosproject.openflow.controller.PacketListener; | 47 | import org.onosproject.openflow.controller.PacketListener; |
48 | import org.onosproject.openflow.controller.RoleState; | 48 | import org.onosproject.openflow.controller.RoleState; |
49 | +import org.onosproject.openflow.controller.OpenFlowSwitch.TableType; | ||
49 | import org.onlab.packet.Ethernet; | 50 | import org.onlab.packet.Ethernet; |
50 | import org.onlab.packet.ONLabLddp; | 51 | import org.onlab.packet.ONLabLddp; |
51 | import org.projectfloodlight.openflow.protocol.OFFactory; | 52 | import org.projectfloodlight.openflow.protocol.OFFactory; |
... | @@ -56,6 +57,7 @@ import org.projectfloodlight.openflow.protocol.OFPortReason; | ... | @@ -56,6 +57,7 @@ import org.projectfloodlight.openflow.protocol.OFPortReason; |
56 | import org.projectfloodlight.openflow.protocol.OFPortStatus; | 57 | import org.projectfloodlight.openflow.protocol.OFPortStatus; |
57 | import org.projectfloodlight.openflow.protocol.ver10.OFFactoryVer10; | 58 | import org.projectfloodlight.openflow.protocol.ver10.OFFactoryVer10; |
58 | import org.projectfloodlight.openflow.types.OFPort; | 59 | import org.projectfloodlight.openflow.types.OFPort; |
60 | +import org.projectfloodlight.openflow.types.TableId; | ||
59 | 61 | ||
60 | import com.google.common.collect.Lists; | 62 | import com.google.common.collect.Lists; |
61 | import com.google.common.collect.Maps; | 63 | import com.google.common.collect.Maps; |
... | @@ -414,10 +416,6 @@ public class OpenFlowLinkProviderTest { | ... | @@ -414,10 +416,6 @@ public class OpenFlowLinkProviderTest { |
414 | } | 416 | } |
415 | 417 | ||
416 | @Override | 418 | @Override |
417 | - public void sendMsg(OFMessage msg, TableType tableType) { | ||
418 | - } | ||
419 | - | ||
420 | - @Override | ||
421 | public void handleMessage(OFMessage fromSwitch) { | 419 | public void handleMessage(OFMessage fromSwitch) { |
422 | } | 420 | } |
423 | 421 | ||
... | @@ -499,6 +497,15 @@ public class OpenFlowLinkProviderTest { | ... | @@ -499,6 +497,15 @@ public class OpenFlowLinkProviderTest { |
499 | return "1.2.3.4:1"; | 497 | return "1.2.3.4:1"; |
500 | } | 498 | } |
501 | 499 | ||
500 | + @Override | ||
501 | + public TableType getTableType(TableId tid) { | ||
502 | + return TableType.NONE; | ||
503 | + } | ||
504 | + | ||
505 | + @Override | ||
506 | + public void transformAndSendMsg(OFMessage msg, TableType tableType) { | ||
507 | + // TODO Auto-generated method stub | ||
508 | + } | ||
502 | 509 | ||
503 | } | 510 | } |
504 | } | 511 | } | ... | ... |
... | @@ -49,6 +49,7 @@ import org.onosproject.openflow.controller.OpenFlowSwitch; | ... | @@ -49,6 +49,7 @@ import org.onosproject.openflow.controller.OpenFlowSwitch; |
49 | import org.onosproject.openflow.controller.OpenFlowSwitchListener; | 49 | import org.onosproject.openflow.controller.OpenFlowSwitchListener; |
50 | import org.onosproject.openflow.controller.PacketListener; | 50 | import org.onosproject.openflow.controller.PacketListener; |
51 | import org.onosproject.openflow.controller.RoleState; | 51 | import org.onosproject.openflow.controller.RoleState; |
52 | +import org.onosproject.openflow.controller.OpenFlowSwitch.TableType; | ||
52 | import org.onlab.packet.ARP; | 53 | import org.onlab.packet.ARP; |
53 | import org.onlab.packet.Ethernet; | 54 | import org.onlab.packet.Ethernet; |
54 | import org.projectfloodlight.openflow.protocol.OFFactory; | 55 | import org.projectfloodlight.openflow.protocol.OFFactory; |
... | @@ -60,6 +61,7 @@ import org.projectfloodlight.openflow.protocol.ver10.OFFactoryVer10; | ... | @@ -60,6 +61,7 @@ import org.projectfloodlight.openflow.protocol.ver10.OFFactoryVer10; |
60 | import org.projectfloodlight.openflow.types.MacAddress; | 61 | import org.projectfloodlight.openflow.types.MacAddress; |
61 | import org.projectfloodlight.openflow.types.OFBufferId; | 62 | import org.projectfloodlight.openflow.types.OFBufferId; |
62 | import org.projectfloodlight.openflow.types.OFPort; | 63 | import org.projectfloodlight.openflow.types.OFPort; |
64 | +import org.projectfloodlight.openflow.types.TableId; | ||
63 | 65 | ||
64 | import com.google.common.collect.Lists; | 66 | import com.google.common.collect.Lists; |
65 | import com.google.common.collect.Sets; | 67 | import com.google.common.collect.Sets; |
... | @@ -347,10 +349,6 @@ public class OpenFlowPacketProviderTest { | ... | @@ -347,10 +349,6 @@ public class OpenFlowPacketProviderTest { |
347 | } | 349 | } |
348 | 350 | ||
349 | @Override | 351 | @Override |
350 | - public void sendMsg(OFMessage msg, TableType tableType) { | ||
351 | - } | ||
352 | - | ||
353 | - @Override | ||
354 | public void handleMessage(OFMessage fromSwitch) { | 352 | public void handleMessage(OFMessage fromSwitch) { |
355 | } | 353 | } |
356 | 354 | ||
... | @@ -432,6 +430,17 @@ public class OpenFlowPacketProviderTest { | ... | @@ -432,6 +430,17 @@ public class OpenFlowPacketProviderTest { |
432 | return "1.2.3.4:1"; | 430 | return "1.2.3.4:1"; |
433 | } | 431 | } |
434 | 432 | ||
433 | + @Override | ||
434 | + public TableType getTableType(TableId tid) { | ||
435 | + return TableType.NONE; | ||
436 | + } | ||
437 | + | ||
438 | + @Override | ||
439 | + public void transformAndSendMsg(OFMessage msg, TableType tableType) { | ||
440 | + // TODO Auto-generated method stub | ||
441 | + | ||
442 | + } | ||
443 | + | ||
435 | } | 444 | } |
436 | 445 | ||
437 | } | 446 | } | ... | ... |
-
Please register or login to post a comment