[ovs-dev] [PATCH 2/5] ofpbuf: Introduce access api for base, data and size.

Pravin pshelar at nicira.com
Tue Apr 1 04:43:18 UTC 2014


From: Pravin Shelar <pshelar at nicira.com>

These functions will be used by later patches.  Following patch
does not change functionality.

Signed-off-by: Pravin B Shelar <pshelar at nicira.com>
---
 lib/bfd.c                     |    2 +-
 lib/cfm.c                     |    2 +-
 lib/dpif-linux.c              |   28 ++---
 lib/dpif-netdev.c             |   27 ++---
 lib/dpif-netdev.h             |    4 +-
 lib/dpif.c                    |   14 +--
 lib/flow.c                    |   54 ++++-----
 lib/jsonrpc.c                 |    6 +-
 lib/lacp.c                    |    2 +-
 lib/learn.c                   |   12 +-
 lib/learning-switch.c         |   20 ++--
 lib/netdev-dpdk.c             |   18 +--
 lib/netdev-dummy.c            |   26 ++---
 lib/netdev-linux.c            |   12 +-
 lib/netlink-socket.c          |   44 +++----
 lib/netlink.c                 |   26 ++---
 lib/nx-match.c                |   29 ++---
 lib/odp-util.c                |   14 +--
 lib/ofp-actions.c             |   44 +++----
 lib/ofp-errors.c              |    2 +-
 lib/ofp-msgs.c                |   42 +++----
 lib/ofp-parse.c               |   40 +++----
 lib/ofp-print.c               |   12 +-
 lib/ofp-util.c                |  252 ++++++++++++++++++++---------------------
 lib/ofpbuf.c                  |   82 +++++++-------
 lib/ofpbuf.h                  |   69 ++++++++---
 lib/packets.c                 |    8 +-
 lib/pcap-file.c               |    8 +-
 lib/rconn.c                   |   12 +-
 lib/route-table.c             |    2 +-
 lib/rtnetlink-link.c          |    2 +-
 lib/stp.c                     |    2 +-
 lib/stream-ssl.c              |    5 +-
 lib/vconn-stream.c            |   22 ++--
 lib/vconn.c                   |   28 ++---
 ofproto/connmgr.c             |    3 +-
 ofproto/fail-open.c           |    8 +-
 ofproto/in-band.c             |    2 +-
 ofproto/netflow.c             |   12 +-
 ofproto/ofproto-dpif-ipfix.c  |   28 ++---
 ofproto/ofproto-dpif-sflow.c  |    6 +-
 ofproto/ofproto-dpif-upcall.c |   30 ++---
 ofproto/ofproto-dpif-xlate.c  |   43 +++----
 ofproto/ofproto-dpif.c        |   43 +++----
 ofproto/ofproto.c             |    4 +-
 tests/test-bundle.c           |    2 +-
 tests/test-flows.c            |    4 +-
 tests/test-netflow.c          |    6 +-
 tests/test-odp.c              |   22 ++--
 tests/test-sflow.c            |    6 +-
 tests/test-vconn.c            |   10 +-
 utilities/ovs-dpctl.c         |   23 ++--
 utilities/ovs-ofctl.c         |  173 ++++++++++++++--------------
 vswitchd/bridge.c             |    4 +-
 54 files changed, 728 insertions(+), 673 deletions(-)

diff --git a/lib/bfd.c b/lib/bfd.c
index cc9e453..a74ace6 100644
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -673,7 +673,7 @@ bfd_process_packet(struct bfd *bfd, const struct flow *flow,
         goto out;
     }
 
-    msg = ofpbuf_at(p, l7 - (uint8_t *)p->data, BFD_PACKET_LEN);
+    msg = ofpbuf_at(p, l7 - (uint8_t *)ofpbuf_get_data(p), BFD_PACKET_LEN);
     if (!msg) {
         VLOG_INFO_RL(&rl, "%s: Received too-short BFD control message (only "
                      "%"PRIdPTR" bytes long, at least %d required).",
diff --git a/lib/cfm.c b/lib/cfm.c
index dcdaa0e..53faf91 100644
--- a/lib/cfm.c
+++ b/lib/cfm.c
@@ -719,7 +719,7 @@ cfm_process_heartbeat(struct cfm *cfm, const struct ofpbuf *p)
     ovs_mutex_lock(&mutex);
 
     eth = p->l2;
-    ccm = ofpbuf_at(p, (uint8_t *)ofpbuf_get_l3(p) - (uint8_t *)p->data,
+    ccm = ofpbuf_at(p, (uint8_t *)ofpbuf_get_l3(p) - (uint8_t *)ofpbuf_get_data(p),
                     CCM_ACCEPT_LEN);
 
     if (!ccm) {
diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
index 779f764..790bd4a 100644
--- a/lib/dpif-linux.c
+++ b/lib/dpif-linux.c
@@ -542,8 +542,8 @@ dpif_linux_port_add__(struct dpif *dpif_, struct netdev *netdev,
         ofpbuf_use_stack(&options, options_stub, sizeof options_stub);
         nl_msg_put_u16(&options, OVS_TUNNEL_ATTR_DST_PORT,
                        ntohs(tnl_cfg->dst_port));
-        request.options = options.data;
-        request.options_len = options.size;
+        request.options = ofpbuf_get_data(&options);
+        request.options_len = ofpbuf_get_size(&options);
     }
 
     request.port_no = *port_nop;
@@ -906,8 +906,8 @@ dpif_linux_flow_get(const struct dpif *dpif_,
             dpif_linux_flow_get_stats(&reply, stats);
         }
         if (actionsp) {
-            buf->data = CONST_CAST(struct nlattr *, reply.actions);
-            buf->size = reply.actions_len;
+            ofpbuf_set_data(buf, CONST_CAST(struct nlattr *, reply.actions));
+            ofpbuf_set_size(buf, reply.actions_len);
             *actionsp = buf;
         } else {
             ofpbuf_delete(buf);
@@ -1110,7 +1110,7 @@ dpif_linux_flow_dump_next_may_destroy_keys(void *state_)
 {
     struct dpif_linux_flow_state *state = state_;
 
-    return state->buffer.size ? false : true;
+    return ofpbuf_get_size(&state->buffer) ? false : true;
 }
 
 static int
@@ -1133,7 +1133,7 @@ dpif_linux_encode_execute(int dp_ifindex, const struct dpif_execute *d_exec,
     size_t key_ofs;
 
     ofpbuf_prealloc_tailroom(buf, (64
-                                   + d_exec->packet->size
+                                   + ofpbuf_get_size(d_exec->packet)
                                    + ODP_KEY_METADATA_SIZE
                                    + d_exec->actions_len));
 
@@ -1144,7 +1144,8 @@ dpif_linux_encode_execute(int dp_ifindex, const struct dpif_execute *d_exec,
     k_exec->dp_ifindex = dp_ifindex;
 
     nl_msg_put_unspec(buf, OVS_PACKET_ATTR_PACKET,
-                      d_exec->packet->data, d_exec->packet->size);
+                      ofpbuf_get_data(d_exec->packet),
+                      ofpbuf_get_size(d_exec->packet));
 
     key_ofs = nl_msg_start_nested(buf, OVS_PACKET_ATTR_KEY);
     odp_key_from_pkt_metadata(buf, &d_exec->md);
@@ -1500,7 +1501,7 @@ parse_odp_packet(struct ofpbuf *buf, struct dpif_upcall *upcall,
     struct ofpbuf b;
     int type;
 
-    ofpbuf_use_const(&b, buf->data, buf->size);
+    ofpbuf_use_const(&b, ofpbuf_get_data(buf), ofpbuf_get_size(buf));
 
     nlmsg = ofpbuf_try_pull(&b, sizeof *nlmsg);
     genl = ofpbuf_try_pull(&b, sizeof *genl);
@@ -1532,8 +1533,9 @@ parse_odp_packet(struct ofpbuf *buf, struct dpif_upcall *upcall,
                                nl_attr_get(a[OVS_PACKET_ATTR_PACKET])) - 1,
                     nl_attr_get_size(a[OVS_PACKET_ATTR_PACKET]) +
                     sizeof(struct nlattr));
-    upcall->packet.data = (char *)upcall->packet.data + sizeof(struct nlattr);
-    upcall->packet.size = nl_attr_get_size(a[OVS_PACKET_ATTR_PACKET]);
+    ofpbuf_set_data(&upcall->packet,
+                    (char *)ofpbuf_get_data(&upcall->packet) + sizeof(struct nlattr));
+    ofpbuf_set_size(&upcall->packet, nl_attr_get_size(a[OVS_PACKET_ATTR_PACKET]));
 
     *dp_ifindex = ovs_header->dp_ifindex;
 
@@ -1778,7 +1780,7 @@ dpif_linux_vport_from_ofpbuf(struct dpif_linux_vport *vport,
 
     dpif_linux_vport_init(vport);
 
-    ofpbuf_use_const(&b, buf->data, buf->size);
+    ofpbuf_use_const(&b, ofpbuf_get_data(buf), ofpbuf_get_size(buf));
     nlmsg = ofpbuf_try_pull(&b, sizeof *nlmsg);
     genl = ofpbuf_try_pull(&b, sizeof *genl);
     ovs_header = ofpbuf_try_pull(&b, sizeof *ovs_header);
@@ -1941,7 +1943,7 @@ dpif_linux_dp_from_ofpbuf(struct dpif_linux_dp *dp, const struct ofpbuf *buf)
 
     dpif_linux_dp_init(dp);
 
-    ofpbuf_use_const(&b, buf->data, buf->size);
+    ofpbuf_use_const(&b, ofpbuf_get_data(buf), ofpbuf_get_size(buf));
     nlmsg = ofpbuf_try_pull(&b, sizeof *nlmsg);
     genl = ofpbuf_try_pull(&b, sizeof *genl);
     ovs_header = ofpbuf_try_pull(&b, sizeof *ovs_header);
@@ -2103,7 +2105,7 @@ dpif_linux_flow_from_ofpbuf(struct dpif_linux_flow *flow,
 
     dpif_linux_flow_init(flow);
 
-    ofpbuf_use_const(&b, buf->data, buf->size);
+    ofpbuf_use_const(&b, ofpbuf_get_data(buf), ofpbuf_get_size(buf));
     nlmsg = ofpbuf_try_pull(&b, sizeof *nlmsg);
     genl = ofpbuf_try_pull(&b, sizeof *genl);
     ovs_header = ofpbuf_try_pull(&b, sizeof *ovs_header);
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index ceee233..b3ecd07 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -1462,8 +1462,8 @@ dpif_netdev_flow_dump_next(const struct dpif *dpif, void *iter_, void *state_,
         odp_flow_key_from_flow(&buf, &netdev_flow->flow,
                                netdev_flow->flow.in_port.odp_port);
 
-        *key = buf.data;
-        *key_len = buf.size;
+        *key = ofpbuf_get_data(&buf);
+        *key_len = ofpbuf_get_size(&buf);
     }
 
     if (key && mask) {
@@ -1476,8 +1476,8 @@ dpif_netdev_flow_dump_next(const struct dpif *dpif, void *iter_, void *state_,
                                odp_to_u32(wc.masks.in_port.odp_port),
                                SIZE_MAX);
 
-        *mask = buf.data;
-        *mask_len = buf.size;
+        *mask = ofpbuf_get_data(&buf);
+        *mask_len = ofpbuf_get_size(&buf);
     }
 
     if (actions || stats) {
@@ -1515,8 +1515,8 @@ dpif_netdev_execute(struct dpif *dpif, struct dpif_execute *execute)
     struct pkt_metadata *md = &execute->md;
     struct flow key;
 
-    if (execute->packet->size < ETH_HEADER_LEN ||
-        execute->packet->size > UINT16_MAX) {
+    if (ofpbuf_get_size(execute->packet) < ETH_HEADER_LEN ||
+        ofpbuf_get_size(execute->packet) > UINT16_MAX) {
         return EINVAL;
     }
 
@@ -1966,7 +1966,7 @@ dp_netdev_flow_used(struct dp_netdev_flow *netdev_flow,
     ovs_mutex_lock(&bucket->mutex);
     bucket->used = MAX(now, bucket->used);
     bucket->packet_count++;
-    bucket->byte_count += packet->size;
+    bucket->byte_count += ofpbuf_get_size(packet);
     bucket->tcp_flags |= tcp_flags;
     ovs_mutex_unlock(&bucket->mutex);
 }
@@ -1997,7 +1997,7 @@ dp_netdev_port_input(struct dp_netdev *dp, struct ofpbuf *packet,
     struct dp_netdev_flow *netdev_flow;
     struct flow key;
 
-    if (packet->size < ETH_HEADER_LEN) {
+    if (ofpbuf_get_size(packet) < ETH_HEADER_LEN) {
         ofpbuf_delete(packet);
         return;
     }
@@ -2045,13 +2045,13 @@ dp_netdev_output_userspace(struct dp_netdev *dp, struct ofpbuf *packet,
         if (userdata) {
             buf_size += NLA_ALIGN(userdata->nla_len);
         }
-        buf_size += packet->size;
+        buf_size += ofpbuf_get_size(packet);
         ofpbuf_init(buf, buf_size);
 
         /* Put ODP flow. */
         odp_flow_key_from_flow(buf, flow, flow->in_port.odp_port);
-        upcall->key = buf->data;
-        upcall->key_len = buf->size;
+        upcall->key = ofpbuf_get_data(buf);
+        upcall->key_len = ofpbuf_get_size(buf);
 
         /* Put userdata. */
         if (userdata) {
@@ -2059,8 +2059,9 @@ dp_netdev_output_userspace(struct dp_netdev *dp, struct ofpbuf *packet,
                                           NLA_ALIGN(userdata->nla_len));
         }
 
-        upcall->packet.data = ofpbuf_put(buf, packet->data, packet->size);
-        upcall->packet.size = packet->size;
+        ofpbuf_set_data(&upcall->packet,
+                        ofpbuf_put(buf, ofpbuf_get_data(packet), ofpbuf_get_size(packet)));
+        ofpbuf_set_size(&upcall->packet, ofpbuf_get_size(packet));
 
         seq_change(q->seq);
 
diff --git a/lib/dpif-netdev.h b/lib/dpif-netdev.h
index 4096785..e4fc11c 100644
--- a/lib/dpif-netdev.h
+++ b/lib/dpif-netdev.h
@@ -34,8 +34,8 @@ enum { DP_NETDEV_HEADROOM = 2 + VLAN_HEADER_LEN };
 
 static inline void dp_packet_pad(struct ofpbuf *b)
 {
-    if (b->size < ETH_TOTAL_MIN) {
-        ofpbuf_put_zeros(b, ETH_TOTAL_MIN - b->size);
+    if (ofpbuf_get_size(b) < ETH_TOTAL_MIN) {
+        ofpbuf_put_zeros(b, ETH_TOTAL_MIN - ofpbuf_get_size(b));
     }
 }
 
diff --git a/lib/dpif.c b/lib/dpif.c
index 6649176..f83734b 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -788,7 +788,7 @@ dpif_flow_stats_extract(const struct flow *flow, const struct ofpbuf *packet,
                         long long int used, struct dpif_flow_stats *stats)
 {
     stats->tcp_flags = ntohs(flow->tcp_flags);
-    stats->n_bytes = packet->size;
+    stats->n_bytes = ofpbuf_get_size(packet);
     stats->n_packets = 1;
     stats->used = used;
 }
@@ -861,8 +861,8 @@ dpif_flow_get(const struct dpif *dpif,
         size_t actions_len;
 
         if (!error && actionsp) {
-            actions = (*actionsp)->data;
-            actions_len = (*actionsp)->size;
+            actions = ofpbuf_get_data(*actionsp);
+            actions_len = ofpbuf_get_size(*actionsp);
         } else {
             actions = NULL;
             actions_len = 0;
@@ -1359,8 +1359,8 @@ dpif_recv(struct dpif *dpif, uint32_t handler_id, struct dpif_upcall *upcall,
         struct ds flow;
         char *packet;
 
-        packet = ofp_packet_to_string(upcall->packet.data,
-                                      upcall->packet.size);
+        packet = ofp_packet_to_string(ofpbuf_get_data(&upcall->packet),
+                                      ofpbuf_get_size(&upcall->packet));
 
         ds_init(&flow);
         odp_flow_key_format(upcall->key, upcall->key_len, &flow);
@@ -1563,8 +1563,8 @@ log_execute_message(struct dpif *dpif, const struct dpif_execute *execute,
         struct ds ds = DS_EMPTY_INITIALIZER;
         char *packet;
 
-        packet = ofp_packet_to_string(execute->packet->data,
-                                      execute->packet->size);
+        packet = ofp_packet_to_string(ofpbuf_get_data(execute->packet),
+                                      ofpbuf_get_size(execute->packet));
         ds_put_format(&ds, "%s: execute ", dpif_name(dpif));
         format_odp_actions(&ds, execute->actions, execute->actions_len);
         if (error) {
diff --git a/lib/flow.c b/lib/flow.c
index 314c1c7..ffa78f2 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -59,10 +59,10 @@ pull_arp(struct ofpbuf *packet)
 static struct ip_header *
 pull_ip(struct ofpbuf *packet)
 {
-    if (packet->size >= IP_HEADER_LEN) {
-        struct ip_header *ip = packet->data;
+    if (ofpbuf_get_size(packet) >= IP_HEADER_LEN) {
+        struct ip_header *ip = ofpbuf_get_data(packet);
         int ip_len = IP_IHL(ip->ip_ihl_ver) * 4;
-        if (ip_len >= IP_HEADER_LEN && packet->size >= ip_len) {
+        if (ip_len >= IP_HEADER_LEN && ofpbuf_get_size(packet) >= ip_len) {
             return ofpbuf_pull(packet, ip_len);
         }
     }
@@ -105,7 +105,7 @@ parse_vlan(struct ofpbuf *b, struct flow *flow)
         ovs_be16 tci;
     };
 
-    if (b->size >= sizeof(struct qtag_prefix) + sizeof(ovs_be16)) {
+    if (ofpbuf_get_size(b) >= sizeof(struct qtag_prefix) + sizeof(ovs_be16)) {
         struct qtag_prefix *qp = ofpbuf_pull(b, sizeof *qp);
         flow->vlan_tci = qp->tci | htons(VLAN_CFI);
     }
@@ -122,11 +122,11 @@ parse_ethertype(struct ofpbuf *b)
         return proto;
     }
 
-    if (b->size < sizeof *llc) {
+    if (ofpbuf_get_size(b) < sizeof *llc) {
         return htons(FLOW_DL_TYPE_NONE);
     }
 
-    llc = b->data;
+    llc = ofpbuf_get_data(b);
     if (llc->llc.llc_dsap != LLC_DSAP_SNAP
         || llc->llc.llc_ssap != LLC_SSAP_SNAP
         || llc->llc.llc_cntl != LLC_CNTL_SNAP
@@ -184,7 +184,7 @@ parse_ipv6(struct ofpbuf *packet, struct flow *flow)
          * accesses within the extension header are within those first 8
          * bytes. All extension headers are required to be at least 8
          * bytes. */
-        if (packet->size < 8) {
+        if (ofpbuf_get_size(packet) < 8) {
             return EINVAL;
         }
 
@@ -193,7 +193,7 @@ parse_ipv6(struct ofpbuf *packet, struct flow *flow)
                 || (nexthdr == IPPROTO_DSTOPTS)) {
             /* These headers, while different, have the fields we care about
              * in the same location and with the same interpretation. */
-            const struct ip6_ext *ext_hdr = packet->data;
+            const struct ip6_ext *ext_hdr = ofpbuf_get_data(packet);
             nexthdr = ext_hdr->ip6e_nxt;
             if (!ofpbuf_try_pull(packet, (ext_hdr->ip6e_len + 1) * 8)) {
                 return EINVAL;
@@ -203,13 +203,13 @@ parse_ipv6(struct ofpbuf *packet, struct flow *flow)
              * we care about are in the same location as the generic
              * option header--only the header length is calculated
              * differently. */
-            const struct ip6_ext *ext_hdr = packet->data;
+            const struct ip6_ext *ext_hdr = ofpbuf_get_data(packet);
             nexthdr = ext_hdr->ip6e_nxt;
             if (!ofpbuf_try_pull(packet, (ext_hdr->ip6e_len + 2) * 4)) {
                return EINVAL;
             }
         } else if (nexthdr == IPPROTO_FRAGMENT) {
-            const struct ovs_16aligned_ip6_frag *frag_hdr = packet->data;
+            const struct ovs_16aligned_ip6_frag *frag_hdr = ofpbuf_get_data(packet);
 
             nexthdr = frag_hdr->ip6f_nxt;
             if (!ofpbuf_try_pull(packet, sizeof *frag_hdr)) {
@@ -235,8 +235,8 @@ parse_ipv6(struct ofpbuf *packet, struct flow *flow)
 static void
 parse_tcp(struct ofpbuf *b, struct flow *flow)
 {
-    if (b->size >= TCP_HEADER_LEN) {
-        const struct tcp_header *tcp = b->data;
+    if (ofpbuf_get_size(b) >= TCP_HEADER_LEN) {
+        const struct tcp_header *tcp = ofpbuf_get_data(b);
 
         flow->tp_src = tcp->tcp_src;
         flow->tp_dst = tcp->tcp_dst;
@@ -247,8 +247,8 @@ parse_tcp(struct ofpbuf *b, struct flow *flow)
 static void
 parse_udp(struct ofpbuf *b, struct flow *flow)
 {
-    if (b->size >= UDP_HEADER_LEN) {
-        const struct udp_header *udp = b->data;
+    if (ofpbuf_get_size(b) >= UDP_HEADER_LEN) {
+        const struct udp_header *udp = ofpbuf_get_data(b);
 
         flow->tp_src = udp->udp_src;
         flow->tp_dst = udp->udp_dst;
@@ -258,8 +258,8 @@ parse_udp(struct ofpbuf *b, struct flow *flow)
 static void
 parse_sctp(struct ofpbuf *b, struct flow *flow)
 {
-    if (b->size >= SCTP_HEADER_LEN) {
-        const struct sctp_header *sctp = b->data;
+    if (ofpbuf_get_size(b) >= SCTP_HEADER_LEN) {
+        const struct sctp_header *sctp = ofpbuf_get_data(b);
 
         flow->tp_src = sctp->sctp_src;
         flow->tp_dst = sctp->sctp_dst;
@@ -291,13 +291,13 @@ parse_icmpv6(struct ofpbuf *b, struct flow *flow)
         }
         flow->nd_target = *nd_target;
 
-        while (b->size >= 8) {
+        while (ofpbuf_get_size(b) >= 8) {
             /* The minimum size of an option is 8 bytes, which also is
              * the size of Ethernet link-layer options. */
-            const struct nd_opt_hdr *nd_opt = b->data;
+            const struct nd_opt_hdr *nd_opt = ofpbuf_get_data(b);
             int opt_len = nd_opt->nd_opt_len * 8;
 
-            if (!opt_len || opt_len > b->size) {
+            if (!opt_len || opt_len > ofpbuf_get_size(b)) {
                 goto invalid;
             }
 
@@ -371,17 +371,17 @@ flow_extract(struct ofpbuf *packet, const struct pkt_metadata *md,
         flow->pkt_mark = md->pkt_mark;
     }
 
-    packet->l2   = b.data;
+    packet->l2   = ofpbuf_get_data(&b);
     ofpbuf_set_l2_5(packet, NULL);
     ofpbuf_set_l3(packet, NULL);
     ofpbuf_set_l4(packet, NULL);
 
-    if (b.size < sizeof *eth) {
+    if (ofpbuf_get_size(&b) < sizeof *eth) {
         return;
     }
 
     /* Link layer. */
-    eth = b.data;
+    eth = ofpbuf_get_data(&b);
     memcpy(flow->dl_src, eth->eth_src, ETH_ADDR_LEN);
     memcpy(flow->dl_dst, eth->eth_dst, ETH_ADDR_LEN);
 
@@ -394,16 +394,16 @@ flow_extract(struct ofpbuf *packet, const struct pkt_metadata *md,
 
     /* Parse mpls, copy l3 ttl. */
     if (eth_type_mpls(flow->dl_type)) {
-        ofpbuf_set_l2_5(packet, b.data);
+        ofpbuf_set_l2_5(packet, ofpbuf_get_data(&b));
         parse_mpls(&b, flow);
     }
 
     /* Network layer. */
-    ofpbuf_set_l3(packet, b.data);
+    ofpbuf_set_l3(packet, ofpbuf_get_data(&b));
     if (flow->dl_type == htons(ETH_TYPE_IP)) {
         const struct ip_header *nh = pull_ip(&b);
         if (nh) {
-            ofpbuf_set_l4(packet, b.data);
+            ofpbuf_set_l4(packet, ofpbuf_get_data(&b));
 
             flow->nw_src = get_16aligned_be32(&nh->ip_src);
             flow->nw_dst = get_16aligned_be32(&nh->ip_dst);
@@ -439,7 +439,7 @@ flow_extract(struct ofpbuf *packet, const struct pkt_metadata *md,
             return;
         }
 
-        ofpbuf_set_l4(packet, b.data);
+        ofpbuf_set_l4(packet, ofpbuf_get_data(&b));
         if (flow->nw_proto == IPPROTO_TCP) {
             parse_tcp(&b, flow);
         } else if (flow->nw_proto == IPPROTO_UDP) {
@@ -1331,7 +1331,7 @@ flow_compose(struct ofpbuf *b, const struct flow *flow)
     eth_compose(b, flow->dl_dst, flow->dl_src, ntohs(flow->dl_type), 0);
     if (flow->dl_type == htons(FLOW_DL_TYPE_NONE)) {
         struct eth_header *eth = b->l2;
-        eth->eth_type = htons(b->size);
+        eth->eth_type = htons(ofpbuf_get_size(b));
         return;
     }
 
diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c
index 643a3c5..bc5f11f 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -119,11 +119,11 @@ jsonrpc_run(struct jsonrpc *rpc)
         struct ofpbuf *buf = ofpbuf_from_list(rpc->output.next);
         int retval;
 
-        retval = stream_send(rpc->stream, buf->data, buf->size);
+        retval = stream_send(rpc->stream, ofpbuf_get_data(buf), ofpbuf_get_size(buf));
         if (retval >= 0) {
             rpc->backlog -= retval;
             ofpbuf_pull(buf, retval);
-            if (!buf->size) {
+            if (!ofpbuf_get_size(buf)) {
                 list_remove(&buf->list_node);
                 ofpbuf_delete(buf);
             }
@@ -256,7 +256,7 @@ jsonrpc_send(struct jsonrpc *rpc, struct jsonrpc_msg *msg)
 
     buf = xmalloc(sizeof *buf);
     ofpbuf_use(buf, s, length);
-    buf->size = length;
+    ofpbuf_set_size(buf, length);
     list_push_back(&rpc->output, &buf->list_node);
     rpc->backlog += length;
 
diff --git a/lib/lacp.c b/lib/lacp.c
index 711d7ec..4b33455 100644
--- a/lib/lacp.c
+++ b/lib/lacp.c
@@ -181,7 +181,7 @@ parse_lacp_packet(const struct ofpbuf *b)
 {
     const struct lacp_pdu *pdu;
 
-    pdu = ofpbuf_at(b, (uint8_t *)ofpbuf_get_l3(b) - (uint8_t *)b->data,
+    pdu = ofpbuf_at(b, (uint8_t *)ofpbuf_get_l3(b) - (uint8_t *)ofpbuf_get_data(b),
                     LACP_PDU_LEN);
 
     if (pdu && pdu->subtype == 1
diff --git a/lib/learn.c b/lib/learn.c
index 61799c9..3354076 100644
--- a/lib/learn.c
+++ b/lib/learn.c
@@ -255,7 +255,7 @@ learn_to_nxast(const struct ofpact_learn *learn, struct ofpbuf *openflow)
     struct nx_action_learn *nal;
     size_t start_ofs;
 
-    start_ofs = openflow->size;
+    start_ofs = ofpbuf_get_size(openflow);
     nal = ofputil_put_NXAST_LEARN(openflow);
     nal->idle_timeout = htons(learn->idle_timeout);
     nal->hard_timeout = htons(learn->hard_timeout);
@@ -287,12 +287,12 @@ learn_to_nxast(const struct ofpact_learn *learn, struct ofpbuf *openflow)
         }
     }
 
-    if ((openflow->size - start_ofs) % 8) {
-        ofpbuf_put_zeros(openflow, 8 - (openflow->size - start_ofs) % 8);
+    if ((ofpbuf_get_size(openflow) - start_ofs) % 8) {
+        ofpbuf_put_zeros(openflow, 8 - (ofpbuf_get_size(openflow) - start_ofs) % 8);
     }
 
     nal = ofpbuf_at_assert(openflow, start_ofs, sizeof *nal);
-    nal->len = htons(openflow->size - start_ofs);
+    nal->len = htons(ofpbuf_get_size(openflow) - start_ofs);
 }
 
 /* Composes 'fm' so that executing it will implement 'learn' given that the
@@ -382,8 +382,8 @@ learn_execute(const struct ofpact_learn *learn, const struct flow *flow,
     }
     ofpact_pad(ofpacts);
 
-    fm->ofpacts = ofpacts->data;
-    fm->ofpacts_len = ofpacts->size;
+    fm->ofpacts = ofpbuf_get_data(ofpacts);
+    fm->ofpacts_len = ofpbuf_get_size(ofpacts);
 }
 
 /* Perform a bitwise-OR on 'wc''s fields that are relevant as sources in
diff --git a/lib/learning-switch.c b/lib/learning-switch.c
index 5620990..4b25f50 100644
--- a/lib/learning-switch.c
+++ b/lib/learning-switch.c
@@ -315,12 +315,12 @@ lswitch_process_packet(struct lswitch *sw, const struct ofpbuf *msg)
 
     switch (type) {
     case OFPTYPE_ECHO_REQUEST:
-        process_echo_request(sw, msg->data);
+        process_echo_request(sw, ofpbuf_get_data(msg));
         break;
 
     case OFPTYPE_FEATURES_REPLY:
         if (sw->state == S_FEATURES_REPLY) {
-            if (!process_switch_features(sw, msg->data)) {
+            if (!process_switch_features(sw, ofpbuf_get_data(msg))) {
                 sw->state = S_SWITCHING;
             } else {
                 rconn_disconnect(sw->rconn);
@@ -329,7 +329,7 @@ lswitch_process_packet(struct lswitch *sw, const struct ofpbuf *msg)
         break;
 
     case OFPTYPE_PACKET_IN:
-        process_packet_in(sw, msg->data);
+        process_packet_in(sw, ofpbuf_get_data(msg));
         break;
 
     case OFPTYPE_FLOW_REMOVED:
@@ -400,7 +400,7 @@ lswitch_process_packet(struct lswitch *sw, const struct ofpbuf *msg)
     case OFPTYPE_TABLE_FEATURES_STATS_REPLY:
     default:
         if (VLOG_IS_DBG_ENABLED()) {
-            char *s = ofp_to_string(msg->data, msg->size, 2);
+            char *s = ofp_to_string(ofpbuf_get_data(msg), ofpbuf_get_size(msg), 2);
             VLOG_DBG_RL(&rl, "%016llx: OpenFlow packet ignored: %s",
                         sw->datapath_id, s);
             free(s);
@@ -598,15 +598,15 @@ process_packet_in(struct lswitch *sw, const struct ofp_header *oh)
     /* Prepare packet_out in case we need one. */
     po.buffer_id = pi.buffer_id;
     if (po.buffer_id == UINT32_MAX) {
-        po.packet = pkt.data;
-        po.packet_len = pkt.size;
+        po.packet = ofpbuf_get_data(&pkt);
+        po.packet_len = ofpbuf_get_size(&pkt);
     } else {
         po.packet = NULL;
         po.packet_len = 0;
     }
     po.in_port = pi.fmd.in_port;
-    po.ofpacts = ofpacts.data;
-    po.ofpacts_len = ofpacts.size;
+    po.ofpacts = ofpbuf_get_data(&ofpacts);
+    po.ofpacts_len = ofpbuf_get_size(&ofpacts);
 
     /* Send the packet, and possibly the whole flow, to the output port. */
     if (sw->max_idle >= 0 && (!sw->ml || out_port != OFPP_FLOOD)) {
@@ -624,8 +624,8 @@ process_packet_in(struct lswitch *sw, const struct ofp_header *oh)
         fm.idle_timeout = sw->max_idle;
         fm.buffer_id = pi.buffer_id;
         fm.out_port = OFPP_NONE;
-        fm.ofpacts = ofpacts.data;
-        fm.ofpacts_len = ofpacts.size;
+        fm.ofpacts = ofpbuf_get_data(&ofpacts);
+        fm.ofpacts_len = ofpbuf_get_size(&ofpacts);
         buffer = ofputil_encode_flow_mod(&fm, sw->protocol);
 
         queue_tx(sw, buffer);
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index f6adf87..5db4b49 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -558,11 +558,11 @@ build_ofpbuf(struct rte_mbuf *pkt)
     b = ofpbuf_new(0);
     b->private_p = pkt;
 
-    b->data = pkt->pkt.data;
-    b->base = (char *)b->data - DP_NETDEV_HEADROOM - VLAN_ETH_HEADER_LEN;
-    b->allocated = pkt->buf_len;
+    ofpbuf_set_data(b, pkt->pkt.data);
+    ofpbuf_set_base(b, (char *)ofpbuf_get_data(b) - DP_NETDEV_HEADROOM - VLAN_ETH_HEADER_LEN);
+    b->allocated =  pkt->buf_len;
+    ofpbuf_set_size(b, rte_pktmbuf_data_len(pkt));
     b->source = OFPBUF_DPDK;
-    b->size = rte_pktmbuf_data_len(pkt);
 
     dp_packet_pad(b);
 
@@ -665,9 +665,9 @@ netdev_dpdk_send(struct netdev *netdev,
     struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
     int ret;
 
-    if (ofpbuf->size > dev->max_packet_len) {
+    if (ofpbuf_get_size(ofpbuf) > dev->max_packet_len) {
         VLOG_WARN_RL(&rl, "Too big size %d max_packet_len %d",
-                     (int)ofpbuf->size , dev->max_packet_len);
+                     (int)ofpbuf_get_size(ofpbuf) , dev->max_packet_len);
 
         ovs_mutex_lock(&dev->mutex);
         dev->stats.tx_dropped++;
@@ -680,15 +680,15 @@ netdev_dpdk_send(struct netdev *netdev,
     rte_prefetch0(&ofpbuf->private_p);
     if (!may_steal ||
         !ofpbuf->private_p || ofpbuf->source != OFPBUF_DPDK) {
-        dpdk_do_tx_copy(netdev, (char *) ofpbuf->data, ofpbuf->size);
+        dpdk_do_tx_copy(netdev, (char *) ofpbuf_get_data(ofpbuf), ofpbuf_get_size(ofpbuf));
     } else {
         struct rte_mbuf *pkt;
         int qid;
 
         pkt = ofpbuf->private_p;
         ofpbuf->private_p = NULL;
-        rte_pktmbuf_data_len(pkt) = ofpbuf->size;
-        rte_pktmbuf_pkt_len(pkt) = ofpbuf->size;
+        rte_pktmbuf_data_len(pkt) = ofpbuf_get_size(ofpbuf);
+        rte_pktmbuf_pkt_len(pkt) = ofpbuf_get_size(ofpbuf);
 
         qid = rte_lcore_id() % NR_QUEUE;
 
diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index 784eff4..908a710 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -198,11 +198,11 @@ dummy_packet_stream_run(struct netdev_dummy *dev, struct dummy_packet_stream *s)
         int retval;
 
         txbuf = ofpbuf_from_list(list_front(&s->txq));
-        retval = stream_send(s->stream, txbuf->data, txbuf->size);
+        retval = stream_send(s->stream, ofpbuf_get_data(txbuf), ofpbuf_get_size(txbuf));
 
         if (retval > 0) {
             ofpbuf_pull(txbuf, retval);
-            if (!txbuf->size) {
+            if (!ofpbuf_get_size(txbuf)) {
                 list_remove(&txbuf->list_node);
                 ofpbuf_delete(txbuf);
             }
@@ -212,17 +212,17 @@ dummy_packet_stream_run(struct netdev_dummy *dev, struct dummy_packet_stream *s)
     }
 
     if (!error) {
-        if (s->rxbuf.size < 2) {
-            n = 2 - s->rxbuf.size;
+        if (ofpbuf_get_size(&s->rxbuf) < 2) {
+            n = 2 - ofpbuf_get_size(&s->rxbuf);
         } else {
             uint16_t frame_len;
 
-            frame_len = ntohs(get_unaligned_be16(s->rxbuf.data));
+            frame_len = ntohs(get_unaligned_be16(ofpbuf_get_data(&s->rxbuf)));
             if (frame_len < ETH_HEADER_LEN) {
                 error = EPROTO;
                 n = 0;
             } else {
-                n = (2 + frame_len) - s->rxbuf.size;
+                n = (2 + frame_len) - ofpbuf_get_size(&s->rxbuf);
             }
         }
     }
@@ -233,8 +233,8 @@ dummy_packet_stream_run(struct netdev_dummy *dev, struct dummy_packet_stream *s)
         retval = stream_recv(s->stream, ofpbuf_tail(&s->rxbuf), n);
 
         if (retval > 0) {
-            s->rxbuf.size += retval;
-            if (retval == n && s->rxbuf.size > 2) {
+            ofpbuf_set_size(&s->rxbuf, ofpbuf_get_size(&s->rxbuf) + retval);
+            if (retval == n && ofpbuf_get_size(&s->rxbuf) > 2) {
                 ofpbuf_pull(&s->rxbuf, 2);
                 netdev_dummy_queue_packet(dev,
                                           ofpbuf_clone(&s->rxbuf));
@@ -242,7 +242,7 @@ dummy_packet_stream_run(struct netdev_dummy *dev, struct dummy_packet_stream *s)
             }
         } else if (retval != -EAGAIN) {
             error = (retval < 0 ? -retval
-                     : s->rxbuf.size ? EPROTO
+                     : ofpbuf_get_size(&s->rxbuf) ? EPROTO
                      : EOF);
         }
     }
@@ -776,7 +776,7 @@ netdev_dummy_rxq_recv(struct netdev_rxq *rxq_, struct ofpbuf **arr, int *c)
     }
     ovs_mutex_lock(&netdev->mutex);
     netdev->stats.rx_packets++;
-    netdev->stats.rx_bytes += packet->size;
+    netdev->stats.rx_bytes += ofpbuf_get_size(packet);
     ovs_mutex_unlock(&netdev->mutex);
 
     dp_packet_pad(packet);
@@ -821,8 +821,8 @@ static int
 netdev_dummy_send(struct netdev *netdev, struct ofpbuf *pkt, bool may_steal)
 {
     struct netdev_dummy *dev = netdev_dummy_cast(netdev);
-    const void *buffer = pkt->data;
-    size_t size = pkt->size;
+    const void *buffer = ofpbuf_get_data(pkt);
+    size_t size = ofpbuf_get_size(pkt);
 
     if (size < ETH_HEADER_LEN) {
         return EMSGSIZE;
@@ -1082,7 +1082,7 @@ eth_from_packet_or_flow(const char *s)
     }
 
     /* Convert odp_key to flow. */
-    fitness = odp_flow_key_to_flow(odp_key.data, odp_key.size, &flow);
+    fitness = odp_flow_key_to_flow(ofpbuf_get_data(&odp_key), ofpbuf_get_size(&odp_key), &flow);
     if (fitness == ODP_FIT_ERROR) {
         ofpbuf_uninit(&odp_key);
         return NULL;
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 6848850..d2c1b89 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -919,7 +919,7 @@ netdev_linux_rxq_recv_sock(int fd, struct ofpbuf *buffer)
     ofpbuf_reserve(buffer, VLAN_HEADER_LEN);
     size = ofpbuf_tailroom(buffer);
 
-    iov.iov_base = buffer->data;
+    iov.iov_base = ofpbuf_get_data(buffer);
     iov.iov_len = size;
     msgh.msg_name = NULL;
     msgh.msg_namelen = 0;
@@ -939,7 +939,7 @@ netdev_linux_rxq_recv_sock(int fd, struct ofpbuf *buffer)
         return EMSGSIZE;
     }
 
-    buffer->size += retval;
+    ofpbuf_set_size(buffer, ofpbuf_get_size(buffer) + retval);
 
     for (cmsg = CMSG_FIRSTHDR(&msgh); cmsg; cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
         const struct tpacket_auxdata *aux;
@@ -972,7 +972,7 @@ netdev_linux_rxq_recv_tap(int fd, struct ofpbuf *buffer)
     size_t size = ofpbuf_tailroom(buffer);
 
     do {
-        retval = read(fd, buffer->data, size);
+        retval = read(fd, ofpbuf_get_data(buffer), size);
     } while (retval < 0 && errno == EINTR);
 
     if (retval < 0) {
@@ -981,7 +981,7 @@ netdev_linux_rxq_recv_tap(int fd, struct ofpbuf *buffer)
         return EMSGSIZE;
     }
 
-    buffer->size += retval;
+    ofpbuf_set_size(buffer, ofpbuf_get_size(buffer) + retval);
     return 0;
 }
 
@@ -1056,8 +1056,8 @@ netdev_linux_rxq_drain(struct netdev_rxq *rxq_)
 static int
 netdev_linux_send(struct netdev *netdev_, struct ofpbuf *pkt, bool may_steal)
 {
-    const void *data = pkt->data;
-    size_t size = pkt->size;
+    const void *data = ofpbuf_get_data(pkt);
+    size_t size = ofpbuf_get_size(pkt);
 
     for (;;) {
         ssize_t retval;
diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c
index 8c8d16b..7cbc05d 100644
--- a/lib/netlink-socket.c
+++ b/lib/netlink-socket.c
@@ -250,15 +250,15 @@ nl_sock_send__(struct nl_sock *sock, const struct ofpbuf *msg,
     struct nlmsghdr *nlmsg = nl_msg_nlmsghdr(msg);
     int error;
 
-    nlmsg->nlmsg_len = msg->size;
+    nlmsg->nlmsg_len = ofpbuf_get_size(msg);
     nlmsg->nlmsg_seq = nlmsg_seq;
     nlmsg->nlmsg_pid = sock->pid;
     do {
         int retval;
-        retval = send(sock->fd, msg->data, msg->size, wait ? 0 : MSG_DONTWAIT);
+        retval = send(sock->fd, ofpbuf_get_data(msg), ofpbuf_get_size(msg), wait ? 0 : MSG_DONTWAIT);
         error = retval < 0 ? errno : 0;
     } while (error == EINTR);
-    log_nlmsg(__func__, error, msg->data, msg->size, sock->protocol);
+    log_nlmsg(__func__, error, ofpbuf_get_data(msg), ofpbuf_get_size(msg), sock->protocol);
     if (!error) {
         COVERAGE_INC(netlink_sent);
     }
@@ -266,7 +266,7 @@ nl_sock_send__(struct nl_sock *sock, const struct ofpbuf *msg,
 }
 
 /* Tries to send 'msg', which must contain a Netlink message, to the kernel on
- * 'sock'.  nlmsg_len in 'msg' will be finalized to match msg->size, nlmsg_pid
+ * 'sock'.  nlmsg_len in 'msg' will be finalized to match ofpbuf_get_size(msg), nlmsg_pid
  * will be set to 'sock''s pid, and nlmsg_seq will be initialized to a fresh
  * sequence number, before the message is sent.
  *
@@ -280,7 +280,7 @@ nl_sock_send(struct nl_sock *sock, const struct ofpbuf *msg, bool wait)
 }
 
 /* Tries to send 'msg', which must contain a Netlink message, to the kernel on
- * 'sock'.  nlmsg_len in 'msg' will be finalized to match msg->size, nlmsg_pid
+ * 'sock'.  nlmsg_len in 'msg' will be finalized to match ofpbuf_get_size(msg), nlmsg_pid
  * will be set to 'sock''s pid, and nlmsg_seq will be initialized to
  * 'nlmsg_seq', before the message is sent.
  *
@@ -314,7 +314,7 @@ nl_sock_recv__(struct nl_sock *sock, struct ofpbuf *buf, bool wait)
     ovs_assert(buf->allocated >= sizeof *nlmsghdr);
     ofpbuf_clear(buf);
 
-    iov[0].iov_base = buf->base;
+    iov[0].iov_base = ofpbuf_get_base(buf);
     iov[0].iov_len = buf->allocated;
     iov[1].iov_base = tail;
     iov[1].iov_len = sizeof tail;
@@ -343,7 +343,7 @@ nl_sock_recv__(struct nl_sock *sock, struct ofpbuf *buf, bool wait)
         return E2BIG;
     }
 
-    nlmsghdr = buf->data;
+    nlmsghdr = ofpbuf_get_data(buf);
     if (retval < sizeof *nlmsghdr
         || nlmsghdr->nlmsg_len < sizeof *nlmsghdr
         || nlmsghdr->nlmsg_len > retval) {
@@ -352,13 +352,13 @@ nl_sock_recv__(struct nl_sock *sock, struct ofpbuf *buf, bool wait)
         return EPROTO;
     }
 
-    buf->size = MIN(retval, buf->allocated);
+    ofpbuf_set_size(buf, MIN(retval, buf->allocated));
     if (retval > buf->allocated) {
         COVERAGE_INC(netlink_recv_jumbo);
         ofpbuf_put(buf, tail, retval - buf->allocated);
     }
 
-    log_nlmsg(__func__, 0, buf->data, buf->size, sock->protocol);
+    log_nlmsg(__func__, 0, ofpbuf_get_data(buf), ofpbuf_get_size(buf), sock->protocol);
     COVERAGE_INC(netlink_received);
 
     return 0;
@@ -424,12 +424,12 @@ nl_sock_transact_multiple__(struct nl_sock *sock,
         struct nl_transaction *txn = transactions[i];
         struct nlmsghdr *nlmsg = nl_msg_nlmsghdr(txn->request);
 
-        nlmsg->nlmsg_len = txn->request->size;
+        nlmsg->nlmsg_len = ofpbuf_get_size(txn->request);
         nlmsg->nlmsg_seq = base_seq + i;
         nlmsg->nlmsg_pid = sock->pid;
 
-        iovs[i].iov_base = txn->request->data;
-        iovs[i].iov_len = txn->request->size;
+        iovs[i].iov_base = ofpbuf_get_data(txn->request);
+        iovs[i].iov_len = ofpbuf_get_size(txn->request);
     }
 
     memset(&msg, 0, sizeof msg);
@@ -442,7 +442,7 @@ nl_sock_transact_multiple__(struct nl_sock *sock,
     for (i = 0; i < n; i++) {
         struct nl_transaction *txn = transactions[i];
 
-        log_nlmsg(__func__, error, txn->request->data, txn->request->size,
+        log_nlmsg(__func__, error, ofpbuf_get_data(txn->request), ofpbuf_get_size(txn->request),
                   sock->protocol);
     }
     if (!error) {
@@ -579,12 +579,12 @@ nl_sock_transact_multiple(struct nl_sock *sock,
 #else
         enum { MAX_BATCH_BYTES = 4096 - 512 };
 #endif
-        bytes = transactions[0]->request->size;
+        bytes = ofpbuf_get_size(transactions[0]->request);
         for (count = 1; count < n && count < max_batch_count; count++) {
-            if (bytes + transactions[count]->request->size > MAX_BATCH_BYTES) {
+            if (bytes + ofpbuf_get_size(transactions[count]->request) > MAX_BATCH_BYTES) {
                 break;
             }
-            bytes += transactions[count]->request->size;
+            bytes += ofpbuf_get_size(transactions[count]->request);
         }
 
         error = nl_sock_transact_multiple__(sock, transactions, count, &done);
@@ -609,7 +609,7 @@ nl_sock_transact_multiple(struct nl_sock *sock,
  * reply, if any, is discarded.
  *
  * Before the message is sent, nlmsg_len in 'request' will be finalized to
- * match msg->size, nlmsg_pid will be set to 'sock''s pid, and nlmsg_seq will
+ * match ofpbuf_get_size(msg), nlmsg_pid will be set to 'sock''s pid, and nlmsg_seq will
  * be initialized, NLM_F_ACK will be set in nlmsg_flags.
  *
  * The caller is responsible for destroying 'request'.
@@ -709,12 +709,12 @@ nl_dump_start(struct nl_dump *dump, int protocol, const struct ofpbuf *request)
  * have been initialized with nl_dump_start(), and 'buffer' must have been
  * initialized. 'buffer' should be at least NL_DUMP_BUFSIZE bytes long.
  *
- * If successful, returns true and points 'reply->data' and 'reply->size' to
+ * If successful, returns true and points 'reply->data' and 'ofpbuf_get_size(reply)' to
  * the message that was retrieved. The caller must not modify 'reply' (because
  * it points within 'buffer', which will be used by future calls to this
  * function).
  *
- * On failure, returns false and sets 'reply->data' to NULL and 'reply->size'
+ * On failure, returns false and sets 'reply->data' to NULL and 'ofpbuf_get_size(reply)'
  * to 0.  Failure might indicate an actual error or merely the end of replies.
  * An error status for the entire dump operation is provided when it is
  * completed by calling nl_dump_done().
@@ -731,11 +731,11 @@ nl_dump_next(struct nl_dump *dump, struct ofpbuf *reply, struct ofpbuf *buffer)
     struct nlmsghdr *nlmsghdr;
     int error = 0;
 
-    reply->data = NULL;
-    reply->size = 0;
+    ofpbuf_set_data(reply, NULL);
+    ofpbuf_set_size(reply, 0);
 
     /* If 'buffer' is empty, fetch another batch of nlmsgs. */
-    while (!buffer->size) {
+    while (!ofpbuf_get_size(buffer)) {
         unsigned int status;
         int retval, seq;
 
diff --git a/lib/netlink.c b/lib/netlink.c
index 96abe46..1ac8563 100644
--- a/lib/netlink.c
+++ b/lib/netlink.c
@@ -67,7 +67,7 @@ nl_msg_nlmsgerr(const struct ofpbuf *msg, int *errorp)
         int code = EPROTO;
         if (!err) {
             VLOG_ERR_RL(&rl, "received invalid nlmsgerr (%"PRIu32"d bytes < %"PRIuSIZE"d)",
-                        msg->size, NLMSG_HDRLEN + sizeof *err);
+                        ofpbuf_get_size(msg), NLMSG_HDRLEN + sizeof *err);
         } else if (err->error <= 0 && err->error > INT_MIN) {
             code = -err->error;
         }
@@ -113,7 +113,7 @@ nl_msg_put_nlmsghdr(struct ofpbuf *msg,
 {
     struct nlmsghdr *nlmsghdr;
 
-    ovs_assert(msg->size == 0);
+    ovs_assert(ofpbuf_get_size(msg) == 0);
 
     nl_msg_reserve(msg, NLMSG_HDRLEN + expected_payload);
     nlmsghdr = nl_msg_put_uninit(msg, NLMSG_HDRLEN);
@@ -152,7 +152,7 @@ nl_msg_put_genlmsghdr(struct ofpbuf *msg, size_t expected_payload,
     struct genlmsghdr *genlmsghdr;
 
     nl_msg_put_nlmsghdr(msg, GENL_HDRLEN + expected_payload, family, flags);
-    ovs_assert(msg->size == NLMSG_HDRLEN);
+    ovs_assert(ofpbuf_get_size(msg) == NLMSG_HDRLEN);
     genlmsghdr = nl_msg_put_uninit(msg, GENL_HDRLEN);
     genlmsghdr->cmd = cmd;
     genlmsghdr->version = version;
@@ -432,7 +432,7 @@ nl_msg_push_string(struct ofpbuf *msg, uint16_t type, const char *value)
 size_t
 nl_msg_start_nested(struct ofpbuf *msg, uint16_t type)
 {
-    size_t offset = msg->size;
+    size_t offset = ofpbuf_get_size(msg);
     nl_msg_put_unspec(msg, type, NULL, 0);
     return offset;
 }
@@ -443,7 +443,7 @@ void
 nl_msg_end_nested(struct ofpbuf *msg, size_t offset)
 {
     struct nlattr *attr = ofpbuf_at_assert(msg, offset, sizeof *attr);
-    attr->nla_len = msg->size - offset;
+    attr->nla_len = ofpbuf_get_size(msg) - offset;
 }
 
 /* Appends a nested Netlink attribute of the given 'type', with the 'size'
@@ -459,25 +459,25 @@ nl_msg_put_nested(struct ofpbuf *msg,
 
 /* If 'buffer' begins with a valid "struct nlmsghdr", pulls the header and its
  * payload off 'buffer', stores header and payload in 'msg->data' and
- * 'msg->size', and returns a pointer to the header.
+ * 'ofpbuf_get_size(msg)', and returns a pointer to the header.
  *
  * If 'buffer' does not begin with a "struct nlmsghdr" or begins with one that
  * is invalid, returns NULL without modifying 'buffer'. */
 struct nlmsghdr *
 nl_msg_next(struct ofpbuf *buffer, struct ofpbuf *msg)
 {
-    if (buffer->size >= sizeof(struct nlmsghdr)) {
+    if (ofpbuf_get_size(buffer) >= sizeof(struct nlmsghdr)) {
         struct nlmsghdr *nlmsghdr = nl_msg_nlmsghdr(buffer);
         size_t len = nlmsghdr->nlmsg_len;
-        if (len >= sizeof *nlmsghdr && len <= buffer->size) {
+        if (len >= sizeof *nlmsghdr && len <= ofpbuf_get_size(buffer)) {
             ofpbuf_use_const(msg, nlmsghdr, len);
             ofpbuf_pull(buffer, len);
             return nlmsghdr;
         }
     }
 
-    msg->data = NULL;
-    msg->size = 0;
+    ofpbuf_set_data(msg, NULL);
+    ofpbuf_set_size(msg, 0);
     return NULL;
 }
 
@@ -728,13 +728,13 @@ nl_policy_parse(const struct ofpbuf *msg, size_t nla_offset,
 
     memset(attrs, 0, n_attrs * sizeof *attrs);
 
-    if (msg->size < nla_offset) {
+    if (ofpbuf_get_size(msg) < nla_offset) {
         VLOG_DBG_RL(&rl, "missing headers in nl_policy_parse");
         return false;
     }
 
     NL_ATTR_FOR_EACH (nla, left, ofpbuf_at(msg, nla_offset, 0),
-                      msg->size - nla_offset)
+                      ofpbuf_get_size(msg) - nla_offset)
     {
         uint16_t type = nl_attr_type(nla);
         if (type < n_attrs && policy[type].type != NL_A_NO_ATTR) {
@@ -798,7 +798,7 @@ nl_attr_find__(const struct nlattr *attrs, size_t size, uint16_t type)
 const struct nlattr *
 nl_attr_find(const struct ofpbuf *buf, size_t hdr_len, uint16_t type)
 {
-    return nl_attr_find__(ofpbuf_at(buf, hdr_len, 0), buf->size - hdr_len,
+    return nl_attr_find__(ofpbuf_at(buf, hdr_len, 0), ofpbuf_get_size(buf) - hdr_len,
                           type);
 }
 
diff --git a/lib/nx-match.c b/lib/nx-match.c
index cd3bf08..cc20807 100644
--- a/lib/nx-match.c
+++ b/lib/nx-match.c
@@ -215,7 +215,7 @@ nx_pull_match__(struct ofpbuf *b, unsigned int match_len, bool strict,
         if (!p) {
             VLOG_DBG_RL(&rl, "nx_match length %u, rounded up to a "
                         "multiple of 8, is longer than space in message (max "
-                        "length %"PRIu32")", match_len, b->size);
+                        "length %"PRIu32")", match_len, ofpbuf_get_size(b));
             return OFPERR_OFPBMC_BAD_LEN;
         }
     }
@@ -251,11 +251,11 @@ nx_pull_match_loose(struct ofpbuf *b, unsigned int match_len,
 static enum ofperr
 oxm_pull_match__(struct ofpbuf *b, bool strict, struct match *match)
 {
-    struct ofp11_match_header *omh = b->data;
+    struct ofp11_match_header *omh = ofpbuf_get_data(b);
     uint8_t *p;
     uint16_t match_len;
 
-    if (b->size < sizeof *omh) {
+    if (ofpbuf_get_size(b) < sizeof *omh) {
         return OFPERR_OFPBMC_BAD_LEN;
     }
 
@@ -272,7 +272,7 @@ oxm_pull_match__(struct ofpbuf *b, bool strict, struct match *match)
     if (!p) {
         VLOG_DBG_RL(&rl, "oxm length %u, rounded up to a "
                     "multiple of 8, is longer than space in message (max "
-                    "length %"PRIu32")", match_len, b->size);
+                    "length %"PRIu32")", match_len, ofpbuf_get_size(b));
         return OFPERR_OFPBMC_BAD_LEN;
     }
 
@@ -568,7 +568,7 @@ nx_put_raw(struct ofpbuf *b, bool oxm, const struct match *match,
            ovs_be64 cookie, ovs_be64 cookie_mask)
 {
     const struct flow *flow = &match->flow;
-    const size_t start_len = b->size;
+    const size_t start_len = ofpbuf_get_size(b);
     int match_len;
     int i;
 
@@ -723,7 +723,7 @@ nx_put_raw(struct ofpbuf *b, bool oxm, const struct match *match,
     /* Cookie. */
     nxm_put_64m(b, NXM_NX_COOKIE, cookie, cookie_mask);
 
-    match_len = b->size - start_len;
+    match_len = ofpbuf_get_size(b) - start_len;
     return match_len;
 }
 
@@ -761,7 +761,7 @@ oxm_put_match(struct ofpbuf *b, const struct match *match)
 {
     int match_len;
     struct ofp11_match_header *omh;
-    size_t start_len = b->size;
+    size_t start_len = ofpbuf_get_size(b);
     ovs_be64 cookie = htonll(0), cookie_mask = htonll(0);
 
     ofpbuf_put_uninit(b, sizeof *omh);
@@ -833,7 +833,7 @@ nx_match_to_string(const uint8_t *p, unsigned int match_len)
 char *
 oxm_match_to_string(const struct ofpbuf *p, unsigned int match_len)
 {
-    const struct ofp11_match_header *omh = p->data;
+    const struct ofp11_match_header *omh = ofpbuf_get_data(p);
     uint16_t match_len_;
     struct ds s;
 
@@ -948,10 +948,10 @@ static int
 nx_match_from_string_raw(const char *s, struct ofpbuf *b)
 {
     const char *full_s = s;
-    const size_t start_len = b->size;
+    const size_t start_len = ofpbuf_get_size(b);
 
     if (!strcmp(s, "<any>")) {
-        /* Ensure that 'b->data' isn't actually null. */
+        /* Ensure that 'ofpbuf_get_data(b)' isn't actually null. */
         ofpbuf_prealloc_tailroom(b, 1);
         return 0;
     }
@@ -1000,7 +1000,7 @@ nx_match_from_string_raw(const char *s, struct ofpbuf *b)
         s++;
     }
 
-    return b->size - start_len;
+    return ofpbuf_get_size(b) - start_len;
 }
 
 int
@@ -1016,7 +1016,7 @@ oxm_match_from_string(const char *s, struct ofpbuf *b)
 {
     int match_len;
     struct ofp11_match_header *omh;
-    size_t start_len = b->size;
+    size_t start_len = ofpbuf_get_size(b);
 
     ofpbuf_put_uninit(b, sizeof *omh);
     match_len = nx_match_from_string_raw(s, b) + sizeof *omh;
@@ -1385,8 +1385,9 @@ nx_stack_pop(struct ofpbuf *stack)
 {
     union mf_subvalue *v = NULL;
 
-    if (stack->size) {
-        stack->size -= sizeof *v;
+    if (ofpbuf_get_size(stack)) {
+
+        ofpbuf_set_size(stack, ofpbuf_get_size(stack) - sizeof *v);
         v = (union mf_subvalue *) ofpbuf_tail(stack);
     }
 
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 956fef1..7fdea63 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -605,7 +605,7 @@ parse_odp_action(const char *s, const struct simap *port_names,
             ofpbuf_init(&buf, 16);
             end = ofpbuf_put_hex(&buf, &s[n], NULL);
             if (end[0] == ')' && end[1] == ')') {
-                odp_put_userspace_action(pid, buf.data, buf.size, actions);
+                odp_put_userspace_action(pid, ofpbuf_get_data(&buf), ofpbuf_get_size(&buf), actions);
                 ofpbuf_uninit(&buf);
                 return (end + 2) - s;
             }
@@ -715,7 +715,7 @@ odp_actions_from_string(const char *s, const struct simap *port_names,
         return 0;
     }
 
-    old_size = actions->size;
+    old_size = ofpbuf_get_size(actions);
     for (;;) {
         int retval;
 
@@ -726,7 +726,7 @@ odp_actions_from_string(const char *s, const struct simap *port_names,
 
         retval = parse_odp_action(s, port_names, actions);
         if (retval < 0 || !strchr(delimiters, s[retval])) {
-            actions->size = old_size;
+            ofpbuf_set_size(actions, old_size);
             return -retval;
         }
         s += retval;
@@ -1442,7 +1442,7 @@ generate_all_wildcard_mask(struct ofpbuf *ofp, const struct nlattr *key)
         nl_msg_end_nested(ofp, nested_mask);
     }
 
-    return ofp->base;
+    return ofpbuf_get_base(ofp);
 }
 
 /* Appends to 'ds' a string representation of the 'key_len' bytes of
@@ -2430,7 +2430,7 @@ int
 odp_flow_from_string(const char *s, const struct simap *port_names,
                      struct ofpbuf *key, struct ofpbuf *mask)
 {
-    const size_t old_size = key->size;
+    const size_t old_size = ofpbuf_get_size(key);
     for (;;) {
         int retval;
 
@@ -2441,7 +2441,7 @@ odp_flow_from_string(const char *s, const struct simap *port_names,
 
         retval = parse_odp_key_mask_attr(s, port_names, key, mask);
         if (retval < 0) {
-            key->size = old_size;
+            ofpbuf_set_size(key, old_size);
             return -retval;
         }
         s += retval;
@@ -3448,7 +3448,7 @@ odp_put_userspace_action(uint32_t pid,
     offset = nl_msg_start_nested(odp_actions, OVS_ACTION_ATTR_USERSPACE);
     nl_msg_put_u32(odp_actions, OVS_USERSPACE_ATTR_PID, pid);
     if (userdata) {
-        userdata_ofs = odp_actions->size + NLA_HDRLEN;
+        userdata_ofs = ofpbuf_get_size(odp_actions) + NLA_HDRLEN;
 
         /* The OVS kernel module before OVS 1.11 and the upstream Linux kernel
          * module before Linux 3.10 required the userdata to be exactly 8 bytes
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index 23d89d3..054efdd 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -711,7 +711,7 @@ ofpacts_pull_openflow_actions(struct ofpbuf *openflow,
     if (actions == NULL) {
         VLOG_WARN_RL(&rl, "OpenFlow message actions length %u exceeds "
                      "remaining message length (%"PRIu32")",
-                     actions_len, openflow->size);
+                     actions_len, ofpbuf_get_size(openflow));
         return OFPERR_OFPBRC_BAD_LEN;
     }
 
@@ -722,7 +722,7 @@ ofpacts_pull_openflow_actions(struct ofpbuf *openflow,
         return error;
     }
 
-    error = ofpacts_verify(ofpacts->data, ofpacts->size);
+    error = ofpacts_verify(ofpbuf_get_data(ofpacts), ofpbuf_get_size(ofpacts));
     if (error) {
         ofpbuf_clear(ofpacts);
     }
@@ -1420,7 +1420,7 @@ ofpacts_copy_last(struct ofpbuf *out, const struct ofpbuf *in,
     const struct ofpact *a;
 
     target = NULL;
-    OFPACT_FOR_EACH (a, in->data, in->size) {
+    OFPACT_FOR_EACH (a, ofpbuf_get_data(in), ofpbuf_get_size(in)) {
         if (a->type == filter) {
             target = a;
         }
@@ -1439,7 +1439,7 @@ ofpacts_copy_all(struct ofpbuf *out, const struct ofpbuf *in,
 {
     const struct ofpact *a;
 
-    OFPACT_FOR_EACH (a, in->data, in->size) {
+    OFPACT_FOR_EACH (a, ofpbuf_get_data(in), ofpbuf_get_size(in)) {
         if (filter(a)) {
             ofpact_copy(out, a);
         }
@@ -1497,7 +1497,7 @@ ofpacts_from_openflow11_for_action_set(const union ofp_action *in,
 {
     enum ofperr error;
     struct ofpact *a;
-    size_t start = out->size;
+    size_t start = ofpbuf_get_size(out);
 
     error = ofpacts_from_openflow(in, n_in, version, out);
 
@@ -1505,7 +1505,7 @@ ofpacts_from_openflow11_for_action_set(const union ofp_action *in,
         return error;
     }
 
-    OFPACT_FOR_EACH (a, ofpact_end(out->data, start), out->size - start) {
+    OFPACT_FOR_EACH (a, ofpact_end(ofpbuf_get_data(out), start), ofpbuf_get_size(out) - start) {
         if (!ofpact_is_allowed_in_actions_set(a)) {
             VLOG_WARN_RL(&rl, "disallowed action in action set");
             return OFPERR_OFPBAC_BAD_TYPE;
@@ -1769,7 +1769,7 @@ ofpacts_pull_openflow_instructions(struct ofpbuf *openflow,
     if (instructions == NULL) {
         VLOG_WARN_RL(&rl, "OpenFlow message instructions length %u exceeds "
                      "remaining message length (%"PRIu32")",
-                     instructions_len, openflow->size);
+                     instructions_len, ofpbuf_get_size(openflow));
         error = OFPERR_OFPBIC_BAD_LEN;
         goto exit;
     }
@@ -1814,7 +1814,7 @@ ofpacts_pull_openflow_instructions(struct ofpbuf *openflow,
         size_t start;
 
         ofpact_pad(ofpacts);
-        start = ofpacts->size;
+        start = ofpbuf_get_size(ofpacts);
         on = ofpact_put(ofpacts, OFPACT_WRITE_ACTIONS,
                         offsetof(struct ofpact_nest, actions));
         get_actions_from_instruction(insts[OVSINST_OFPIT11_WRITE_ACTIONS],
@@ -1825,7 +1825,7 @@ ofpacts_pull_openflow_instructions(struct ofpbuf *openflow,
             goto exit;
         }
         on = ofpbuf_at_assert(ofpacts, start, sizeof *on);
-        on->ofpact.len = ofpacts->size - start;
+        on->ofpact.len = ofpbuf_get_size(ofpacts) - start;
     }
     if (insts[OVSINST_OFPIT11_WRITE_METADATA]) {
         const struct ofp11_instruction_write_metadata *oiwm;
@@ -1848,7 +1848,7 @@ ofpacts_pull_openflow_instructions(struct ofpbuf *openflow,
         ogt->table_id = oigt->table_id;
     }
 
-    error = ofpacts_verify(ofpacts->data, ofpacts->size);
+    error = ofpacts_verify(ofpbuf_get_data(ofpacts), ofpbuf_get_size(ofpacts));
 exit:
     if (error) {
         ofpbuf_clear(ofpacts);
@@ -2288,23 +2288,23 @@ ofpact_write_metadata_to_nxast(const struct ofpact_metadata *om,
 static void
 ofpact_note_to_nxast(const struct ofpact_note *note, struct ofpbuf *out)
 {
-    size_t start_ofs = out->size;
+    size_t start_ofs = ofpbuf_get_size(out);
     struct nx_action_note *nan;
     unsigned int remainder;
     unsigned int len;
 
     nan = ofputil_put_NXAST_NOTE(out);
-    out->size -= sizeof nan->note;
+    ofpbuf_set_size(out, ofpbuf_get_size(out) - sizeof nan->note);
 
     ofpbuf_put(out, note->data, note->length);
 
-    len = out->size - start_ofs;
+    len = ofpbuf_get_size(out) - start_ofs;
     remainder = len % OFP_ACTION_ALIGN;
     if (remainder) {
         ofpbuf_put_zeros(out, OFP_ACTION_ALIGN - remainder);
     }
     nan = ofpbuf_at(out, start_ofs, sizeof *nan);
-    nan->len = htons(out->size - start_ofs);
+    nan->len = htons(ofpbuf_get_size(out) - start_ofs);
 }
 
 static void
@@ -2981,7 +2981,7 @@ ofpacts_put_openflow_actions(const struct ofpact ofpacts[], size_t ofpacts_len,
                              enum ofp_version ofp_version)
 {
     const struct ofpact *a;
-    size_t start_size = openflow->size;
+    size_t start_size = ofpbuf_get_size(openflow);
 
     void (*translate)(const struct ofpact *a, struct ofpbuf *out) =
         (ofp_version == OFP10_VERSION) ? ofpact_to_openflow10 :
@@ -2991,7 +2991,7 @@ ofpacts_put_openflow_actions(const struct ofpact ofpacts[], size_t ofpacts_len,
     OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) {
         translate(a, openflow);
     }
-    return openflow->size - start_size;
+    return ofpbuf_get_size(openflow) - start_size;
 }
 
 static void
@@ -3001,10 +3001,10 @@ ofpacts_update_instruction_actions(struct ofpbuf *openflow, size_t ofs)
 
     /* Update the instruction's length (or, if it's empty, delete it). */
     oia = ofpbuf_at_assert(openflow, ofs, sizeof *oia);
-    if (openflow->size > ofs + sizeof *oia) {
-        oia->len = htons(openflow->size - ofs);
+    if (ofpbuf_get_size(openflow) > ofs + sizeof *oia) {
+        oia->len = htons(ofpbuf_get_size(openflow) - ofs);
     } else {
-        openflow->size = ofs;
+        ofpbuf_set_size(openflow, ofs);
     }
 }
 
@@ -3055,7 +3055,7 @@ ofpacts_put_openflow_instructions(const struct ofpact ofpacts[],
             break;
 
         case OVSINST_OFPIT11_APPLY_ACTIONS: {
-            const size_t ofs = openflow->size;
+            const size_t ofs = ofpbuf_get_size(openflow);
             const size_t ofpacts_len_left =
                 (uint8_t*)ofpact_end(ofpacts, ofpacts_len) - (uint8_t*)a;
             const struct ofpact *action;
@@ -3080,7 +3080,7 @@ ofpacts_put_openflow_instructions(const struct ofpact ofpacts[],
         }
 
         case OVSINST_OFPIT11_WRITE_ACTIONS: {
-            const size_t ofs = openflow->size;
+            const size_t ofs = ofpbuf_get_size(openflow);
             const struct ofpact_nest *on;
 
             on = ofpact_get_WRITE_ACTIONS(a);
@@ -3648,7 +3648,7 @@ ofpact_update_len(struct ofpbuf *ofpacts, struct ofpact *ofpact)
 void
 ofpact_pad(struct ofpbuf *ofpacts)
 {
-    unsigned int pad = PAD_SIZE(ofpacts->size, OFPACT_ALIGNTO);
+    unsigned int pad = PAD_SIZE(ofpbuf_get_size(ofpacts), OFPACT_ALIGNTO);
     if (pad) {
         ofpbuf_put_zeros(ofpacts, pad);
     }
diff --git a/lib/ofp-errors.c b/lib/ofp-errors.c
index a8c5c31..7f0f8f5 100644
--- a/lib/ofp-errors.c
+++ b/lib/ofp-errors.c
@@ -323,7 +323,7 @@ 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, b.data, b.size);
+        ofpbuf_use_const(payload, ofpbuf_get_data(&b), ofpbuf_get_size(&b));
     }
     return error;
 }
diff --git a/lib/ofp-msgs.c b/lib/ofp-msgs.c
index 677d359..320a7ff 100644
--- a/lib/ofp-msgs.c
+++ b/lib/ofp-msgs.c
@@ -371,7 +371,7 @@ ofpraw_decode_assert(const struct ofp_header *oh)
 }
 
 /* Determines the OFPRAW_* type of the OpenFlow message in 'msg', which starts
- * at 'msg->data' and has length 'msg->size' bytes.  On success, returns 0 and
+ * at 'ofpbuf_get_data(msg)' and has length 'ofpbuf_get_size(msg)' bytes.  On success, returns 0 and
  * stores the type into '*rawp'.  On failure, returns an OFPERR_* error code
  * and zeros '*rawp'.
  *
@@ -382,7 +382,7 @@ ofpraw_decode_assert(const struct ofp_header *oh)
  * (including the stats headers, vendor header, and any subtype header) with
  * ofpbuf_pull().  It also sets 'msg->l2' to the start of the OpenFlow header
  * and 'msg->l3' just beyond the headers (that is, to the final value of
- * msg->data). */
+ * ofpbuf_get_data(msg)). */
 enum ofperr
 ofpraw_pull(enum ofpraw *rawp, struct ofpbuf *msg)
 {
@@ -399,12 +399,12 @@ ofpraw_pull(enum ofpraw *rawp, struct ofpbuf *msg)
     enum ofpraw raw;
 
     /* Set default outputs. */
-    msg->l2 = msg->data;
-    ofpbuf_set_l3(msg, msg->data);
+    msg->l2 = ofpbuf_get_data(msg);
+    ofpbuf_set_l3(msg, ofpbuf_get_data(msg));
     *rawp = 0;
 
-    len = msg->size;
-    error = ofphdrs_decode(&hdrs, msg->data, len);
+    len = ofpbuf_get_size(msg);
+    error = ofphdrs_decode(&hdrs, ofpbuf_get_data(msg), len);
     if (error) {
         return error;
     }
@@ -417,7 +417,7 @@ ofpraw_pull(enum ofpraw *rawp, struct ofpbuf *msg)
     info = raw_info_get(raw);
     instance = raw_instance_get(info, hdrs.version);
     msg->l2 = ofpbuf_pull(msg, instance->hdrs_len);
-    ofpbuf_set_l3(msg, msg->data);
+    ofpbuf_set_l3(msg, ofpbuf_get_data(msg));
 
     min_len = instance->hdrs_len + info->min_body;
     switch (info->extra_multiple) {
@@ -670,7 +670,7 @@ ofpraw_put__(enum ofpraw raw, uint8_t version, ovs_be32 xid,
     oh = buf->l2;
     oh->version = version;
     oh->type = hdrs->type;
-    oh->length = htons(buf->size);
+    oh->length = htons(ofpbuf_get_size(buf));
     oh->xid = xid;
 
     if (hdrs->type == OFPT_VENDOR) {
@@ -790,7 +790,7 @@ ofptype_decode(enum ofptype *typep, const struct ofp_header *oh)
 }
 
 /* Determines the OFPTYPE_* type of the OpenFlow message in 'msg', which starts
- * at 'msg->data' and has length 'msg->size' bytes.  On success, returns 0 and
+ * at 'ofpbuf_get_data(msg)' and has length 'ofpbuf_get_size(msg)' bytes.  On success, returns 0 and
  * stores the type into '*typep'.  On failure, returns an OFPERR_* error code
  * and zeros '*typep'.
  *
@@ -801,7 +801,7 @@ ofptype_decode(enum ofptype *typep, const struct ofp_header *oh)
  * (including the stats headers, vendor header, and any subtype header) with
  * ofpbuf_pull().  It also sets 'msg->l2' to the start of the OpenFlow header
  * and 'msg->l3' just beyond the headers (that is, to the final value of
- * msg->data). */
+ * ofpbuf_get_data(msg)). */
 enum ofperr
 ofptype_pull(enum ofptype *typep, struct ofpbuf *buf)
 {
@@ -824,12 +824,12 @@ ofptype_from_ofpraw(enum ofpraw raw)
 }
 
 /* Updates the 'length' field of the OpenFlow message in 'buf' to
- * 'buf->size'. */
+ * 'ofpbuf_get_size(buf)'. */
 void
 ofpmsg_update_length(struct ofpbuf *buf)
 {
     struct ofp_header *oh = ofpbuf_at_assert(buf, 0, sizeof *oh);
-    oh->length = htons(buf->size);
+    oh->length = htons(ofpbuf_get_size(buf));
 }
 
 /* Returns just past the Openflow header (including the stats headers, vendor
@@ -880,7 +880,7 @@ ofpmp_reserve(struct list *replies, size_t len)
 {
     struct ofpbuf *msg = ofpbuf_from_list(list_back(replies));
 
-    if (msg->size + len <= UINT16_MAX) {
+    if (ofpbuf_get_size(msg) + len <= UINT16_MAX) {
         ofpbuf_prealloc_tailroom(msg, len);
         return msg;
     } else {
@@ -888,16 +888,16 @@ ofpmp_reserve(struct list *replies, size_t len)
         struct ofpbuf *next;
         struct ofphdrs hdrs;
 
-        ofphdrs_decode_assert(&hdrs, msg->data, msg->size);
+        ofphdrs_decode_assert(&hdrs, ofpbuf_get_data(msg), ofpbuf_get_size(msg));
         hdrs_len = ofphdrs_len(&hdrs);
 
         next = ofpbuf_new(MAX(1024, hdrs_len + len));
-        ofpbuf_put(next, msg->data, hdrs_len);
-        next->l2 = next->data;
+        ofpbuf_put(next, ofpbuf_get_data(msg), hdrs_len);
+        next->l2 = ofpbuf_get_data(next);
         ofpbuf_set_l3(next, ofpbuf_tail(next));
         list_push_back(replies, &next->list_node);
 
-        *ofpmp_flags__(msg->data) |= htons(OFPSF_REPLY_MORE);
+        *ofpmp_flags__(ofpbuf_get_data(msg)) |= htons(OFPSF_REPLY_MORE);
 
         return next;
     }
@@ -927,11 +927,11 @@ ofpmp_postappend(struct list *replies, size_t start_ofs)
     struct ofpbuf *msg = ofpbuf_from_list(list_back(replies));
 
     ovs_assert(start_ofs <= UINT16_MAX);
-    if (msg->size > UINT16_MAX) {
-        size_t len = msg->size - start_ofs;
+    if (ofpbuf_get_size(msg) > UINT16_MAX) {
+        size_t len = ofpbuf_get_size(msg) - start_ofs;
         memcpy(ofpmp_append(replies, len),
-               (const uint8_t *) msg->data + start_ofs, len);
-        msg->size = start_ofs;
+               (const uint8_t *) ofpbuf_get_data(msg) + start_ofs, len);
+        ofpbuf_set_size(msg, start_ofs);
     }
 }
 
diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index 5c5bb06..02f0ad7 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -632,7 +632,7 @@ parse_named_action(enum ofputil_action_code code,
                    char *arg, struct ofpbuf *ofpacts,
                    enum ofputil_protocol *usable_protocols)
 {
-    size_t orig_size = ofpacts->size;
+    size_t orig_size = ofpbuf_get_size(ofpacts);
     struct ofpact_tunnel *tunnel;
     struct ofpact_vlan_vid *vlan_vid;
     struct ofpact_vlan_pcp *vlan_pcp;
@@ -929,7 +929,7 @@ parse_named_action(enum ofputil_action_code code,
     }
 
     if (error) {
-        ofpacts->size = orig_size;
+        ofpbuf_set_size(ofpacts, orig_size);
     }
     return error;
 }
@@ -978,7 +978,7 @@ static char * WARN_UNUSED_RESULT
 str_to_ofpacts__(char *str, struct ofpbuf *ofpacts,
                  enum ofputil_protocol *usable_protocols)
 {
-    size_t orig_size = ofpacts->size;
+    size_t orig_size = ofpbuf_get_size(ofpacts);
     char *pos, *act, *arg;
     int n_actions;
 
@@ -988,7 +988,7 @@ str_to_ofpacts__(char *str, struct ofpbuf *ofpacts,
         char *error = str_to_ofpact__(pos, act, arg, ofpacts, n_actions,
                                       usable_protocols);
         if (error) {
-            ofpacts->size = orig_size;
+            ofpbuf_set_size(ofpacts, orig_size);
             return error;
         }
         n_actions++;
@@ -1007,7 +1007,7 @@ static char * WARN_UNUSED_RESULT
 str_to_ofpacts(char *str, struct ofpbuf *ofpacts,
                enum ofputil_protocol *usable_protocols)
 {
-    size_t orig_size = ofpacts->size;
+    size_t orig_size = ofpbuf_get_size(ofpacts);
     char *error_s;
     enum ofperr error;
 
@@ -1016,9 +1016,9 @@ str_to_ofpacts(char *str, struct ofpbuf *ofpacts,
         return error_s;
     }
 
-    error = ofpacts_verify(ofpacts->data, ofpacts->size);
+    error = ofpacts_verify(ofpbuf_get_data(ofpacts), ofpbuf_get_size(ofpacts));
     if (error) {
-        ofpacts->size = orig_size;
+        ofpbuf_set_size(ofpacts, orig_size);
         return xstrdup("Incorrect action ordering");
     }
 
@@ -1050,16 +1050,16 @@ parse_named_instruction(enum ovs_instruction_type type,
         size_t ofs;
 
         ofpact_pad(ofpacts);
-        ofs = ofpacts->size;
+        ofs = ofpbuf_get_size(ofpacts);
         on = ofpact_put(ofpacts, OFPACT_WRITE_ACTIONS,
                         offsetof(struct ofpact_nest, actions));
         error_s = str_to_ofpacts__(arg, ofpacts, usable_protocols);
 
         on = ofpbuf_at_assert(ofpacts, ofs, sizeof *on);
-        on->ofpact.len = ofpacts->size - ofs;
+        on->ofpact.len = ofpbuf_get_size(ofpacts) - ofs;
 
         if (error_s) {
-            ofpacts->size = ofs;
+            ofpbuf_set_size(ofpacts, ofs);
         }
         break;
     }
@@ -1095,7 +1095,7 @@ parse_named_instruction(enum ovs_instruction_type type,
 
     /* If write_metadata is specified as an action AND an instruction, ofpacts
        could be invalid. */
-    error = ofpacts_verify(ofpacts->data, ofpacts->size);
+    error = ofpacts_verify(ofpbuf_get_data(ofpacts), ofpbuf_get_size(ofpacts));
     if (error) {
         return xstrdup("Incorrect instruction ordering");
     }
@@ -1110,7 +1110,7 @@ static char * WARN_UNUSED_RESULT
 str_to_inst_ofpacts(char *str, struct ofpbuf *ofpacts,
                     enum ofputil_protocol *usable_protocols)
 {
-    size_t orig_size = ofpacts->size;
+    size_t orig_size = ofpbuf_get_size(ofpacts);
     char *pos, *inst, *arg;
     int type;
     const char *prev_inst = NULL;
@@ -1124,7 +1124,7 @@ str_to_inst_ofpacts(char *str, struct ofpbuf *ofpacts,
             char *error = str_to_ofpact__(pos, inst, arg, ofpacts, n_actions,
                                           usable_protocols);
             if (error) {
-                ofpacts->size = orig_size;
+                ofpbuf_set_size(ofpacts, orig_size);
                 return error;
             }
 
@@ -1134,20 +1134,20 @@ str_to_inst_ofpacts(char *str, struct ofpbuf *ofpacts,
                 continue;
             }
         } else if (type == OVSINST_OFPIT11_APPLY_ACTIONS) {
-            ofpacts->size = orig_size;
+            ofpbuf_set_size(ofpacts, orig_size);
             return xasprintf("%s isn't supported. Just write actions then "
                              "it is interpreted as apply_actions", inst);
         } else {
             char *error = parse_named_instruction(type, arg, ofpacts,
                                                   usable_protocols);
             if (error) {
-                ofpacts->size = orig_size;
+                ofpbuf_set_size(ofpacts, orig_size);
                 return error;
             }
         }
 
         if (type <= prev_type) {
-            ofpacts->size = orig_size;
+            ofpbuf_set_size(ofpacts, orig_size);
             if (type == prev_type) {
                 return xasprintf("instruction %s may be specified only once",
                                  inst);
@@ -1433,7 +1433,7 @@ parse_ofp_str__(struct ofputil_flow_mod *fm, int command, char *string,
         if (!error) {
             enum ofperr err;
 
-            err = ofpacts_check(ofpacts.data, ofpacts.size, &fm->match.flow,
+            err = ofpacts_check(ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts), &fm->match.flow,
                                 OFPP_MAX, fm->table_id, 255, usable_protocols);
             if (!err && !usable_protocols) {
                 err = OFPERR_OFPBAC_MATCH_INCONSISTENT;
@@ -1449,7 +1449,7 @@ parse_ofp_str__(struct ofputil_flow_mod *fm, int command, char *string,
             return error;
         }
 
-        fm->ofpacts_len = ofpacts.size;
+        fm->ofpacts_len = ofpbuf_get_size(&ofpacts);
         fm->ofpacts = ofpbuf_steal_data(&ofpacts);
     } else {
         fm->ofpacts_len = 0;
@@ -2130,8 +2130,8 @@ parse_bucket_str(struct ofputil_bucket *bucket, char *str_,
     }
 
     ofpact_pad(&ofpacts);
-    bucket->ofpacts = ofpacts.data;
-    bucket->ofpacts_len = ofpacts.size;
+    bucket->ofpacts = ofpbuf_get_data(&ofpacts);
+    bucket->ofpacts_len = ofpbuf_get_size(&ofpacts);
 
     return NULL;
 }
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index b88d1e7..b6c3431 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -1361,9 +1361,9 @@ ofp_print_error_msg(struct ds *string, const struct ofp_header *oh)
     ds_put_format(string, " %s\n", ofperr_get_name(error));
 
     if (error == OFPERR_OFPHFC_INCOMPATIBLE || error == OFPERR_OFPHFC_EPERM) {
-        ds_put_printable(string, payload.data, payload.size);
+        ds_put_printable(string, ofpbuf_get_data(&payload), ofpbuf_get_size(&payload));
     } else {
-        s = ofp_to_string(payload.data, payload.size, 1);
+        s = ofp_to_string(ofpbuf_get_data(&payload), ofpbuf_get_size(&payload), 1);
         ds_put_cstr(string, s);
         free(s);
     }
@@ -1663,7 +1663,7 @@ ofp_print_ofpst_table_reply13(struct ds *string, const struct ofp_header *oh,
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
     ofpraw_pull_assert(&b);
 
-    n = b.size / sizeof *ts;
+    n = ofpbuf_get_size(&b) / sizeof *ts;
     ds_put_format(string, " %"PRIuSIZE" tables\n", n);
     if (verbosity < 1) {
         return;
@@ -1693,7 +1693,7 @@ ofp_print_ofpst_table_reply12(struct ds *string, const struct ofp_header *oh,
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
     ofpraw_pull_assert(&b);
 
-    n = b.size / sizeof *ts;
+    n = ofpbuf_get_size(&b) / sizeof *ts;
     ds_put_format(string, " %"PRIuSIZE" tables\n", n);
     if (verbosity < 1) {
         return;
@@ -1720,7 +1720,7 @@ ofp_print_ofpst_table_reply11(struct ds *string, const struct ofp_header *oh,
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
     ofpraw_pull_assert(&b);
 
-    n = b.size / sizeof *ts;
+    n = ofpbuf_get_size(&b) / sizeof *ts;
     ds_put_format(string, " %"PRIuSIZE" tables\n", n);
     if (verbosity < 1) {
         return;
@@ -1760,7 +1760,7 @@ ofp_print_ofpst_table_reply10(struct ds *string, const struct ofp_header *oh,
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
     ofpraw_pull_assert(&b);
 
-    n = b.size / sizeof *ts;
+    n = ofpbuf_get_size(&b) / sizeof *ts;
     ds_put_format(string, " %"PRIuSIZE" tables\n", n);
     if (verbosity < 1) {
         return;
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index d0002d5..603d128 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -265,10 +265,10 @@ enum ofperr
 ofputil_pull_ofp11_match(struct ofpbuf *buf, struct match *match,
                          uint16_t *padded_match_len)
 {
-    struct ofp11_match_header *omh = buf->data;
+    struct ofp11_match_header *omh = ofpbuf_get_data(buf);
     uint16_t match_len;
 
-    if (buf->size < sizeof *omh) {
+    if (ofpbuf_get_size(buf) < sizeof *omh) {
         return OFPERR_OFPBMC_BAD_LEN;
     }
 
@@ -278,7 +278,7 @@ ofputil_pull_ofp11_match(struct ofpbuf *buf, struct match *match,
     case OFPMT_STANDARD: {
         struct ofp11_match *om;
 
-        if (match_len != sizeof *om || buf->size < sizeof *om) {
+        if (match_len != sizeof *om || ofpbuf_get_size(buf) < sizeof *om) {
             return OFPERR_OFPBMC_BAD_LEN;
         }
         om = ofpbuf_pull(buf, sizeof *om);
@@ -1234,15 +1234,15 @@ ofputil_decode_hello(const struct ofp_header *oh, uint32_t *allowed_versions)
     ofpbuf_pull(&msg, sizeof *oh);
 
     *allowed_versions = version_bitmap_from_version(oh->version);
-    while (msg.size) {
+    while (ofpbuf_get_size(&msg)) {
         const struct ofp_hello_elem_header *oheh;
         unsigned int len;
 
-        if (msg.size < sizeof *oheh) {
+        if (ofpbuf_get_size(&msg) < sizeof *oheh) {
             return false;
         }
 
-        oheh = msg.data;
+        oheh = ofpbuf_get_data(&msg);
         len = ntohs(oheh->length);
         if (len < sizeof *oheh || !ofpbuf_try_pull(&msg, ROUND_UP(len, 8))) {
             return false;
@@ -1543,7 +1543,7 @@ ofputil_decode_flow_mod(struct ofputil_flow_mod *fm,
             return error;
         }
 
-        error = ofpacts_pull_openflow_instructions(&b, b.size, oh->version,
+        error = ofpacts_pull_openflow_instructions(&b, ofpbuf_get_size(&b), oh->version,
                                                    ofpacts);
         if (error) {
             return error;
@@ -1610,7 +1610,7 @@ ofputil_decode_flow_mod(struct ofputil_flow_mod *fm,
             ofputil_normalize_match(&fm->match);
 
             /* Now get the actions. */
-            error = ofpacts_pull_openflow_actions(&b, b.size, oh->version,
+            error = ofpacts_pull_openflow_actions(&b, ofpbuf_get_size(&b), oh->version,
                                                   ofpacts);
             if (error) {
                 return error;
@@ -1644,7 +1644,7 @@ ofputil_decode_flow_mod(struct ofputil_flow_mod *fm,
             if (error) {
                 return error;
             }
-            error = ofpacts_pull_openflow_actions(&b, b.size, oh->version,
+            error = ofpacts_pull_openflow_actions(&b, ofpbuf_get_size(&b), oh->version,
                                                   ofpacts);
             if (error) {
                 return error;
@@ -1679,8 +1679,8 @@ ofputil_decode_flow_mod(struct ofputil_flow_mod *fm,
         }
     }
 
-    fm->ofpacts = ofpacts->data;
-    fm->ofpacts_len = ofpacts->size;
+    fm->ofpacts = ofpbuf_get_data(ofpacts);
+    fm->ofpacts_len = ofpbuf_get_size(ofpacts);
 
     error = ofputil_decode_flow_mod_flags(raw_flags, fm->command,
                                           oh->version, &fm->flags);
@@ -1778,9 +1778,9 @@ ofputil_decode_meter_mod(const struct ofp_header *oh,
             mm->meter.flags & OFPMF13_PKTPS) {
             return OFPERR_OFPMMFC_BAD_FLAGS;
         }
-        mm->meter.bands = bands->data;
+        mm->meter.bands = ofpbuf_get_data(bands);
 
-        error = ofputil_pull_bands(&b, b.size, &mm->meter.n_bands, bands);
+        error = ofputil_pull_bands(&b, ofpbuf_get_size(&b), &mm->meter.n_bands, bands);
         if (error) {
             return error;
         }
@@ -1856,14 +1856,14 @@ ofputil_append_meter_config(struct list *replies,
                             const struct ofputil_meter_config *mc)
 {
     struct ofpbuf *msg = ofpbuf_from_list(list_back(replies));
-    size_t start_ofs = msg->size;
+    size_t start_ofs = ofpbuf_get_size(msg);
     struct ofp13_meter_config *reply = ofpbuf_put_uninit(msg, sizeof *reply);
     reply->flags = htons(mc->flags);
     reply->meter_id = htonl(mc->meter_id);
 
     ofputil_put_bands(mc->n_bands, mc->bands, msg);
 
-    reply->length = htons(msg->size - start_ofs);
+    reply->length = htons(ofpbuf_get_size(msg) - start_ofs);
 
     ofpmp_postappend(replies, start_ofs);
 }
@@ -1922,7 +1922,7 @@ ofputil_decode_meter_config(struct ofpbuf *msg,
         ofpraw_pull_assert(msg);
     }
 
-    if (!msg->size) {
+    if (!ofpbuf_get_size(msg)) {
         return EOF;
     }
 
@@ -1930,7 +1930,7 @@ ofputil_decode_meter_config(struct ofpbuf *msg,
     if (!omc) {
         VLOG_WARN_RL(&bad_ofmsg_rl,
                      "OFPMP_METER_CONFIG reply has %"PRIu32" leftover bytes at end",
-                     msg->size);
+                     ofpbuf_get_size(msg));
         return OFPERR_OFPBRC_BAD_LEN;
     }
 
@@ -1942,7 +1942,7 @@ ofputil_decode_meter_config(struct ofpbuf *msg,
     }
     mc->meter_id = ntohl(omc->meter_id);
     mc->flags = ntohs(omc->flags);
-    mc->bands = bands->data;
+    mc->bands = ofpbuf_get_data(bands);
 
     return 0;
 }
@@ -1998,7 +1998,7 @@ ofputil_decode_meter_stats(struct ofpbuf *msg,
         ofpraw_pull_assert(msg);
     }
 
-    if (!msg->size) {
+    if (!ofpbuf_get_size(msg)) {
         return EOF;
     }
 
@@ -2006,7 +2006,7 @@ ofputil_decode_meter_stats(struct ofpbuf *msg,
     if (!oms) {
         VLOG_WARN_RL(&bad_ofmsg_rl,
                      "OFPMP_METER reply has %"PRIu32" leftover bytes at end",
-                     msg->size);
+                     ofpbuf_get_size(msg));
         return OFPERR_OFPBRC_BAD_LEN;
     }
 
@@ -2022,7 +2022,7 @@ ofputil_decode_meter_stats(struct ofpbuf *msg,
     ms->byte_in_count = ntohll(oms->byte_in_count);
     ms->duration_sec = ntohl(oms->duration_sec);
     ms->duration_nsec = ntohl(oms->duration_nsec);
-    ms->bands = bands->data;
+    ms->bands = ofpbuf_get_data(bands);
 
     return 0;
 }
@@ -2250,7 +2250,7 @@ ofputil_decode_nxst_flow_request(struct ofputil_flow_stats_request *fsr,
     if (error) {
         return error;
     }
-    if (b->size) {
+    if (ofpbuf_get_size(b)) {
         return OFPERR_OFPBRC_BAD_LEN;
     }
 
@@ -2306,12 +2306,12 @@ ofputil_decode_queue_get_config_request(const struct ofp_header *oh,
 
     switch ((int) raw) {
     case OFPRAW_OFPT10_QUEUE_GET_CONFIG_REQUEST:
-        qgcr10 = b.data;
+        qgcr10 = ofpbuf_get_data(&b);
         *port = u16_to_ofp(ntohs(qgcr10->port));
         return 0;
 
     case OFPRAW_OFPT11_QUEUE_GET_CONFIG_REQUEST:
-        qgcr11 = b.data;
+        qgcr11 = ofpbuf_get_data(&b);
         return ofputil_port_from_ofp11(qgcr11->port, port);
     }
 
@@ -2380,17 +2380,17 @@ void
 ofputil_append_queue_get_config_reply(struct ofpbuf *reply,
                                       const struct ofputil_queue_config *oqc)
 {
-    const struct ofp_header *oh = reply->data;
+    const struct ofp_header *oh = ofpbuf_get_data(reply);
     size_t start_ofs, len_ofs;
     ovs_be16 *len;
 
-    start_ofs = reply->size;
+    start_ofs = ofpbuf_get_size(reply);
     if (oh->version < OFP12_VERSION) {
         struct ofp10_packet_queue *opq10;
 
         opq10 = ofpbuf_put_zeros(reply, sizeof *opq10);
         opq10->queue_id = htonl(oqc->queue_id);
-        len_ofs = (char *) &opq10->len - (char *) reply->data;
+        len_ofs = (char *) &opq10->len - (char *) ofpbuf_get_data(reply);
     } else {
         struct ofp11_queue_get_config_reply *qgcr11;
         struct ofp12_packet_queue *opq12;
@@ -2402,14 +2402,14 @@ ofputil_append_queue_get_config_reply(struct ofpbuf *reply,
         opq12 = ofpbuf_put_zeros(reply, sizeof *opq12);
         opq12->port = port;
         opq12->queue_id = htonl(oqc->queue_id);
-        len_ofs = (char *) &opq12->len - (char *) reply->data;
+        len_ofs = (char *) &opq12->len - (char *) ofpbuf_get_data(reply);
     }
 
     put_queue_rate(reply, OFPQT_MIN_RATE, oqc->min_rate);
     put_queue_rate(reply, OFPQT_MAX_RATE, oqc->max_rate);
 
     len = ofpbuf_at(reply, len_ofs, sizeof *len);
-    *len = htons(reply->size - start_ofs);
+    *len = htons(ofpbuf_get_size(reply) - start_ofs);
 }
 
 /* Decodes the initial part of an OFPT_QUEUE_GET_CONFIG_REPLY from 'reply' and
@@ -2468,7 +2468,7 @@ ofputil_pull_queue_get_config_reply(struct ofpbuf *reply,
     unsigned int opq_len;
     unsigned int len;
 
-    if (!reply->size) {
+    if (!ofpbuf_get_size(reply)) {
         return EOF;
     }
 
@@ -2498,7 +2498,7 @@ ofputil_pull_queue_get_config_reply(struct ofpbuf *reply,
         opq_len = sizeof *opq12;
     }
 
-    if (len < opq_len || len > reply->size + opq_len || len % 8) {
+    if (len < opq_len || len > ofpbuf_get_size(reply) + opq_len || len % 8) {
         return OFPERR_OFPBRC_BAD_LEN;
     }
     len -= opq_len;
@@ -2511,7 +2511,7 @@ ofputil_pull_queue_get_config_reply(struct ofpbuf *reply,
 
         hdr = ofpbuf_at_assert(reply, 0, sizeof *hdr);
         prop_len = ntohs(hdr->len);
-        if (prop_len < sizeof *hdr || prop_len > reply->size || prop_len % 8) {
+        if (prop_len < sizeof *hdr || prop_len > ofpbuf_get_size(reply) || prop_len % 8) {
             return OFPERR_OFPBRC_BAD_LEN;
         }
 
@@ -2553,10 +2553,10 @@ ofputil_decode_flow_stats_request(struct ofputil_flow_stats_request *fsr,
     raw = ofpraw_pull_assert(&b);
     switch ((int) raw) {
     case OFPRAW_OFPST10_FLOW_REQUEST:
-        return ofputil_decode_ofpst10_flow_request(fsr, b.data, false);
+        return ofputil_decode_ofpst10_flow_request(fsr, ofpbuf_get_data(&b), false);
 
     case OFPRAW_OFPST10_AGGREGATE_REQUEST:
-        return ofputil_decode_ofpst10_flow_request(fsr, b.data, true);
+        return ofputil_decode_ofpst10_flow_request(fsr, ofpbuf_get_data(&b), true);
 
     case OFPRAW_OFPST11_FLOW_REQUEST:
         return ofputil_decode_ofpst11_flow_request(fsr, &b, false);
@@ -2688,7 +2688,7 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs,
     }
     oh = msg->l2;
 
-    if (!msg->size) {
+    if (!ofpbuf_get_size(msg)) {
         return EOF;
     } else if (raw == OFPRAW_OFPST11_FLOW_REPLY
                || raw == OFPRAW_OFPST13_FLOW_REPLY) {
@@ -2699,7 +2699,7 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs,
         ofs = ofpbuf_try_pull(msg, sizeof *ofs);
         if (!ofs) {
             VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply has %"PRIu32" leftover "
-                         "bytes at end", msg->size);
+                         "bytes at end", ofpbuf_get_size(msg));
             return EINVAL;
         }
 
@@ -2749,7 +2749,7 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs,
         ofs = ofpbuf_try_pull(msg, sizeof *ofs);
         if (!ofs) {
             VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply has %"PRIu32" leftover "
-                         "bytes at end", msg->size);
+                         "bytes at end", ofpbuf_get_size(msg));
             return EINVAL;
         }
 
@@ -2785,7 +2785,7 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs,
         nfs = ofpbuf_try_pull(msg, sizeof *nfs);
         if (!nfs) {
             VLOG_WARN_RL(&bad_ofmsg_rl, "NXST_FLOW reply has %"PRIu32" leftover "
-                         "bytes at end", msg->size);
+                         "bytes at end", ofpbuf_get_size(msg));
             return EINVAL;
         }
 
@@ -2830,8 +2830,8 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs,
         OVS_NOT_REACHED();
     }
 
-    fs->ofpacts = ofpacts->data;
-    fs->ofpacts_len = ofpacts->size;
+    fs->ofpacts = ofpbuf_get_data(ofpacts);
+    fs->ofpacts_len = ofpbuf_get_size(ofpacts);
 
     return 0;
 }
@@ -2854,11 +2854,11 @@ ofputil_append_flow_stats_reply(const struct ofputil_flow_stats *fs,
                                 struct list *replies)
 {
     struct ofpbuf *reply = ofpbuf_from_list(list_back(replies));
-    size_t start_ofs = reply->size;
+    size_t start_ofs = ofpbuf_get_size(reply);
     enum ofpraw raw;
-    enum ofp_version version = ((struct ofp_header *)reply->data)->version;
+    enum ofp_version version = ((struct ofp_header *)ofpbuf_get_data(reply))->version;
 
-    ofpraw_decode_partial(&raw, reply->data, reply->size);
+    ofpraw_decode_partial(&raw, ofpbuf_get_data(reply), ofpbuf_get_size(reply));
     if (raw == OFPRAW_OFPST11_FLOW_REPLY || raw == OFPRAW_OFPST13_FLOW_REPLY) {
         struct ofp11_flow_stats *ofs;
 
@@ -2868,7 +2868,7 @@ ofputil_append_flow_stats_reply(const struct ofputil_flow_stats *fs,
                                           version);
 
         ofs = ofpbuf_at_assert(reply, start_ofs, sizeof *ofs);
-        ofs->length = htons(reply->size - start_ofs);
+        ofs->length = htons(ofpbuf_get_size(reply) - start_ofs);
         ofs->table_id = fs->table_id;
         ofs->pad = 0;
         ofs->duration_sec = htonl(fs->duration_sec);
@@ -2892,7 +2892,7 @@ ofputil_append_flow_stats_reply(const struct ofputil_flow_stats *fs,
         ofpacts_put_openflow_actions(fs->ofpacts, fs->ofpacts_len, reply,
                                      version);
         ofs = ofpbuf_at_assert(reply, start_ofs, sizeof *ofs);
-        ofs->length = htons(reply->size - start_ofs);
+        ofs->length = htons(ofpbuf_get_size(reply) - start_ofs);
         ofs->table_id = fs->table_id;
         ofs->pad = 0;
         ofputil_match_to_ofp10_match(&fs->match, &ofs->match);
@@ -2916,7 +2916,7 @@ ofputil_append_flow_stats_reply(const struct ofputil_flow_stats *fs,
         ofpacts_put_openflow_actions(fs->ofpacts, fs->ofpacts_len, reply,
                                      version);
         nfs = ofpbuf_at_assert(reply, start_ofs, sizeof *nfs);
-        nfs->length = htons(reply->size - start_ofs);
+        nfs->length = htons(ofpbuf_get_size(reply) - start_ofs);
         nfs->table_id = fs->table_id;
         nfs->pad = 0;
         nfs->duration_sec = htonl(fs->duration_sec);
@@ -3049,7 +3049,7 @@ ofputil_decode_flow_removed(struct ofputil_flow_removed *fr,
         if (error) {
             return error;
         }
-        if (b.size) {
+        if (ofpbuf_get_size(&b)) {
             return OFPERR_OFPBRC_BAD_LEN;
         }
 
@@ -3159,8 +3159,8 @@ static void
 ofputil_decode_packet_in_finish(struct ofputil_packet_in *pin,
                                 struct match *match, struct ofpbuf *b)
 {
-    pin->packet = b->data;
-    pin->packet_len = b->size;
+    pin->packet = ofpbuf_get_data(b);
+    pin->packet_len = ofpbuf_get_size(b);
 
     pin->fmd.in_port = match->flow.in_port.ofp_port;
     pin->fmd.tun_id = match->flow.tunnel.tun_id;
@@ -3221,7 +3221,7 @@ ofputil_decode_packet_in(struct ofputil_packet_in *pin,
         opi = ofpbuf_pull(&b, offsetof(struct ofp10_packet_in, data));
 
         pin->packet = opi->data;
-        pin->packet_len = b.size;
+        pin->packet_len = ofpbuf_get_size(&b);
 
         pin->fmd.in_port = u16_to_ofp(ntohs(opi->in_port));
         pin->reason = opi->reason;
@@ -3233,8 +3233,8 @@ ofputil_decode_packet_in(struct ofputil_packet_in *pin,
 
         opi = ofpbuf_pull(&b, sizeof *opi);
 
-        pin->packet = b.data;
-        pin->packet_len = b.size;
+        pin->packet = ofpbuf_get_data(&b);
+        pin->packet_len = ofpbuf_get_size(&b);
 
         pin->buffer_id = ntohl(opi->buffer_id);
         error = ofputil_port_from_ofp11(opi->in_port, &pin->fmd.in_port);
@@ -3559,12 +3559,12 @@ ofputil_decode_packet_out(struct ofputil_packet_out *po,
         return OFPERR_OFPBRC_BAD_PORT;
     }
 
-    po->ofpacts = ofpacts->data;
-    po->ofpacts_len = ofpacts->size;
+    po->ofpacts = ofpbuf_get_data(ofpacts);
+    po->ofpacts_len = ofpbuf_get_size(ofpacts);
 
     if (po->buffer_id == UINT32_MAX) {
-        po->packet = b.data;
-        po->packet_len = b.size;
+        po->packet = ofpbuf_get_data(&b);
+        po->packet_len = ofpbuf_get_size(&b);
     } else {
         po->packet = NULL;
         po->packet_len = 0;
@@ -3750,7 +3750,7 @@ ofputil_put_phy_port(enum ofp_version ofp_version,
     switch (ofp_version) {
     case OFP10_VERSION: {
         struct ofp10_phy_port *opp;
-        if (b->size + sizeof *opp <= UINT16_MAX) {
+        if (ofpbuf_get_size(b) + sizeof *opp <= UINT16_MAX) {
             opp = ofpbuf_put_uninit(b, sizeof *opp);
             ofputil_encode_ofp10_phy_port(pp, opp);
         }
@@ -3761,7 +3761,7 @@ ofputil_put_phy_port(enum ofp_version ofp_version,
     case OFP12_VERSION:
     case OFP13_VERSION: {
         struct ofp11_port *op;
-        if (b->size + sizeof *op <= UINT16_MAX) {
+        if (ofpbuf_get_size(b) + sizeof *op <= UINT16_MAX) {
             op = ofpbuf_put_uninit(b, sizeof *op);
             ofputil_encode_ofp11_port(pp, op);
         }
@@ -3902,7 +3902,7 @@ ofputil_decode_switch_features(const struct ofp_header *oh,
     features->capabilities = ntohl(osf->capabilities) &
         ofputil_capabilities_mask(oh->version);
 
-    if (b->size % ofputil_get_phy_port_size(oh->version)) {
+    if (ofpbuf_get_size(b) % ofputil_get_phy_port_size(oh->version)) {
         return OFPERR_OFPBRC_BAD_LEN;
     }
 
@@ -3945,12 +3945,12 @@ max_ports_in_features(const struct ofp_header *oh)
 bool
 ofputil_switch_features_ports_trunc(struct ofpbuf *b)
 {
-    struct ofp_header *oh = b->data;
+    struct ofp_header *oh = ofpbuf_get_data(b);
 
     if (max_ports_in_features(oh)) {
         /* Remove all the ports. */
-        b->size = (sizeof(struct ofp_header)
-                   + sizeof(struct ofp_switch_features));
+        ofpbuf_set_size(b, (sizeof(struct ofp_header) +
+                            sizeof(struct ofp_switch_features)));
         ofpmsg_update_length(b);
 
         return true;
@@ -4043,7 +4043,7 @@ void
 ofputil_put_switch_features_port(const struct ofputil_phy_port *pp,
                                  struct ofpbuf *b)
 {
-    const struct ofp_header *oh = b->data;
+    const struct ofp_header *oh = ofpbuf_get_data(b);
 
     if (oh->version < OFP13_VERSION) {
         ofputil_put_phy_port(oh->version, pp, b);
@@ -4130,7 +4130,7 @@ ofputil_decode_port_mod(const struct ofp_header *oh,
     raw = ofpraw_pull_assert(&b);
 
     if (raw == OFPRAW_OFPT10_PORT_MOD) {
-        const struct ofp10_port_mod *opm = b.data;
+        const struct ofp10_port_mod *opm = ofpbuf_get_data(&b);
 
         pm->port_no = u16_to_ofp(ntohs(opm->port_no));
         memcpy(pm->hw_addr, opm->hw_addr, ETH_ADDR_LEN);
@@ -4138,7 +4138,7 @@ ofputil_decode_port_mod(const struct ofp_header *oh,
         pm->mask = ntohl(opm->mask) & OFPPC10_ALL;
         pm->advertise = netdev_port_features_from_ofp10(opm->advertise);
     } else if (raw == OFPRAW_OFPT11_PORT_MOD) {
-        const struct ofp11_port_mod *opm = b.data;
+        const struct ofp11_port_mod *opm = ofpbuf_get_data(&b);
         enum ofperr error;
 
         error = ofputil_port_from_ofp11(opm->port_no, &pm->port_no);
@@ -4218,19 +4218,19 @@ ofputil_pull_property(struct ofpbuf *msg, struct ofpbuf *payload,
     struct ofp_prop_header *oph;
     unsigned int len;
 
-    if (msg->size < sizeof *oph) {
+    if (ofpbuf_get_size(msg) < sizeof *oph) {
         return OFPERR_OFPTFFC_BAD_LEN;
     }
 
-    oph = msg->data;
+    oph = ofpbuf_get_data(msg);
     len = ntohs(oph->len);
-    if (len < sizeof *oph || ROUND_UP(len, 8) > msg->size) {
+    if (len < sizeof *oph || ROUND_UP(len, 8) > ofpbuf_get_size(msg)) {
         return OFPERR_OFPTFFC_BAD_LEN;
     }
 
     *typep = ntohs(oph->type);
     if (payload) {
-        ofpbuf_use_const(payload, msg->data, len);
+        ofpbuf_use_const(payload, ofpbuf_get_data(msg), len);
         ofpbuf_pull(payload, sizeof *oph);
     }
     ofpbuf_pull(msg, ROUND_UP(len, 8));
@@ -4256,7 +4256,7 @@ parse_table_ids(struct ofpbuf *payload, uint32_t *ids)
     uint16_t type;
 
     *ids = 0;
-    while (payload->size > 0) {
+    while (ofpbuf_get_size(payload) > 0) {
         enum ofperr error = ofputil_pull_property(payload, NULL, &type);
         if (error) {
             return error;
@@ -4272,7 +4272,7 @@ static enum ofperr
 parse_instruction_ids(struct ofpbuf *payload, bool loose, uint32_t *insts)
 {
     *insts = 0;
-    while (payload->size > 0) {
+    while (ofpbuf_get_size(payload) > 0) {
         enum ovs_instruction_type inst;
         enum ofperr error;
         uint16_t ofpit;
@@ -4299,8 +4299,8 @@ parse_table_features_next_table(struct ofpbuf *payload,
     size_t i;
 
     memset(next_tables, 0, bitmap_n_bytes(255));
-    for (i = 0; i < payload->size; i++) {
-        uint8_t id = ((const uint8_t *) payload->data)[i];
+    for (i = 0; i < ofpbuf_get_size(payload); i++) {
+        uint8_t id = ((const uint8_t *) ofpbuf_get_data(payload))[i];
         if (id >= 255) {
             return OFPERR_OFPTFFC_BAD_ARGUMENT;
         }
@@ -4348,7 +4348,7 @@ parse_oxms(struct ofpbuf *payload, bool loose,
     uint64_t exact, masked;
 
     exact = masked = 0;
-    while (payload->size > 0) {
+    while (ofpbuf_get_size(payload) > 0) {
         const struct mf_field *field;
         enum ofperr error;
         bool hasmask;
@@ -4401,21 +4401,21 @@ ofputil_decode_table_features(struct ofpbuf *msg,
     unsigned int len;
 
     if (!msg->l2) {
-        msg->l2 = msg->data;
+        msg->l2 = ofpbuf_get_data(msg);
         ofpraw_pull_assert(msg);
     }
 
-    if (!msg->size) {
+    if (!ofpbuf_get_size(msg)) {
         return EOF;
     }
 
-    if (msg->size < sizeof *otf) {
+    if (ofpbuf_get_size(msg) < sizeof *otf) {
         return OFPERR_OFPTFFC_BAD_LEN;
     }
 
-    otf = msg->data;
+    otf = ofpbuf_get_data(msg);
     len = ntohs(otf->length);
-    if (len < sizeof *otf || len % 8 || len > msg->size) {
+    if (len < sizeof *otf || len % 8 || len > ofpbuf_get_size(msg)) {
         return OFPERR_OFPTFFC_BAD_LEN;
     }
     ofpbuf_pull(msg, sizeof *otf);
@@ -4431,7 +4431,7 @@ ofputil_decode_table_features(struct ofpbuf *msg,
     tf->config = ntohl(otf->config);
     tf->max_entries = ntohl(otf->max_entries);
 
-    while (msg->size > 0) {
+    while (ofpbuf_get_size(msg) > 0) {
         struct ofpbuf payload;
         enum ofperr error;
         uint16_t type;
@@ -4564,7 +4564,7 @@ ofputil_decode_table_mod(const struct ofp_header *oh,
     raw = ofpraw_pull_assert(&b);
 
     if (raw == OFPRAW_OFPT11_TABLE_MOD) {
-        const struct ofp11_table_mod *otm = b.data;
+        const struct ofp11_table_mod *otm = ofpbuf_get_data(&b);
 
         pm->table_id = otm->table_id;
         pm->config = ntohl(otm->config);
@@ -4943,18 +4943,18 @@ ofputil_decode_flow_monitor_request(struct ofputil_flow_monitor_request *rq,
     uint16_t flags;
 
     if (!msg->l2) {
-        msg->l2 = msg->data;
+        msg->l2 = ofpbuf_get_data(msg);
         ofpraw_pull_assert(msg);
     }
 
-    if (!msg->size) {
+    if (!ofpbuf_get_size(msg)) {
         return EOF;
     }
 
     nfmr = ofpbuf_try_pull(msg, sizeof *nfmr);
     if (!nfmr) {
         VLOG_WARN_RL(&bad_ofmsg_rl, "NXST_FLOW_MONITOR request has %"PRIu32" "
-                     "leftover bytes at end", msg->size);
+                     "leftover bytes at end", ofpbuf_get_size(msg));
         return OFPERR_OFPBRC_BAD_LEN;
     }
 
@@ -4987,11 +4987,11 @@ ofputil_append_flow_monitor_request(
     size_t start_ofs;
     int match_len;
 
-    if (!msg->size) {
+    if (!ofpbuf_get_size(msg)) {
         ofpraw_put(OFPRAW_NXST_FLOW_MONITOR_REQUEST, OFP10_VERSION, msg);
     }
 
-    start_ofs = msg->size;
+    start_ofs = ofpbuf_get_size(msg);
     ofpbuf_put_zeros(msg, sizeof *nfmr);
     match_len = nx_put_match(msg, &rq->match, htonll(0), htonll(0));
 
@@ -5028,24 +5028,24 @@ ofputil_decode_flow_update(struct ofputil_flow_update *update,
     struct ofp_header *oh;
 
     if (!msg->l2) {
-        msg->l2 = msg->data;
+        msg->l2 = ofpbuf_get_data(msg);
         ofpraw_pull_assert(msg);
     }
 
-    if (!msg->size) {
+    if (!ofpbuf_get_size(msg)) {
         return EOF;
     }
 
-    if (msg->size < sizeof(struct nx_flow_update_header)) {
+    if (ofpbuf_get_size(msg) < sizeof(struct nx_flow_update_header)) {
         goto bad_len;
     }
 
     oh = msg->l2;
 
-    nfuh = msg->data;
+    nfuh = ofpbuf_get_data(msg);
     update->event = ntohs(nfuh->event);
     length = ntohs(nfuh->length);
-    if (length > msg->size || length % 8) {
+    if (length > ofpbuf_get_size(msg) || length % 8) {
         goto bad_len;
     }
 
@@ -5096,8 +5096,8 @@ ofputil_decode_flow_update(struct ofputil_flow_update *update,
             return error;
         }
 
-        update->ofpacts = ofpacts->data;
-        update->ofpacts_len = ofpacts->size;
+        update->ofpacts = ofpbuf_get_data(ofpacts);
+        update->ofpacts_len = ofpbuf_get_size(ofpacts);
         return 0;
     } else {
         VLOG_WARN_RL(&bad_ofmsg_rl,
@@ -5108,7 +5108,7 @@ ofputil_decode_flow_update(struct ofputil_flow_update *update,
 
 bad_len:
     VLOG_WARN_RL(&bad_ofmsg_rl, "NXST_FLOW_MONITOR reply has %"PRIu32" "
-                 "leftover bytes at end", msg->size);
+                 "leftover bytes at end", ofpbuf_get_size(msg));
     return OFPERR_OFPBRC_BAD_LEN;
 }
 
@@ -5154,7 +5154,7 @@ ofputil_append_flow_update(const struct ofputil_flow_update *update,
     enum ofp_version version;
 
     msg = ofpbuf_from_list(list_back(replies));
-    start_ofs = msg->size;
+    start_ofs = ofpbuf_get_size(msg);
     version = ((struct ofp_header *)msg->l2)->version;
 
     if (update->event == NXFME_ABBREV) {
@@ -5181,7 +5181,7 @@ ofputil_append_flow_update(const struct ofputil_flow_update *update,
     }
 
     nfuh = ofpbuf_at_assert(msg, start_ofs, sizeof *nfuh);
-    nfuh->length = htons(msg->size - start_ofs);
+    nfuh->length = htons(ofpbuf_get_size(msg) - start_ofs);
     nfuh->event = htons(update->event);
 
     ofpmp_postappend(replies, start_ofs);
@@ -5207,14 +5207,14 @@ ofputil_encode_packet_out(const struct ofputil_packet_out *po,
 
         msg = ofpraw_alloc(OFPRAW_OFPT10_PACKET_OUT, OFP10_VERSION, size);
         ofpbuf_put_zeros(msg, sizeof *opo);
-        actions_ofs = msg->size;
+        actions_ofs = ofpbuf_get_size(msg);
         ofpacts_put_openflow_actions(po->ofpacts, po->ofpacts_len, msg,
                                      ofp_version);
 
         opo = ofpbuf_get_l3(msg);
         opo->buffer_id = htonl(po->buffer_id);
         opo->in_port = htons(ofp_to_u16(po->in_port));
-        opo->actions_len = htons(msg->size - actions_ofs);
+        opo->actions_len = htons(ofpbuf_get_size(msg) - actions_ofs);
         break;
     }
 
@@ -5268,8 +5268,8 @@ make_echo_reply(const struct ofp_header *rq)
     ofpbuf_use_const(&rq_buf, rq, ntohs(rq->length));
     ofpraw_pull_assert(&rq_buf);
 
-    reply = ofpraw_alloc_reply(OFPRAW_OFPT_ECHO_REPLY, rq, rq_buf.size);
-    ofpbuf_put(reply, rq_buf.data, rq_buf.size);
+    reply = ofpraw_alloc_reply(OFPRAW_OFPT_ECHO_REPLY, rq, ofpbuf_get_size(&rq_buf));
+    ofpbuf_put(reply, ofpbuf_get_data(&rq_buf), ofpbuf_get_size(&rq_buf));
     return reply;
 }
 
@@ -5572,7 +5572,7 @@ ofputil_pull_phy_port(enum ofp_version ofp_version, struct ofpbuf *b,
  * 'ofp_version', returns the number of elements. */
 size_t ofputil_count_phy_ports(uint8_t ofp_version, struct ofpbuf *b)
 {
-    return b->size / ofputil_get_phy_port_size(ofp_version);
+    return ofpbuf_get_size(b) / ofputil_get_phy_port_size(ofp_version);
 }
 
 /* ofp-util.def lists the mapping from names to action. */
@@ -5982,7 +5982,7 @@ ofputil_append_port_stat(struct list *replies,
                          const struct ofputil_port_stats *ops)
 {
     struct ofpbuf *msg = ofpbuf_from_list(list_back(replies));
-    struct ofp_header *oh = msg->data;
+    struct ofp_header *oh = ofpbuf_get_data(msg);
 
     switch ((enum ofp_version)oh->version) {
     case OFP13_VERSION: {
@@ -6107,7 +6107,7 @@ ofputil_count_port_stats(const struct ofp_header *oh)
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
     ofpraw_pull_assert(&b);
 
-    return b.size / ofputil_get_port_stats_size(oh->version);
+    return ofpbuf_get_size(&b) / ofputil_get_port_stats_size(oh->version);
 }
 
 /* Converts an OFPST_PORT_STATS reply in 'msg' into an abstract
@@ -6133,7 +6133,7 @@ ofputil_decode_port_stats(struct ofputil_port_stats *ps, struct ofpbuf *msg)
         return error;
     }
 
-    if (!msg->size) {
+    if (!ofpbuf_get_size(msg)) {
         return EOF;
     } else if (raw == OFPRAW_OFPST13_PORT_REPLY) {
         const struct ofp13_port_stats *ps13;
@@ -6165,7 +6165,7 @@ ofputil_decode_port_stats(struct ofputil_port_stats *ps, struct ofpbuf *msg)
 
  bad_len:
     VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_PORT reply has %"PRIu32" leftover "
-                 "bytes at end", msg->size);
+                 "bytes at end", ofpbuf_get_size(msg));
     return OFPERR_OFPBRC_BAD_LEN;
 }
 
@@ -6321,7 +6321,7 @@ ofputil_append_group_stats(struct list *replies,
                            const struct ofputil_group_stats *ogs)
 {
     struct ofpbuf *msg = ofpbuf_from_list(list_back(replies));
-    struct ofp_header *oh = msg->data;
+    struct ofp_header *oh = ofpbuf_get_data(msg);
 
     switch ((enum ofp_version)oh->version) {
     case OFP11_VERSION:
@@ -6458,7 +6458,7 @@ ofputil_decode_group_stats_reply(struct ofpbuf *msg,
         return error;
     }
 
-    if (!msg->size) {
+    if (!ofpbuf_get_size(msg)) {
         return EOF;
     }
 
@@ -6484,7 +6484,7 @@ ofputil_decode_group_stats_reply(struct ofpbuf *msg,
 
     if (!ogs11) {
         VLOG_WARN_RL(&bad_ofmsg_rl, "%s reply has %"PRIu32" leftover bytes at end",
-                     ofpraw_get_name(raw), msg->size);
+                     ofpraw_get_name(raw), ofpbuf_get_size(msg));
         return OFPERR_OFPBRC_BAD_LEN;
     }
     length = ntohs(ogs11->length);
@@ -6503,7 +6503,7 @@ ofputil_decode_group_stats_reply(struct ofpbuf *msg,
     obc = ofpbuf_try_pull(msg, gs->n_buckets * sizeof *obc);
     if (!obc) {
         VLOG_WARN_RL(&bad_ofmsg_rl, "%s reply has %"PRIu32" leftover bytes at end",
-                     ofpraw_get_name(raw), msg->size);
+                     ofpraw_get_name(raw), ofpbuf_get_size(msg));
         return OFPERR_OFPBRC_BAD_LEN;
     }
 
@@ -6528,26 +6528,26 @@ ofputil_append_group_desc_reply(const struct ofputil_group_desc *gds,
     struct ofp11_group_desc_stats *ogds;
     struct ofputil_bucket *bucket;
     size_t start_ogds;
-    enum ofp_version version = ((struct ofp_header *)reply->data)->version;
+    enum ofp_version version = ((struct ofp_header *)ofpbuf_get_data(reply))->version;
 
-    start_ogds = reply->size;
+    start_ogds = ofpbuf_get_size(reply);
     ofpbuf_put_zeros(reply, sizeof *ogds);
     LIST_FOR_EACH (bucket, list_node, buckets) {
         struct ofp11_bucket *ob;
         size_t start_ob;
 
-        start_ob = reply->size;
+        start_ob = ofpbuf_get_size(reply);
         ofpbuf_put_zeros(reply, sizeof *ob);
         ofpacts_put_openflow_actions(bucket->ofpacts, bucket->ofpacts_len,
                                      reply, version);
         ob = ofpbuf_at_assert(reply, start_ob, sizeof *ob);
-        ob->len = htons(reply->size - start_ob);
+        ob->len = htons(ofpbuf_get_size(reply) - start_ob);
         ob->weight = htons(bucket->weight);
         ob->watch_port = ofputil_port_to_ofp11(bucket->watch_port);
         ob->watch_group = htonl(bucket->watch_group);
     }
     ogds = ofpbuf_at_assert(reply, start_ogds, sizeof *ogds);
-    ogds->length = htons(reply->size - start_ogds);
+    ogds->length = htons(ofpbuf_get_size(reply) - start_ogds);
     ogds->type = gds->type;
     ogds->group_id = htonl(gds->group_id);
 
@@ -6607,7 +6607,7 @@ ofputil_pull_buckets(struct ofpbuf *msg, size_t buckets_length,
         }
         bucket->watch_group = ntohl(ob->watch_group);
         bucket->ofpacts = ofpbuf_steal_data(&ofpacts);
-        bucket->ofpacts_len = ofpacts.size;
+        bucket->ofpacts_len = ofpbuf_get_size(&ofpacts);
         list_push_back(buckets, &bucket->list_node);
     }
 
@@ -6635,21 +6635,21 @@ ofputil_decode_group_desc_reply(struct ofputil_group_desc *gd,
         ofpraw_pull_assert(msg);
     }
 
-    if (!msg->size) {
+    if (!ofpbuf_get_size(msg)) {
         return EOF;
     }
 
     ogds = ofpbuf_try_pull(msg, sizeof *ogds);
     if (!ogds) {
         VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST11_GROUP_DESC reply has %"PRIu32" "
-                     "leftover bytes at end", msg->size);
+                     "leftover bytes at end", ofpbuf_get_size(msg));
         return OFPERR_OFPBRC_BAD_LEN;
     }
     gd->type = ogds->type;
     gd->group_id = ntohl(ogds->group_id);
 
     length = ntohs(ogds->length);
-    if (length < sizeof *ogds || length - sizeof *ogds > msg->size) {
+    if (length < sizeof *ogds || length - sizeof *ogds > ofpbuf_get_size(msg)) {
         VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST11_GROUP_DESC reply claims invalid "
                      "length %"PRIuSIZE, length);
         return OFPERR_OFPBRC_BAD_LEN;
@@ -6691,11 +6691,11 @@ ofputil_encode_group_mod(enum ofp_version ofp_version,
     case OFP13_VERSION:
     case OFP14_VERSION:
         b = ofpraw_alloc(OFPRAW_OFPT11_GROUP_MOD, ofp_version, 0);
-        start_ogm = b->size;
+        start_ogm = ofpbuf_get_size(b);
         ofpbuf_put_zeros(b, sizeof *ogm);
 
         LIST_FOR_EACH (bucket, list_node, &gm->buckets) {
-            start_bucket = b->size;
+            start_bucket = ofpbuf_get_size(b);
             ofpbuf_put_zeros(b, sizeof *ob);
             if (bucket->ofpacts && bucket->ofpacts_len) {
                 ofpacts_put_openflow_actions(bucket->ofpacts,
@@ -6703,7 +6703,7 @@ ofputil_encode_group_mod(enum ofp_version ofp_version,
                                              ofp_version);
             }
             ob = ofpbuf_at_assert(b, start_bucket, sizeof *ob);
-            ob->len = htons(b->size - start_bucket);;
+            ob->len = htons(ofpbuf_get_size(b) - start_bucket);;
             ob->weight = htons(bucket->weight);
             ob->watch_port = ofputil_port_to_ofp11(bucket->watch_port);
             ob->watch_group = htonl(bucket->watch_group);
@@ -6741,7 +6741,7 @@ ofputil_decode_group_mod(const struct ofp_header *oh,
     gm->type = ogm->type;
     gm->group_id = ntohl(ogm->group_id);
 
-    err = ofputil_pull_buckets(&msg, msg.size, oh->version, &gm->buckets);
+    err = ofputil_pull_buckets(&msg, ofpbuf_get_size(&msg), oh->version, &gm->buckets);
     if (err) {
         return err;
     }
@@ -6868,7 +6868,7 @@ ofputil_count_queue_stats(const struct ofp_header *oh)
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
     ofpraw_pull_assert(&b);
 
-    return b.size / ofputil_get_queue_stats_size(oh->version);
+    return ofpbuf_get_size(&b) / ofputil_get_queue_stats_size(oh->version);
 }
 
 static enum ofperr
@@ -6941,7 +6941,7 @@ ofputil_decode_queue_stats(struct ofputil_queue_stats *qs, struct ofpbuf *msg)
         return error;
     }
 
-    if (!msg->size) {
+    if (!ofpbuf_get_size(msg)) {
         return EOF;
     } else if (raw == OFPRAW_OFPST13_QUEUE_REPLY) {
         const struct ofp13_queue_stats *qs13;
@@ -6973,7 +6973,7 @@ ofputil_decode_queue_stats(struct ofputil_queue_stats *qs, struct ofpbuf *msg)
 
  bad_len:
     VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_QUEUE reply has %"PRIu32" leftover "
-                 "bytes at end", msg->size);
+                 "bytes at end", ofpbuf_get_size(msg));
     return OFPERR_OFPBRC_BAD_LEN;
 }
 
@@ -7020,7 +7020,7 @@ ofputil_append_queue_stat(struct list *replies,
                           const struct ofputil_queue_stats *oqs)
 {
     struct ofpbuf *msg = ofpbuf_from_list(list_back(replies));
-    struct ofp_header *oh = msg->data;
+    struct ofp_header *oh = ofpbuf_get_data(msg);
 
     switch ((enum ofp_version)oh->version) {
     case OFP13_VERSION: {
diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c
index 56e1ec6..8763e49 100644
--- a/lib/ofpbuf.c
+++ b/lib/ofpbuf.c
@@ -26,10 +26,12 @@ static void
 ofpbuf_use__(struct ofpbuf *b, void *base, size_t allocated,
              enum ofpbuf_source source)
 {
-    b->base = b->data = base;
+    ofpbuf_set_base(b, base);
+    ofpbuf_set_data(b, base);
+    ofpbuf_set_size(b, 0);
+
     b->allocated = allocated;
     b->source = source;
-    b->size = 0;
     b->l2 = NULL;
     b->l2_5_ofs = b->l3_ofs = b->l4_ofs = UINT16_MAX;
     list_poison(&b->list_node);
@@ -96,7 +98,7 @@ void
 ofpbuf_use_const(struct ofpbuf *b, const void *data, size_t size)
 {
     ofpbuf_use__(b, CONST_CAST(void *, data), size, OFPBUF_STACK);
-    b->size = size;
+    ofpbuf_set_size(b, size);
 }
 
 /* Initializes 'b' as an empty ofpbuf with an initial capacity of 'size'
@@ -113,7 +115,7 @@ ofpbuf_uninit(struct ofpbuf *b)
 {
     if (b) {
         if (b->source == OFPBUF_MALLOC) {
-            free(b->base);
+            free(ofpbuf_get_base(b));
         }
         if (b->source == OFPBUF_DPDK) {
             free_dpdk_buf(b);
@@ -150,7 +152,7 @@ ofpbuf_new_with_headroom(size_t size, size_t headroom)
 }
 
 /* Creates and returns a new ofpbuf that initially contains a copy of the
- * 'buffer->size' bytes of data starting at 'buffer->data' with no headroom or
+ * 'ofpbuf_get_size(buffer)' bytes of data starting at 'buffer->data' with no headroom or
  * tailroom. */
 struct ofpbuf *
 ofpbuf_clone(const struct ofpbuf *buffer)
@@ -165,10 +167,11 @@ ofpbuf_clone_with_headroom(const struct ofpbuf *buffer, size_t headroom)
 {
     struct ofpbuf *new_buffer;
 
-    new_buffer = ofpbuf_clone_data_with_headroom(buffer->data, buffer->size,
+    new_buffer = ofpbuf_clone_data_with_headroom(ofpbuf_get_data(buffer),
+                                                 ofpbuf_get_size(buffer),
                                                  headroom);
     if (buffer->l2) {
-        uintptr_t data_delta = (char *)new_buffer->data - (char *)buffer->data;
+        uintptr_t data_delta = (char *)ofpbuf_get_data(new_buffer) - (char *)ofpbuf_get_data(buffer);
 
         new_buffer->l2 = (char *) buffer->l2 + data_delta;
     }
@@ -202,7 +205,7 @@ static void
 ofpbuf_copy__(struct ofpbuf *b, uint8_t *new_base,
               size_t new_headroom, size_t new_tailroom)
 {
-    const uint8_t *old_base = b->base;
+    const uint8_t *old_base = ofpbuf_get_base(b);
     size_t old_headroom = ofpbuf_headroom(b);
     size_t old_tailroom = ofpbuf_tailroom(b);
     size_t copy_headroom = MIN(old_headroom, new_headroom);
@@ -210,7 +213,7 @@ ofpbuf_copy__(struct ofpbuf *b, uint8_t *new_base,
 
     memcpy(&new_base[new_headroom - copy_headroom],
            &old_base[old_headroom - copy_headroom],
-           copy_headroom + b->size + copy_tailroom);
+           copy_headroom + ofpbuf_get_size(b) + copy_tailroom);
 }
 
 /* Reallocates 'b' so that it has exactly 'new_headroom' and 'new_tailroom'
@@ -221,7 +224,7 @@ ofpbuf_resize__(struct ofpbuf *b, size_t new_headroom, size_t new_tailroom)
     void *new_base, *new_data;
     size_t new_allocated;
 
-    new_allocated = new_headroom + b->size + new_tailroom;
+    new_allocated = new_headroom + ofpbuf_get_size(b) + new_tailroom;
 
     switch (b->source) {
     case OFPBUF_DPDK:
@@ -229,11 +232,11 @@ ofpbuf_resize__(struct ofpbuf *b, size_t new_headroom, size_t new_tailroom)
 
     case OFPBUF_MALLOC:
         if (new_headroom == ofpbuf_headroom(b)) {
-            new_base = xrealloc(b->base, new_allocated);
+            new_base = xrealloc(ofpbuf_get_base(b), new_allocated);
         } else {
             new_base = xmalloc(new_allocated);
             ofpbuf_copy__(b, new_base, new_headroom, new_tailroom);
-            free(b->base);
+            free(ofpbuf_get_base(b));
         }
         break;
 
@@ -251,13 +254,13 @@ ofpbuf_resize__(struct ofpbuf *b, size_t new_headroom, size_t new_tailroom)
     }
 
     b->allocated = new_allocated;
-    b->base = new_base;
+    ofpbuf_set_base(b, new_base);
 
     new_data = (char *) new_base + new_headroom;
-    if (b->data != new_data) {
-        uintptr_t data_delta = (char *) new_data - (char *) b->data;
+    if (ofpbuf_get_data(b) != new_data) {
+        uintptr_t data_delta = (char *) new_data - (char *) ofpbuf_get_data(b);
 
-        b->data = new_data;
+        ofpbuf_set_data(b, new_data);
         if (b->l2) {
             b->l2 = (char *) b->l2 + data_delta;
         }
@@ -307,8 +310,8 @@ ofpbuf_trim(struct ofpbuf *b)
 void
 ofpbuf_padto(struct ofpbuf *b, size_t length)
 {
-    if (b->size < length) {
-        ofpbuf_put_zeros(b, length - b->size);
+    if (ofpbuf_get_size(b) < length) {
+        ofpbuf_put_zeros(b, length - ofpbuf_get_size(b));
     }
 }
 
@@ -324,9 +327,9 @@ ofpbuf_shift(struct ofpbuf *b, int delta)
                : true);
 
     if (delta != 0) {
-        char *dst = (char *) b->data + delta;
-        memmove(dst, b->data, b->size);
-        b->data = dst;
+        char *dst = (char *) ofpbuf_get_data(b) + delta;
+        memmove(dst, ofpbuf_get_data(b), ofpbuf_get_size(b));
+        ofpbuf_set_data(b, dst);
     }
 }
 
@@ -339,7 +342,7 @@ ofpbuf_put_uninit(struct ofpbuf *b, size_t size)
     void *p;
     ofpbuf_prealloc_tailroom(b, size);
     p = ofpbuf_tail(b);
-    b->size += size;
+    ofpbuf_set_size(b, ofpbuf_get_size(b) + size);
     return p;
 }
 
@@ -373,7 +376,7 @@ ofpbuf_put(struct ofpbuf *b, const void *p, size_t size)
 char *
 ofpbuf_put_hex(struct ofpbuf *b, const char *s, size_t *n)
 {
-    size_t initial_size = b->size;
+    size_t initial_size = ofpbuf_get_size(b);
     for (;;) {
         uint8_t byte;
         bool ok;
@@ -382,7 +385,7 @@ ofpbuf_put_hex(struct ofpbuf *b, const char *s, size_t *n)
         byte = hexits_value(s, 2, &ok);
         if (!ok) {
             if (n) {
-                *n = b->size - initial_size;
+                *n = ofpbuf_get_size(b) - initial_size;
             }
             return CONST_CAST(char *, s);
         }
@@ -397,9 +400,9 @@ ofpbuf_put_hex(struct ofpbuf *b, const char *s, size_t *n)
 void
 ofpbuf_reserve(struct ofpbuf *b, size_t size)
 {
-    ovs_assert(!b->size);
+    ovs_assert(!ofpbuf_get_size(b));
     ofpbuf_prealloc_tailroom(b, size);
-    b->data = (char*)b->data + size;
+    ofpbuf_set_data(b, (char*)ofpbuf_get_data(b) + size);
 }
 
 /* Reserves 'size' bytes of headroom so that they can be later allocated with
@@ -408,9 +411,9 @@ void
 ofpbuf_reserve_with_tailroom(struct ofpbuf *b, size_t headroom,
                              size_t tailroom)
 {
-    ovs_assert(!b->size);
+    ovs_assert(!ofpbuf_get_size(b));
     ofpbuf_prealloc_tailroom(b, headroom + tailroom);
-    b->data = (char*)b->data + headroom;
+    ofpbuf_set_data(b, (char*)ofpbuf_get_data(b) + headroom);
 }
 
 /* Prefixes 'size' bytes to the head end of 'b', reallocating and copying its
@@ -420,9 +423,9 @@ void *
 ofpbuf_push_uninit(struct ofpbuf *b, size_t size)
 {
     ofpbuf_prealloc_headroom(b, size);
-    b->data = (char*)b->data - size;
-    b->size += size;
-    return b->data;
+    ofpbuf_set_data(b, (char*)ofpbuf_get_data(b) - size);
+    ofpbuf_set_size(b, ofpbuf_get_size(b) + size);
+    return ofpbuf_get_data(b);
 }
 
 /* Prefixes 'size' zeroed bytes to the head end of 'b', reallocating and
@@ -456,15 +459,16 @@ ofpbuf_steal_data(struct ofpbuf *b)
     void *p;
     ovs_assert(b->source != OFPBUF_DPDK);
 
-    if (b->source == OFPBUF_MALLOC && b->data == b->base) {
-        p = b->data;
+    if (b->source == OFPBUF_MALLOC && ofpbuf_get_data(b) == ofpbuf_get_base(b)) {
+        p = ofpbuf_get_data(b);
     } else {
-        p = xmemdup(b->data, b->size);
+        p = xmemdup(ofpbuf_get_data(b), ofpbuf_get_size(b));
         if (b->source == OFPBUF_MALLOC) {
-            free(b->base);
+            free(ofpbuf_get_base(b));
         }
     }
-    b->base = b->data = NULL;
+    ofpbuf_set_base(b, NULL);
+    ofpbuf_set_data(b, NULL);
     return p;
 }
 
@@ -477,9 +481,9 @@ ofpbuf_to_string(const struct ofpbuf *b, size_t maxbytes)
 
     ds_init(&s);
     ds_put_format(&s, "size=%"PRIu32", allocated=%"PRIu32", head=%"PRIuSIZE", tail=%"PRIuSIZE"\n",
-                  b->size, b->allocated,
+                  ofpbuf_get_size(b), b->allocated,
                   ofpbuf_headroom(b), ofpbuf_tailroom(b));
-    ds_put_hex_dump(&s, b->data, MIN(b->size, maxbytes), 0, false);
+    ds_put_hex_dump(&s, ofpbuf_get_data(b), MIN(ofpbuf_get_size(b), maxbytes), 0, false);
     return ds_cstr(&s);
 }
 
@@ -516,7 +520,7 @@ ofpbuf_resize_l2_5(struct ofpbuf *b, int increment)
         ofpbuf_pull(b, -increment);
     }
 
-    b->l2 = b->data;
+    b->l2 = ofpbuf_get_data(b);
     /* Adjust layer offsets after l2_5. */
     ofpbuf_adjust_layer_offset(&b->l3_ofs, increment);
     ofpbuf_adjust_layer_offset(&b->l4_ofs, increment);
diff --git a/lib/ofpbuf.h b/lib/ofpbuf.h
index 9becedd..a261a44 100644
--- a/lib/ofpbuf.h
+++ b/lib/ofpbuf.h
@@ -58,6 +58,14 @@ struct ofpbuf {
 #endif
 };
 
+static inline void * ofpbuf_get_data(const struct ofpbuf *);
+static inline void ofpbuf_set_data(struct ofpbuf *, void *);
+static inline void * ofpbuf_get_base(const struct ofpbuf *);
+static inline void ofpbuf_set_base(struct ofpbuf *, void *);
+
+static inline uint32_t ofpbuf_get_size(const struct ofpbuf *);
+static inline void ofpbuf_set_size(struct ofpbuf *, uint32_t);
+
 void * ofpbuf_resize_l2(struct ofpbuf *, int increment);
 void * ofpbuf_resize_l2_5(struct ofpbuf *, int increment);
 static inline void * ofpbuf_get_l2_5(const struct ofpbuf *);
@@ -136,7 +144,7 @@ static inline bool ofpbuf_equal(const struct ofpbuf *, const struct ofpbuf *);
 static inline void *ofpbuf_get_uninit_pointer(struct ofpbuf *b)
 {
     /* XXX: If 'source' is OFPBUF_DPDK memory gets leaked! */
-    return b && b->source == OFPBUF_MALLOC ? b->base : NULL;
+    return b && b->source == OFPBUF_MALLOC ? ofpbuf_get_base(b) : NULL;
 }
 
 /* Frees memory that 'b' points to, as well as 'b' itself. */
@@ -153,7 +161,7 @@ static inline void ofpbuf_delete(struct ofpbuf *b)
 static inline void *ofpbuf_at(const struct ofpbuf *b, size_t offset,
                               size_t size)
 {
-    return offset + size <= b->size ? (char *) b->data + offset : NULL;
+    return offset + size <= ofpbuf_get_size(b) ? (char *) ofpbuf_get_data(b) + offset : NULL;
 }
 
 /* Returns a pointer to byte 'offset' in 'b', which must contain at least
@@ -161,21 +169,21 @@ static inline void *ofpbuf_at(const struct ofpbuf *b, size_t offset,
 static inline void *ofpbuf_at_assert(const struct ofpbuf *b, size_t offset,
                                      size_t size)
 {
-    ovs_assert(offset + size <= b->size);
-    return ((char *) b->data) + offset;
+    ovs_assert(offset + size <= ofpbuf_get_size(b));
+    return ((char *) ofpbuf_get_data(b)) + offset;
 }
 
 /* Returns the byte following the last byte of data in use in 'b'. */
 static inline void *ofpbuf_tail(const struct ofpbuf *b)
 {
-    return (char *) b->data + b->size;
+    return (char *) ofpbuf_get_data(b) + ofpbuf_get_size(b);
 }
 
 /* Returns the byte following the last byte allocated for use (but not
  * necessarily in use) by 'b'. */
 static inline void *ofpbuf_end(const struct ofpbuf *b)
 {
-    return (char *) b->base + b->allocated;
+    return (char *) ofpbuf_get_base(b) + b->allocated;
 }
 
 /* Returns the number of bytes of headroom in 'b', that is, the number of bytes
@@ -184,7 +192,7 @@ static inline void *ofpbuf_end(const struct ofpbuf *b)
  * headroom is 0.) */
 static inline size_t ofpbuf_headroom(const struct ofpbuf *b)
 {
-    return (char*)b->data - (char*)b->base;
+    return (char*)ofpbuf_get_data(b) - (char*)ofpbuf_get_base(b);
 }
 
 /* Returns the number of bytes that may be appended to the tail end of ofpbuf
@@ -197,18 +205,18 @@ static inline size_t ofpbuf_tailroom(const struct ofpbuf *b)
 /* Clears any data from 'b'. */
 static inline void ofpbuf_clear(struct ofpbuf *b)
 {
-    b->data = b->base;
-    b->size = 0;
+    ofpbuf_set_data(b, ofpbuf_get_base(b));
+    ofpbuf_set_size(b, 0);
 }
 
 /* Removes 'size' bytes from the head end of 'b', which must contain at least
  * 'size' bytes of data.  Returns the first byte of data removed. */
 static inline void *ofpbuf_pull(struct ofpbuf *b, size_t size)
 {
-    void *data = b->data;
-    ovs_assert(b->size >= size);
-    b->data = (char*)b->data + size;
-    b->size -= size;
+    void *data = ofpbuf_get_data(b);
+    ovs_assert(ofpbuf_get_size(b) >= size);
+    ofpbuf_set_data(b, (char*)ofpbuf_get_data(b) + size);
+    ofpbuf_set_size(b, ofpbuf_get_size(b) - size);
     return data;
 }
 
@@ -217,7 +225,7 @@ static inline void *ofpbuf_pull(struct ofpbuf *b, size_t size)
  * null pointer without modifying 'b'. */
 static inline void *ofpbuf_try_pull(struct ofpbuf *b, size_t size)
 {
-    return b->size >= size ? ofpbuf_pull(b, size) : NULL;
+    return ofpbuf_get_size(b) >= size ? ofpbuf_pull(b, size) : NULL;
 }
 
 static inline struct ofpbuf *ofpbuf_from_list(const struct list *list)
@@ -227,7 +235,8 @@ static inline struct ofpbuf *ofpbuf_from_list(const struct list *list)
 
 static inline bool ofpbuf_equal(const struct ofpbuf *a, const struct ofpbuf *b)
 {
-    return a->size == b->size && memcmp(a->data, b->data, a->size) == 0;
+    return ofpbuf_get_size(a) == ofpbuf_get_size(b) &&
+           memcmp(ofpbuf_get_data(a), ofpbuf_get_data(b), ofpbuf_get_size(a)) == 0;
 }
 
 static inline void * ofpbuf_get_l2_5(const struct ofpbuf *b)
@@ -299,6 +308,36 @@ static inline const void *ofpbuf_get_icmp_payload(const struct ofpbuf *b)
         ? (const char *)ofpbuf_get_l4(b) + ICMP_HEADER_LEN : NULL;
 }
 
+static inline void * ofpbuf_get_data(const struct ofpbuf *b)
+{
+    return b->data;
+}
+
+static inline void ofpbuf_set_data(struct ofpbuf *b, void *d)
+{
+    b->data = d;
+}
+
+static inline void * ofpbuf_get_base(const struct ofpbuf *b)
+{
+    return b->base;
+}
+
+static inline void ofpbuf_set_base(struct ofpbuf *b, void *d)
+{
+    b->base = d;
+}
+
+static inline uint32_t ofpbuf_get_size(const struct ofpbuf *b)
+{
+    return b->size;
+}
+
+static inline void ofpbuf_set_size(struct ofpbuf *b, uint32_t v)
+{
+    b->size = v;
+}
+
 #ifdef  __cplusplus
 }
 #endif
diff --git a/lib/packets.c b/lib/packets.c
index 3366089..794441b 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -196,7 +196,7 @@ eth_pop_vlan(struct ofpbuf *packet)
 {
     struct vlan_eth_header *veh = packet->l2;
 
-    if (packet->size >= sizeof *veh
+    if (ofpbuf_get_size(packet) >= sizeof *veh
         && veh->veth_type == htons(ETH_TYPE_VLAN)) {
 
         memmove((char *)veh + VLAN_HEADER_LEN, veh, 2 * ETH_ADDR_LEN);
@@ -329,7 +329,7 @@ pop_mpls(struct ofpbuf *packet, ovs_be16 ethtype)
             ofpbuf_set_l2_5(packet, NULL);
         }
         /* Shift the l2 header forward. */
-        memmove((char*)packet->data + MPLS_HLEN, packet->data, len);
+        memmove((char*)ofpbuf_get_data(packet) + MPLS_HLEN, ofpbuf_get_data(packet), len);
         ofpbuf_resize_l2_5(packet, -MPLS_HLEN);
     }
 }
@@ -353,7 +353,7 @@ eth_from_hex(const char *hex, struct ofpbuf **packetp)
         return "Trailing garbage in packet data";
     }
 
-    if (packet->size < ETH_HEADER_LEN) {
+    if (ofpbuf_get_size(packet) < ETH_HEADER_LEN) {
         ofpbuf_delete(packet);
         *packetp = NULL;
         return "Packet data too short for Ethernet";
@@ -850,7 +850,7 @@ packet_set_sctp_port(struct ofpbuf *packet, ovs_be16 src, ovs_be16 dst)
 {
     struct sctp_header *sh = ofpbuf_get_l4(packet);
     ovs_be32 old_csum, old_correct_csum, new_csum;
-    uint16_t tp_len = packet->size - ((uint8_t*)sh - (uint8_t*)packet->data);
+    uint16_t tp_len = ofpbuf_get_size(packet) - ((uint8_t*)sh - (uint8_t*)ofpbuf_get_data(packet));
 
     old_csum = sh->sctp_csum;
     sh->sctp_csum = 0;
diff --git a/lib/pcap-file.c b/lib/pcap-file.c
index a92e7d3..c4a2fe5 100644
--- a/lib/pcap-file.c
+++ b/lib/pcap-file.c
@@ -198,10 +198,10 @@ ovs_pcap_write(FILE *file, struct ofpbuf *buf)
     xgettimeofday(&tv);
     prh.ts_sec = tv.tv_sec;
     prh.ts_usec = tv.tv_usec;
-    prh.incl_len = buf->size;
-    prh.orig_len = buf->size;
+    prh.incl_len = ofpbuf_get_size(buf);
+    prh.orig_len = ofpbuf_get_size(buf);
     ignore(fwrite(&prh, sizeof prh, 1, file));
-    ignore(fwrite(buf->data, buf->size, 1, file));
+    ignore(fwrite(ofpbuf_get_data(buf), ofpbuf_get_size(buf), 1, file));
 }
 
 struct tcp_key {
@@ -346,7 +346,7 @@ tcp_reader_run(struct tcp_reader *r, const struct flow *flow,
         /* Shift all of the existing payload to the very beginning of the
          * allocated space, so that we reuse allocated space instead of
          * continually expanding it. */
-        ofpbuf_shift(payload, (char *) payload->base - (char *) payload->data);
+        ofpbuf_shift(payload, (char *) ofpbuf_get_base(payload) - (char *) ofpbuf_get_data(payload));
 
         ofpbuf_put(payload, l7, l7_length);
         stream->seq_no += l7_length;
diff --git a/lib/rconn.c b/lib/rconn.c
index a5368d5..6e28864 100644
--- a/lib/rconn.c
+++ b/lib/rconn.c
@@ -718,11 +718,11 @@ rconn_send__(struct rconn *rc, struct ofpbuf *b,
         copy_to_monitor(rc, b);
 
         if (counter) {
-            rconn_packet_counter_inc(counter, b->size);
+            rconn_packet_counter_inc(counter, ofpbuf_get_size(b));
         }
 
         /* Use 'l2' as a private pointer while 'b' is in txq. */
-        ovs_assert(b->l2 == b->data);
+        ovs_assert(b->l2 == ofpbuf_get_data(b));
         b->l2 = counter;
 
         list_push_back(&rc->txq, &b->list_node);
@@ -1107,7 +1107,7 @@ try_send(struct rconn *rc)
     OVS_REQUIRES(rc->mutex)
 {
     struct ofpbuf *msg = ofpbuf_from_list(rc->txq.next);
-    unsigned int n_bytes = msg->size;
+    unsigned int n_bytes = ofpbuf_get_size(msg);
     struct rconn_packet_counter *counter = msg->l2;
     int retval;
 
@@ -1115,7 +1115,7 @@ try_send(struct rconn *rc)
      * after sending, if sending is successful, because it is then owned by the
      * vconn, which might have freed it already. */
     list_remove(&msg->list_node);
-    msg->l2 = msg->data; /* Restore 'l2'. */
+    msg->l2 = ofpbuf_get_data(msg); /* Restore 'l2'. */
 
     retval = vconn_send(rc->vconn, msg);
     if (retval) {
@@ -1214,7 +1214,7 @@ flush_queue(struct rconn *rc)
         struct ofpbuf *b = ofpbuf_from_list(list_pop_front(&rc->txq));
         struct rconn_packet_counter *counter = b->l2;
         if (counter) {
-            rconn_packet_counter_dec(counter, b->size);
+            rconn_packet_counter_dec(counter, ofpbuf_get_size(b));
         }
         COVERAGE_INC(rconn_discarded);
         ofpbuf_delete(b);
@@ -1324,7 +1324,7 @@ is_admitted_msg(const struct ofpbuf *b)
     enum ofptype type;
     enum ofperr error;
 
-    error = ofptype_decode(&type, b->data);
+    error = ofptype_decode(&type, ofpbuf_get_data(b));
     if (error) {
         return false;
     }
diff --git a/lib/route-table.c b/lib/route-table.c
index fdc21e8..e165ffc 100644
--- a/lib/route-table.c
+++ b/lib/route-table.c
@@ -272,7 +272,7 @@ route_table_parse(struct ofpbuf *buf, struct route_table_msg *change)
         const struct rtmsg *rtm;
         const struct nlmsghdr *nlmsg;
 
-        nlmsg = buf->data;
+        nlmsg = ofpbuf_get_data(buf);
         rtm = ofpbuf_at(buf, NLMSG_HDRLEN, sizeof *rtm);
 
         if (rtm->rtm_family != AF_INET) {
diff --git a/lib/rtnetlink-link.c b/lib/rtnetlink-link.c
index 308338f..f56947e 100644
--- a/lib/rtnetlink-link.c
+++ b/lib/rtnetlink-link.c
@@ -58,7 +58,7 @@ rtnetlink_link_parse(struct ofpbuf *buf,
         const struct nlmsghdr *nlmsg;
         const struct ifinfomsg *ifinfo;
 
-        nlmsg  = buf->data;
+        nlmsg  = ofpbuf_get_data(buf);
         ifinfo = ofpbuf_at(buf, NLMSG_HDRLEN, sizeof *ifinfo);
 
         change->nlmsg_type     = nlmsg->nlmsg_type;
diff --git a/lib/stp.c b/lib/stp.c
index 78dacb3..4d5f2f1 100644
--- a/lib/stp.c
+++ b/lib/stp.c
@@ -1542,7 +1542,7 @@ stp_send_bpdu(struct stp_port *p, const void *bpdu, size_t bpdu_size)
     /* 802.2 header. */
     memcpy(eth->eth_dst, eth_addr_stp, ETH_ADDR_LEN);
     /* p->stp->send_bpdu() must fill in source address. */
-    eth->eth_type = htons(pkt->size - ETH_HEADER_LEN);
+    eth->eth_type = htons(ofpbuf_get_size(pkt) - ETH_HEADER_LEN);
 
     /* LLC header. */
     llc->llc_dsap = STP_LLC_DSAP;
diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c
index 14d62c4..2e7efab 100644
--- a/lib/stream-ssl.c
+++ b/lib/stream-ssl.c
@@ -650,14 +650,15 @@ ssl_do_tx(struct stream *stream)
 
     for (;;) {
         int old_state = SSL_get_state(sslv->ssl);
-        int ret = SSL_write(sslv->ssl, sslv->txbuf->data, sslv->txbuf->size);
+        int ret = SSL_write(sslv->ssl,
+                            ofpbuf_get_data(sslv->txbuf), ofpbuf_get_size(sslv->txbuf));
         if (old_state != SSL_get_state(sslv->ssl)) {
             sslv->rx_want = SSL_NOTHING;
         }
         sslv->tx_want = SSL_NOTHING;
         if (ret > 0) {
             ofpbuf_pull(sslv->txbuf, ret);
-            if (sslv->txbuf->size == 0) {
+            if (ofpbuf_get_size(sslv->txbuf) == 0) {
                 return 0;
             }
         } else {
diff --git a/lib/vconn-stream.c b/lib/vconn-stream.c
index d169840..a3dff4f 100644
--- a/lib/vconn-stream.c
+++ b/lib/vconn-stream.c
@@ -103,7 +103,7 @@ vconn_stream_close(struct vconn *vconn)
     struct vconn_stream *s = vconn_stream_cast(vconn);
 
     if ((vconn->error == EPROTO || s->n_packets < 1) && s->rxbuf) {
-        stream_report_content(s->rxbuf->data, s->rxbuf->size, STREAM_OPENFLOW,
+        stream_report_content(ofpbuf_get_data(s->rxbuf), ofpbuf_get_size(s->rxbuf), STREAM_OPENFLOW,
                               THIS_MODULE, vconn_get_name(vconn));
     }
 
@@ -126,14 +126,14 @@ vconn_stream_recv__(struct vconn_stream *s, int rx_len)
     struct ofpbuf *rx = s->rxbuf;
     int want_bytes, retval;
 
-    want_bytes = rx_len - rx->size;
+    want_bytes = rx_len - ofpbuf_get_size(rx);
     ofpbuf_prealloc_tailroom(rx, want_bytes);
     retval = stream_recv(s->stream, ofpbuf_tail(rx), want_bytes);
     if (retval > 0) {
-        rx->size += retval;
+        ofpbuf_set_size(rx, ofpbuf_get_size(rx) + retval);
         return retval == want_bytes ? 0 : EAGAIN;
     } else if (retval == 0) {
-        if (rx->size) {
+        if (ofpbuf_get_size(rx)) {
             VLOG_ERR_RL(&rl, "connection dropped mid-packet");
             return EPROTO;
         }
@@ -156,7 +156,7 @@ vconn_stream_recv(struct vconn *vconn, struct ofpbuf **bufferp)
     }
 
     /* Read ofp_header. */
-    if (s->rxbuf->size < sizeof(struct ofp_header)) {
+    if (ofpbuf_get_size(s->rxbuf) < sizeof(struct ofp_header)) {
         int retval = vconn_stream_recv__(s, sizeof(struct ofp_header));
         if (retval) {
             return retval;
@@ -164,12 +164,12 @@ vconn_stream_recv(struct vconn *vconn, struct ofpbuf **bufferp)
     }
 
     /* Read payload. */
-    oh = s->rxbuf->data;
+    oh = ofpbuf_get_data(s->rxbuf);
     rx_len = ntohs(oh->length);
     if (rx_len < sizeof(struct ofp_header)) {
         VLOG_ERR_RL(&rl, "received too-short ofp_header (%d bytes)", rx_len);
         return EPROTO;
-    } else if (s->rxbuf->size < rx_len) {
+    } else if (ofpbuf_get_size(s->rxbuf) < rx_len) {
         int retval = vconn_stream_recv__(s, rx_len);
         if (retval) {
             return retval;
@@ -199,8 +199,8 @@ vconn_stream_send(struct vconn *vconn, struct ofpbuf *buffer)
         return EAGAIN;
     }
 
-    retval = stream_send(s->stream, buffer->data, buffer->size);
-    if (retval == buffer->size) {
+    retval = stream_send(s->stream, ofpbuf_get_data(buffer), ofpbuf_get_size(buffer));
+    if (retval == ofpbuf_get_size(buffer)) {
         ofpbuf_delete(buffer);
         return 0;
     } else if (retval >= 0 || retval == -EAGAIN) {
@@ -225,7 +225,7 @@ vconn_stream_run(struct vconn *vconn)
         return;
     }
 
-    retval = stream_send(s->stream, s->txbuf->data, s->txbuf->size);
+    retval = stream_send(s->stream, ofpbuf_get_data(s->txbuf), ofpbuf_get_size(s->txbuf));
     if (retval < 0) {
         if (retval != -EAGAIN) {
             VLOG_ERR_RL(&rl, "send: %s", ovs_strerror(-retval));
@@ -234,7 +234,7 @@ vconn_stream_run(struct vconn *vconn)
         }
     } else if (retval > 0) {
         ofpbuf_pull(s->txbuf, retval);
-        if (!s->txbuf->size) {
+        if (!ofpbuf_get_size(s->txbuf)) {
             vconn_stream_clear_txbuf(s);
             return;
         }
diff --git a/lib/vconn.c b/lib/vconn.c
index d6d239f..16b32dc 100644
--- a/lib/vconn.c
+++ b/lib/vconn.c
@@ -456,16 +456,16 @@ vcs_recv_hello(struct vconn *vconn)
         enum ofptype type;
         enum ofperr error;
 
-        error = ofptype_decode(&type, b->data);
+        error = ofptype_decode(&type, ofpbuf_get_data(b));
         if (!error && type == OFPTYPE_HELLO) {
             char *peer_s, *local_s;
             uint32_t common_versions;
 
-            if (!ofputil_decode_hello(b->data, &vconn->peer_versions)) {
+            if (!ofputil_decode_hello(ofpbuf_get_data(b), &vconn->peer_versions)) {
                 struct ds msg = DS_EMPTY_INITIALIZER;
                 ds_put_format(&msg, "%s: unknown data in hello:\n",
                               vconn->name);
-                ds_put_hex_dump(&msg, b->data, b->size, 0, true);
+                ds_put_hex_dump(&msg, ofpbuf_get_data(b), ofpbuf_get_size(b), 0, true);
                 VLOG_WARN_RL(&bad_ofmsg_rl, "%s", ds_cstr(&msg));
                 ds_destroy(&msg);
             }
@@ -495,7 +495,7 @@ vcs_recv_hello(struct vconn *vconn)
             ofpbuf_delete(b);
             return;
         } else {
-            char *s = ofp_to_string(b->data, b->size, 1);
+            char *s = ofp_to_string(ofpbuf_get_data(b), ofpbuf_get_size(b), 1);
             VLOG_WARN_RL(&bad_ofmsg_rl,
                          "%s: received message while expecting hello: %s",
                          vconn->name, s);
@@ -598,11 +598,11 @@ vconn_recv(struct vconn *vconn, struct ofpbuf **msgp)
         retval = do_recv(vconn, &msg);
     }
     if (!retval && !vconn->recv_any_version) {
-        const struct ofp_header *oh = msg->data;
+        const struct ofp_header *oh = ofpbuf_get_data(msg);
         if (oh->version != vconn->version) {
             enum ofptype type;
 
-            if (ofptype_decode(&type, msg->data)
+            if (ofptype_decode(&type, ofpbuf_get_data(msg))
                 || (type != OFPTYPE_HELLO &&
                     type != OFPTYPE_ERROR &&
                     type != OFPTYPE_ECHO_REQUEST &&
@@ -641,7 +641,7 @@ do_recv(struct vconn *vconn, struct ofpbuf **msgp)
     if (!retval) {
         COVERAGE_INC(vconn_received);
         if (VLOG_IS_DBG_ENABLED()) {
-            char *s = ofp_to_string((*msgp)->data, (*msgp)->size, 1);
+            char *s = ofp_to_string(ofpbuf_get_data(*msgp), ofpbuf_get_size(*msgp), 1);
             VLOG_DBG_RL(&ofmsg_rl, "%s: received: %s", vconn->name, s);
             free(s);
         }
@@ -674,14 +674,14 @@ do_send(struct vconn *vconn, struct ofpbuf *msg)
 {
     int retval;
 
-    ovs_assert(msg->size >= sizeof(struct ofp_header));
+    ovs_assert(ofpbuf_get_size(msg) >= sizeof(struct ofp_header));
 
     ofpmsg_update_length(msg);
     if (!VLOG_IS_DBG_ENABLED()) {
         COVERAGE_INC(vconn_sent);
         retval = (vconn->class->send)(vconn, msg);
     } else {
-        char *s = ofp_to_string(msg->data, msg->size, 1);
+        char *s = ofp_to_string(ofpbuf_get_data(msg), ofpbuf_get_size(msg), 1);
         retval = (vconn->class->send)(vconn, msg);
         if (retval != EAGAIN) {
             VLOG_DBG_RL(&ofmsg_rl, "%s: sent (%s): %s",
@@ -763,7 +763,7 @@ vconn_recv_xid(struct vconn *vconn, ovs_be32 xid, struct ofpbuf **replyp)
             *replyp = NULL;
             return error;
         }
-        recv_xid = ((struct ofp_header *) reply->data)->xid;
+        recv_xid = ((struct ofp_header *) ofpbuf_get_data(reply))->xid;
         if (xid == recv_xid) {
             *replyp = reply;
             return 0;
@@ -790,7 +790,7 @@ int
 vconn_transact(struct vconn *vconn, struct ofpbuf *request,
                struct ofpbuf **replyp)
 {
-    ovs_be32 send_xid = ((struct ofp_header *) request->data)->xid;
+    ovs_be32 send_xid = ((struct ofp_header *) ofpbuf_get_data(request))->xid;
     int error;
 
     *replyp = NULL;
@@ -824,7 +824,7 @@ vconn_transact_noreply(struct vconn *vconn, struct ofpbuf *request,
     *replyp = NULL;
 
     /* Send request. */
-    request_xid = ((struct ofp_header *) request->data)->xid;
+    request_xid = ((struct ofp_header *) ofpbuf_get_data(request))->xid;
     error = vconn_send_block(vconn, request);
     if (error) {
         ofpbuf_delete(request);
@@ -833,7 +833,7 @@ vconn_transact_noreply(struct vconn *vconn, struct ofpbuf *request,
 
     /* Send barrier. */
     barrier = ofputil_encode_barrier_request(vconn_get_version(vconn));
-    barrier_xid = ((struct ofp_header *) barrier->data)->xid;
+    barrier_xid = ((struct ofp_header *) ofpbuf_get_data(barrier))->xid;
     error = vconn_send_block(vconn, barrier);
     if (error) {
         ofpbuf_delete(barrier);
@@ -852,7 +852,7 @@ vconn_transact_noreply(struct vconn *vconn, struct ofpbuf *request,
             return error;
         }
 
-        msg_xid = ((struct ofp_header *) msg->data)->xid;
+        msg_xid = ((struct ofp_header *) ofpbuf_get_data(msg))->xid;
         if (msg_xid == request_xid) {
             if (*replyp) {
                 VLOG_WARN_RL(&bad_ofmsg_rl, "%s: duplicate replies with "
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 9bc1897..9102248 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -1823,7 +1823,8 @@ connmgr_flushed(struct connmgr *mgr)
         ofpact_pad(&ofpacts);
 
         match_init_catchall(&match);
-        ofproto_add_flow(mgr->ofproto, &match, 0, ofpacts.data, ofpacts.size);
+        ofproto_add_flow(mgr->ofproto, &match, 0, ofpbuf_get_data(&ofpacts),
+                                                  ofpbuf_get_size(&ofpacts));
 
         ofpbuf_uninit(&ofpacts);
     }
diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c
index 467cafa..9cb1b7f 100644
--- a/ofproto/fail-open.c
+++ b/ofproto/fail-open.c
@@ -125,11 +125,11 @@ send_bogus_packet_ins(struct fail_open *fo)
     compose_rarp(&b, mac);
 
     memset(&pin, 0, sizeof pin);
-    pin.up.packet = b.data;
-    pin.up.packet_len = b.size;
+    pin.up.packet = ofpbuf_get_data(&b);
+    pin.up.packet_len = ofpbuf_get_size(&b);
     pin.up.reason = OFPR_NO_MATCH;
     pin.up.fmd.in_port = OFPP_LOCAL;
-    pin.send_len = b.size;
+    pin.send_len = ofpbuf_get_size(&b);
     pin.miss_type = OFPROTO_PACKET_IN_NO_MISS;
     connmgr_send_packet_in(fo->connmgr, &pin);
 
@@ -230,7 +230,7 @@ fail_open_flushed(struct fail_open *fo)
 
         match_init_catchall(&match);
         ofproto_add_flow(fo->ofproto, &match, FAIL_OPEN_PRIORITY,
-                         ofpacts.data, ofpacts.size);
+                         ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts));
 
         ofpbuf_uninit(&ofpacts);
     }
diff --git a/ofproto/in-band.c b/ofproto/in-band.c
index 416043e..044580e 100644
--- a/ofproto/in-band.c
+++ b/ofproto/in-band.c
@@ -382,7 +382,7 @@ in_band_run(struct in_band *ib)
         switch (rule->op) {
         case ADD:
             ofproto_add_flow(ib->ofproto, &rule->match, rule->priority,
-                             ofpacts.data, ofpacts.size);
+                             ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts));
             break;
 
         case DEL:
diff --git a/ofproto/netflow.c b/ofproto/netflow.c
index a093749..b3090c8 100644
--- a/ofproto/netflow.c
+++ b/ofproto/netflow.c
@@ -110,7 +110,7 @@ gen_netflow_rec(struct netflow *nf, struct netflow_flow *nf_flow,
     struct netflow_v5_header *nf_hdr;
     struct netflow_v5_record *nf_rec;
 
-    if (!nf->packet.size) {
+    if (!ofpbuf_get_size(&nf->packet)) {
         struct timespec now;
 
         time_wall_timespec(&now);
@@ -127,7 +127,7 @@ gen_netflow_rec(struct netflow *nf, struct netflow_flow *nf_flow,
         nf_hdr->sampling_interval = htons(0);
     }
 
-    nf_hdr = nf->packet.data;
+    nf_hdr = ofpbuf_get_data(&nf->packet);
     nf_hdr->count = htons(ntohs(nf_hdr->count) + 1);
 
     nf_rec = ofpbuf_put_zeros(&nf->packet, sizeof *nf_rec);
@@ -313,9 +313,9 @@ netflow_run__(struct netflow *nf) OVS_REQUIRES(mutex)
     long long int now = time_msec();
     struct netflow_flow *nf_flow, *next;
 
-    if (nf->packet.size) {
-        collectors_send(nf->collectors, nf->packet.data, nf->packet.size);
-        nf->packet.size = 0;
+    if (ofpbuf_get_size(&nf->packet)) {
+        collectors_send(nf->collectors, ofpbuf_get_data(&nf->packet), ofpbuf_get_size(&nf->packet));
+        ofpbuf_set_size(&nf->packet, 0);
     }
 
     if (!nf->active_timeout || now < nf->next_timeout) {
@@ -354,7 +354,7 @@ netflow_wait(struct netflow *nf) OVS_EXCLUDED(mutex)
     if (nf->active_timeout) {
         poll_timer_wait_until(nf->next_timeout);
     }
-    if (nf->packet.size) {
+    if (ofpbuf_get_size(&nf->packet)) {
         poll_immediate_wake();
     }
     ovs_mutex_unlock(&mutex);
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index c8fb3d7..558c7af 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -724,11 +724,11 @@ ipfix_send_msg(const struct collectors *collectors, struct ofpbuf *msg)
     struct ipfix_header *hdr;
 
     /* Adjust the length in the header. */
-    hdr = msg->data;
-    hdr->length = htons(msg->size);
+    hdr = ofpbuf_get_data(msg);
+    hdr->length = htons(ofpbuf_get_size(msg));
 
-    collectors_send(collectors, msg->data, msg->size);
-    msg->size = 0;
+    collectors_send(collectors, ofpbuf_get_data(msg), ofpbuf_get_size(msg));
+    ofpbuf_set_size(msg, 0);
 }
 
 static uint16_t
@@ -852,7 +852,7 @@ ipfix_send_template_msg(struct dpif_ipfix_exporter *exporter,
 
     ipfix_init_header(export_time_sec, exporter->seq_number, obs_domain_id,
                       &msg);
-    set_hdr_offset = msg.size;
+    set_hdr_offset = ofpbuf_get_size(&msg);
 
     /* Add a Template Set. */
     set_hdr = ofpbuf_put_zeros(&msg, sizeof *set_hdr);
@@ -867,20 +867,20 @@ ipfix_send_template_msg(struct dpif_ipfix_exporter *exporter,
                     l4 != IPFIX_PROTO_L4_UNKNOWN) {
                     continue;
                 }
-                tmpl_hdr_offset = msg.size;
+                tmpl_hdr_offset = ofpbuf_get_size(&msg);
                 tmpl_hdr = ofpbuf_put_zeros(&msg, sizeof *tmpl_hdr);
                 tmpl_hdr->template_id = htons(
                     ipfix_get_template_id(l2, l3, l4));
                 field_count = ipfix_define_template_fields(l2, l3, l4, &msg);
                 tmpl_hdr = (struct ipfix_template_record_header*)
-                    ((uint8_t*)msg.data + tmpl_hdr_offset);
+                    ((uint8_t*)ofpbuf_get_data(&msg) + tmpl_hdr_offset);
                 tmpl_hdr->field_count = htons(field_count);
             }
         }
     }
 
-    set_hdr = (struct ipfix_set_header*)((uint8_t*)msg.data + set_hdr_offset);
-    set_hdr->length = htons(msg.size - set_hdr_offset);
+    set_hdr = (struct ipfix_set_header*)((uint8_t*)ofpbuf_get_data(&msg) + set_hdr_offset);
+    set_hdr->length = htons(ofpbuf_get_size(&msg) - set_hdr_offset);
 
     /* XXX: Add Options Template Sets, at least to define a Flow Keys
      * Option Template. */
@@ -1084,7 +1084,7 @@ ipfix_cache_entry_init(struct ipfix_flow_cache_entry *entry,
 
     ethernet_header_length = (l2 == IPFIX_PROTO_L2_VLAN)
         ? VLAN_ETH_HEADER_LEN : ETH_HEADER_LEN;
-    ethernet_total_length = packet->size;
+    ethernet_total_length = ofpbuf_get_size(packet);
 
     /* Common Ethernet entities. */
     {
@@ -1154,7 +1154,7 @@ ipfix_cache_entry_init(struct ipfix_flow_cache_entry *entry,
         data_icmp->icmp_code = ntohs(flow->tp_dst) & 0xff;
     }
 
-    flow_key->flow_key_msg_part_size = msg.size;
+    flow_key->flow_key_msg_part_size = ofpbuf_get_size(&msg);
 
     {
         struct timeval now;
@@ -1205,7 +1205,7 @@ ipfix_put_data_set(uint32_t export_time_sec,
     size_t set_hdr_offset;
     struct ipfix_set_header *set_hdr;
 
-    set_hdr_offset = msg->size;
+    set_hdr_offset = ofpbuf_get_size(msg);
 
     /* Put a Data Set. */
     set_hdr = ofpbuf_put_zeros(msg, sizeof *set_hdr);
@@ -1259,8 +1259,8 @@ ipfix_put_data_set(uint32_t export_time_sec,
             entry->maximum_ip_total_length);
     }
 
-    set_hdr = (struct ipfix_set_header*)((uint8_t*)msg->data + set_hdr_offset);
-    set_hdr->length = htons(msg->size - set_hdr_offset);
+    set_hdr = (struct ipfix_set_header*)((uint8_t*)ofpbuf_get_data(msg) + set_hdr_offset);
+    set_hdr->length = htons(ofpbuf_get_size(msg) - set_hdr_offset);
 }
 
 /* Send an IPFIX message with a single data record. */
diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c
index eeff13f..2197472 100644
--- a/ofproto/ofproto-dpif-sflow.c
+++ b/ofproto/ofproto-dpif-sflow.c
@@ -602,12 +602,12 @@ dpif_sflow_received(struct dpif_sflow *ds, struct ofpbuf *packet,
     header->header_protocol = SFLHEADER_ETHERNET_ISO8023;
     /* The frame_length should include the Ethernet FCS (4 bytes),
      * but it has already been stripped,  so we need to add 4 here. */
-    header->frame_length = packet->size + 4;
+    header->frame_length = ofpbuf_get_size(packet) + 4;
     /* Ethernet FCS stripped off. */
     header->stripped = 4;
-    header->header_length = MIN(packet->size,
+    header->header_length = MIN(ofpbuf_get_size(packet),
                                 sampler->sFlowFsMaximumHeaderSize);
-    header->header_bytes = packet->data;
+    header->header_bytes = ofpbuf_get_data(packet);
 
     /* Add extended switch element. */
     memset(&switchElem, 0, sizeof(switchElem));
diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index 5b5fb6e..a38ed83 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -1043,7 +1043,7 @@ handle_upcalls(struct handler *handler, struct list *upcalls)
                 miss = existing_miss;
             }
             miss->stats.tcp_flags |= ntohs(miss->flow.tcp_flags);
-            miss->stats.n_bytes += packet->size;
+            miss->stats.n_bytes += ofpbuf_get_size(packet);
             miss->stats.n_packets++;
 
             upcall->flow_miss = miss;
@@ -1164,7 +1164,7 @@ handle_upcalls(struct handler *handler, struct list *upcalls)
              * the packet contained no VLAN.  So, we must remove the
              * VLAN header from the packet before trying to execute the
              * actions. */
-            if (miss->xout.odp_actions.size) {
+            if (ofpbuf_get_size(&miss->xout.odp_actions)) {
                 eth_pop_vlan(packet);
             }
 
@@ -1204,21 +1204,21 @@ handle_upcalls(struct handler *handler, struct list *upcalls)
             op->u.flow_put.flags = DPIF_FP_CREATE | DPIF_FP_MODIFY;
             op->u.flow_put.key = miss->key;
             op->u.flow_put.key_len = miss->key_len;
-            op->u.flow_put.mask = mask.data;
-            op->u.flow_put.mask_len = mask.size;
+            op->u.flow_put.mask = ofpbuf_get_data(&mask);
+            op->u.flow_put.mask_len = ofpbuf_get_size(&mask);
             op->u.flow_put.stats = NULL;
 
             if (!miss->xout.slow) {
-                op->u.flow_put.actions = miss->xout.odp_actions.data;
-                op->u.flow_put.actions_len = miss->xout.odp_actions.size;
+                op->u.flow_put.actions = ofpbuf_get_data(&miss->xout.odp_actions);
+                op->u.flow_put.actions_len = ofpbuf_get_size(&miss->xout.odp_actions);
             } else {
                 struct ofpbuf buf;
 
                 ofpbuf_use_stack(&buf, miss->slow_path_buf,
                                  sizeof miss->slow_path_buf);
                 compose_slow_path(udpif, &miss->xout, miss->odp_in_port, &buf);
-                op->u.flow_put.actions = buf.data;
-                op->u.flow_put.actions_len = buf.size;
+                op->u.flow_put.actions = ofpbuf_get_data(&buf);
+                op->u.flow_put.actions_len = ofpbuf_get_size(&buf);
             }
         }
 
@@ -1228,15 +1228,15 @@ handle_upcalls(struct handler *handler, struct list *upcalls)
          * upcall. */
         miss->flow.vlan_tci = flow_vlan_tci;
 
-        if (miss->xout.odp_actions.size) {
+        if (ofpbuf_get_size(&miss->xout.odp_actions)) {
 
             op = &ops[n_ops++];
             op->type = DPIF_OP_EXECUTE;
             op->u.execute.packet = packet;
             odp_key_to_pkt_metadata(miss->key, miss->key_len,
                                     &op->u.execute.md);
-            op->u.execute.actions = miss->xout.odp_actions.data;
-            op->u.execute.actions_len = miss->xout.odp_actions.size;
+            op->u.execute.actions = ofpbuf_get_data(&miss->xout.odp_actions);
+            op->u.execute.actions_len = ofpbuf_get_size(&miss->xout.odp_actions);
             op->u.execute.needs_help = (miss->xout.slow & SLOW_ACTION) != 0;
         }
     }
@@ -1257,8 +1257,8 @@ handle_upcalls(struct handler *handler, struct list *upcalls)
             struct ofproto_packet_in *pin;
 
             pin = xmalloc(sizeof *pin);
-            pin->up.packet = xmemdup(packet->data, packet->size);
-            pin->up.packet_len = packet->size;
+            pin->up.packet = xmemdup(ofpbuf_get_data(packet), ofpbuf_get_size(packet));
+            pin->up.packet_len = ofpbuf_get_size(packet);
             pin->up.reason = OFPR_NO_MATCH;
             pin->up.table_id = 0;
             pin->up.cookie = OVS_BE64_MAX;
@@ -1390,8 +1390,8 @@ revalidate_ukey(struct udpif *udpif, struct udpif_flow_dump *udump,
     }
 
     if (!xout.slow) {
-        ofpbuf_use_const(&xout_actions, xout.odp_actions.data,
-                         xout.odp_actions.size);
+        ofpbuf_use_const(&xout_actions, ofpbuf_get_data(&xout.odp_actions),
+                         ofpbuf_get_size(&xout.odp_actions));
     } else {
         ofpbuf_use_stack(&xout_actions, slow_path_buf, sizeof slow_path_buf);
         compose_slow_path(udpif, &xout, odp_in_port, &xout_actions);
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index e26b7c9..efe8821 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -703,7 +703,7 @@ stp_process_packet(const struct xport *xport, const struct ofpbuf *packet)
 {
     struct stp_port *sp = xport_get_stp_port(xport);
     struct ofpbuf payload = *packet;
-    struct eth_header *eth = payload.data;
+    struct eth_header *eth = ofpbuf_get_data(&payload);
 
     /* Sink packets on ports that have STP disabled when the bridge has
      * STP enabled. */
@@ -712,12 +712,12 @@ stp_process_packet(const struct xport *xport, const struct ofpbuf *packet)
     }
 
     /* Trim off padding on payload. */
-    if (payload.size > ntohs(eth->eth_type) + ETH_HEADER_LEN) {
-        payload.size = ntohs(eth->eth_type) + ETH_HEADER_LEN;
+    if (ofpbuf_get_size(&payload) > ntohs(eth->eth_type) + ETH_HEADER_LEN) {
+        ofpbuf_set_size(&payload, ntohs(eth->eth_type) + ETH_HEADER_LEN);
     }
 
     if (ofpbuf_try_pull(&payload, ETH_HEADER_LEN + LLC_HEADER_LEN)) {
-        stp_received_bpdu(sp, payload.data, payload.size);
+        stp_received_bpdu(sp, ofpbuf_get_data(&payload), ofpbuf_get_size(&payload));
     }
 }
 
@@ -1742,12 +1742,12 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port,
                 /* Forwarding is disabled by STP.  Let OFPP_NORMAL and the
                  * learning action look at the packet, then drop it. */
                 struct flow old_base_flow = ctx->base_flow;
-                size_t old_size = ctx->xout->odp_actions.size;
+                size_t old_size = ofpbuf_get_size(&ctx->xout->odp_actions);
                 mirror_mask_t old_mirrors = ctx->xout->mirrors;
                 xlate_table_action(ctx, flow->in_port.ofp_port, 0, true, true);
                 ctx->xout->mirrors = old_mirrors;
                 ctx->base_flow = old_base_flow;
-                ctx->xout->odp_actions.size = old_size;
+                ofpbuf_set_size(&ctx->xout->odp_actions, old_size);
             }
         }
 
@@ -1867,9 +1867,9 @@ xlate_resubmit_resource_check(struct xlate_ctx *ctx)
                     MAX_RESUBMIT_RECURSION);
     } else if (ctx->resubmits >= MAX_RESUBMITS) {
         VLOG_ERR_RL(&rl, "over %d resubmit actions", MAX_RESUBMITS);
-    } else if (ctx->xout->odp_actions.size > UINT16_MAX) {
+    } else if (ofpbuf_get_size(&ctx->xout->odp_actions) > UINT16_MAX) {
         VLOG_ERR_RL(&rl, "resubmits yielded over 64 kB of actions");
-    } else if (ctx->stack.size >= 65536) {
+    } else if (ofpbuf_get_size(&ctx->stack) >= 65536) {
         VLOG_ERR_RL(&rl, "resubmits yielded over 64 kB of stack");
     } else {
         return true;
@@ -1955,7 +1955,7 @@ xlate_group_bucket(struct xlate_ctx *ctx, const struct ofputil_bucket *bucket)
 
     ofpacts_execute_action_set(&action_list, &action_set);
     ctx->recurse++;
-    do_xlate_actions(action_list.data, action_list.size, ctx);
+    do_xlate_actions(ofpbuf_get_data(&action_list), ofpbuf_get_size(&action_list), ctx);
     ctx->recurse--;
 
     ofpbuf_uninit(&action_set);
@@ -2135,11 +2135,12 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
                                           &ctx->xout->odp_actions,
                                           &ctx->xout->wc);
 
-    odp_execute_actions(NULL, packet, false, &md, ctx->xout->odp_actions.data,
-                        ctx->xout->odp_actions.size, NULL);
+    odp_execute_actions(NULL, packet, false, &md,
+                        ofpbuf_get_data(&ctx->xout->odp_actions),
+                        ofpbuf_get_size(&ctx->xout->odp_actions), NULL);
 
     pin = xmalloc(sizeof *pin);
-    pin->up.packet_len = packet->size;
+    pin->up.packet_len = ofpbuf_get_size(packet);
     pin->up.packet = ofpbuf_steal_data(packet);
     pin->up.reason = reason;
     pin->up.table_id = ctx->table_id;
@@ -2551,7 +2552,7 @@ xlate_action_set(struct xlate_ctx *ctx)
 
     ofpbuf_use_stub(&action_list, action_list_stub, sizeof action_list_stub);
     ofpacts_execute_action_set(&action_list, &ctx->action_set);
-    do_xlate_actions(action_list.data, action_list.size, ctx);
+    do_xlate_actions(ofpbuf_get_data(&action_list), ofpbuf_get_size(&action_list), ctx);
     ofpbuf_uninit(&action_list);
 }
 
@@ -2897,8 +2898,8 @@ xlate_out_copy(struct xlate_out *dst, const struct xlate_out *src)
 
     ofpbuf_use_stub(&dst->odp_actions, dst->odp_actions_stub,
                     sizeof dst->odp_actions_stub);
-    ofpbuf_put(&dst->odp_actions, src->odp_actions.data,
-               src->odp_actions.size);
+    ofpbuf_put(&dst->odp_actions, ofpbuf_get_data(&src->odp_actions),
+               ofpbuf_get_size(&src->odp_actions));
 }
 
 static struct skb_priority_to_dscp *
@@ -2943,8 +2944,8 @@ actions_output_to_local_port(const struct xlate_ctx *ctx)
     const struct nlattr *a;
     unsigned int left;
 
-    NL_ATTR_FOR_EACH_UNSAFE (a, left, ctx->xout->odp_actions.data,
-                             ctx->xout->odp_actions.size) {
+    NL_ATTR_FOR_EACH_UNSAFE (a, left, ofpbuf_get_data(&ctx->xout->odp_actions),
+                             ofpbuf_get_size(&ctx->xout->odp_actions)) {
         if (nl_attr_type(a) == OVS_ACTION_ATTR_OUTPUT
             && nl_attr_get_odp_port(a) == local_odp_port) {
             return true;
@@ -3131,7 +3132,7 @@ xlate_actions__(struct xlate_in *xin, struct xlate_out *xout)
 
         add_sflow_action(&ctx);
         add_ipfix_action(&ctx);
-        sample_actions_len = ctx.xout->odp_actions.size;
+        sample_actions_len = ofpbuf_get_size(&ctx.xout->odp_actions);
 
         if (tnl_may_send && (!in_port || may_receive(in_port, &ctx))) {
             do_xlate_actions(ofpacts, ofpacts_len, &ctx);
@@ -3139,11 +3140,11 @@ xlate_actions__(struct xlate_in *xin, struct xlate_out *xout)
             /* We've let OFPP_NORMAL and the learning action look at the
              * packet, so drop it now if forwarding is disabled. */
             if (in_port && !xport_stp_forward_state(in_port)) {
-                ctx.xout->odp_actions.size = sample_actions_len;
+                ofpbuf_set_size(&ctx.xout->odp_actions, sample_actions_len);
             }
         }
 
-        if (ctx.action_set.size) {
+        if (ofpbuf_get_size(&ctx.action_set)) {
             xlate_action_set(&ctx);
         }
 
@@ -3160,7 +3161,7 @@ xlate_actions__(struct xlate_in *xin, struct xlate_out *xout)
         }
     }
 
-    if (nl_attr_oversized(ctx.xout->odp_actions.size)) {
+    if (nl_attr_oversized(ofpbuf_get_size(&ctx.xout->odp_actions))) {
         /* These datapath actions are too big for a Netlink attribute, so we
          * can't hand them to the kernel directly.  dpif_execute() can execute
          * them one by one with help, so just mark the result as SLOW_ACTION to
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 7172cb2..51cf3a3 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -946,8 +946,8 @@ check_variable_length_userdata(struct dpif_backer *backer)
 
     /* Execute the actions.  On older datapaths this fails with ERANGE, on
      * newer datapaths it succeeds. */
-    execute.actions = actions.data;
-    execute.actions_len = actions.size;
+    execute.actions = ofpbuf_get_data(&actions);
+    execute.actions_len = ofpbuf_get_size(&actions);
     execute.packet = &packet;
     execute.md = PKT_METADATA_INITIALIZER(0);
     execute.needs_help = false;
@@ -1009,7 +1009,7 @@ check_max_mpls_depth(struct dpif_backer *backer)
         odp_flow_key_from_flow(&key, &flow, 0);
 
         error = dpif_flow_put(backer->dpif, DPIF_FP_CREATE | DPIF_FP_MODIFY,
-                              key.data, key.size, NULL, 0, NULL, 0, NULL);
+                              ofpbuf_get_data(&key), ofpbuf_get_size(&key), NULL, 0, NULL, 0, NULL);
         if (error && error != EEXIST) {
             if (error != EINVAL) {
                 VLOG_WARN("%s: MPLS stack length feature probe failed (%s)",
@@ -1018,7 +1018,7 @@ check_max_mpls_depth(struct dpif_backer *backer)
             break;
         }
 
-        error = dpif_flow_del(backer->dpif, key.data, key.size, NULL);
+        error = dpif_flow_del(backer->dpif, ofpbuf_get_data(&key), ofpbuf_get_size(&key), NULL);
         if (error) {
             VLOG_WARN("%s: failed to delete MPLS feature probe flow",
                       dpif_name(backer->dpif));
@@ -1117,8 +1117,8 @@ add_internal_flow(struct ofproto_dpif *ofproto, int id,
     fm.buffer_id = 0;
     fm.out_port = 0;
     fm.flags = 0;
-    fm.ofpacts = ofpacts->data;
-    fm.ofpacts_len = ofpacts->size;
+    fm.ofpacts = ofpbuf_get_data(ofpacts);
+    fm.ofpacts_len = ofpbuf_get_size(ofpacts);
 
     error = ofproto_flow_mod(&ofproto->up, &fm);
     if (error) {
@@ -2420,7 +2420,7 @@ bundle_send_learning_packets(struct ofbundle *bundle)
                                                            e->mac, e->vlan,
                                                            &port_void);
             /* Temporarily use l2 as a private pointer (see below). */
-            ovs_assert(learning_packet->l2 == learning_packet->data);
+            ovs_assert(learning_packet->l2 == ofpbuf_get_data(learning_packet));
             learning_packet->l2 = port_void;
             list_push_back(&packets, &learning_packet->list_node);
         }
@@ -2433,7 +2433,7 @@ bundle_send_learning_packets(struct ofbundle *bundle)
         void *port_void = learning_packet->l2;
 
         /* Restore l2. */
-        learning_packet->l2 = learning_packet->data;
+        learning_packet->l2 = ofpbuf_get_data(learning_packet);
         ret = ofproto_dpif_send_packet(port_void, learning_packet);
         if (ret) {
             error = ret;
@@ -3005,8 +3005,8 @@ ofproto_dpif_execute_actions(struct ofproto_dpif *ofproto,
     if (in_port == OFPP_NONE) {
         in_port = OFPP_LOCAL;
     }
-    execute.actions = xout.odp_actions.data;
-    execute.actions_len = xout.odp_actions.size;
+    execute.actions = ofpbuf_get_data(&xout.odp_actions);
+    execute.actions_len = ofpbuf_get_size(&xout.odp_actions);
     execute.packet = packet;
     execute.md.tunnel = flow->tunnel;
     execute.md.skb_priority = flow->skb_priority;
@@ -3517,7 +3517,7 @@ ofproto_dpif_send_packet(const struct ofport_dpif *ofport, struct ofpbuf *packet
 
     ovs_mutex_lock(&ofproto->stats_mutex);
     ofproto->stats.tx_packets++;
-    ofproto->stats.tx_bytes += packet->size;
+    ofproto->stats.tx_bytes += ofpbuf_get_size(packet);
     ovs_mutex_unlock(&ofproto->stats_mutex);
     return error;
 }
@@ -3731,7 +3731,8 @@ trace_format_odp(struct ds *result, int level, const char *title,
 
     ds_put_char_multiple(result, '\t', level);
     ds_put_format(result, "%s: ", title);
-    format_odp_actions(result, odp_actions->data, odp_actions->size);
+    format_odp_actions(result, ofpbuf_get_data(odp_actions),
+                               ofpbuf_get_size(odp_actions));
     ds_put_char(result, '\n');
 }
 
@@ -3855,7 +3856,8 @@ parse_flow_and_packet(int argc, const char *argv[],
             goto exit;
         }
 
-        if (xlate_receive(backer, NULL, odp_key.data, odp_key.size, flow,
+        if (xlate_receive(backer, NULL, ofpbuf_get_data(&odp_key),
+                          ofpbuf_get_size(&odp_key), flow,
                           ofprotop, NULL, NULL, NULL, NULL)) {
             error = "Invalid datapath flow";
             goto exit;
@@ -3883,7 +3885,7 @@ parse_flow_and_packet(int argc, const char *argv[],
 
     /* Generate a packet, if requested. */
     if (packet) {
-        if (!packet->size) {
+        if (!ofpbuf_get_size(packet)) {
             flow_compose(packet, flow);
         } else {
             struct pkt_metadata md = pkt_metadata_from_flow(flow);
@@ -3996,11 +3998,11 @@ ofproto_unixctl_trace_actions(struct unixctl_conn *conn, int argc,
         goto exit;
     }
     if (enforce_consistency) {
-        retval = ofpacts_check_consistency(ofpacts.data, ofpacts.size, &flow,
-                                           u16_to_ofp(ofproto->up.max_ports),
+        retval = ofpacts_check_consistency(ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts),
+                                           &flow, u16_to_ofp(ofproto->up.max_ports),
                                            0, 0, usable_protocols);
     } else {
-        retval = ofpacts_check(ofpacts.data, ofpacts.size, &flow,
+        retval = ofpacts_check(ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts), &flow,
                                u16_to_ofp(ofproto->up.max_ports), 0, 0,
                                &usable_protocols);
     }
@@ -4012,7 +4014,8 @@ ofproto_unixctl_trace_actions(struct unixctl_conn *conn, int argc,
         goto exit;
     }
 
-    ofproto_trace(ofproto, &flow, packet, ofpacts.data, ofpacts.size, &result);
+    ofproto_trace(ofproto, &flow, packet,
+                  ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts), &result);
     unixctl_command_reply(conn, ds_cstr(&result));
 
 exit:
@@ -4081,8 +4084,8 @@ ofproto_trace(struct ofproto_dpif *ofproto, const struct flow *flow,
         trace_format_megaflow(ds, 0, "Megaflow", &trace);
 
         ds_put_cstr(ds, "Datapath actions: ");
-        format_odp_actions(ds, trace.xout.odp_actions.data,
-                           trace.xout.odp_actions.size);
+        format_odp_actions(ds, ofpbuf_get_data(&trace.xout.odp_actions),
+                           ofpbuf_get_size(&trace.xout.odp_actions));
 
         if (trace.xout.slow) {
             enum slow_path_reason slow;
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index b2d6526..15c1674 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -5842,7 +5842,7 @@ static enum ofperr
 handle_openflow__(struct ofconn *ofconn, const struct ofpbuf *msg)
     OVS_EXCLUDED(ofproto_mutex)
 {
-    const struct ofp_header *oh = msg->data;
+    const struct ofp_header *oh = ofpbuf_get_data(msg);
     enum ofptype type;
     enum ofperr error;
 
@@ -6015,7 +6015,7 @@ handle_openflow(struct ofconn *ofconn, const struct ofpbuf *ofp_msg)
 {
     int error = handle_openflow__(ofconn, ofp_msg);
     if (error && error != OFPROTO_POSTPONE) {
-        ofconn_send_error(ofconn, ofp_msg->data, error);
+        ofconn_send_error(ofconn, ofpbuf_get_data(ofp_msg), error);
     }
     COVERAGE_INC(ofproto_recv_openflow);
     return error != OFPROTO_POSTPONE;
diff --git a/tests/test-bundle.c b/tests/test-bundle.c
index 5e5ef52..b1ec9ab 100644
--- a/tests/test-bundle.c
+++ b/tests/test-bundle.c
@@ -78,7 +78,7 @@ parse_bundle_actions(char *actions)
         ovs_fatal(0, "%s", error);
     }
 
-    action = ofpacts.data;
+    action = ofpbuf_get_data(&ofpacts);
     bundle = ofpact_get_BUNDLE(xmemdup(action, action->len));
     ofpbuf_uninit(&ofpacts);
 
diff --git a/tests/test-flows.c b/tests/test-flows.c
index a498142..16732bb 100644
--- a/tests/test-flows.c
+++ b/tests/test-flows.c
@@ -79,8 +79,8 @@ main(int argc OVS_UNUSED, char *argv[])
             errors++;
             printf("mismatch on packet #%d (1-based).\n", n);
             printf("Packet:\n");
-            ofp_print_packet(stdout, packet->data, packet->size);
-            ovs_hex_dump(stdout, packet->data, packet->size, 0, true);
+            ofp_print_packet(stdout, ofpbuf_get_data(packet), ofpbuf_get_size(packet));
+            ovs_hex_dump(stdout, ofpbuf_get_data(packet), ofpbuf_get_size(packet), 0, true);
             match_print(&match);
             printf("Expected flow:\n%s\n", exp_s);
             printf("Actually extracted flow:\n%s\n", got_s);
diff --git a/tests/test-netflow.c b/tests/test-netflow.c
index 392c6ec..728aa41 100644
--- a/tests/test-netflow.c
+++ b/tests/test-netflow.c
@@ -161,8 +161,8 @@ print_netflow(struct ofpbuf *buf)
         putchar('\n');
     }
 
-    if (buf->size) {
-        printf("%"PRIu32" extra bytes after last record\n", buf->size);
+    if (ofpbuf_get_size(buf)) {
+        printf("%"PRIu32" extra bytes after last record\n", ofpbuf_get_size(buf));
     }
 }
 
@@ -213,7 +213,7 @@ main(int argc, char *argv[])
 
         ofpbuf_clear(&buf);
         do {
-            retval = read(sock, buf.data, buf.allocated);
+            retval = read(sock, ofpbuf_get_data(&buf), buf.allocated);
         } while (retval < 0 && errno == EINTR);
         if (retval > 0) {
             ofpbuf_put_uninit(&buf, retval);
diff --git a/tests/test-odp.c b/tests/test-odp.c
index d41db84..214dcb6 100644
--- a/tests/test-odp.c
+++ b/tests/test-odp.c
@@ -55,7 +55,7 @@ parse_keys(bool wc_keys)
 
         if (!wc_keys) {
             /* Convert odp_key to flow. */
-            fitness = odp_flow_key_to_flow(odp_key.data, odp_key.size, &flow);
+            fitness = odp_flow_key_to_flow(ofpbuf_get_data(&odp_key), ofpbuf_get_size(&odp_key), &flow);
             switch (fitness) {
                 case ODP_FIT_PERFECT:
                     break;
@@ -77,9 +77,9 @@ parse_keys(bool wc_keys)
             ofpbuf_init(&odp_key, 0);
             odp_flow_key_from_flow(&odp_key, &flow, flow.in_port.odp_port);
 
-            if (odp_key.size > ODPUTIL_FLOW_KEY_BYTES) {
+            if (ofpbuf_get_size(&odp_key) > ODPUTIL_FLOW_KEY_BYTES) {
                 printf ("too long: %"PRIu32" > %d\n",
-                        odp_key.size, ODPUTIL_FLOW_KEY_BYTES);
+                        ofpbuf_get_size(&odp_key), ODPUTIL_FLOW_KEY_BYTES);
                 exit_code = 1;
             }
         }
@@ -87,10 +87,10 @@ parse_keys(bool wc_keys)
         /* Convert odp_key to string. */
         ds_init(&out);
         if (wc_keys) {
-            odp_flow_format(odp_key.data, odp_key.size,
-                            odp_mask.data, odp_mask.size, NULL, &out, false);
+            odp_flow_format(ofpbuf_get_data(&odp_key), ofpbuf_get_size(&odp_key),
+                            ofpbuf_get_data(&odp_mask), ofpbuf_get_size(&odp_mask), NULL, &out, false);
         } else {
-            odp_flow_key_format(odp_key.data, odp_key.size, &out);
+            odp_flow_key_format(ofpbuf_get_data(&odp_key), ofpbuf_get_size(&odp_key), &out);
         }
         puts(ds_cstr(&out));
         ds_destroy(&out);
@@ -125,7 +125,7 @@ parse_actions(void)
 
         /* Convert odp_actions back to string. */
         ds_init(&out);
-        format_odp_actions(&out, odp_actions.data, odp_actions.size);
+        format_odp_actions(&out, ofpbuf_get_data(&odp_actions), ofpbuf_get_size(&odp_actions));
         puts(ds_cstr(&out));
         ds_destroy(&out);
 
@@ -183,8 +183,8 @@ parse_filter(char *filter_parse)
             struct match match, match_filter;
             struct minimatch minimatch;
 
-            odp_flow_key_to_flow(odp_key.data, odp_key.size, &flow);
-            odp_flow_key_to_mask(odp_mask.data, odp_mask.size, &wc.masks,
+            odp_flow_key_to_flow(ofpbuf_get_data(&odp_key), ofpbuf_get_size(&odp_key), &flow);
+            odp_flow_key_to_mask(ofpbuf_get_data(&odp_mask), ofpbuf_get_size(&odp_mask), &wc.masks,
                                  &flow);
             match_init(&match, &flow, &wc);
 
@@ -200,8 +200,8 @@ parse_filter(char *filter_parse)
         }
         /* Convert odp_key to string. */
         ds_init(&out);
-        odp_flow_format(odp_key.data, odp_key.size,
-                        odp_mask.data, odp_mask.size, NULL, &out, false);
+        odp_flow_format(ofpbuf_get_data(&odp_key), ofpbuf_get_size(&odp_key),
+                        ofpbuf_get_data(&odp_mask), ofpbuf_get_size(&odp_mask), NULL, &out, false);
         puts(ds_cstr(&out));
         ds_destroy(&out);
 
diff --git a/tests/test-sflow.c b/tests/test-sflow.c
index deebd82..10439ef 100644
--- a/tests/test-sflow.c
+++ b/tests/test-sflow.c
@@ -468,13 +468,13 @@ static void
 print_sflow(struct ofpbuf *buf)
 {
     char *dgram_buf;
-    int dgram_len = buf->size;
+    int dgram_len = ofpbuf_get_size(buf);
     struct sflow_xdr xdrDatagram;
     struct sflow_xdr *x = &xdrDatagram;
 
     memset(x, 0, sizeof *x);
     if (SFLOWXDR_try(x)) {
-        SFLOWXDR_assert(x, (dgram_buf = ofpbuf_try_pull(buf, buf->size)));
+        SFLOWXDR_assert(x, (dgram_buf = ofpbuf_try_pull(buf, ofpbuf_get_size(buf))));
         sflowxdr_init(x, dgram_buf, dgram_len);
         SFLOWXDR_assert(x, dgram_len >= SFLOW_MIN_LEN);
         process_datagram(x);
@@ -529,7 +529,7 @@ main(int argc, char *argv[])
 
         ofpbuf_clear(&buf);
         do {
-            retval = read(sock, buf.data, buf.allocated);
+            retval = read(sock, ofpbuf_get_data(&buf), buf.allocated);
         } while (retval < 0 && errno == EINTR);
         if (retval > 0) {
             ofpbuf_put_uninit(&buf, retval);
diff --git a/tests/test-vconn.c b/tests/test-vconn.c
index 76757f4..54461ab 100644
--- a/tests/test-vconn.c
+++ b/tests/test-vconn.c
@@ -356,7 +356,7 @@ test_send_plain_hello(int argc OVS_UNUSED, char *argv[])
 
     hello = ofpraw_alloc_xid(OFPRAW_OFPT_HELLO, OFP10_VERSION,
                              htonl(0x12345678), 0);
-    test_send_hello(type, hello->data, hello->size, 0);
+    test_send_hello(type, ofpbuf_get_data(hello), ofpbuf_get_size(hello), 0);
     ofpbuf_delete(hello);
 }
 
@@ -374,7 +374,7 @@ test_send_long_hello(int argc OVS_UNUSED, char *argv[])
                              htonl(0x12345678), EXTRA_BYTES);
     ofpbuf_put_zeros(hello, EXTRA_BYTES);
     ofpmsg_update_length(hello);
-    test_send_hello(type, hello->data, hello->size, 0);
+    test_send_hello(type, ofpbuf_get_data(hello), ofpbuf_get_size(hello), 0);
     ofpbuf_delete(hello);
 }
 
@@ -388,7 +388,7 @@ test_send_echo_hello(int argc OVS_UNUSED, char *argv[])
 
     echo = ofpraw_alloc_xid(OFPRAW_OFPT_ECHO_REQUEST, OFP10_VERSION,
                              htonl(0x12345678), 0);
-    test_send_hello(type, echo->data, echo->size, EPROTO);
+    test_send_hello(type, ofpbuf_get_data(echo), ofpbuf_get_size(echo), EPROTO);
     ofpbuf_delete(echo);
 }
 
@@ -414,8 +414,8 @@ test_send_invalid_version_hello(int argc OVS_UNUSED, char *argv[])
 
     hello = ofpraw_alloc_xid(OFPRAW_OFPT_HELLO, OFP10_VERSION,
                              htonl(0x12345678), 0);
-    ((struct ofp_header *) hello->data)->version = 0;
-    test_send_hello(type, hello->data, hello->size, EPROTO);
+    ((struct ofp_header *) ofpbuf_get_data(hello))->version = 0;
+    test_send_hello(type, ofpbuf_get_data(hello), ofpbuf_get_size(hello), EPROTO);
     ofpbuf_delete(hello);
 }
 
diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c
index 4b00118..f5f15c4 100644
--- a/utilities/ovs-dpctl.c
+++ b/utilities/ovs-dpctl.c
@@ -883,9 +883,10 @@ dpctl_put_flow(int argc, char *argv[], enum dpif_flow_put_flags flags)
     run(odp_actions_from_string(actions_s, NULL, &actions), "parsing actions");
 
     run(dpif_flow_put(dpif, flags,
-                      key.data, key.size,
-                      mask.size == 0 ? NULL : mask.data, mask.size,
-                      actions.data, actions.size,
+                      ofpbuf_get_data(&key), ofpbuf_get_size(&key),
+                      ofpbuf_get_size(&mask) == 0 ? NULL : ofpbuf_get_data(&mask),
+                      ofpbuf_get_size(&mask),
+                      ofpbuf_get_data(&actions), ofpbuf_get_size(&actions),
                       print_statistics ? &stats : NULL),
         "updating flow table");
 
@@ -952,7 +953,7 @@ dpctl_del_flow(int argc, char *argv[])
     run(odp_flow_from_string(key_s, &port_names, &key, &mask), "parsing flow key");
 
     run(dpif_flow_del(dpif,
-                      key.data, key.size,
+                      ofpbuf_get_data(&key), ofpbuf_get_size(&key),
                       print_statistics ? &stats : NULL), "deleting flow");
 
     simap_destroy(&port_names);
@@ -1005,7 +1006,7 @@ dpctl_parse_actions(int argc, char *argv[])
             "odp_actions_from_string");
 
         ds_init(&s);
-        format_odp_actions(&s, actions.data, actions.size);
+        format_odp_actions(&s, ofpbuf_get_data(&actions), ofpbuf_get_size(&actions));
         puts(ds_cstr(&s));
         ds_destroy(&s);
 
@@ -1141,10 +1142,10 @@ dpctl_normalize_actions(int argc, char *argv[])
         "odp_flow_key_from_string");
 
     ds_clear(&s);
-    odp_flow_format(keybuf.data, keybuf.size, NULL, 0, NULL, &s, verbosity);
+    odp_flow_format(ofpbuf_get_data(&keybuf), ofpbuf_get_size(&keybuf), NULL, 0, NULL, &s, verbosity);
     printf("input flow: %s\n", ds_cstr(&s));
 
-    run(odp_flow_key_to_flow(keybuf.data, keybuf.size, &flow),
+    run(odp_flow_key_to_flow(ofpbuf_get_data(&keybuf), ofpbuf_get_size(&keybuf), &flow),
         "odp_flow_key_to_flow");
     ofpbuf_uninit(&keybuf);
 
@@ -1156,12 +1157,12 @@ dpctl_normalize_actions(int argc, char *argv[])
 
     if (verbosity) {
         ds_clear(&s);
-        format_odp_actions(&s, odp_actions.data, odp_actions.size);
+        format_odp_actions(&s, ofpbuf_get_data(&odp_actions), ofpbuf_get_size(&odp_actions));
         printf("input actions: %s\n", ds_cstr(&s));
     }
 
     hmap_init(&actions_per_flow);
-    NL_ATTR_FOR_EACH (a, left, odp_actions.data, odp_actions.size) {
+    NL_ATTR_FOR_EACH (a, left, ofpbuf_get_data(&odp_actions), ofpbuf_get_size(&odp_actions)) {
         const struct ovs_action_push_vlan *push;
         switch(nl_attr_type(a)) {
         case OVS_ACTION_ATTR_POP_VLAN:
@@ -1192,7 +1193,7 @@ dpctl_normalize_actions(int argc, char *argv[])
     for (i = 0; i < n_afs; i++) {
         const struct actions_for_flow *af = afs[i];
 
-        sort_output_actions(af->actions.data, af->actions.size);
+        sort_output_actions(ofpbuf_get_data(&af->actions), ofpbuf_get_size(&af->actions));
 
         if (af->flow.vlan_tci != htons(0)) {
             printf("vlan(vid=%"PRIu16",pcp=%d): ",
@@ -1212,7 +1213,7 @@ dpctl_normalize_actions(int argc, char *argv[])
         }
 
         ds_clear(&s);
-        format_odp_actions(&s, af->actions.data, af->actions.size);
+        format_odp_actions(&s, ofpbuf_get_data(&af->actions), ofpbuf_get_size(&af->actions));
         puts(ds_cstr(&s));
     }
     ds_destroy(&s);
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 1294247..831efc4 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -468,7 +468,7 @@ dump_transaction(struct vconn *vconn, struct ofpbuf *request)
     ofpmsg_update_length(request);
     run(vconn_transact(vconn, request, &reply), "talking to %s",
         vconn_get_name(vconn));
-    ofp_print(stdout, reply->data, reply->size, verbosity + 1);
+    ofp_print(stdout, ofpbuf_get_data(reply), ofpbuf_get_size(reply), verbosity + 1);
     ofpbuf_delete(reply);
 }
 
@@ -487,13 +487,13 @@ dump_trivial_transaction(const char *vconn_name, enum ofpraw raw)
 static void
 dump_stats_transaction(struct vconn *vconn, struct ofpbuf *request)
 {
-    const struct ofp_header *request_oh = request->data;
+    const struct ofp_header *request_oh = ofpbuf_get_data(request);
     ovs_be32 send_xid = request_oh->xid;
     enum ofpraw request_raw;
     enum ofpraw reply_raw;
     bool done = false;
 
-    ofpraw_decode_partial(&request_raw, request->data, request->size);
+    ofpraw_decode_partial(&request_raw, ofpbuf_get_data(request), ofpbuf_get_size(request));
     reply_raw = ofpraw_stats_request_to_reply(request_raw,
                                               request_oh->version);
 
@@ -503,20 +503,20 @@ dump_stats_transaction(struct vconn *vconn, struct ofpbuf *request)
         struct ofpbuf *reply;
 
         run(vconn_recv_block(vconn, &reply), "OpenFlow packet receive failed");
-        recv_xid = ((struct ofp_header *) reply->data)->xid;
+        recv_xid = ((struct ofp_header *) ofpbuf_get_data(reply))->xid;
         if (send_xid == recv_xid) {
             enum ofpraw raw;
 
-            ofp_print(stdout, reply->data, reply->size, verbosity + 1);
+            ofp_print(stdout, ofpbuf_get_data(reply), ofpbuf_get_size(reply), verbosity + 1);
 
-            ofpraw_decode(&raw, reply->data);
+            ofpraw_decode(&raw, ofpbuf_get_data(reply));
             if (ofptype_from_ofpraw(raw) == OFPTYPE_ERROR) {
                 done = true;
             } else if (raw == reply_raw) {
-                done = !ofpmp_more(reply->data);
+                done = !ofpmp_more(ofpbuf_get_data(reply));
             } else {
                 ovs_fatal(0, "received bad reply: %s",
-                          ofp_to_string(reply->data, reply->size,
+                          ofp_to_string(ofpbuf_get_data(reply), ofpbuf_get_size(reply),
                                         verbosity + 1));
             }
         } else {
@@ -556,7 +556,7 @@ transact_multiple_noreply(struct vconn *vconn, struct list *requests)
     run(vconn_transact_multiple_noreply(vconn, requests, &reply),
         "talking to %s", vconn_get_name(vconn));
     if (reply) {
-        ofp_print(stderr, reply->data, reply->size, verbosity + 2);
+        ofp_print(stderr, ofpbuf_get_data(reply), ofpbuf_get_size(reply), verbosity + 2);
         exit(1);
     }
     ofpbuf_delete(reply);
@@ -626,7 +626,7 @@ ofctl_show(int argc OVS_UNUSED, char *argv[])
     run(vconn_transact(vconn, request, &reply), "talking to %s", vconn_name);
 
     trunc = ofputil_switch_features_ports_trunc(reply);
-    ofp_print(stdout, reply->data, reply->size, verbosity + 1);
+    ofp_print(stdout, ofpbuf_get_data(reply), ofpbuf_get_size(reply), verbosity + 1);
 
     ofpbuf_delete(reply);
 
@@ -689,8 +689,8 @@ fetch_port_by_features(const char *vconn_name,
     run(vconn_transact(vconn, request, &reply), "talking to %s", vconn_name);
     vconn_close(vconn);
 
-    oh = reply->data;
-    if (ofptype_decode(&type, reply->data)
+    oh = ofpbuf_get_data(reply);
+    if (ofptype_decode(&type, ofpbuf_get_data(reply))
         || type != OFPTYPE_FEATURES_REPLY) {
         ovs_fatal(0, "%s: received bad features reply", vconn_name);
     }
@@ -733,7 +733,7 @@ fetch_port_by_stats(const char *vconn_name,
     bool found = false;
 
     request = ofpraw_alloc(OFPRAW_OFPST_PORT_DESC_REQUEST, OFP10_VERSION, 0);
-    send_xid = ((struct ofp_header *) request->data)->xid;
+    send_xid = ((struct ofp_header *) ofpbuf_get_data(request))->xid;
 
     open_vconn(vconn_name, &vconn);
     send_openflow_buffer(vconn, request);
@@ -742,9 +742,9 @@ fetch_port_by_stats(const char *vconn_name,
         struct ofpbuf *reply;
 
         run(vconn_recv_block(vconn, &reply), "OpenFlow packet receive failed");
-        recv_xid = ((struct ofp_header *) reply->data)->xid;
+        recv_xid = ((struct ofp_header *) ofpbuf_get_data(reply))->xid;
         if (send_xid == recv_xid) {
-            struct ofp_header *oh = reply->data;
+            struct ofp_header *oh = ofpbuf_get_data(reply);
             enum ofptype type;
             struct ofpbuf b;
             uint16_t flags;
@@ -753,7 +753,7 @@ fetch_port_by_stats(const char *vconn_name,
             if (ofptype_pull(&type, &b)
                 || type != OFPTYPE_PORT_DESC_STATS_REPLY) {
                 ovs_fatal(0, "received bad reply: %s",
-                          ofp_to_string(reply->data, reply->size,
+                          ofp_to_string(ofpbuf_get_data(reply), ofpbuf_get_size(reply),
                                         verbosity + 1));
             }
 
@@ -858,7 +858,7 @@ try_set_protocol(struct vconn *vconn, enum ofputil_protocol want,
         run(vconn_transact_noreply(vconn, request, &reply),
             "talking to %s", vconn_get_name(vconn));
         if (reply) {
-            char *s = ofp_to_string(reply->data, reply->size, 2);
+            char *s = ofp_to_string(ofpbuf_get_data(reply), ofpbuf_get_size(reply), 2);
             VLOG_DBG("%s: failed to set protocol, switch replied: %s",
                      vconn_get_name(vconn), s);
             free(s);
@@ -991,7 +991,7 @@ ofctl_dump_flows(int argc, char *argv[])
         size_t i;
 
         vconn = prepare_dump_flows(argc, argv, false, &request);
-        send_xid = ((struct ofp_header *) request->data)->xid;
+        send_xid = ((struct ofp_header *) ofpbuf_get_data(request))->xid;
         send_openflow_buffer(vconn, request);
 
         fses = NULL;
@@ -1261,13 +1261,13 @@ openflow_from_hex(const char *hex, struct ofpbuf **msgp)
         return "Trailing garbage in hex data";
     }
 
-    if (msg->size < sizeof(struct ofp_header)) {
+    if (ofpbuf_get_size(msg) < sizeof(struct ofp_header)) {
         ofpbuf_delete(msg);
         return "Message too short for OpenFlow";
     }
 
-    oh = msg->data;
-    if (msg->size != ntohs(oh->length)) {
+    oh = ofpbuf_get_data(msg);
+    if (ofpbuf_get_size(msg) != ntohs(oh->length)) {
         ofpbuf_delete(msg);
         return "Message size does not match length in OpenFlow header";
     }
@@ -1300,7 +1300,7 @@ ofctl_send(struct unixctl_conn *conn, int argc,
         }
 
         fprintf(stderr, "send: ");
-        ofp_print(stderr, msg->data, msg->size, verbosity);
+        ofp_print(stderr, ofpbuf_get_data(msg), ofpbuf_get_size(msg), verbosity);
 
         error = vconn_send_block(vconn, msg);
         if (error) {
@@ -1449,8 +1449,8 @@ monitor_vconn(struct vconn *vconn, bool reply_to_echo_requests)
                 free(s);
             }
 
-            ofptype_decode(&type, b->data);
-            ofp_print(stderr, b->data, b->size, verbosity + 2);
+            ofptype_decode(&type, ofpbuf_get_data(b));
+            ofp_print(stderr, ofpbuf_get_data(b), ofpbuf_get_size(b), verbosity + 2);
 
             switch ((int) type) {
             case OFPTYPE_BARRIER_REPLY:
@@ -1464,7 +1464,7 @@ monitor_vconn(struct vconn *vconn, bool reply_to_echo_requests)
                 if (reply_to_echo_requests) {
                     struct ofpbuf *reply;
 
-                    reply = make_echo_reply(b->data);
+                    reply = make_echo_reply(ofpbuf_get_data(b));
                     retval = vconn_send_block(vconn, reply);
                     if (retval) {
                         ovs_fatal(retval, "failed to send echo reply");
@@ -1543,7 +1543,7 @@ ofctl_monitor(int argc, char *argv[])
             run(vconn_transact_noreply(vconn, spif, &reply),
                 "talking to %s", vconn_get_name(vconn));
             if (reply) {
-                char *s = ofp_to_string(reply->data, reply->size, 2);
+                char *s = ofp_to_string(ofpbuf_get_data(reply), ofpbuf_get_size(reply), 2);
                 VLOG_DBG("%s: failed to set packet in format to nxm, controller"
                         " replied: %s. Falling back to the switch default.",
                         vconn_get_name(vconn), s);
@@ -1604,7 +1604,7 @@ ofctl_probe(int argc OVS_UNUSED, char *argv[])
     open_vconn(argv[1], &vconn);
     request = make_echo_request(vconn_get_version(vconn));
     run(vconn_transact(vconn, request, &reply), "talking to %s", argv[1]);
-    if (reply->size != sizeof(struct ofp_header)) {
+    if (ofpbuf_get_size(reply) != sizeof(struct ofp_header)) {
         ovs_fatal(0, "reply does not match request");
     }
     ofpbuf_delete(reply);
@@ -1630,8 +1630,8 @@ ofctl_packet_out(int argc, char *argv[])
 
     po.buffer_id = UINT32_MAX;
     po.in_port = str_to_port_no(argv[1], argv[2]);
-    po.ofpacts = ofpacts.data;
-    po.ofpacts_len = ofpacts.size;
+    po.ofpacts = ofpbuf_get_data(&ofpacts);
+    po.ofpacts_len = ofpbuf_get_size(&ofpacts);
 
     protocol = open_vconn(argv[1], &vconn);
     for (i = 4; i < argc; i++) {
@@ -1643,8 +1643,8 @@ ofctl_packet_out(int argc, char *argv[])
             ovs_fatal(0, "%s", error_msg);
         }
 
-        po.packet = packet->data;
-        po.packet_len = packet->size;
+        po.packet = ofpbuf_get_data(packet);
+        po.packet_len = ofpbuf_get_size(packet);
         opo = ofputil_encode_packet_out(&po, protocol);
         transact_noreply(vconn, opo);
         ofpbuf_delete(packet);
@@ -1835,7 +1835,7 @@ ofctl_ofp_parse(int argc OVS_UNUSED, char *argv[])
             ovs_fatal(0, "%s: unexpected end of file mid-message", filename);
         }
 
-        ofp_print(stdout, b.data, b.size, verbosity + 2);
+        ofp_print(stdout, ofpbuf_get_data(&b), ofpbuf_get_size(&b), verbosity + 2);
     }
     ofpbuf_uninit(&b);
 
@@ -1894,16 +1894,17 @@ ofctl_ofp_parse_pcap(int argc OVS_UNUSED, char *argv[])
                 is_openflow_port(flow.tp_dst, argv + 2))) {
             struct ofpbuf *payload = tcp_reader_run(reader, &flow, packet);
             if (payload) {
-                while (payload->size >= sizeof(struct ofp_header)) {
+                while (ofpbuf_get_size(payload) >= sizeof(struct ofp_header)) {
                     const struct ofp_header *oh;
+                    void *data = ofpbuf_get_data(payload);
                     int length;
 
                     /* Align OpenFlow on 8-byte boundary for safe access. */
-                    ofpbuf_shift(payload, -((intptr_t) payload->data & 7));
+                    ofpbuf_shift(payload, -((intptr_t) data & 7));
 
-                    oh = payload->data;
+                    oh = ofpbuf_get_data(payload);
                     length = ntohs(oh->length);
-                    if (payload->size < length) {
+                    if (ofpbuf_get_size(payload) < length) {
                         break;
                     }
 
@@ -1921,7 +1922,7 @@ ofctl_ofp_parse_pcap(int argc OVS_UNUSED, char *argv[])
                     printf(IP_FMT".%"PRIu16" > "IP_FMT".%"PRIu16":\n",
                            IP_ARGS(flow.nw_src), ntohs(flow.tp_src),
                            IP_ARGS(flow.nw_dst), ntohs(flow.tp_dst));
-                    ofp_print(stdout, payload->data, length, verbosity + 1);
+                    ofp_print(stdout, ofpbuf_get_data(payload), length, verbosity + 1);
                     ofpbuf_pull(payload, length);
                 }
             }
@@ -1959,18 +1960,18 @@ ofctl_ping(int argc, char *argv[])
         run(vconn_transact(vconn, ofpbuf_clone(request), &reply), "transact");
         xgettimeofday(&end);
 
-        rpy_hdr = reply->data;
+        rpy_hdr = ofpbuf_get_data(reply);
         if (ofptype_pull(&type, reply)
             || type != OFPTYPE_ECHO_REPLY
-            || reply->size != payload
+            || ofpbuf_get_size(reply) != payload
             || memcmp(ofpbuf_get_l3(request), ofpbuf_get_l3(reply), payload)) {
             printf("Reply does not match request.  Request:\n");
-            ofp_print(stdout, request, request->size, verbosity + 2);
+            ofp_print(stdout, request, ofpbuf_get_size(request), verbosity + 2);
             printf("Reply:\n");
-            ofp_print(stdout, reply, reply->size, verbosity + 2);
+            ofp_print(stdout, reply, ofpbuf_get_size(reply), verbosity + 2);
         }
         printf("%"PRIu32" bytes from %s: xid=%08"PRIx32" time=%.1f ms\n",
-               reply->size, argv[1], ntohl(rpy_hdr->xid),
+               ofpbuf_get_size(reply), argv[1], ntohl(rpy_hdr->xid),
                    (1000*(double)(end.tv_sec - start.tv_sec))
                    + (.001*(end.tv_usec - start.tv_usec)));
         ofpbuf_delete(request);
@@ -2377,12 +2378,12 @@ recv_flow_stats_reply(struct vconn *vconn, ovs_be32 send_xid,
             do {
                 run(vconn_recv_block(vconn, &reply),
                     "OpenFlow packet receive failed");
-            } while (((struct ofp_header *) reply->data)->xid != send_xid);
+            } while (((struct ofp_header *) ofpbuf_get_data(reply))->xid != send_xid);
 
-            error = ofptype_decode(&type, reply->data);
+            error = ofptype_decode(&type, ofpbuf_get_data(reply));
             if (error || type != OFPTYPE_FLOW_STATS_REPLY) {
                 ovs_fatal(0, "received bad reply: %s",
-                          ofp_to_string(reply->data, reply->size,
+                          ofp_to_string(ofpbuf_get_data(reply), ofpbuf_get_size(reply),
                                         verbosity + 1));
             }
         }
@@ -2432,7 +2433,7 @@ read_flows_from_switch(struct vconn *vconn,
     fsr.table_id = 0xff;
     fsr.cookie = fsr.cookie_mask = htonll(0);
     request = ofputil_encode_flow_stats_request(&fsr, protocol);
-    send_xid = ((struct ofp_header *) request->data)->xid;
+    send_xid = ((struct ofp_header *) ofpbuf_get_data(request))->xid;
     send_openflow_buffer(vconn, request);
 
     reply = NULL;
@@ -2735,7 +2736,7 @@ ofctl_parse_flows__(struct ofputil_flow_mod *fms, size_t n_fms,
         struct ofpbuf *msg;
 
         msg = ofputil_encode_flow_mod(fm, protocol);
-        ofp_print(stdout, msg->data, msg->size, verbosity);
+        ofp_print(stdout, ofpbuf_get_data(msg), ofpbuf_get_size(msg), verbosity);
         ofpbuf_delete(msg);
 
         free(fm->ofpacts);
@@ -2828,7 +2829,7 @@ ofctl_parse_nxm__(bool oxm)
             } else {
                 match_len = nx_put_match(&nx_match, &match,
                                          cookie, cookie_mask);
-                out = nx_match_to_string(nx_match.data, match_len);
+                out = nx_match_to_string(ofpbuf_get_data(&nx_match), match_len);
             }
 
             puts(out);
@@ -2910,8 +2911,8 @@ ofctl_parse_ofp10_actions(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 
         /* Convert to ofpacts. */
         ofpbuf_init(&ofpacts, 0);
-        size = of10_in.size;
-        error = ofpacts_pull_openflow_actions(&of10_in, of10_in.size,
+        size = ofpbuf_get_size(&of10_in);
+        error = ofpacts_pull_openflow_actions(&of10_in, ofpbuf_get_size(&of10_in),
                                               OFP10_VERSION, &ofpacts);
         if (error) {
             printf("bad OF1.1 actions: %s\n\n", ofperr_get_name(error));
@@ -2924,17 +2925,17 @@ ofctl_parse_ofp10_actions(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         /* Print cls_rule. */
         ds_init(&s);
         ds_put_cstr(&s, "actions=");
-        ofpacts_format(ofpacts.data, ofpacts.size, &s);
+        ofpacts_format(ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts), &s);
         puts(ds_cstr(&s));
         ds_destroy(&s);
 
         /* Convert back to ofp10 actions and print differences from input. */
         ofpbuf_init(&of10_out, 0);
-        ofpacts_put_openflow_actions(ofpacts.data, ofpacts.size, &of10_out,
+        ofpacts_put_openflow_actions(ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts), &of10_out,
                                      OFP10_VERSION);
 
-        print_differences("", of10_in.data, of10_in.size,
-                          of10_out.data, of10_out.size);
+        print_differences("", ofpbuf_get_data(&of10_in), ofpbuf_get_size(&of10_in),
+                          ofpbuf_get_data(&of10_out), ofpbuf_get_size(&of10_out));
         putchar('\n');
 
         ofpbuf_uninit(&ofpacts);
@@ -2980,9 +2981,9 @@ ofctl_parse_ofp10_match(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         if (ofpbuf_put_hex(&match_expout, ds_cstr(&expout), NULL)[0] != '\0') {
             ovs_fatal(0, "Trailing garbage in hex data");
         }
-        if (match_expout.size != sizeof(struct ofp10_match)) {
+        if (ofpbuf_get_size(&match_expout) != sizeof(struct ofp10_match)) {
             ovs_fatal(0, "Input is %"PRIu32" bytes, expected %"PRIuSIZE,
-                      match_expout.size, sizeof(struct ofp10_match));
+                      ofpbuf_get_size(&match_expout), sizeof(struct ofp10_match));
         }
 
         /* Parse hex bytes for input. */
@@ -2995,18 +2996,18 @@ ofctl_parse_ofp10_match(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         if (ofpbuf_put_hex(&match_in, ds_cstr(&in), NULL)[0] != '\0') {
             ovs_fatal(0, "Trailing garbage in hex data");
         }
-        if (match_in.size != sizeof(struct ofp10_match)) {
+        if (ofpbuf_get_size(&match_in) != sizeof(struct ofp10_match)) {
             ovs_fatal(0, "Input is %"PRIu32" bytes, expected %"PRIuSIZE,
-                      match_in.size, sizeof(struct ofp10_match));
+                      ofpbuf_get_size(&match_in), sizeof(struct ofp10_match));
         }
 
         /* Convert to cls_rule and print. */
-        ofputil_match_from_ofp10_match(match_in.data, &match);
+        ofputil_match_from_ofp10_match(ofpbuf_get_data(&match_in), &match);
         match_print(&match);
 
         /* Convert back to ofp10_match and print differences from input. */
         ofputil_match_to_ofp10_match(&match, &match_out);
-        print_differences("", match_expout.data, match_expout.size,
+        print_differences("", ofpbuf_get_data(&match_expout), ofpbuf_get_size(&match_expout),
                           &match_out, sizeof match_out);
 
         /* Normalize, then convert and compare again. */
@@ -3044,13 +3045,13 @@ ofctl_parse_ofp11_match(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         if (ofpbuf_put_hex(&match_in, ds_cstr(&in), NULL)[0] != '\0') {
             ovs_fatal(0, "Trailing garbage in hex data");
         }
-        if (match_in.size != sizeof(struct ofp11_match)) {
+        if (ofpbuf_get_size(&match_in) != sizeof(struct ofp11_match)) {
             ovs_fatal(0, "Input is %"PRIu32" bytes, expected %"PRIuSIZE,
-                      match_in.size, sizeof(struct ofp11_match));
+                      ofpbuf_get_size(&match_in), sizeof(struct ofp11_match));
         }
 
         /* Convert to match. */
-        error = ofputil_match_from_ofp11_match(match_in.data, &match);
+        error = ofputil_match_from_ofp11_match(ofpbuf_get_data(&match_in), &match);
         if (error) {
             printf("bad ofp11_match: %s\n\n", ofperr_get_name(error));
             ofpbuf_uninit(&match_in);
@@ -3063,7 +3064,7 @@ ofctl_parse_ofp11_match(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         /* Convert back to ofp11_match and print differences from input. */
         ofputil_match_to_ofp11_match(&match, &match_out);
 
-        print_differences("", match_in.data, match_in.size,
+        print_differences("", ofpbuf_get_data(&match_in), ofpbuf_get_size(&match_in),
                           &match_out, sizeof match_out);
         putchar('\n');
 
@@ -3098,8 +3099,8 @@ ofctl_parse_ofp11_actions(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 
         /* Convert to ofpacts. */
         ofpbuf_init(&ofpacts, 0);
-        size = of11_in.size;
-        error = ofpacts_pull_openflow_actions(&of11_in, of11_in.size,
+        size = ofpbuf_get_size(&of11_in);
+        error = ofpacts_pull_openflow_actions(&of11_in, ofpbuf_get_size(&of11_in),
                                               OFP11_VERSION, &ofpacts);
         if (error) {
             printf("bad OF1.1 actions: %s\n\n", ofperr_get_name(error));
@@ -3112,17 +3113,17 @@ ofctl_parse_ofp11_actions(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         /* Print cls_rule. */
         ds_init(&s);
         ds_put_cstr(&s, "actions=");
-        ofpacts_format(ofpacts.data, ofpacts.size, &s);
+        ofpacts_format(ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts), &s);
         puts(ds_cstr(&s));
         ds_destroy(&s);
 
         /* Convert back to ofp11 actions and print differences from input. */
         ofpbuf_init(&of11_out, 0);
-        ofpacts_put_openflow_actions(ofpacts.data, ofpacts.size, &of11_out,
+        ofpacts_put_openflow_actions(ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts), &of11_out,
                                      OFP11_VERSION);
 
-        print_differences("", of11_in.data, of11_in.size,
-                          of11_out.data, of11_out.size);
+        print_differences("", ofpbuf_get_data(&of11_in), ofpbuf_get_size(&of11_in),
+                          ofpbuf_get_data(&of11_out), ofpbuf_get_size(&of11_out));
         putchar('\n');
 
         ofpbuf_uninit(&ofpacts);
@@ -3168,14 +3169,14 @@ ofctl_parse_ofp11_instructions(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 
         /* Convert to ofpacts. */
         ofpbuf_init(&ofpacts, 0);
-        size = of11_in.size;
-        error = ofpacts_pull_openflow_instructions(&of11_in, of11_in.size,
+        size = ofpbuf_get_size(&of11_in);
+        error = ofpacts_pull_openflow_instructions(&of11_in, ofpbuf_get_size(&of11_in),
                                                    OFP11_VERSION, &ofpacts);
         if (!error) {
             /* Verify actions, enforce consistency. */
             struct flow flow;
             memset(&flow, 0, sizeof flow);
-            error = ofpacts_check_consistency(ofpacts.data, ofpacts.size,
+            error = ofpacts_check_consistency(ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts),
                                               &flow, OFPP_MAX,
                                               table_id ? atoi(table_id) : 0,
                                               255, OFPUTIL_P_OF11_STD);
@@ -3191,18 +3192,18 @@ ofctl_parse_ofp11_instructions(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         /* Print cls_rule. */
         ds_init(&s);
         ds_put_cstr(&s, "actions=");
-        ofpacts_format(ofpacts.data, ofpacts.size, &s);
+        ofpacts_format(ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts), &s);
         puts(ds_cstr(&s));
         ds_destroy(&s);
 
         /* Convert back to ofp11 instructions and print differences from
          * input. */
         ofpbuf_init(&of11_out, 0);
-        ofpacts_put_openflow_instructions(ofpacts.data, ofpacts.size,
+        ofpacts_put_openflow_instructions(ofpbuf_get_data(&ofpacts), ofpbuf_get_size(&ofpacts),
                                           &of11_out, OFP13_VERSION);
 
-        print_differences("", of11_in.data, of11_in.size,
-                          of11_out.data, of11_out.size);
+        print_differences("", ofpbuf_get_data(&of11_in), ofpbuf_get_size(&of11_in),
+                          ofpbuf_get_data(&of11_out), ofpbuf_get_size(&of11_out));
         putchar('\n');
 
         ofpbuf_uninit(&ofpacts);
@@ -3289,7 +3290,7 @@ ofctl_check_vlan(int argc OVS_UNUSED, char *argv[])
     /* Convert to and from NXM. */
     ofpbuf_init(&nxm, 0);
     nxm_match_len = nx_put_match(&nxm, &match, htonll(0), htonll(0));
-    nxm_s = nx_match_to_string(nxm.data, nxm_match_len);
+    nxm_s = nx_match_to_string(ofpbuf_get_data(&nxm), nxm_match_len);
     error = nx_pull_match(&nxm, nxm_match_len, &nxm_match, NULL, NULL);
     printf("NXM: %s -> ", nxm_s);
     if (error) {
@@ -3395,19 +3396,19 @@ ofctl_encode_error_reply(int argc OVS_UNUSED, char *argv[])
     if (ofpbuf_put_hex(&request, argv[2], NULL)[0] != '\0') {
         ovs_fatal(0, "Trailing garbage in hex data");
     }
-    if (request.size < sizeof(struct ofp_header)) {
+    if (ofpbuf_get_size(&request) < sizeof(struct ofp_header)) {
         ovs_fatal(0, "Request too short");
     }
 
-    oh = request.data;
-    if (request.size != ntohs(oh->length)) {
+    oh = ofpbuf_get_data(&request);
+    if (ofpbuf_get_size(&request) != ntohs(oh->length)) {
         ovs_fatal(0, "Request size inconsistent");
     }
 
-    reply = ofperr_encode_reply(error, request.data);
+    reply = ofperr_encode_reply(error, ofpbuf_get_data(&request));
     ofpbuf_uninit(&request);
 
-    ovs_hex_dump(stdout, reply->data, reply->size, 0, false);
+    ovs_hex_dump(stdout, ofpbuf_get_data(reply), ofpbuf_get_size(reply), 0, false);
     ofpbuf_delete(reply);
 }
 
@@ -3423,7 +3424,7 @@ ofctl_ofp_print(int argc, char *argv[])
     if (ofpbuf_put_hex(&packet, argv[1], NULL)[0] != '\0') {
         ovs_fatal(0, "trailing garbage following hex bytes");
     }
-    ofp_print(stdout, packet.data, packet.size, argc > 2 ? atoi(argv[2]) : 2);
+    ofp_print(stdout, ofpbuf_get_data(&packet), ofpbuf_get_size(&packet), argc > 2 ? atoi(argv[2]) : 2);
     ofpbuf_uninit(&packet);
 }
 
@@ -3436,8 +3437,8 @@ ofctl_encode_hello(int argc OVS_UNUSED, char *argv[])
     struct ofpbuf *hello;
 
     hello = ofputil_encode_hello(bitmap);
-    ovs_hex_dump(stdout, hello->data, hello->size, 0, false);
-    ofp_print(stdout, hello->data, hello->size, verbosity);
+    ovs_hex_dump(stdout, ofpbuf_get_data(hello), ofpbuf_get_size(hello), 0, false);
+    ofp_print(stdout, ofpbuf_get_data(hello), ofpbuf_get_size(hello), verbosity);
     ofpbuf_delete(hello);
 }
 
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index db85856..db196d1 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -3650,8 +3650,8 @@ iface_configure_qos(struct iface *iface, const struct ovsrec_qos *qos)
     }
 
     if (iface->ofp_port != OFPP_NONE) {
-        const struct ofproto_port_queue *port_queues = queues_buf.data;
-        size_t n_queues = queues_buf.size / sizeof *port_queues;
+        const struct ofproto_port_queue *port_queues = ofpbuf_get_data(&queues_buf);
+        size_t n_queues = ofpbuf_get_size(&queues_buf) / sizeof *port_queues;
 
         ofproto_port_set_queues(iface->port->bridge->ofproto, iface->ofp_port,
                                 port_queues, n_queues);
-- 
1.7.9.5




More information about the dev mailing list