conntrack_flush(struct conntrack *ct, const uint16_t *zone)
{
    unsigned i;

    for (i = 0; i < CONNTRACK_BUCKETS; i++) {
        struct conn *conn, *next;

        ct_lock_lock(&ct->buckets[i].lock);
        HMAP_FOR_EACH_SAFE (conn, next, node, &ct->buckets[i].connections) {
            if ((!zone || *zone == conn->key.zone) &&
                (conn->conn_type == CT_CONN_TYPE_DEFAULT)) {
                conn_clean(ct, conn, &ct->buckets[i]);
            }
        }
        ct_lock_unlock(&ct->buckets[i].lock);
    }

    ct_rwlock_wrlock(&ct->resources_lock);
    struct alg_exp_node *alg_exp_node, *alg_exp_node_next;
    HMAP_FOR_EACH_SAFE (alg_exp_node, alg_exp_node_next,
                       node, &ct->alg_expectations) {
        if (!zone || *zone == alg_exp_node->key.zone) {
            ovs_list_remove(&alg_exp_node->exp_node);
            hmap_remove(&ct->alg_expectations, &alg_exp_node->node);
            free(alg_exp_node);
        }
    }
    ct_rwlock_unlock(&ct->resources_lock);
    return 0;
}
conntrack_flush(struct conntrack *ct, const uint16_t *zone)
{
    unsigned i;

    for (i = 0; i < CONNTRACK_BUCKETS; i++) {
        struct conn *conn, *next;

        ct_lock_lock(&ct->buckets[i].lock);
        HMAP_FOR_EACH_SAFE (conn, next, node, &ct->buckets[i].connections) {
            if ((!zone || *zone == conn->key.zone) &&
                (conn->conn_type == CT_CONN_TYPE_DEFAULT)) {
                conn_clean(ct, conn, &ct->buckets[i]);
            }
        }
        ct_lock_unlock(&ct->buckets[i].lock);
    }

    ct_rwlock_wrlock(&ct->resources_lock);
    struct alg_exp_node *alg_exp_node, *alg_exp_node_next;
    HMAP_FOR_EACH_SAFE (alg_exp_node, alg_exp_node_next,
                       node, &ct->alg_expectations) {
        if (!zone || *zone == alg_exp_node->key.zone) {
            ovs_list_remove(&alg_exp_node->exp_node);
            hmap_remove(&ct->alg_expectations, &alg_exp_node->node);
            free(alg_exp_node);
        }
    }
    ct_rwlock_unlock(&ct->resources_lock);
    return 0;
}