[ovs-dev] [PATCH v5] packets: packet metadata from flow function instead of macro.

Gurucharan Shetty shettyg at nicira.com
Fri Mar 21 17:43:37 UTC 2014


Commit 03fbdf8d9c80a (lib/flow: Retain ODPP_NONE on flow_extract())
replaced packet metadata initialization function by a macro.
Visual studio does not like nested structure initialization that
is done in that macro.

This commit replaces the macro by a function.

CC: Jarno Rajahalme <jrajahalme at nicira.com>
Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
 lib/packets.h                 |   15 ++++++++++++---
 ofproto/ofproto-dpif-upcall.c |    2 +-
 ofproto/ofproto-dpif.c        |    2 +-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/lib/packets.h b/lib/packets.h
index 18a3b17..f6a4f43 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -42,9 +42,18 @@ struct pkt_metadata {
 #define PKT_METADATA_INITIALIZER(PORT) \
     (struct pkt_metadata){ { 0, 0, 0, 0, 0, 0}, 0, 0, {(PORT)} }
 
-#define PKT_METADATA_INITIALIZER_FLOW(FLOW) \
-    (struct pkt_metadata){ (FLOW)->tunnel, (FLOW)->skb_priority, \
-            (FLOW)->pkt_mark, (FLOW)->in_port }
+static inline struct pkt_metadata
+pkt_metadata_from_flow(const struct flow *flow)
+{
+    struct pkt_metadata md;
+
+    md.tunnel = flow->tunnel;
+    md.skb_priority = flow->skb_priority;
+    md.pkt_mark = flow->pkt_mark;
+    md.in_port = flow->in_port;
+
+    return md;
+}
 
 bool dpid_from_string(const char *s, uint64_t *dpidp);
 
diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index 0048943..b931ab6 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -1016,7 +1016,7 @@ handle_upcalls(struct handler *handler, struct list *upcalls)
         type = classify_upcall(upcall);
         if (type == MISS_UPCALL) {
             uint32_t hash;
-            struct pkt_metadata md = PKT_METADATA_INITIALIZER_FLOW(&flow);
+            struct pkt_metadata md = pkt_metadata_from_flow(&flow);
 
             flow_extract(packet, &md, &miss->flow);
             hash = flow_hash(&miss->flow, 0);
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 8ce439d..744aa8c 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -3876,7 +3876,7 @@ parse_flow_and_packet(int argc, const char *argv[],
         if (!packet->size) {
             flow_compose(packet, flow);
         } else {
-            struct pkt_metadata md = PKT_METADATA_INITIALIZER_FLOW(flow);
+            struct pkt_metadata md = pkt_metadata_from_flow(flow);
 
             /* Use the metadata from the flow and the packet argument
              * to reconstruct the flow. */
-- 
1.7.9.5




More information about the dev mailing list