summaryrefslogtreecommitdiff
path: root/ovn/controller/lport.h
blob: f09e2eb11a7083f787fa1cce11e512e7922d1cfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Copyright (c) 2015, 2016 Nicira, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef OVN_LPORT_H
#define OVN_LPORT_H 1

#include <stdint.h>
#include "hmap.h"

struct ovsdb_idl;
struct sbrec_datapath_binding;

/* Logical port and multicast group indexes
 * ========================================
 *
 * This data structure holds multiple indexes over logical ports, to allow for
 * efficient searching for logical ports by name or number.
 */

struct lport_index {
    struct hmap by_name;
    struct hmap by_key;
};

void lport_index_init(struct lport_index *, struct ovsdb_idl *);
void lport_index_destroy(struct lport_index *);

const struct sbrec_port_binding *lport_lookup_by_name(
    const struct lport_index *, const char *name);
const struct sbrec_port_binding *lport_lookup_by_key(
    const struct lport_index *, uint32_t dp_key, uint16_t port_key);

/* Multicast group index
 * =====================
 *
 * This is separate from the logical port index because of namespace issues:
 * logical port names are globally unique, but multicast group names are only
 * unique within the scope of a logical datapath.
 *
 * Multicast groups could be indexed by number also, but so far the clients do
 * not need this index. */

struct mcgroup_index {
    struct hmap by_dp_name;
};

void mcgroup_index_init(struct mcgroup_index *, struct ovsdb_idl *);
void mcgroup_index_destroy(struct mcgroup_index *);

const struct sbrec_multicast_group *mcgroup_lookup_by_dp_name(
    const struct mcgroup_index *,
    const struct sbrec_datapath_binding *,
    const char *name);

#endif /* ovn/lport.h */