From: Ben Pfaff Date: Thu, 7 Nov 2013 17:39:03 +0000 (-0800) Subject: vconn: Reply with OFPBRC_BAD_VERSION for bad version. X-Git-Tag: v2.1.0~140 X-Git-Url: http://git.cascardo.eti.br/?a=commitdiff_plain;h=2b4cca6fc24ece6c727f877a9f17dd5f32da7f84;p=cascardo%2Fovs.git vconn: Reply with OFPBRC_BAD_VERSION for bad version. Testers keep wanting to know why this doesn't work. I think it's a silly test, but it's easy enough to make them happy. Signed-off-by: Ben Pfaff --- 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])