summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@ovn.org>2022-07-11 18:55:22 +0200
committerIlya Maximets <i.maximets@ovn.org>2022-07-13 00:50:23 +0200
commitb159525903d12f1e8824285db7a6bb88fea465c8 (patch)
treea83ff19007a7c6737ad7f511f9f4f73504ce4473
parent78387e88bdcf4704b88584405f66eaeb90103139 (diff)
downloadopenvswitch-b159525903d12f1e8824285db7a6bb88fea465c8.tar.gz
conntrack: Check for expiration before comparing the keys during the lookup.
This could save some costly key comparison miss, especially in the case there are many expired connections waiting for the sweeper to evict them. Acked-by: Aaron Conole <aconole@redhat.com> Co-authored-by: Paolo Valerio <pvalerio@redhat.com> Signed-off-by: Paolo Valerio <pvalerio@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
-rw-r--r--lib/conntrack.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/conntrack.c b/lib/conntrack.c
index 468450a89..13c5ab628 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -586,14 +586,17 @@ conn_key_lookup(struct conntrack *ct, const struct conn_key *key,
bool found = false;
CMAP_FOR_EACH_WITH_HASH (conn, cm_node, hash, &ct->conns) {
- if (!conn_key_cmp(&conn->key, key) && !conn_expired(conn, now)) {
+ if (conn_expired(conn, now)) {
+ continue;
+ }
+ if (!conn_key_cmp(&conn->key, key)) {
found = true;
if (reply) {
*reply = false;
}
break;
}
- if (!conn_key_cmp(&conn->rev_key, key) && !conn_expired(conn, now)) {
+ if (!conn_key_cmp(&conn->rev_key, key)) {
found = true;
if (reply) {
*reply = true;