diff options
-rw-r--r-- | lib/vconn.c | 16 | ||||
-rw-r--r-- | tests/ofproto.at | 23 |
2 files changed, 38 insertions, 1 deletions
diff --git a/lib/vconn.c b/lib/vconn.c index 5708987d5..2a83eda47 100644 --- a/lib/vconn.c +++ b/lib/vconn.c @@ -631,11 +631,25 @@ vconn_recv(struct vconn *vconn, struct ofpbuf **msgp) type != OFPTYPE_ERROR && type != OFPTYPE_ECHO_REQUEST && type != OFPTYPE_ECHO_REPLY)) { + struct ofpbuf *reply; + VLOG_ERR_RL(&bad_ofmsg_rl, "%s: received OpenFlow version " "0x%02"PRIx8" != expected %02x", vconn->name, oh->version, vconn->version); + + /* Send a "bad version" reply, if we can. */ + reply = ofperr_encode_reply(OFPERR_OFPBRC_BAD_VERSION, oh); + retval = vconn_send(vconn, reply); + if (retval) { + VLOG_INFO_RL(&bad_ofmsg_rl, + "%s: failed to queue error reply (%s)", + vconn->name, ovs_strerror(retval)); + ofpbuf_delete(reply); + } + + /* Suppress the received message, as if it had not arrived. */ + retval = EAGAIN; ofpbuf_delete(msg); - retval = EPROTO; } } } diff --git a/tests/ofproto.at b/tests/ofproto.at index f730465b2..c410d2959 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -6,6 +6,29 @@ AT_CHECK([ovs-ofctl -vwarn probe br0]) OVS_VSWITCHD_STOP AT_CLEANUP +AT_SETUP([ofproto - handling messages with bad version]) +OVS_VSWITCHD_START + +# Start a monitor running OpenFlow 1.0, then send the switch an OF1.1 features +# request +AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile]) +ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log +AT_CAPTURE_FILE([monitor.log]) +ovs-appctl -t ovs-ofctl ofctl/send 0205000801234567 +ovs-appctl -t ovs-ofctl ofctl/barrier +ovs-appctl -t ovs-ofctl exit + +AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)// +/ECHO/d' monitor.log], [0], [dnl +send: OFPT_FEATURES_REQUEST (OF1.1): +OFPT_ERROR (OF1.1): OFPBRC_BAD_VERSION +OFPT_FEATURES_REQUEST (OF1.1): +OFPT_BARRIER_REPLY: +]) + +OVS_VSWITCHD_STOP(["/received OpenFlow version 0x02 != expected 01/d"]) +AT_CLEANUP + AT_SETUP([ofproto - feature request, config request]) OVS_VSWITCHD_START AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout]) |