ofconn_send_error(const struct ofconn *ofconn,
const struct ofp_header *request, int error)
{
- struct ofpbuf *msg = ofputil_encode_error_msg(error, request);
+ struct ofpbuf *msg;
+
+ msg = ofputil_encode_error_msg(error, request);
if (msg) {
+ static struct vlog_rate_limit err_rl = VLOG_RATE_LIMIT_INIT(10, 10);
+
+ if (!VLOG_DROP_INFO(&err_rl)) {
+ const struct ofputil_msg_type *type;
+ const char *type_name;
+ size_t request_len;
+ char *error_s;
+
+ request_len = ntohs(request->length);
+ type_name = (!ofputil_decode_msg_type_partial(request,
+ MIN(64, request_len),
+ &type)
+ ? ofputil_msg_type_name(type)
+ : "invalid");
+
+ error_s = ofputil_error_to_string(error);
+ VLOG_INFO("%s: sending %s error reply to %s message",
+ rconn_get_name(ofconn->rconn), error_s, type_name);
+ free(error_s);
+ }
ofconn_send_reply(ofconn, msg);
}
}
/* Checks whether 'ofconn' is a slave controller. If so, returns an OpenFlow
* error message code (composed with ofp_mkerr()) for the caller to propagate
- * upward. Otherwise, returns 0.
- *
- * The log message mentions 'msg_type'. */
+ * upward. Otherwise, returns 0. */
static int
-reject_slave_controller(struct ofconn *ofconn, const char *msg_type)
+reject_slave_controller(const struct ofconn *ofconn)
{
if (ofconn_get_type(ofconn) == OFCONN_PRIMARY
&& ofconn_get_role(ofconn) == NX_ROLE_SLAVE) {
- static struct vlog_rate_limit perm_rl = VLOG_RATE_LIMIT_INIT(1, 5);
- VLOG_WARN_RL(&perm_rl, "rejecting %s message from slave controller",
- msg_type);
-
return ofp_mkerr(OFPET_BAD_REQUEST, OFPBRC_EPERM);
} else {
return 0;
COVERAGE_INC(ofproto_packet_out);
- error = reject_slave_controller(ofconn, "OFPT_PACKET_OUT");
+ error = reject_slave_controller(ofconn);
if (error) {
return error;
}
struct ofport *port;
int error;
- error = reject_slave_controller(ofconn, "OFPT_PORT_MOD");
+ error = reject_slave_controller(ofconn);
if (error) {
return error;
}
struct ofputil_flow_mod fm;
int error;
- error = reject_slave_controller(ofconn, "flow_mod");
+ error = reject_slave_controller(ofconn);
if (error) {
return error;
}
uint32_t role;
if (ofconn_get_type(ofconn) != OFCONN_PRIMARY) {
- VLOG_WARN_RL(&rl, "ignoring role request on service connection");
return ofp_mkerr(OFPET_BAD_REQUEST, OFPBRC_EPERM);
}
role = ntohl(nrr->role);
if (role != NX_ROLE_OTHER && role != NX_ROLE_MASTER
&& role != NX_ROLE_SLAVE) {
- VLOG_WARN_RL(&rl, "received request for unknown role %"PRIu32, role);
-
/* There's no good error code for this. */
return ofp_mkerr(OFPET_BAD_REQUEST, -1);
}
case OFPUTIL_NXST_FLOW_REPLY:
case OFPUTIL_NXST_AGGREGATE_REPLY:
default:
- if (VLOG_IS_WARN_ENABLED()) {
- char *s = ofp_to_string(oh, ntohs(oh->length), 2);
- VLOG_DBG_RL(&rl, "OpenFlow message ignored: %s", s);
- free(s);
- }
if (oh->type == OFPT_STATS_REQUEST || oh->type == OFPT_STATS_REPLY) {
return ofp_mkerr(OFPET_BAD_REQUEST, OFPBRC_BAD_STAT);
} else {