alshabib

fixed of13 glitches

Change-Id: Iaaaec162cc3b33f25912da8b06e509d1ff7e2ec4
...@@ -122,7 +122,7 @@ class RoleManager implements RoleHandler { ...@@ -122,7 +122,7 @@ class RoleManager implements RoleHandler {
122 //FIXME fix below when we actually use generation ids 122 //FIXME fix below when we actually use generation ids
123 .setGenerationId(U64.ZERO) 123 .setGenerationId(U64.ZERO)
124 .build(); 124 .build();
125 - sw.sendMsg(rrm); 125 + sw.write(rrm);
126 return xid; 126 return xid;
127 } 127 }
128 128
......
...@@ -138,7 +138,7 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch { ...@@ -138,7 +138,7 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch {
138 .buildBarrierRequest() 138 .buildBarrierRequest()
139 .setXid(xid) 139 .setXid(xid)
140 .build(); 140 .build();
141 - sendMsg(br); 141 + write(br);
142 } 142 }
143 143
144 @Override 144 @Override
...@@ -227,7 +227,7 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch { ...@@ -227,7 +227,7 @@ public class OFSwitchImplOVS13 extends AbstractOpenFlowSwitch {
227 .setHardTimeout(0) 227 .setHardTimeout(0)
228 .setXid(getNextTransactionId()) 228 .setXid(getNextTransactionId())
229 .build(); 229 .build();
230 - sendMsg(tableMissEntry); 230 + write(tableMissEntry);
231 } 231 }
232 232
233 } 233 }
......
...@@ -40,15 +40,15 @@ public enum OFType { ...@@ -40,15 +40,15 @@ public enum OFType {
40 PORT_STATUS, 40 PORT_STATUS,
41 PACKET_OUT, 41 PACKET_OUT,
42 FLOW_MOD, 42 FLOW_MOD,
43 + GROUP_MOD,
43 PORT_MOD, 44 PORT_MOD,
45 + TABLE_MOD,
44 STATS_REQUEST, 46 STATS_REQUEST,
45 STATS_REPLY, 47 STATS_REPLY,
46 BARRIER_REQUEST, 48 BARRIER_REQUEST,
47 BARRIER_REPLY, 49 BARRIER_REPLY,
48 QUEUE_GET_CONFIG_REQUEST, 50 QUEUE_GET_CONFIG_REQUEST,
49 QUEUE_GET_CONFIG_REPLY, 51 QUEUE_GET_CONFIG_REPLY,
50 - GROUP_MOD,
51 - TABLE_MOD,
52 ROLE_REQUEST, 52 ROLE_REQUEST,
53 ROLE_REPLY, 53 ROLE_REPLY,
54 GET_ASYNC_REQUEST, 54 GET_ASYNC_REQUEST,
......
...@@ -20,6 +20,7 @@ import org.onlab.packet.VlanId; ...@@ -20,6 +20,7 @@ import org.onlab.packet.VlanId;
20 import org.projectfloodlight.openflow.protocol.OFFlowRemoved; 20 import org.projectfloodlight.openflow.protocol.OFFlowRemoved;
21 import org.projectfloodlight.openflow.protocol.OFFlowRemovedReason; 21 import org.projectfloodlight.openflow.protocol.OFFlowRemovedReason;
22 import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; 22 import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry;
23 +import org.projectfloodlight.openflow.protocol.OFInstructionType;
23 import org.projectfloodlight.openflow.protocol.action.OFAction; 24 import org.projectfloodlight.openflow.protocol.action.OFAction;
24 import org.projectfloodlight.openflow.protocol.action.OFActionOutput; 25 import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
25 import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst; 26 import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst;
...@@ -28,11 +29,15 @@ import org.projectfloodlight.openflow.protocol.action.OFActionSetNwDst; ...@@ -28,11 +29,15 @@ import org.projectfloodlight.openflow.protocol.action.OFActionSetNwDst;
28 import org.projectfloodlight.openflow.protocol.action.OFActionSetNwSrc; 29 import org.projectfloodlight.openflow.protocol.action.OFActionSetNwSrc;
29 import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp; 30 import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp;
30 import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanVid; 31 import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanVid;
32 +import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
33 +import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions;
31 import org.projectfloodlight.openflow.protocol.match.Match; 34 import org.projectfloodlight.openflow.protocol.match.Match;
32 import org.projectfloodlight.openflow.protocol.match.MatchField; 35 import org.projectfloodlight.openflow.protocol.match.MatchField;
33 import org.projectfloodlight.openflow.types.IPv4Address; 36 import org.projectfloodlight.openflow.types.IPv4Address;
34 import org.slf4j.Logger; 37 import org.slf4j.Logger;
35 38
39 +import com.google.common.collect.Lists;
40 +
36 public class FlowRuleBuilder { 41 public class FlowRuleBuilder {
37 private final Logger log = getLogger(getClass()); 42 private final Logger log = getLogger(getClass());
38 43
...@@ -44,15 +49,16 @@ public class FlowRuleBuilder { ...@@ -44,15 +49,16 @@ public class FlowRuleBuilder {
44 49
45 private final Dpid dpid; 50 private final Dpid dpid;
46 51
47 - 52 + private final boolean addedRule;
48 53
49 54
50 public FlowRuleBuilder(Dpid dpid, OFFlowStatsEntry entry) { 55 public FlowRuleBuilder(Dpid dpid, OFFlowStatsEntry entry) {
51 this.stat = entry; 56 this.stat = entry;
52 this.match = entry.getMatch(); 57 this.match = entry.getMatch();
53 - this.actions = entry.getActions(); 58 + this.actions = getActions(entry);
54 this.dpid = dpid; 59 this.dpid = dpid;
55 this.removed = null; 60 this.removed = null;
61 + this.addedRule = true;
56 } 62 }
57 63
58 public FlowRuleBuilder(Dpid dpid, OFFlowRemoved removed) { 64 public FlowRuleBuilder(Dpid dpid, OFFlowRemoved removed) {
...@@ -62,11 +68,12 @@ public class FlowRuleBuilder { ...@@ -62,11 +68,12 @@ public class FlowRuleBuilder {
62 this.dpid = dpid; 68 this.dpid = dpid;
63 this.actions = null; 69 this.actions = null;
64 this.stat = null; 70 this.stat = null;
71 + this.addedRule = false;
65 72
66 } 73 }
67 74
68 public FlowRule build() { 75 public FlowRule build() {
69 - if (stat != null) { 76 + if (addedRule) {
70 return new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)), 77 return new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)),
71 buildSelector(), buildTreatment(), stat.getPriority(), 78 buildSelector(), buildTreatment(), stat.getPriority(),
72 FlowRuleState.ADDED, stat.getDurationNsec() / 1000000, 79 FlowRuleState.ADDED, stat.getDurationNsec() / 1000000,
...@@ -84,6 +91,26 @@ public class FlowRuleBuilder { ...@@ -84,6 +91,26 @@ public class FlowRuleBuilder {
84 } 91 }
85 } 92 }
86 93
94 + private List<OFAction> getActions(OFFlowStatsEntry entry) {
95 + switch (entry.getVersion()) {
96 + case OF_10:
97 + return entry.getActions();
98 + case OF_11:
99 + case OF_12:
100 + case OF_13:
101 + List<OFInstruction> ins = entry.getInstructions();
102 + for (OFInstruction in : ins) {
103 + if (in.getType().equals(OFInstructionType.APPLY_ACTIONS)) {
104 + OFInstructionApplyActions apply = (OFInstructionApplyActions) in;
105 + return apply.getActions();
106 + }
107 + }
108 + return Lists.newLinkedList();
109 + default:
110 + log.warn("Unknown OF version {}", entry.getVersion());
111 + }
112 + return Lists.newLinkedList();
113 + }
87 114
88 private TrafficTreatment buildTreatment() { 115 private TrafficTreatment buildTreatment() {
89 TrafficTreatment.Builder builder = new DefaultTrafficTreatment.Builder(); 116 TrafficTreatment.Builder builder = new DefaultTrafficTreatment.Builder();
......
...@@ -2,6 +2,7 @@ package org.onlab.onos.provider.of.flow.impl; ...@@ -2,6 +2,7 @@ package org.onlab.onos.provider.of.flow.impl;
2 2
3 import static org.slf4j.LoggerFactory.getLogger; 3 import static org.slf4j.LoggerFactory.getLogger;
4 4
5 +import java.util.List;
5 import java.util.Map; 6 import java.util.Map;
6 7
7 import org.apache.felix.scr.annotations.Activate; 8 import org.apache.felix.scr.annotations.Activate;
...@@ -24,14 +25,22 @@ import org.onlab.onos.openflow.controller.OpenFlowEventListener; ...@@ -24,14 +25,22 @@ import org.onlab.onos.openflow.controller.OpenFlowEventListener;
24 import org.onlab.onos.openflow.controller.OpenFlowSwitch; 25 import org.onlab.onos.openflow.controller.OpenFlowSwitch;
25 import org.onlab.onos.openflow.controller.OpenFlowSwitchListener; 26 import org.onlab.onos.openflow.controller.OpenFlowSwitchListener;
26 import org.onlab.onos.openflow.controller.RoleState; 27 import org.onlab.onos.openflow.controller.RoleState;
28 +import org.projectfloodlight.openflow.protocol.OFActionType;
27 import org.projectfloodlight.openflow.protocol.OFFlowRemoved; 29 import org.projectfloodlight.openflow.protocol.OFFlowRemoved;
28 import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; 30 import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry;
29 import org.projectfloodlight.openflow.protocol.OFFlowStatsReply; 31 import org.projectfloodlight.openflow.protocol.OFFlowStatsReply;
32 +import org.projectfloodlight.openflow.protocol.OFInstructionType;
30 import org.projectfloodlight.openflow.protocol.OFMessage; 33 import org.projectfloodlight.openflow.protocol.OFMessage;
31 import org.projectfloodlight.openflow.protocol.OFPortStatus; 34 import org.projectfloodlight.openflow.protocol.OFPortStatus;
32 import org.projectfloodlight.openflow.protocol.OFStatsReply; 35 import org.projectfloodlight.openflow.protocol.OFStatsReply;
33 import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags; 36 import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags;
34 import org.projectfloodlight.openflow.protocol.OFStatsType; 37 import org.projectfloodlight.openflow.protocol.OFStatsType;
38 +import org.projectfloodlight.openflow.protocol.OFVersion;
39 +import org.projectfloodlight.openflow.protocol.action.OFAction;
40 +import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
41 +import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
42 +import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions;
43 +import org.projectfloodlight.openflow.types.OFPort;
35 import org.slf4j.Logger; 44 import org.slf4j.Logger;
36 45
37 import com.google.common.collect.ArrayListMultimap; 46 import com.google.common.collect.ArrayListMultimap;
...@@ -178,8 +187,9 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -178,8 +187,9 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
178 //final List<FlowRule> entries = Lists.newLinkedList(); 187 //final List<FlowRule> entries = Lists.newLinkedList();
179 188
180 for (OFFlowStatsEntry reply : replies.getEntries()) { 189 for (OFFlowStatsEntry reply : replies.getEntries()) {
190 + if (!tableMissRule(dpid, reply)) {
181 completeEntries.put(did, new FlowRuleBuilder(dpid, reply).build()); 191 completeEntries.put(did, new FlowRuleBuilder(dpid, reply).build());
182 - //entries.add(new FlowRuleBuilder(dpid, reply).build()); 192 + }
183 } 193 }
184 194
185 if (!stats.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) { 195 if (!stats.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
...@@ -189,6 +199,29 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -189,6 +199,29 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
189 } 199 }
190 } 200 }
191 201
202 + private boolean tableMissRule(Dpid dpid, OFFlowStatsEntry reply) {
203 + // TODO NEED TO FIND A BETTER WAY TO AVOID DOING THIS
204 + if (reply.getVersion().equals(OFVersion.OF_10) ||
205 + reply.getMatch().getMatchFields().iterator().hasNext()) {
206 + return false;
207 + }
208 + for (OFInstruction ins : reply.getInstructions()) {
209 + if (ins.getType() == OFInstructionType.APPLY_ACTIONS) {
210 + OFInstructionApplyActions apply = (OFInstructionApplyActions) ins;
211 + List<OFAction> acts = apply.getActions();
212 + for (OFAction act : acts) {
213 + if (act.getType() == OFActionType.OUTPUT) {
214 + OFActionOutput out = (OFActionOutput) act;
215 + if (out.getPort() == OFPort.CONTROLLER) {
216 + return true;
217 + }
218 + }
219 + }
220 + }
221 + }
222 + return false;
223 + }
224 +
192 } 225 }
193 226
194 227
......