packets: packet metadata from flow function instead of macro.
authorGurucharan Shetty <gshetty@nicira.com>
Fri, 21 Mar 2014 17:36:52 +0000 (10:36 -0700)
committerGurucharan Shetty <gshetty@nicira.com>
Mon, 24 Mar 2014 17:56:31 +0000 (10:56 -0700)
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@nicira.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
lib/packets.h
ofproto/ofproto-dpif-upcall.c
ofproto/ofproto-dpif.c

index 18a3b17..f6a4f43 100644 (file)
@@ -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);
 
index 0048943..b931ab6 100644 (file)
@@ -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);
index 8ce439d..744aa8c 100644 (file)
@@ -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. */