diff options
author | Anand Kumar <kumaranand@vmware.com> | 2017-09-05 16:53:04 -0700 |
---|---|---|
committer | Alin Gabriel Serdean <aserdean@ovn.org> | 2017-09-07 22:35:09 +0300 |
commit | 5ff834831f00fd3be016ead1f07c0abb68a2e45b (patch) | |
tree | 02a904038b60a8bd22a4e086372682f4b54b27ae /datapath-windows | |
parent | 49705e1b843b47d6b7830bd59e68f8e908bb0410 (diff) | |
download | openvswitch-5ff834831f00fd3be016ead1f07c0abb68a2e45b.tar.gz |
datapath-windows: Increment ct packet counters based on ct_state.
For a given packet, packet counters in conntrack should be accounted only
once, even if the packet is processed multiple times by conntrack.
When a packet is processed by conntrack, ct_state flag is set to
OVS_CS_F_TRACKED. Use this state to identify if a packet has been
processed previously by conntrack.
Also update the ct packet counters when ct entry is created.
With this patch, the conntrack's packet counters behavior is similar
to linux
Signed-off-by: Anand Kumar <kumaranand@vmware.com>
Acked-by: Ram Shashank Ram <rams@vmware.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Acked-by: Alin Serdean <aserdean@ovn.org>
Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Diffstat (limited to 'datapath-windows')
-rw-r--r-- | datapath-windows/ovsext/Conntrack.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/datapath-windows/ovsext/Conntrack.c b/datapath-windows/ovsext/Conntrack.c index 8bcda05e2..f0d135be3 100644 --- a/datapath-windows/ovsext/Conntrack.c +++ b/datapath-windows/ovsext/Conntrack.c @@ -169,6 +169,18 @@ OvsPostCtEventEntry(POVS_CT_ENTRY entry, UINT8 type) OvsPostCtEvent(&ctEventEntry); } +static __inline VOID +OvsCtIncrementCounters(POVS_CT_ENTRY entry, BOOLEAN reply, PNET_BUFFER_LIST nbl) +{ + if (reply) { + entry->rev_key.byteCount+= OvsPacketLenNBL(nbl); + entry->rev_key.packetCount++; + } else { + entry->key.byteCount += OvsPacketLenNBL(nbl); + entry->key.packetCount++; + } +} + static __inline BOOLEAN OvsCtAddEntry(POVS_CT_ENTRY entry, OvsConntrackKeyLookupCtx *ctx, PNAT_ACTION_INFO natInfo, UINT64 now) @@ -287,6 +299,9 @@ OvsCtEntryCreate(OvsForwardingContext *fwdCtx, } OvsCtUpdateFlowKey(key, state, ctx->key.zone, 0, NULL); + if (entry) { + OvsCtIncrementCounters(entry, ctx->reply, curNbl); + } return entry; } @@ -382,18 +397,6 @@ OvsCtKeyAreSame(OVS_CT_KEY ctxKey, OVS_CT_KEY entryKey) (ctxKey.zone == entryKey.zone)); } -static __inline VOID -OvsCtIncrementCounters(POVS_CT_ENTRY entry, BOOLEAN reply, PNET_BUFFER_LIST nbl) -{ - if (reply) { - entry->rev_key.byteCount+= OvsPacketLenNBL(nbl); - entry->rev_key.packetCount++; - } else { - entry->key.byteCount += OvsPacketLenNBL(nbl); - entry->key.packetCount++; - } -} - POVS_CT_ENTRY OvsCtLookup(OvsConntrackKeyLookupCtx *ctx) { @@ -732,6 +735,13 @@ OvsCtExecute_(OvsForwardingContext *fwdCtx, return NDIS_STATUS_RESOURCES; } + /* Increment the counters soon after the lookup, since we set ct.state + * to OVS_CS_F_TRACKED after processing the ct entry. + */ + if (entry && (!(key->ct.state & OVS_CS_F_TRACKED))) { + OvsCtIncrementCounters(entry, ctx.reply, curNbl); + } + if (!entry) { /* If no matching entry was found, create one and add New state */ entry = OvsCtEntryCreate(fwdCtx, key->ipKey.nwProto, @@ -740,7 +750,6 @@ OvsCtExecute_(OvsForwardingContext *fwdCtx, &entryCreated); } else { /* Process the entry and update CT flags */ - OvsCtIncrementCounters(entry, ctx.reply, curNbl); entry = OvsProcessConntrackEntry(fwdCtx, layers->l4Offset, &ctx, key, zone, natInfo, commit, currentTime, &entryCreated); |