Coverage Report

Created: 2025-07-11 06:11

/src/openvswitch/lib/versions.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2016 Nicira, Inc.
3
 *
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:
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
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.
15
 */
16
17
#ifndef VERSIONS_H
18
#define VERSIONS_H 1
19
20
#include "ovs-atomic.h"
21
#include "openvswitch/type-props.h"
22
23
typedef uint64_t ovs_version_t;
24
25
0
#define OVS_VERSION_MIN 0                  /* Default version number to use. */
26
0
#define OVS_VERSION_MAX (TYPE_MAXIMUM(ovs_version_t) - 1)
27
0
#define OVS_VERSION_NOT_REMOVED TYPE_MAXIMUM(ovs_version_t)
28
29
/*
30
 * OVS_VERSION_NOT_REMOVED has a special meaning for 'remove_version',
31
 * meaning that the rule has been added but not yet removed.
32
 */
33
struct versions {
34
    ovs_version_t add_version;              /* Version object was added in. */
35
    ATOMIC(ovs_version_t) remove_version;   /* Version object is removed in. */
36
};
37
38
#define VERSIONS_INITIALIZER(ADD, REMOVE) \
39
0
    (struct versions){ ADD, REMOVE }
40
41
static inline void
42
versions_set_remove_version(struct versions *versions, ovs_version_t version)
43
0
{
44
0
    atomic_store_relaxed(&versions->remove_version, version);
45
0
}
Unexecuted instantiation: flow_extract_target.c:versions_set_remove_version
Unexecuted instantiation: ofp-util.c:versions_set_remove_version
Unexecuted instantiation: ovs-router.c:versions_set_remove_version
Unexecuted instantiation: tnl-ports.c:versions_set_remove_version
Unexecuted instantiation: classifier.c:versions_set_remove_version
Unexecuted instantiation: meta-flow.c:versions_set_remove_version
Unexecuted instantiation: nx-match.c:versions_set_remove_version
46
47
static inline bool
48
versions_visible_in_version(const struct versions *versions,
49
                            ovs_version_t version)
50
0
{
51
0
    ovs_version_t remove_version;
52
53
    /* C11 does not want to access an atomic via a const object pointer. */
54
0
    atomic_read_relaxed(&CONST_CAST(struct versions *,
55
0
                                    versions)->remove_version,
56
0
                        &remove_version);
57
58
0
    return versions->add_version <= version && version < remove_version;
59
0
}
Unexecuted instantiation: flow_extract_target.c:versions_visible_in_version
Unexecuted instantiation: ofp-util.c:versions_visible_in_version
Unexecuted instantiation: ovs-router.c:versions_visible_in_version
Unexecuted instantiation: tnl-ports.c:versions_visible_in_version
Unexecuted instantiation: classifier.c:versions_visible_in_version
Unexecuted instantiation: meta-flow.c:versions_visible_in_version
Unexecuted instantiation: nx-match.c:versions_visible_in_version
60
61
static inline bool
62
versions_is_eventually_invisible(const struct versions *versions)
63
0
{
64
0
    ovs_version_t remove_version;
65
66
    /* C11 does not want to access an atomic via a const object pointer. */
67
0
    atomic_read_relaxed(&CONST_CAST(struct versions *,
68
0
                                    versions)->remove_version,
69
0
                        &remove_version);
70
71
0
    return remove_version < OVS_VERSION_NOT_REMOVED;
72
0
}
Unexecuted instantiation: flow_extract_target.c:versions_is_eventually_invisible
Unexecuted instantiation: ofp-util.c:versions_is_eventually_invisible
Unexecuted instantiation: ovs-router.c:versions_is_eventually_invisible
Unexecuted instantiation: tnl-ports.c:versions_is_eventually_invisible
Unexecuted instantiation: classifier.c:versions_is_eventually_invisible
Unexecuted instantiation: meta-flow.c:versions_is_eventually_invisible
Unexecuted instantiation: nx-match.c:versions_is_eventually_invisible
73
74
#endif /* VERSIONS_H */