netdev-dpdk: fix mbuf leaks
[cascardo/ovs.git] / lib / ofp-errors.c
index bd4e43a..f9e1fa9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2012, 2013, 2014, 2016 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@
 #include "ofp-util.h"
 #include "ofpbuf.h"
 #include "openflow/openflow.h"
-#include "vlog.h"
+#include "openvswitch/vlog.h"
 
 VLOG_DEFINE_THIS_MODULE(ofp_errors);
 
@@ -52,6 +52,8 @@ ofperr_domain_from_version(enum ofp_version version)
         return &ofperr_of13;
     case OFP14_VERSION:
         return &ofperr_of14;
+    case OFP15_VERSION:
+        return &ofperr_of15;
     default:
         return NULL;
     }
@@ -282,17 +284,15 @@ ofperr_decode_msg(const struct ofp_header *oh, struct ofpbuf *payload)
     const struct ofp_error_msg *oem;
     enum ofpraw raw;
     uint16_t type, code;
-    enum ofperr error;
     uint32_t vendor;
-    struct ofpbuf b;
 
     if (payload) {
         memset(payload, 0, sizeof *payload);
     }
 
     /* Pull off the error message. */
-    ofpbuf_use_const(&b, oh, ntohs(oh->length));
-    error = ofpraw_pull(&raw, &b);
+    struct ofpbuf b = ofpbuf_const_initializer(oh, ntohs(oh->length));
+    enum ofperr error = ofpraw_pull(&raw, &b);
     if (error) {
         return 0;
     }
@@ -325,8 +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_init(payload, ofpbuf_size(&b));
-        ofpbuf_push(payload, ofpbuf_data(&b), ofpbuf_size(&b));
+        ofpbuf_init(payload, b.size);
+        ofpbuf_push(payload, b.data, b.size);
     }
     return error;
 }