summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/Stt.c
diff options
context:
space:
mode:
authorWilson Peng <pweisong@vmware.com>2022-04-06 21:18:19 +0800
committerAlin-Gabriel Serdean <aserdean@ovn.org>2022-04-10 05:18:59 +0300
commitedb2335861d629f791467f77729e743378dac15f (patch)
tree82268b884ee34ba9aa689eec2ea3708649971ee4 /datapath-windows/ovsext/Stt.c
parent9d70f4a7c3df3bb33e64d8866e3aa752d747de70 (diff)
downloadopenvswitch-edb2335861d629f791467f77729e743378dac15f.tar.gz
datapath-windows: Add IPv6 Geneve tunnel support in Windows
In the first step OVS Windows will support IPv6 tunnel(Geneve IPv6 tunnel). Implementation on Windows ------------------------- 1. For the IPv6 tunnel support,  OvsIPTunnelKey will replace original OvsIPv4TunnelKey in the related flow context handing. 2. The related src and dst address will be  changed to SOCKADDR_INET type from UINT32. 3. For the IPv6 tunnel,  one node running OVS-Windows could encapsulate IPv4/IPv6 Packets via IPV6 Geneve Tunnel, and the node could also encapsulate IPv4/IPv6 packet Via IPv4 Geneve tunnel. 4. Related IPHelper data structure will be adapted to support IPv6 Tunnel. In the IPHelper part the related Windows API(such as GetUnicastIpAddressTable/GetBestRoute2/GetIpNetEntry2/ ResolveIpNetEntry2) and Windows data structure(MIB_IPFORWARD_ROW2/MIB_IPNET_ROW2/IP_ADDRESS_PREFIX) Have already supported both IPv4 and IPV6. Now OVS Windows has been adjusted some functions And data structured to support IPV6 tunnel also. 5. OVS_TUNNEL_KEY_ATTR_IPV6_SRC and OVS_TUNNEL_KEY_ATTR_IPV6_DST filed will be supported in OVS-Windows kernel for IPV6 tunnel. Testing done. ------------------------- Related topo, 1 Windows VM(Win2019) and 2 Ubuntu 16.04 server. Both VMs Are running on one ESX host. 1. Setup one IPV6 Geneve Tunnel between 1 Windows VM and 1 Ubuntu server. Windows VM, vif0( 6000::2/40.1.1.10) vif1(5000::2)—— Ubuntu VM Eth2(5000::9), name space ns1 with interface ns1_link_peer(6000::9/40.1.1.2) Related tunnnel, ovs-vsctl.exe add-port br-int bms-tun0 -- set interface bms-tun0 type=Geneve options:csum=true options:key=flow options:local_ip="5000::2" options:remote_ip=flow In this topo, traffic from Vif0(Win) to ns1_link_peer(Ubuntu) will be gone through the Geneve tunnel (5000::2—>5000::9) for both IPv4 traffic(40.1.1.10-->40.1.1.2) and IPv6 traffic(6000::2—>6000::9) 2. Setup one IPV4 Geneve Tunnel between Windows VM and 1 Ubuntu server. Windows VM, vif0( 6000::2/40.1.1.10) vif1(50.1.1.11)—— Ubuntu, Eth2(50.1.1.9), name space ns1 with interface ns1_link_peer(6000::19/40.1.1.9) Related tunnnel, ovs-vsctl.exe -- set Interface bms-tun0 type=geneve options:csum=true options:key=flow options:local_ip="50.1.1.11" options:remote_ip=flow In this topo, traffic from Vif0(Win) to ns1_link_peer(Ubuntu) will be gone through the Geneve Tunnel (50.1.1.11—>50.1.1.9) for both IPv4 traffic(40.1.1.10-->40.1.1.9) and IPv6 traffic(6000::2—>6000::19). 3.Regression test for IpV4 in Antrea project (about 60 test case) is PASS Future Work ----------- Add other type IPv6 tunnel support for Gre/Vxlan/Stt. Signed-off-by: Wilson Peng <pweisong@vmware.com> Signed-off-by: Alin-Gabriel Serdean <aserdean@ovn.org>
Diffstat (limited to 'datapath-windows/ovsext/Stt.c')
-rw-r--r--datapath-windows/ovsext/Stt.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/datapath-windows/ovsext/Stt.c b/datapath-windows/ovsext/Stt.c
index 0220a6e80..ebdebb690 100644
--- a/datapath-windows/ovsext/Stt.c
+++ b/datapath-windows/ovsext/Stt.c
@@ -46,7 +46,7 @@ static OVS_STT_THREAD_CTX sttDefragThreadCtx;
static NDIS_STATUS
OvsDoEncapStt(POVS_VPORT_ENTRY vport, PNET_BUFFER_LIST curNbl,
- const OvsIPv4TunnelKey *tunKey,
+ const OvsIPTunnelKey *tunKey,
const POVS_FWD_INFO fwdInfo,
POVS_PACKET_HDR_INFO layers,
POVS_SWITCH_CONTEXT switchContext,
@@ -104,7 +104,7 @@ OvsCleanupSttTunnel(POVS_VPORT_ENTRY vport)
NDIS_STATUS
OvsEncapStt(POVS_VPORT_ENTRY vport,
PNET_BUFFER_LIST curNbl,
- OvsIPv4TunnelKey *tunKey,
+ OvsIPTunnelKey *tunKey,
POVS_SWITCH_CONTEXT switchContext,
POVS_PACKET_HDR_INFO layers,
PNET_BUFFER_LIST *newNbl,
@@ -114,7 +114,13 @@ OvsEncapStt(POVS_VPORT_ENTRY vport,
NDIS_STATUS status;
UNREFERENCED_PARAMETER(switchContext);
- status = OvsLookupIPFwdInfo(tunKey->src, tunKey->dst, &fwdInfo);
+
+ if (tunKey->dst.si_family != AF_INET) {
+ /*V6 tunnel support will be supported later*/
+ return NDIS_STATUS_FAILURE;
+ }
+
+ status = OvsLookupIPhFwdInfo(tunKey->src, tunKey->dst, &fwdInfo);
if (status != STATUS_SUCCESS) {
OvsFwdIPHelperRequest(NULL, 0, tunKey, NULL, NULL, NULL);
/*
@@ -140,7 +146,7 @@ OvsEncapStt(POVS_VPORT_ENTRY vport,
NDIS_STATUS
OvsDoEncapStt(POVS_VPORT_ENTRY vport,
PNET_BUFFER_LIST curNbl,
- const OvsIPv4TunnelKey *tunKey,
+ const OvsIPTunnelKey *tunKey,
const POVS_FWD_INFO fwdInfo,
POVS_PACKET_HDR_INFO layers,
POVS_SWITCH_CONTEXT switchContext,
@@ -301,8 +307,8 @@ OvsDoEncapStt(POVS_VPORT_ENTRY vport,
outerIpHdr->ttl = tunKey->ttl? tunKey->ttl : 64;
outerIpHdr->protocol = IPPROTO_TCP;
outerIpHdr->check = 0;
- outerIpHdr->saddr = fwdInfo->srcIpAddr;
- outerIpHdr->daddr = tunKey->dst;
+ outerIpHdr->saddr = fwdInfo->srcIphAddr.Ipv4.sin_addr.s_addr;
+ outerIpHdr->daddr = tunKey->dst.Ipv4.sin_addr.s_addr;
/* L4 header */
RtlZeroMemory(outerTcpHdr, sizeof *outerTcpHdr);
@@ -370,8 +376,8 @@ OvsDoEncapStt(POVS_VPORT_ENTRY vport,
*/
outerIpHdr->check = IPChecksum((UINT8 *)outerIpHdr,
sizeof *outerIpHdr, 0);
- outerTcpHdr->check = IPPseudoChecksum(&fwdInfo->srcIpAddr,
- (uint32 *)&tunKey->dst,
+ outerTcpHdr->check = IPPseudoChecksum((UINT32*)&fwdInfo->srcIphAddr.Ipv4.sin_addr.s_addr,
+ (UINT32*)&tunKey->dst.Ipv4.sin_addr.s_addr,
IPPROTO_TCP, (uint16)0);
lsoInfo.Value = 0;
@@ -382,8 +388,8 @@ OvsDoEncapStt(POVS_VPORT_ENTRY vport,
NET_BUFFER_LIST_INFO(curNbl,
TcpLargeSendNetBufferListInfo) = lsoInfo.Value;
} else {
- outerTcpHdr->check = IPPseudoChecksum(&fwdInfo->srcIpAddr,
- (uint32 *) &tunKey->dst,
+ outerTcpHdr->check = IPPseudoChecksum((UINT32*)&fwdInfo->srcIphAddr.Ipv4.sin_addr.s_addr,
+ (UINT32*)&tunKey->dst.Ipv4.sin_addr.s_addr,
IPPROTO_TCP,
(uint16) tcpChksumLen);
}
@@ -912,7 +918,7 @@ OvsDecapSetOffloads(PNET_BUFFER_LIST *curNbl,
NDIS_STATUS
OvsDecapStt(POVS_SWITCH_CONTEXT switchContext,
PNET_BUFFER_LIST curNbl,
- OvsIPv4TunnelKey *tunKey,
+ OvsIPTunnelKey *tunKey,
PNET_BUFFER_LIST *newNbl)
{
NDIS_STATUS status;
@@ -925,6 +931,12 @@ OvsDecapStt(POVS_SWITCH_CONTEXT switchContext,
UINT32 advanceCnt, hdrLen;
OVS_PACKET_HDR_INFO layers = { 0 };
+
+ if (tunKey->dst.si_family != AF_INET) {
+ /*V6 tunnel support will be supported later*/
+ return NDIS_STATUS_FAILURE;
+ }
+
status = OvsExtractLayers(curNbl, &layers);
if (status != NDIS_STATUS_SUCCESS) {
return status;
@@ -1004,8 +1016,10 @@ OvsDecapStt(POVS_SWITCH_CONTEXT switchContext,
ASSERT(sttHdr);
/* Initialize the tunnel key */
- tunKey->dst = ipHdr->daddr;
- tunKey->src = ipHdr->saddr;
+ tunKey->dst.Ipv4.sin_addr.s_addr = ipHdr->daddr;
+ tunKey->dst.si_family = AF_INET;
+ tunKey->src.Ipv4.sin_addr.s_addr = ipHdr->saddr;
+ tunKey->src.si_family = AF_INET;
tunKey->tunnelId = sttHdr->key;
tunKey->flags = OVS_TNL_F_KEY;
tunKey->tos = ipHdr->tos;