Skip to content

Commit

Permalink
datapath-windows: Pass fwdCtx to conntrack
Browse files Browse the repository at this point in the history
There are dependencies in Contrack module such as NAT and fragmentation on
OvsForwardingContext. This patch will make OvsForwardingContext public
in order to implement these functionalities.

Signed-off-by: Yin Lin <[email protected]>
Acked-by: Alin Serdean <[email protected]>
Signed-off-by: Gurucharan Shetty <[email protected]>
  • Loading branch information
linyinvmware authored and shettyg committed Apr 21, 2017
1 parent 42c1e58 commit ae584af
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 63 deletions.
61 changes: 2 additions & 59 deletions datapath-windows/ovsext/Actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,63 +70,6 @@ typedef struct _OVS_ACTION_STATS {

OVS_ACTION_STATS ovsActionStats;

/*
* There a lot of data that needs to be maintained while executing the pipeline
* as dictated by the actions of a flow, across different functions at different
* levels. Such data is put together in a 'context' structure. Care should be
* exercised while adding new members to the structure - only add ones that get
* used across multiple stages in the pipeline/get used in multiple functions.
*/
typedef struct OvsForwardingContext {
POVS_SWITCH_CONTEXT switchContext;
/* The NBL currently used in the pipeline. */
PNET_BUFFER_LIST curNbl;
/* NDIS forwarding detail for 'curNbl'. */
PNDIS_SWITCH_FORWARDING_DETAIL_NET_BUFFER_LIST_INFO fwdDetail;
/* Array of destination ports for 'curNbl'. */
PNDIS_SWITCH_FORWARDING_DESTINATION_ARRAY destinationPorts;
/* send flags while sending 'curNbl' into NDIS. */
ULONG sendFlags;
/* Total number of output ports, used + unused, in 'curNbl'. */
UINT32 destPortsSizeIn;
/* Total number of used output ports in 'curNbl'. */
UINT32 destPortsSizeOut;
/*
* If 'curNbl' is not owned by OVS, they need to be tracked, if they need to
* be freed/completed.
*/
OvsCompletionList *completionList;
/*
* vport number of 'curNbl' when it is passed from the PIF bridge to the INT
* bridge. ie. during tunneling on the Rx side.
*/
UINT32 srcVportNo;

/*
* Tunnel key:
* - specified in actions during tunneling Tx
* - extracted from an NBL during tunneling Rx
*/
OvsIPv4TunnelKey tunKey;

/*
* Tunneling - Tx:
* To store the output port, when it is a tunneled port. We don't foresee
* multiple tunneled ports as outport for any given NBL.
*/
POVS_VPORT_ENTRY tunnelTxNic;

/*
* Tunneling - Rx:
* Points to the Internal port on the PIF Bridge, if the packet needs to be
* de-tunneled.
*/
POVS_VPORT_ENTRY tunnelRxNic;

/* header information */
OVS_PACKET_HDR_INFO layers;
} OvsForwardingContext;

/*
* --------------------------------------------------------------------------
* OvsInitForwardingCtx --
Expand Down Expand Up @@ -2032,8 +1975,8 @@ OvsDoExecuteActions(POVS_SWITCH_CONTEXT switchContext,
}
}

status = OvsExecuteConntrackAction(ovsFwdCtx.curNbl, layers,
key, (const PNL_ATTR)a);
status = OvsExecuteConntrackAction(&ovsFwdCtx, key,
(const PNL_ATTR)a);
if (status != NDIS_STATUS_SUCCESS) {
OVS_LOG_ERROR("CT Action failed");
dropReason = L"OVS-conntrack action failed";
Expand Down
58 changes: 58 additions & 0 deletions datapath-windows/ovsext/Actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,64 @@
#include "Switch.h"
#include "PacketIO.h"


/*
* There a lot of data that needs to be maintained while executing the pipeline
* as dictated by the actions of a flow, across different functions at different
* levels. Such data is put together in a 'context' structure. Care should be
* exercised while adding new members to the structure - only add ones that get
* used across multiple stages in the pipeline/get used in multiple functions.
*/
typedef struct OvsForwardingContext {
POVS_SWITCH_CONTEXT switchContext;
/* The NBL currently used in the pipeline. */
PNET_BUFFER_LIST curNbl;
/* NDIS forwarding detail for 'curNbl'. */
PNDIS_SWITCH_FORWARDING_DETAIL_NET_BUFFER_LIST_INFO fwdDetail;
/* Array of destination ports for 'curNbl'. */
PNDIS_SWITCH_FORWARDING_DESTINATION_ARRAY destinationPorts;
/* send flags while sending 'curNbl' into NDIS. */
ULONG sendFlags;
/* Total number of output ports, used + unused, in 'curNbl'. */
UINT32 destPortsSizeIn;
/* Total number of used output ports in 'curNbl'. */
UINT32 destPortsSizeOut;
/*
* If 'curNbl' is not owned by OVS, they need to be tracked, if they need to
* be freed/completed.
*/
OvsCompletionList *completionList;
/*
* vport number of 'curNbl' when it is passed from the PIF bridge to the INT
* bridge. ie. during tunneling on the Rx side.
*/
UINT32 srcVportNo;

/*
* Tunnel key:
* - specified in actions during tunneling Tx
* - extracted from an NBL during tunneling Rx
*/
OvsIPv4TunnelKey tunKey;

/*
* Tunneling - Tx:
* To store the output port, when it is a tunneled port. We don't foresee
* multiple tunneled ports as outport for any given NBL.
*/
POVS_VPORT_ENTRY tunnelTxNic;

/*
* Tunneling - Rx:
* Points to the Internal port on the PIF Bridge, if the packet needs to be
* de-tunneled.
*/
POVS_VPORT_ENTRY tunnelRxNic;

/* header information */
OVS_PACKET_HDR_INFO layers;
} OvsForwardingContext;

NDIS_STATUS
OvsActionsExecute(POVS_SWITCH_CONTEXT switchContext,
OvsCompletionList *completionList,
Expand Down
5 changes: 3 additions & 2 deletions datapath-windows/ovsext/Conntrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,7 @@ OvsCtExecute_(PNET_BUFFER_LIST curNbl,
*---------------------------------------------------------------------------
*/
NDIS_STATUS
OvsExecuteConntrackAction(PNET_BUFFER_LIST curNbl,
OVS_PACKET_HDR_INFO *layers,
OvsExecuteConntrackAction(OvsForwardingContext *fwdCtx,
OvsFlowKey *key,
const PNL_ATTR a)
{
Expand All @@ -722,6 +721,8 @@ OvsExecuteConntrackAction(PNET_BUFFER_LIST curNbl,
MD_MARK *mark = NULL;
MD_LABELS *labels = NULL;
PCHAR helper = NULL;
PNET_BUFFER_LIST curNbl = fwdCtx->curNbl;
OVS_PACKET_HDR_INFO *layers = &fwdCtx->layers;

NDIS_STATUS status;

Expand Down
4 changes: 2 additions & 2 deletions datapath-windows/ovsext/Conntrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "precomp.h"
#include "Flow.h"
#include "Debug.h"
#include "Actions.h"
#include <stddef.h>

#ifdef OVS_DBG_MOD
Expand Down Expand Up @@ -155,8 +156,7 @@ OvsGetTcpPayloadLength(PNET_BUFFER_LIST nbl)
VOID OvsCleanupConntrack(VOID);
NTSTATUS OvsInitConntrack(POVS_SWITCH_CONTEXT context);

NDIS_STATUS OvsExecuteConntrackAction(PNET_BUFFER_LIST curNbl,
OVS_PACKET_HDR_INFO *layers,
NDIS_STATUS OvsExecuteConntrackAction(OvsForwardingContext *fwdCtx,
OvsFlowKey *key,
const PNL_ATTR a);
BOOLEAN OvsConntrackValidateTcpPacket(const TCPHdr *tcp);
Expand Down

0 comments on commit ae584af

Please sign in to comment.