X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fconnection%2Flistener%2FOpenflowProtocolListenerInitialImpl.java;h=fb6cdcb0282033028ac05529287a3b2b4244edb7;hb=c1eaf465f43b9cddf8065bafbc04af408cd134ee;hp=a69696a6734d0d06753aa2c8ed2055af1fefa231;hpb=213dc5f10a2193184808e67f5fb81edc19ccd8bc;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/OpenflowProtocolListenerInitialImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/OpenflowProtocolListenerInitialImpl.java index a69696a673..fb6cdcb028 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/OpenflowProtocolListenerInitialImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/OpenflowProtocolListenerInitialImpl.java @@ -46,7 +46,9 @@ public class OpenflowProtocolListenerInitialImpl implements OpenflowProtocolList @Override public void onEchoRequestMessage(final EchoRequestMessage echoRequestMessage) { - LOG.debug("echo request received: {}", echoRequestMessage.getXid()); + if (LOG.isDebugEnabled()) { + LOG.debug("echo request received: {}", echoRequestMessage.getXid()); + } EchoReplyInputBuilder builder = new EchoReplyInputBuilder(); builder.setVersion(echoRequestMessage.getVersion()); builder.setXid(echoRequestMessage.getXid()); @@ -57,52 +59,63 @@ public class OpenflowProtocolListenerInitialImpl implements OpenflowProtocolList @Override public void onErrorMessage(final ErrorMessage notification) { - // TODO: log + LOG.debug("NOOP: Error message received during handshake phase: {}", notification); } @Override public void onExperimenterMessage(final ExperimenterMessage notification) { - // NOOP - + LOG.debug("NOOP: Experimenter message during handshake phase not supported: {}", notification); } @Override public void onFlowRemovedMessage(final FlowRemovedMessage notification) { - // NOOP + LOG.debug("NOOP: Flow-removed message during handshake phase not supported: {}", notification); } @Override public void onHelloMessage(final HelloMessage hello) { - LOG.debug("processing HELLO.xid: {}", hello.getXid()); - if (connectionContext.getConnectionState() == null) { - connectionContext.setConnectionState(ConnectionContext.CONNECTION_STATE.HANDSHAKING); - } - - if (checkState(ConnectionContext.CONNECTION_STATE.HANDSHAKING)) { - final HandshakeStepWrapper handshakeStepWrapper = new HandshakeStepWrapper( - hello, handshakeContext.getHandshakeManager(), connectionContext.getConnectionAdapter()); - //handshakeContext.getHandshakePool().submit(handshakeStepWrapper); - // use up netty thread - handshakeStepWrapper.run(); + LOG.debug("processing HELLO.xid: {} from device {}", hello.getXid(), + connectionContext.getConnectionAdapter().getRemoteAddress()); + final ConnectionContext.CONNECTION_STATE connectionState = connectionContext.getConnectionState(); + if (connectionState == null + || ConnectionContext.CONNECTION_STATE.HANDSHAKING.equals(connectionState)) { + synchronized (connectionContext) { + if (connectionContext.getConnectionState() == null) { + // got here before connection ready notification + connectionContext.changeStateToHandshaking(); + } + + if (checkState(ConnectionContext.CONNECTION_STATE.HANDSHAKING)) { + final HandshakeStepWrapper handshakeStepWrapper = new HandshakeStepWrapper( + hello, handshakeContext.getHandshakeManager(), connectionContext.getConnectionAdapter()); + // use up netty thread + handshakeStepWrapper.run(); + } else { + LOG.debug("already out of handshake phase but still received hello message from device {}", + connectionContext.getConnectionAdapter().getRemoteAddress()); + } + } } else { //TODO: consider disconnecting of bad behaving device + LOG.warn("Hello message received outside handshake phase:{} ", hello); + LOG.debug("already touched by onConnectionReady event from device {} (or finished handshake)", + connectionContext.getConnectionAdapter().getRemoteAddress()); } - } @Override public void onMultipartReplyMessage(final MultipartReplyMessage notification) { - // NOOP + LOG.debug("NOOP: Multipart-reply message during handshake phase not supported: {}", notification); } @Override public void onPacketInMessage(final PacketInMessage notification) { - // NOOP + LOG.debug("NOOP: Packet-in message during handshake phase not supported: {}", notification); } @Override public void onPortStatusMessage(final PortStatusMessage notification) { - // NOOP + connectionContext.handlePortStatusMessage(notification); } /**