summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/Actions.c
diff options
context:
space:
mode:
Diffstat (limited to 'datapath-windows/ovsext/Actions.c')
-rw-r--r--datapath-windows/ovsext/Actions.c62
1 files changed, 37 insertions, 25 deletions
diff --git a/datapath-windows/ovsext/Actions.c b/datapath-windows/ovsext/Actions.c
index 218e7db81..c66ece080 100644
--- a/datapath-windows/ovsext/Actions.c
+++ b/datapath-windows/ovsext/Actions.c
@@ -186,19 +186,29 @@ OvsDetectTunnelRxPkt(OvsForwardingContext *ovsFwdCtx,
* packets only if they are at least VXLAN header size.
*/
- /*
- * For some of the tunnel types such as GRE, the dstPort is not applicable
- * since GRE does not have a L4 port. We use '0' for convenience.
- */
- if (!flowKey->ipKey.nwFrag) {
- UINT16 dstPort = htons(flowKey->ipKey.l4.tpDst);
+ /*
+ * For some of the tunnel types such as GRE, the dstPort is not applicable
+ * since GRE does not have a L4 port. We use '0' for convenience.
+ */
- ASSERT(flowKey->ipKey.nwProto != IPPROTO_GRE || dstPort == 0);
+ if ((flowKey->l2.dlType == htons(ETH_TYPE_IPV4) &&
+ !flowKey->ipKey.nwFrag) ||
+ (flowKey->l2.dlType == htons(ETH_TYPE_IPV6) &&
+ !flowKey->ipv6Key.nwFrag)) {
+ UINT16 dstPort = 0;
+ uint8_t nwProto = 0;
+ if (flowKey->l2.dlType == htons(ETH_TYPE_IPV6)) {
+ dstPort = htons(flowKey->ipv6Key.l4.tpDst);
+ nwProto = flowKey->ipv6Key.nwProto;
+ } else if (flowKey->l2.dlType == htons(ETH_TYPE_IPV4)) {
+ dstPort = htons(flowKey->ipKey.l4.tpDst);
+ nwProto = flowKey->ipKey.nwProto;
+ }
+ ASSERT(nwProto != IPPROTO_GRE || dstPort == 0);
tunnelVport =
OvsFindTunnelVportByDstPortAndNWProto(ovsFwdCtx->switchContext,
- dstPort,
- flowKey->ipKey.nwProto);
+ dstPort, nwProto);
if (tunnelVport) {
switch(tunnelVport->ovsType) {
case OVS_VPORT_TYPE_STT:
@@ -290,12 +300,12 @@ OvsDetectTunnelPkt(OvsForwardingContext *ovsFwdCtx,
(vport->ovsType != OVS_VPORT_TYPE_NETDEV &&
vport->ovsType != OVS_VPORT_TYPE_INTERNAL &&
!OvsIsTunnelVportType(vport->ovsType))) {
- ovsFwdCtx->tunKey.dst = 0;
+ RtlZeroMemory(&ovsFwdCtx->tunKey.dst, sizeof(ovsFwdCtx->tunKey.dst));
}
}
/* Tunnel the packet only if tunnel context is set. */
- if (ovsFwdCtx->tunKey.dst != 0) {
+ if (!OvsIphIsZero(&(ovsFwdCtx->tunKey.dst))) {
switch(dstVport->ovsType) {
case OVS_VPORT_TYPE_GRE:
ovsActionStats.txGre++;
@@ -470,7 +480,7 @@ static __inline VOID
OvsClearTunTxCtx(OvsForwardingContext *ovsFwdCtx)
{
ovsFwdCtx->tunnelTxNic = NULL;
- ovsFwdCtx->tunKey.dst = 0;
+ RtlZeroMemory(&ovsFwdCtx->tunKey.dst, sizeof(ovsFwdCtx->tunKey.dst));
}
@@ -484,7 +494,7 @@ static __inline VOID
OvsClearTunRxCtx(OvsForwardingContext *ovsFwdCtx)
{
ovsFwdCtx->tunnelRxNic = NULL;
- ovsFwdCtx->tunKey.dst = 0;
+ RtlZeroMemory(&ovsFwdCtx->tunKey.dst, sizeof(ovsFwdCtx->tunKey.dst));
}
@@ -540,7 +550,7 @@ OvsCompleteNBLForwardingCtx(OvsForwardingContext *ovsFwdCtx,
* --------------------------------------------------------------------------
*/
static __inline NDIS_STATUS
-OvsDoFlowLookupOutput(OvsForwardingContext *ovsFwdCtx)
+OvsDoFlowLookupOutput(OvsForwardingContext* ovsFwdCtx)
{
OvsFlowKey key = { 0 };
OvsFlow *flow = NULL;
@@ -557,11 +567,11 @@ OvsDoFlowLookupOutput(OvsForwardingContext *ovsFwdCtx)
ASSERT(vport->nicState == NdisSwitchNicStateConnected);
/* Assert that in the Rx direction, key is always setup. */
- ASSERT(ovsFwdCtx->tunnelRxNic == NULL || ovsFwdCtx->tunKey.dst != 0);
+ ASSERT(ovsFwdCtx->tunnelRxNic == NULL || !OvsIphIsZero(&(ovsFwdCtx->tunKey.dst)));
status =
OvsExtractFlow(ovsFwdCtx->curNbl, ovsFwdCtx->srcVportNo,
&key, &ovsFwdCtx->layers,
- ovsFwdCtx->tunKey.dst != 0 ? &ovsFwdCtx->tunKey : NULL);
+ !OvsIphIsZero(&(ovsFwdCtx->tunKey.dst))? &(ovsFwdCtx->tunKey):NULL);
if (status != NDIS_STATUS_SUCCESS) {
OvsCompleteNBLForwardingCtx(ovsFwdCtx,
L"OVS-Flow extract failed");
@@ -647,6 +657,7 @@ OvsTunnelPortTx(OvsForwardingContext *ovsFwdCtx)
OvsDoFragmentNbl(ovsFwdCtx, ctx->mru);
}
OVS_FWD_INFO switchFwdInfo = { 0 };
+
/* Apply the encapsulation. The encapsulation will not consume the NBL. */
switch(ovsFwdCtx->tunnelTxNic->ovsType) {
case OVS_VPORT_TYPE_GRE:
@@ -915,11 +926,11 @@ OvsOutputForwardingCtx(OvsForwardingContext *ovsFwdCtx)
if (ovsFwdCtx->tunnelTxNic != NULL) {
status = OvsTunnelPortTx(ovsFwdCtx);
ASSERT(ovsFwdCtx->tunnelTxNic == NULL);
- ASSERT(ovsFwdCtx->tunKey.dst == 0);
+ ASSERT(OvsIphIsZero(&(ovsFwdCtx->tunKey.dst)));
} else if (ovsFwdCtx->tunnelRxNic != NULL) {
status = OvsTunnelPortRx(ovsFwdCtx);
ASSERT(ovsFwdCtx->tunnelRxNic == NULL);
- ASSERT(ovsFwdCtx->tunKey.dst == 0);
+ ASSERT(OvsIphIsZero(&(ovsFwdCtx->tunKey.dst)));
}
ASSERT(ovsFwdCtx->curNbl == NULL);
@@ -1753,10 +1764,10 @@ OvsExecuteSetAction(OvsForwardingContext *ovsFwdCtx,
case OVS_KEY_ATTR_TUNNEL:
{
- OvsIPv4TunnelKey tunKey;
+ OvsIPTunnelKey tunKey = { 0 };
tunKey.flow_hash = (uint16)(hash ? *hash : OvsHashFlow(key));
tunKey.dst_port = key->ipKey.l4.tpDst;
- NTSTATUS convertStatus = OvsTunnelAttrToIPv4TunnelKey((PNL_ATTR)a, &tunKey);
+ NTSTATUS convertStatus = OvsTunnelAttrToIPTunnelKey((PNL_ATTR)a, &tunKey);
status = SUCCEEDED(convertStatus) ? NDIS_STATUS_SUCCESS : NDIS_STATUS_FAILURE;
ASSERT(status == NDIS_STATUS_SUCCESS);
RtlCopyMemory(&ovsFwdCtx->tunKey, &tunKey, sizeof ovsFwdCtx->tunKey);
@@ -1874,7 +1885,7 @@ OvsOutputUserspaceAction(OvsForwardingContext *ovsFwdCtx,
POVS_PACKET_HDR_INFO layers = &ovsFwdCtx->layers;
BOOLEAN isRecv = FALSE;
OVS_FWD_INFO fwdInfo;
- OvsIPv4TunnelKey tunKey;
+ OvsIPTunnelKey tunKey;
POVS_VPORT_ENTRY vport = OvsFindVportByPortNo(ovsFwdCtx->switchContext,
ovsFwdCtx->srcVportNo);
@@ -1894,10 +1905,11 @@ OvsOutputUserspaceAction(OvsForwardingContext *ovsFwdCtx,
if (egrTunAttr) {
RtlZeroMemory(&tunKey, sizeof tunKey);
RtlCopyMemory(&tunKey, &ovsFwdCtx->tunKey, sizeof tunKey);
- if (!tunKey.src) {
- status = OvsLookupIPFwdInfo(tunKey.src, tunKey.dst, &fwdInfo);
- if (status == NDIS_STATUS_SUCCESS && tunKey.dst == fwdInfo.dstIpAddr) {
- tunKey.src = fwdInfo.srcIpAddr;
+ if (!OvsIphIsZero(&(tunKey.src))) {
+ status = OvsLookupIPhFwdInfo(tunKey.src, tunKey.dst, &fwdInfo);
+ if (status == NDIS_STATUS_SUCCESS &&
+ OvsIphAddrEquals(&(tunKey.dst), &(fwdInfo.dstIphAddr))) {
+ OvsCopyIphAddress(&(tunKey.src), &fwdInfo.srcIphAddr);
}
}
tunKey.flow_hash = tunKey.flow_hash ? tunKey.flow_hash : MAXINT16;