diff options
author | Ashlee Young <ashlee@onosfw.com> | 2015-10-23 08:31:31 -0700 |
---|---|---|
committer | Ashlee Young <ashlee@onosfw.com> | 2015-10-23 08:31:31 -0700 |
commit | e52e67767076b29cb01939aa7bdd8fee9d205cc1 (patch) | |
tree | b8c2d28231bccc2a280fea429a9af7297c62f58f /framework/src/onos/openflow | |
parent | a912c5ce9968da5936a695064f22083898e7b93d (diff) |
Update ONOS src to commit id 69b36d5d11e81e28e56b46ba44e4b8cd701c5867
Change-Id: I9c13045711dbf9c0181106b66a6bf22c72bcf330
Signed-off-by: Ashlee Young <ashlee@onosfw.com>
Diffstat (limited to 'framework/src/onos/openflow')
3 files changed, 33 insertions, 6 deletions
diff --git a/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitch.java b/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitch.java index 1b6810be..51a2ce42 100644 --- a/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitch.java +++ b/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitch.java @@ -30,6 +30,14 @@ public interface OpenFlowSwitch { /** * Writes the message to the driver. * + * Note: + * Calling {@link #sendMsg(OFMessage)} does NOT guarantee the messages to be + * transmitted on the wire in order, especially during role transition. + * The messages may be reordered at the switch side. + * + * Calling {@link #sendMsg(List)} guarantee the messages inside the list + * to be transmitted on the wire in order. + * * @param msg the message to write */ void sendMsg(OFMessage msg); diff --git a/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java b/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java index 2f6357bd..2c19837e 100644 --- a/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java +++ b/framework/src/onos/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java @@ -79,6 +79,8 @@ public abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour protected OFFeaturesReply features; protected OFDescStatsReply desc; + List<OFMessage> messagesPendingMastership; + @Override public void init(Dpid dpid, OFDescStatsReply desc, OFVersion ofv) { this.dpid = dpid; @@ -96,16 +98,21 @@ public abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour } @Override - public void sendMsg(OFMessage m) { - if (role == RoleState.MASTER && channel.isConnected()) { - channel.write(Collections.singletonList(m)); - } + public void sendMsg(OFMessage msg) { + this.sendMsg(Collections.singletonList(msg)); } @Override public final void sendMsg(List<OFMessage> msgs) { if (role == RoleState.MASTER && channel.isConnected()) { channel.write(msgs); + } else if (messagesPendingMastership != null) { + messagesPendingMastership.addAll(msgs); + log.debug("Enqueue message for switch {}. queue size after is {}", + dpid, messagesPendingMastership.size()); + } else { + log.warn("Dropping message for switch {} (role: {}, connected: {}): {}", + dpid, role, channel.isConnected(), msgs); } } @@ -232,6 +239,12 @@ public abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour @Override public final void transitionToMasterSwitch() { this.agent.transitionToMasterSwitch(dpid); + if (messagesPendingMastership != null) { + this.sendMsg(messagesPendingMastership); + log.debug("Sending {} pending messages to switch {}", + messagesPendingMastership.size(), dpid); + messagesPendingMastership = null; + } } @Override @@ -278,6 +291,11 @@ public abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour log.debug("Sending role {} to switch {}", role, getStringId()); if (role == RoleState.SLAVE || role == RoleState.EQUAL) { this.role = role; + } else { + if (messagesPendingMastership == null) { + log.debug("Initializing new queue for switch {}", dpid); + messagesPendingMastership = new ArrayList<>(); + } } } else { this.role = role; diff --git a/framework/src/onos/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageEncoder.java b/framework/src/onos/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageEncoder.java index df7865d3..4c1b16fe 100644 --- a/framework/src/onos/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageEncoder.java +++ b/framework/src/onos/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageEncoder.java @@ -25,7 +25,6 @@ import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; import org.projectfloodlight.openflow.protocol.OFMessage; - /** * Encode an openflow message for output into a ChannelBuffer, for use in a * netty pipeline. @@ -50,7 +49,9 @@ public class OFMessageEncoder extends OneToOneEncoder { ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); for (OFMessage ofm : msglist) { - ofm.writeTo(buf); + if (ofm != null) { + ofm.writeTo(buf); + } } return buf; } |