From fc3431c6a09e625343dd39b57b86839af90a08fd Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Fri, 21 Mar 2014 10:36:52 -0700 Subject: [PATCH] packets: packet metadata from flow function instead of macro. 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 Signed-off-by: Gurucharan Shetty Acked-by: Jarno Rajahalme --- 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 18a3b17ca..f6a4f43b6 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 0048943e9..b931ab653 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 8ce439d9f..744aa8ce1 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. */ -- 2.43.0