From 877a19b785baf189e073a126891fccf4914873c4 Mon Sep 17 00:00:00 2001 From: Sorin Vinturis Date: Fri, 25 Mar 2016 14:49:27 +0000 Subject: [PATCH] datapath-windows: Extract flow metadata in execute cmd handler. Signed-off-by: Sorin Vinturis Acked-by: Sairam Venugopal Acked-by: Nithin Raju Signed-off-by: Ben Pfaff --- datapath-windows/ovsext/DpInternal.h | 1 + datapath-windows/ovsext/Flow.c | 19 +++++++++++++++++++ datapath-windows/ovsext/Flow.h | 2 ++ datapath-windows/ovsext/User.c | 7 +++++++ 4 files changed, 29 insertions(+) diff --git a/datapath-windows/ovsext/DpInternal.h b/datapath-windows/ovsext/DpInternal.h index bf568362fbf..d26833f5076 100644 --- a/datapath-windows/ovsext/DpInternal.h +++ b/datapath-windows/ovsext/DpInternal.h @@ -270,6 +270,7 @@ typedef struct OvsPacketExecute { uint32_t actionsLen; PCHAR packetBuf; PNL_ATTR actions; + PNL_ATTR *keyAttrs; } OvsPacketExecute; diff --git a/datapath-windows/ovsext/Flow.c b/datapath-windows/ovsext/Flow.c index a82b51b0d39..f15a3de6ea9 100644 --- a/datapath-windows/ovsext/Flow.c +++ b/datapath-windows/ovsext/Flow.c @@ -1757,6 +1757,25 @@ DeleteAllFlows(OVS_DATAPATH *datapath) } } +NDIS_STATUS +OvsGetFlowMetadata(OvsFlowKey *key, + PNL_ATTR *keyAttrs) +{ + NDIS_STATUS status = NDIS_STATUS_SUCCESS; + + if (keyAttrs[OVS_KEY_ATTR_RECIRC_ID]) { + key->recircId = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_RECIRC_ID]); + key->l2.keyLen += sizeof(key->recircId); + } + + if (keyAttrs[OVS_KEY_ATTR_DP_HASH]) { + key->dpHash = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_DP_HASH]); + key->l2.keyLen += sizeof(key->dpHash); + } + + return status; +} + /* *---------------------------------------------------------------------------- * Initializes 'flow' members from 'packet', 'skb_priority', 'tun_id', and diff --git a/datapath-windows/ovsext/Flow.h b/datapath-windows/ovsext/Flow.h index 78bf7ccb712..310c4721c50 100644 --- a/datapath-windows/ovsext/Flow.h +++ b/datapath-windows/ovsext/Flow.h @@ -51,6 +51,8 @@ NDIS_STATUS OvsDeleteFlowTable(OVS_DATAPATH *datapath); NDIS_STATUS OvsAllocateFlowTable(OVS_DATAPATH *datapath, POVS_SWITCH_CONTEXT switchContext); +NDIS_STATUS OvsGetFlowMetadata(OvsFlowKey *key, + PNL_ATTR *keyAttrs); NDIS_STATUS OvsExtractFlow(const NET_BUFFER_LIST *pkt, UINT32 inPort, OvsFlowKey *flow, POVS_PACKET_HDR_INFO layers, OvsIPv4TunnelKey *tunKey); diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c index cadffdab847..6b2d94add2d 100644 --- a/datapath-windows/ovsext/User.c +++ b/datapath-windows/ovsext/User.c @@ -383,6 +383,7 @@ _MapNlAttrToOvsPktExec(PNL_ATTR *nlAttrs, PNL_ATTR *keyAttrs, execute->actionsLen = NlAttrGetSize(nlAttrs[OVS_PACKET_ATTR_ACTIONS]); execute->inPort = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_IN_PORT]); + execute->keyAttrs = keyAttrs; } NTSTATUS @@ -429,6 +430,11 @@ OvsExecuteDpIoctl(OvsPacketExecute *execute) } // XXX: Figure out if any of the other members of fwdDetail need to be set. + status = OvsGetFlowMetadata(&key, execute->keyAttrs); + if (status != STATUS_SUCCESS) { + goto dropit; + } + ndisStatus = OvsExtractFlow(pNbl, fwdDetail->SourcePortId, &key, &layers, NULL); if (ndisStatus == NDIS_STATUS_SUCCESS) { @@ -450,6 +456,7 @@ OvsExecuteDpIoctl(OvsPacketExecute *execute) } } +dropit: if (pNbl) { OvsCompleteNBL(gOvsSwitchContext, pNbl, TRUE); }