mirror of
https://github.com/openvswitch/ovs
synced 2025-10-25 15:07:05 +00:00
ofp-util: Make ofputil_encode_set_protocol() able to return failure.
Soon, it's not going to be possible to switch between every possible protocol on an established OpenFlow connection, yet ofputil_encode_set_protocol() didn't have a documented way to report such a problem. This commit adds a means for reporting and makes its callers able to handle the problem. Also, initially make ofputil_encode_set_protocol() fail when the current and requested protocols are for different OpenFlow versions. Signed-off-by: Ben Pfaff <blp@nicira.com> Reviewed-by: Simon Horman <horms@verge.net.au>
This commit is contained in:
@@ -1201,15 +1201,25 @@ ofputil_encode_hello(uint32_t allowed_versions)
|
||||
* connection if the switch processes the returned message correctly. (If
|
||||
* '*next != want' then the caller will have to iterate.)
|
||||
*
|
||||
* If 'current == want', returns NULL and stores 'current' in '*next'. */
|
||||
* If 'current == want', or if it is not possible to transition from 'current'
|
||||
* to 'want' (because, for example, 'current' and 'want' use different OpenFlow
|
||||
* protocol versions), returns NULL and stores 'current' in '*next'. */
|
||||
struct ofpbuf *
|
||||
ofputil_encode_set_protocol(enum ofputil_protocol current,
|
||||
enum ofputil_protocol want,
|
||||
enum ofputil_protocol *next)
|
||||
{
|
||||
enum ofp_version cur_version, want_version;
|
||||
enum ofputil_protocol cur_base, want_base;
|
||||
bool cur_tid, want_tid;
|
||||
|
||||
cur_version = ofputil_protocol_to_ofp_version(current);
|
||||
want_version = ofputil_protocol_to_ofp_version(want);
|
||||
if (cur_version != want_version) {
|
||||
*next = current;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cur_base = ofputil_protocol_to_base(current);
|
||||
want_base = ofputil_protocol_to_base(want);
|
||||
if (cur_base != want_base) {
|
||||
|
||||
Reference in New Issue
Block a user