@Override void processOFError(OFChannelHandler h, OFErrorMsg m) throws IOException, SwitchStateException { // if we get here, then the error message is for something else if (m.getErrType() == OFErrorType.BAD_REQUEST && ((OFBadRequestErrorMsg) m).getCode() == OFBadRequestCode.EPERM) { // We are the master controller and the switch returned // a permission error. This is a likely indicator that // the switch thinks we are slave. Reassert our // role // FIXME: this could be really bad during role transitions // if two controllers are master (even if its only for // a brief period). We might need to see if these errors // persist before we reassert h.sw.reassertRole(); } else if (m.getErrType() == OFErrorType.FLOW_MOD_FAILED && ((OFFlowModFailedErrorMsg) m).getCode() == OFFlowModFailedCode.ALL_TABLES_FULL) { h.sw.setTableFull(true); } else { logError(h, m); } h.dispatchMessage(m); }
@Override void processOFError(OFErrorMsg m) { /* * HP ProCurve switches do not support * the ofpt_barrier_request message. * * Look for an error from a bad ofpt_barrier_request, * log a warning, but proceed. */ if (m.getErrType() == OFErrorType.BAD_REQUEST && ((OFBadRequestErrorMsg) m).getCode() == OFBadRequestCode.BAD_TYPE && ((OFBadRequestErrorMsg) m).getData().getParsedMessage().get() instanceof OFBarrierRequest) { log.warn("Switch does not support Barrier Request messages. Could be an HP ProCurve."); } else { logErrorDisconnect(m); } }
@Override void processOFError(OFChannelHandler h, OFErrorMsg m) { if (m.getErrType() == OFErrorType.BAD_REQUEST) { OFBadRequestErrorMsg badRequest = (OFBadRequestErrorMsg) m; if (badRequest.getCode() == OFBadRequestCode.BAD_TYPE) { log.debug("{} does not support GetConfig, moving on", h.getSwitchInfoString()); try { nextState(h); return; } catch (IOException e) { log.error("Exception thrown transitioning to next", e); logErrorDisconnect(h, m); } } } logErrorDisconnect(h, m); }
@Override void processOFError(OFErrorMsg m) { if ((m.getErrType() == OFErrorType.BAD_REQUEST) && ((((OFBadRequestErrorMsg)m).getCode() == OFBadRequestCode.MULTIPART_BUFFER_OVERFLOW) || ((OFBadRequestErrorMsg)m).getCode() == OFBadRequestCode.BAD_STAT)) { log.warn("Switch {} is {} but does not support OFTableFeaturesStats. Assuming all tables can perform any match, action, and instruction in the spec.", sw.getId().toString(), sw.getOFFactory().getVersion().toString()); } else { log.error("Received unexpected OFErrorMsg {} on switch {}.", m.toString(), sw.getId().toString()); } nextState(); }
@Override void processOFError(OFErrorMsg m) { // role changer will ignore the error if it isn't for it boolean didHandle = roleChanger.deliverError(m); if (didHandle) return; if ((m.getErrType() == OFErrorType.BAD_REQUEST) && (((OFBadRequestErrorMsg)m).getCode() == OFBadRequestCode.EPERM)) { // We are the master controller and the switch returned // a permission error. This is a likely indicator that // the switch thinks we are slave. Reassert our // role // FIXME: this could be really bad during role transitions // if two controllers are master (even if its only for // a brief period). We might need to see if these errors // persist before we reassert switchManagerCounters.epermErrorWhileSwitchIsMaster.increment(); log.warn("Received permission error from switch {} while" + "being master. Reasserting master role.", getSwitchInfoString()); reassertRole(OFControllerRole.ROLE_MASTER); } else if ((m.getErrType() == OFErrorType.FLOW_MOD_FAILED) && (((OFFlowModFailedErrorMsg)m).getCode() == OFFlowModFailedCode.ALL_TABLES_FULL)) { sw.setTableFull(true); } else { logError(m); } dispatchMessage(m); }
@LogMessageDoc(level="WARN", message="Received permission error from switch {} while" + "being master. Reasserting master role.", explanation="The switch has denied an operation likely " + "indicating inconsistent controller roles", recommendation="This situation can occurs transiently during role" + " changes. If, however, the condition persists or happens" + " frequently this indicates a role inconsistency. " + LogMessageDoc.CHECK_CONTROLLER ) @Override void processOFError(OFErrorMsg m) { // role changer will ignore the error if it isn't for it boolean didHandle = roleChanger.deliverError(m); if (didHandle) return; if ((m.getErrType() == OFErrorType.BAD_REQUEST) && (((OFBadRequestErrorMsg)m).getCode() == OFBadRequestCode.EPERM)) { // We are the master controller and the switch returned // a permission error. This is a likely indicator that // the switch thinks we are slave. Reassert our // role // FIXME: this could be really bad during role transitions // if two controllers are master (even if its only for // a brief period). We might need to see if these errors // persist before we reassert switchManagerCounters.epermErrorWhileSwitchIsMaster.increment(); log.warn("Received permission error from switch {} while" + "being master. Reasserting master role.", getSwitchInfoString()); reassertRole(OFControllerRole.ROLE_MASTER); } else if ((m.getErrType() == OFErrorType.FLOW_MOD_FAILED) && (((OFFlowModFailedErrorMsg)m).getCode() == OFFlowModFailedCode.ALL_TABLES_FULL)) { sw.setTableFull(true); } else { logError(m); } dispatchMessage(m); }
@Override void processOFError(OFErrorMsg m) { // role changer will ignore the error if it isn't for it boolean didHandle = roleChanger.deliverError(m); if (didHandle) return; if ((m.getErrType() == OFErrorType.BAD_REQUEST) && (((OFBadRequestErrorMsg)m).getCode() == OFBadRequestCode.EPERM)) { // We are the EQUAL controller and the switch returned // a permission error. This is a likely indicator that // the switch thinks we are slave. Reassert our // role // FIXME: this could be really bad during role transitions // if two controllers are master (even if its only for // a brief period). We might need to see if these errors // persist before we reassert switchManagerCounters.epermErrorWhileSwitchIsMaster.increment(); log.warn("Received permission error from switch {} while" + "being master. Reasserting master role.", getSwitchInfoString()); reassertRole(OFControllerRole.ROLE_EQUAL); } else if ((m.getErrType() == OFErrorType.FLOW_MOD_FAILED) && (((OFFlowModFailedErrorMsg)m).getCode() == OFFlowModFailedCode.ALL_TABLES_FULL)) { sw.setTableFull(true); } else { logError(m); } dispatchMessage(m); }
@Override void processOFError(OFChannelHandler h, OFErrorMsg m) throws IOException, SwitchStateException { // if we get here, then the error message is for something else if (m.getErrType() == OFErrorType.BAD_REQUEST && (((OFBadRequestErrorMsg) m).getCode() == OFBadRequestCode.EPERM || ((OFBadRequestErrorMsg) m).getCode() == OFBadRequestCode.IS_SLAVE)) { // We are the master controller and the switch returned // a permission error. This is a likely indicator that // the switch thinks we are slave. Reassert our // role // FIXME: this could be really bad during role transitions // if two controllers are master (even if its only for // a brief period). We might need to see if these errors // persist before we reassert h.sw.reassertRole(); } else if (m.getErrType() == OFErrorType.FLOW_MOD_FAILED && ((OFFlowModFailedErrorMsg) m).getCode() == OFFlowModFailedCode.ALL_TABLES_FULL) { h.sw.setTableFull(true); } else { logError(h, m); } h.dispatchMessage(m); }
@Override public void processControllerCommand(Channel channel, OFMessage msg) { OFControllerRole myRole = role(channel); if (OFControllerRole.ROLE_SLAVE.equals(myRole)) { OFBadRequestErrorMsg errorMsg = FACTORY.errorMsgs() .buildBadRequestErrorMsg() .setXid(msg.getXid()) .setCode(OFBadRequestCode.IS_SLAVE) .build(); channel.writeAndFlush(Collections.singletonList(errorMsg)); return; } switch (msg.getType()) { case PORT_MOD: OFPortMod portMod = (OFPortMod) msg; processPortMod(portMod); break; case FLOW_MOD: OFFlowMod flowMod = (OFFlowMod) msg; processFlowMod(flowMod); break; case GROUP_MOD: OFGroupMod groupMod = (OFGroupMod) msg; processGroupMod(groupMod); break; case METER_MOD: OFMeterMod meterMod = (OFMeterMod) msg; processMeterMod(meterMod, channel); break; case TABLE_MOD: log.debug("processControllerCommand: {} not yet supported for {}", msg.getType(), msg); break; default: log.warn("Unexpected message {} received for switch {}", msg.getType(), this); } }
/** * Called if we receive an error message. If the xid matches the * pending request we handle it otherwise we ignore it. * * Note: since we only keep the last pending request we might get * error messages for earlier role requests that we won't be able * to handle */ @Override public synchronized RoleRecvStatus deliverError(OFErrorMsg error) throws SwitchStateException { RoleState errorRole = pendingReplies.getIfPresent(error.getXid()); if (errorRole == null) { if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) { log.debug("Received an error msg from sw {} for a role request," + " but not for pending request in role-changer; " + " ignoring error {} ...", sw.getStringId(), error); } else { log.debug("Received an error msg from sw {}, but no pending " + "requests in role-changer; not handling ...", sw.getStringId()); } return RoleRecvStatus.OTHER_EXPECTATION; } // it is an error related to a currently pending role request message if (error.getErrType() == OFErrorType.BAD_REQUEST) { log.error("Received a error msg {} from sw {} for " + "pending role request {}. Switch driver indicates " + "role-messaging is supported. Possible issues in " + "switch driver configuration?", ((OFBadRequestErrorMsg) error).toString(), sw.getStringId(), errorRole); return RoleRecvStatus.UNSUPPORTED; } if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) { OFRoleRequestFailedErrorMsg rrerr = (OFRoleRequestFailedErrorMsg) error; switch (rrerr.getCode()) { case BAD_ROLE: // switch says that current-role-req has bad role? // for now we disconnect // fall-thru case STALE: // switch says that current-role-req has stale gen-id? // for now we disconnect // fall-thru case UNSUP: // switch says that current-role-req has role that // cannot be supported? for now we disconnect String msgx = String.format("Switch: [%s], " + "received Error to for pending role request [%s]. " + "Error:[%s]. Disconnecting switch ... ", sw.getStringId(), errorRole, rrerr); throw new SwitchStateException(msgx); default: break; } } // This error message was for a role request message but we dont know // how to handle errors for nicira role request messages return RoleRecvStatus.OTHER_EXPECTATION; }
/** * Called if we receive an error message. If the xid matches the * pending request we handle it otherwise we ignore it. * * Note: since we only keep the last pending request we might get * error messages for earlier role requests that we won't be able * to handle */ @Override public synchronized RoleRecvStatus deliverError(OFErrorMsg error) throws SwitchStateException { RoleState errorRole = pendingReplies.getIfPresent(error.getXid()); if (errorRole == null) { if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) { log.debug("Received an error msg from sw {} for a role request," + " but not for pending request in role-changer; " + " ignoring error {} ...", sw.getStringId(), error); } else { log.debug("Received an error msg from sw {}, but no pending " + "requests in role-changer; not handling ...", sw.getStringId()); } return RoleRecvStatus.OTHER_EXPECTATION; } // it is an error related to a currently pending role request message if (error.getErrType() == OFErrorType.BAD_REQUEST) { log.error("Received a error msg {} from sw {} for " + "pending role request {}. Switch driver indicates " + "role-messaging is supported. Possible issues in " + "switch driver configuration?", new Object[] { ((OFBadRequestErrorMsg) error).toString(), sw.getStringId(), errorRole }); return RoleRecvStatus.UNSUPPORTED; } if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) { OFRoleRequestFailedErrorMsg rrerr = (OFRoleRequestFailedErrorMsg) error; switch (rrerr.getCode()) { case BAD_ROLE: // switch says that current-role-req has bad role? // for now we disconnect // fall-thru case STALE: // switch says that current-role-req has stale gen-id? // for now we disconnect // fall-thru case UNSUP: // switch says that current-role-req has role that // cannot be supported? for now we disconnect String msgx = String.format("Switch: [%s], " + "received Error to for pending role request [%s]. " + "Error:[%s]. Disconnecting switch ... ", sw.getStringId(), errorRole, rrerr); throw new SwitchStateException(msgx); default: break; } } // This error message was for a role request message but we dont know // how to handle errors for nicira role request messages return RoleRecvStatus.OTHER_EXPECTATION; }
/** * Called if we receive an error message. If the xid matches the pending * request we handle it otherwise we ignore it. * * Note: since we only keep the last pending request we might get error * messages for earlier role requests that we won't be able to handle */ synchronized RoleRecvStatus deliverError(OFErrorMsg error) throws SwitchStateException { if (!requestPending) { log.debug("Received an error msg from sw {}, but no pending " + "requests in role-changer; not handling ...", getSwitchInfoString()); return RoleRecvStatus.OTHER_EXPECTATION; } if (pendingXid != error.getXid()) { if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) { log.debug("Received an error msg from sw {} for a role request," + " but not for pending request in role-changer; " + " ignoring error {} ...", getSwitchInfoString(), error); } return RoleRecvStatus.OTHER_EXPECTATION; } // it is an error related to a currently pending role request // message requestPending = false; // we got a response, even though it is an // error if (error.getErrType() == OFErrorType.BAD_REQUEST) { counters.roleReplyErrorUnsupported.updateCounterWithFlush(); log.error("Received a error msg {} from sw {} in state {} for " + "pending role request {}. Switch driver indicates " + "role-messaging is supported. Possible issues in " + "switch driver configuration?", new Object[] { ((OFBadRequestErrorMsg) error).toString(), getSwitchInfoString(), state, pendingRole }); return RoleRecvStatus.UNSUPPORTED; } if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) { OFRoleRequestFailedErrorMsg rrerr = (OFRoleRequestFailedErrorMsg) error; switch (rrerr.getCode()) { case BAD_ROLE: // switch says that current-role-req has bad role? // for now we disconnect // fall-thru case STALE: // switch says that current-role-req has stale gen-id? // for now we disconnect // fall-thru case UNSUP: // switch says that current-role-req has role that // cannot be supported? for now we disconnect String msgx = String.format("Switch: [%s], State: [%s], " + "received Error to for pending role request [%s]. " + "Error:[%s]. Disconnecting switch ... ", OFChannelHandler.this.getSwitchInfoString(), OFChannelHandler.this.state.toString(), pendingRole, rrerr); throw new SwitchStateException(msgx); default: break; } } // This error message was for a role request message but we dont // know // how to handle errors for nicira role request messages return RoleRecvStatus.OTHER_EXPECTATION; }
@LogMessageDoc(level = "WARN", message = "Received permission error from switch {} while" + "being master. Reasserting master role.", explanation = "The switch has denied an operation likely " + "indicating inconsistent controller roles", recommendation = "This situation can occurs transiently during role" + " changes. If, however, the condition persists or happens" + " frequently this indicates a role inconsistency. " + LogMessageDoc.CHECK_CONTROLLER) @Override void processOFError(OFChannelHandler h, OFErrorMsg m) throws IOException, SwitchStateException { // first check if the error msg is in response to a role-request // message RoleRecvStatus rrstatus = h.roleChanger.deliverError(m); if (rrstatus != RoleRecvStatus.OTHER_EXPECTATION) { // rolechanger has handled the error message - we are done return; } // if we get here, then the error message is for something else if (m.getErrType() == OFErrorType.BAD_REQUEST && ((OFBadRequestErrorMsg) m).getCode() == OFBadRequestCode.EPERM) { // We are the master controller and the switch returned // a permission error. This is a likely indicator that // the switch thinks we are slave. Reassert our // role // FIXME: this could be really bad during role transitions // if two controllers are master (even if its only for // a brief period). We might need to see if these errors // persist before we reassert h.counters.epermErrorWhileSwitchIsMaster.updateCounterWithFlush(); log.warn("Received permission error from switch {} while" + "being master. Reasserting master role.", h.getSwitchInfoString()); // h.controller.reassertRole(h, Role.MASTER); // XXX S reassert in role changer or reconsider if all this // stuff is really needed } else if (m.getErrType() == OFErrorType.FLOW_MOD_FAILED && ((OFFlowModFailedErrorMsg) m).getCode() == OFFlowModFailedCode.ALL_TABLES_FULL) { h.sw.setTableFull(true); } else { logError(h, m); } h.dispatchMessage(m); }