X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fofp-errors.c;h=bd4e43a4ed93d99e60a0ecaf4326531cb5292394;hb=003ce655b7116d18c86a74c50391e54990346931;hp=d1e4dbf98edd91561b9fde512dfeb2de0cb9338c;hpb=1f317cb5c2aa446c4b0252634a4a70dcc3682f93;p=sliver-openvswitch.git diff --git a/lib/ofp-errors.c b/lib/ofp-errors.c index d1e4dbf98..bd4e43a4e 100644 --- a/lib/ofp-errors.c +++ b/lib/ofp-errors.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013 Nicira, Inc. + * Copyright (c) 2012, 2013, 2014 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -272,8 +272,10 @@ ofperr_get_code(enum ofperr error, enum ofp_version version) /* Tries to decode 'oh', which should be an OpenFlow OFPT_ERROR message. * Returns an OFPERR_* constant on success, 0 on failure. * - * If 'payload' is nonnull, on success '*payload' is initialized to the - * error's payload, and on failure it is cleared. */ + * If 'payload' is nonnull, on success '*payload' is initialized with a copy of + * the error's payload (copying is required because the payload is not properly + * aligned). The caller must free the payload (with ofpbuf_uninit()) when it + * is no longer needed. On failure, '*payload' is cleared. */ enum ofperr ofperr_decode_msg(const struct ofp_header *oh, struct ofpbuf *payload) { @@ -323,7 +325,8 @@ ofperr_decode_msg(const struct ofp_header *oh, struct ofpbuf *payload) /* Translate the error type and code into an ofperr. */ error = ofperr_decode(oh->version, vendor, type, code); if (error && payload) { - ofpbuf_use_const(payload, ofpbuf_data(&b), ofpbuf_size(&b)); + ofpbuf_init(payload, ofpbuf_size(&b)); + ofpbuf_push(payload, ofpbuf_data(&b), ofpbuf_size(&b)); } return error; }