X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fofp-util.c;fp=lib%2Fofp-util.c;h=ad3fb369219fe8f666219719be1ef1fa40f4d9a4;hb=e43928f2862b83a3c13e8662490a22fa25405be5;hp=6ff9df894b72564f15693982d00a38aef96250e3;hpb=7cd903564fa4f64a815af311232213f0e770d012;p=openvswitch diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 6ff9df89..ad3fb369 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -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) {