[ovs-dev] [PATCH 3/5] ofp-util: Avoid C++ keyword 'public' in name of struct member.

Ben Pfaff blp at ovn.org
Mon Jul 31 02:54:58 UTC 2017


This allows a C++ program to include ofp-util.h.

Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 include/openvswitch/ofp-util.h |  2 +-
 lib/ofp-print.c                |  4 ++--
 lib/ofp-util.c                 | 26 +++++++++++++-------------
 ofproto/connmgr.c              | 14 +++++++-------
 ofproto/fail-open.c            |  2 +-
 ofproto/ofproto-dpif-xlate.c   | 14 +++++++-------
 ofproto/ofproto-dpif.c         |  8 ++++----
 7 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/include/openvswitch/ofp-util.h b/include/openvswitch/ofp-util.h
index 07723b427ce8..5d911af89671 100644
--- a/include/openvswitch/ofp-util.h
+++ b/include/openvswitch/ofp-util.h
@@ -500,7 +500,7 @@ bool ofputil_packet_in_reason_from_string(const char *,
  * to any process other than ovs-vswitchd.  Therefore, only ovs-vswitchd should
  * use ofputil_packet_in_private and the functions that operate on it. */
 struct ofputil_packet_in_private {
-    struct ofputil_packet_in public;
+    struct ofputil_packet_in base;
 
     /* NXCPT_BRIDGE. */
     struct uuid bridge;
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 7e3000f776bd..92c000b61dea 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -122,7 +122,7 @@ ofp_print_packet_in(struct ds *string, const struct ofp_header *oh,
 {
     char reasonbuf[OFPUTIL_PACKET_IN_REASON_BUFSIZE];
     struct ofputil_packet_in_private pin;
-    const struct ofputil_packet_in *public = &pin.public;
+    const struct ofputil_packet_in *public = &pin.base;
     uint32_t buffer_id;
     size_t total_len;
     enum ofperr error;
@@ -168,7 +168,7 @@ ofp_print_packet_in(struct ds *string, const struct ofp_header *oh,
 
     if (public->userdata_len) {
         ds_put_cstr(string, " userdata=");
-        format_hex_arg(string, pin.public.userdata, pin.public.userdata_len);
+        format_hex_arg(string, pin.base.userdata, pin.base.userdata_len);
         ds_put_char(string, '\n');
     }
 
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index dabd1f220683..6ee7e11f87a5 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -3720,7 +3720,7 @@ ofputil_put_packet_in_private(const struct ofputil_packet_in_private *pin,
                               enum ofp_version version, size_t include_bytes,
                               struct ofpbuf *msg)
 {
-    ofputil_put_packet_in(&pin->public, version, include_bytes, msg);
+    ofputil_put_packet_in(&pin->base, version, include_bytes, msg);
 
     size_t continuation_ofs = ofpprop_start_nested(msg, NXPINT_CONTINUATION);
     size_t inner_ofs = msg->size;
@@ -3852,7 +3852,7 @@ ofputil_encode_nx_packet_in2(const struct ofputil_packet_in_private *pin,
                              enum ofp_version version, size_t include_bytes)
 {
     /* 'extra' is just an estimate of the space required. */
-    size_t extra = (pin->public.packet_len
+    size_t extra = (pin->base.packet_len
                     + NXM_TYPICAL_LEN   /* flow_metadata */
                     + pin->stack_size * 4
                     + pin->actions_len
@@ -3862,9 +3862,9 @@ ofputil_encode_nx_packet_in2(const struct ofputil_packet_in_private *pin,
                                           htonl(0), extra);
 
     ofputil_put_packet_in_private(pin, version, include_bytes, msg);
-    if (pin->public.userdata_len) {
-        ofpprop_put(msg, NXPINT_USERDATA, pin->public.userdata,
-                    pin->public.userdata_len);
+    if (pin->base.userdata_len) {
+        ofpprop_put(msg, NXPINT_USERDATA, pin->base.userdata,
+                    pin->base.userdata_len);
     }
 
     ofpmsg_update_length(msg);
@@ -3947,11 +3947,11 @@ ofputil_encode_packet_in_private(const struct ofputil_packet_in_private *pin,
         case OFPUTIL_P_OF10_STD_TID:
         case OFPUTIL_P_OF10_NXM:
         case OFPUTIL_P_OF10_NXM_TID:
-            msg = ofputil_encode_ofp10_packet_in(&pin->public);
+            msg = ofputil_encode_ofp10_packet_in(&pin->base);
             break;
 
         case OFPUTIL_P_OF11_STD:
-            msg = ofputil_encode_ofp11_packet_in(&pin->public);
+            msg = ofputil_encode_ofp11_packet_in(&pin->base);
             break;
 
         case OFPUTIL_P_OF12_OXM:
@@ -3959,7 +3959,7 @@ ofputil_encode_packet_in_private(const struct ofputil_packet_in_private *pin,
         case OFPUTIL_P_OF14_OXM:
         case OFPUTIL_P_OF15_OXM:
         case OFPUTIL_P_OF16_OXM:
-            msg = ofputil_encode_ofp12_packet_in(&pin->public, version);
+            msg = ofputil_encode_ofp12_packet_in(&pin->base, version);
             break;
 
         default:
@@ -3968,18 +3968,18 @@ ofputil_encode_packet_in_private(const struct ofputil_packet_in_private *pin,
         break;
 
     case NXPIF_NXT_PACKET_IN:
-        msg = ofputil_encode_nx_packet_in(&pin->public, version);
+        msg = ofputil_encode_nx_packet_in(&pin->base, version);
         break;
 
     case NXPIF_NXT_PACKET_IN2:
         return ofputil_encode_nx_packet_in2(pin, version,
-                                            pin->public.packet_len);
+                                            pin->base.packet_len);
 
     default:
         OVS_NOT_REACHED();
     }
 
-    ofpbuf_put(msg, pin->public.packet, pin->public.packet_len);
+    ofpbuf_put(msg, pin->base.packet, pin->base.packet_len);
     ofpmsg_update_length(msg);
     return msg;
 }
@@ -4104,7 +4104,7 @@ ofputil_decode_packet_in_private(const struct ofp_header *oh, bool loose,
     struct ofpbuf continuation;
     enum ofperr error;
     error = ofputil_decode_packet_in(oh, loose, tun_table, vl_mff_map,
-                                     &pin->public, total_len, buffer_id,
+                                     &pin->base, total_len, buffer_id,
                                      &continuation);
     if (error) {
         return error;
@@ -4193,7 +4193,7 @@ ofputil_decode_packet_in_private(const struct ofp_header *oh, bool loose,
 /* Frees data in 'pin' that is dynamically allocated by
  * ofputil_decode_packet_in_private().
  *
- * 'pin->public' contains some pointer members that
+ * 'pin->base' contains some pointer members that
  * ofputil_decode_packet_in_private() doesn't initialize to newly allocated
  * data, so this function doesn't free those. */
 void
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 2dc414d31239..c0ce828ce00a 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -1740,7 +1740,7 @@ connmgr_send_async_msg(struct connmgr *mgr,
         if (protocol == OFPUTIL_P_NONE || !rconn_is_connected(ofconn->rconn)
             || ofconn->controller_id != am->controller_id
             || !ofconn_receives_async_msg(ofconn, am->oam,
-                                          am->pin.up.public.reason)) {
+                                          am->pin.up.base.reason)) {
             continue;
         }
 
@@ -1748,11 +1748,11 @@ connmgr_send_async_msg(struct connmgr *mgr,
             &am->pin.up, protocol, ofconn->packet_in_format);
 
         struct ovs_list txq;
-        bool is_miss = (am->pin.up.public.reason == OFPR_NO_MATCH ||
-                        am->pin.up.public.reason == OFPR_EXPLICIT_MISS ||
-                        am->pin.up.public.reason == OFPR_IMPLICIT_MISS);
+        bool is_miss = (am->pin.up.base.reason == OFPR_NO_MATCH ||
+                        am->pin.up.base.reason == OFPR_EXPLICIT_MISS ||
+                        am->pin.up.base.reason == OFPR_IMPLICIT_MISS);
         pinsched_send(ofconn->schedulers[is_miss],
-                      am->pin.up.public.flow_metadata.flow.in_port.ofp_port,
+                      am->pin.up.base.flow_metadata.flow.in_port.ofp_port,
                       msg, &txq);
         do_send_packet_ins(ofconn, &txq);
     }
@@ -2322,8 +2322,8 @@ ofmonitor_wait(struct connmgr *mgr)
 void
 ofproto_async_msg_free(struct ofproto_async_msg *am)
 {
-    free(am->pin.up.public.packet);
-    free(am->pin.up.public.userdata);
+    free(am->pin.up.base.packet);
+    free(am->pin.up.base.userdata);
     free(am->pin.up.stack);
     free(am->pin.up.actions);
     free(am->pin.up.action_set);
diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c
index e038e77ffe29..914a51b4b64f 100644
--- a/ofproto/fail-open.c
+++ b/ofproto/fail-open.c
@@ -128,7 +128,7 @@ send_bogus_packet_ins(struct fail_open *fo)
         .oam = OAM_PACKET_IN,
         .pin = {
             .up = {
-                .public = {
+                .base = {
                     .packet = dp_packet_data(&b),
                     .packet_len = dp_packet_size(&b),
                     .flow_metadata = MATCH_CATCHALL_INITIALIZER,
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 7f7adb280eaf..c1037936723c 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -4517,7 +4517,7 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
         .oam = OAM_PACKET_IN,
         .pin = {
             .up = {
-                .public = {
+                .base = {
                     .packet = dp_packet_steal_data(packet),
                     .packet_len = packet_len,
                     .reason = reason,
@@ -4532,7 +4532,7 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
             .max_len = len,
         },
     };
-    flow_get_metadata(&ctx->xin->flow, &am->pin.up.public.flow_metadata);
+    flow_get_metadata(&ctx->xin->flow, &am->pin.up.base.flow_metadata);
 
     /* Async messages are only sent once, so if we send one now, no
      * xlate cache entry is created.  */
@@ -4562,7 +4562,7 @@ emit_continuation(struct xlate_ctx *ctx, const struct frozen_state *state)
         .oam = OAM_PACKET_IN,
         .pin = {
             .up = {
-                .public = {
+                .base = {
                     .userdata = xmemdup(ctx->pause->userdata,
                                         ctx->pause->userdata_len),
                     .userdata_len = ctx->pause->userdata_len,
@@ -4585,7 +4585,7 @@ emit_continuation(struct xlate_ctx *ctx, const struct frozen_state *state)
             .max_len = UINT16_MAX,
         },
     };
-    flow_get_metadata(ctx->paused_flow, &am->pin.up.public.flow_metadata);
+    flow_get_metadata(ctx->paused_flow, &am->pin.up.base.flow_metadata);
 
     /* Async messages are only sent once, so if we send one now, no
      * xlate cache entry is created.  */
@@ -6877,8 +6877,8 @@ xlate_resume(struct ofproto_dpif *ofproto,
              enum slow_path_reason *slow)
 {
     struct dp_packet packet;
-    dp_packet_use_const(&packet, pin->public.packet,
-                        pin->public.packet_len);
+    dp_packet_use_const(&packet, pin->base.packet,
+                        pin->base.packet_len);
 
     struct flow flow;
     flow_extract(&packet, &flow);
@@ -6916,7 +6916,7 @@ xlate_resume(struct ofproto_dpif *ofproto,
         .action_set_len = pin->action_set_len,
     };
     frozen_metadata_from_flow(&state.metadata,
-                              &pin->public.flow_metadata.flow);
+                              &pin->base.flow_metadata.flow);
     xin.frozen_state = &state;
 
     struct xlate_out xout;
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 823e506f1f7c..b82ed55d24d3 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -4865,14 +4865,14 @@ nxt_resume(struct ofproto *ofproto_,
 
     /* Steal 'pin->packet' and put it into a dp_packet. */
     struct dp_packet packet;
-    dp_packet_init(&packet, pin->public.packet_len);
-    dp_packet_put(&packet, pin->public.packet, pin->public.packet_len);
+    dp_packet_init(&packet, pin->base.packet_len);
+    dp_packet_put(&packet, pin->base.packet, pin->base.packet_len);
 
-    pkt_metadata_from_flow(&packet.md, &pin->public.flow_metadata.flow);
+    pkt_metadata_from_flow(&packet.md, &pin->base.flow_metadata.flow);
 
     /* Fix up in_port. */
     ofproto_dpif_set_packet_odp_port(ofproto,
-                                     pin->public.flow_metadata.flow.in_port.ofp_port,
+                                     pin->base.flow_metadata.flow.in_port.ofp_port,
                                      &packet);
 
     struct flow headers;
-- 
2.10.2



More information about the dev mailing list