2 * Copyright (c) 2015, 2016 VMware, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __OVS_CONNTRACK_H_
18 #define __OVS_CONNTRACK_H_ 1
27 uint32_t ipv4_aligned
;
28 struct in6_addr ipv6_aligned
;
38 typedef enum CT_UPDATE_RES
{
44 /* Metadata mark for masked write to conntrack mark */
45 typedef struct MD_MARK
{
50 /* Metadata label for masked write to conntrack label. */
51 typedef struct MD_LABELS
{
52 struct ovs_key_ct_labels value
;
53 struct ovs_key_ct_labels mask
;
56 typedef struct _OVS_CT_KEY
{
57 struct ct_endpoint src
;
58 struct ct_endpoint dst
;
64 } OVS_CT_KEY
, *POVS_CT_KEY
;
66 typedef struct OVS_CT_ENTRY
{
72 UINT64 timestampStart
;
73 struct ovs_key_ct_labels labels
;
74 } OVS_CT_ENTRY
, *POVS_CT_ENTRY
;
76 typedef struct OvsConntrackKeyLookupCtx
{
82 } OvsConntrackKeyLookupCtx
;
84 #define CT_HASH_TABLE_SIZE ((UINT32)1 << 10)
85 #define CT_HASH_TABLE_MASK (CT_HASH_TABLE_SIZE - 1)
86 #define CT_INTERVAL_SEC 10000000LL //1s
87 #define CT_ENTRY_TIMEOUT (2 * 60 * CT_INTERVAL_SEC) // 2m
88 #define CT_CLEANUP_INTERVAL (2 * 60 * CT_INTERVAL_SEC) // 2m
91 /* Given POINTER, the address of the given MEMBER in a STRUCT object, returns
93 #define CONTAINER_OF(POINTER, STRUCT, MEMBER) \
94 ((STRUCT *) (void *) ((char *) (POINTER) - \
95 offsetof (STRUCT, MEMBER)))
97 VOID
OvsCleanupConntrack(VOID
);
98 NTSTATUS
OvsInitConntrack(POVS_SWITCH_CONTEXT context
);
100 NDIS_STATUS
OvsExecuteConntrackAction(PNET_BUFFER_LIST curNbl
,
101 OVS_PACKET_HDR_INFO
*layers
,
104 BOOLEAN
OvsConntrackValidateTcpPacket(const TCPHdr
*tcp
);
105 OVS_CT_ENTRY
* OvsConntrackCreateTcpEntry(const TCPHdr
*tcp
,
106 PNET_BUFFER_LIST nbl
,
108 NDIS_STATUS
OvsCtMapTcpProtoInfoToNl(PNL_BUFFER nlBuf
,
109 OVS_CT_ENTRY
*conn_
);
110 OVS_CT_ENTRY
* OvsConntrackCreateOtherEntry(UINT64 now
);
111 enum CT_UPDATE_RES
OvsConntrackUpdateTcpEntry(OVS_CT_ENTRY
* conn_
,
113 PNET_BUFFER_LIST nbl
,
116 enum ct_update_res
OvsConntrackUpdateOtherEntry(OVS_CT_ENTRY
*conn_
,
120 OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry
,
128 #endif /* __OVS_CONNTRACK_H_ */