File: route.h

package info (click to toggle)
ovn 26.03.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,480 kB
  • sloc: ansic: 117,371; xml: 25,046; sh: 3,524; python: 1,918; makefile: 866
file content (109 lines) | stat: -rw-r--r-- 3,588 bytes parent folder | download | duplicates (2)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 * Copyright (c) 2025, Canonical, Ltd.
 * Copyright (c) 2025, STACKIT GmbH & Co. KG
 *
 * 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 ROUTE_H
#define ROUTE_H 1

#include <stdbool.h>
#include <netinet/in.h>
#include <net/if.h>
#include "openvswitch/hmap.h"
#include "sset.h"
#include "smap.h"

struct hmap;
struct ovsdb_idl_index;
struct route_data;
struct sbrec_chassis;
struct sbrec_port_binding;
struct sbrec_datapath_binding;

struct route_ctx_in {
    const struct sbrec_advertised_route_table *advertised_route_table;
    struct ovsdb_idl_index *sbrec_port_binding_by_name;
    const struct sbrec_chassis *chassis;
    const char *dynamic_routing_port_mapping;
    const struct hmap *local_datapaths;
    struct shash *local_bindings;
};

struct route_ctx_out {
    struct hmap *tracked_re_datapaths;

    /* Contains the tracked_ports that in the last run were bound locally. */
    struct sset *tracked_ports_local;

    /* Contains the tracked_ports that in the last run were not bound
     * locally. */
    struct sset *tracked_ports_remote;

    /* Contains all the currently configured dynamic-routing-port-name values
     * on all datapaths.
     */
    struct sset *filtered_ports;

    /* Contains struct advertise_datapath_entry */
    struct hmap *announce_routes;
};

struct advertise_datapath_entry {
    struct hmap_node node;

    const struct sbrec_datapath_binding *db;
    bool maintain_vrf;
    char vrf_name[IFNAMSIZ + 1];
    struct in6_addr ipv4_nexthop;
    struct in6_addr ipv6_nexthop;

    struct hmap routes;

    /* The name of the port bindings locally bound for this datapath and
     * running route exchange logic.
     * The key is the port name and the value is the ifname if set. This may
     * be empty if the all ports specified dynamic-routing-port-name, but no
     * such referenced port is local. In this case we should only advertise
     * routes but not learn them. */
    struct smap bound_ports;
};

struct advertise_route_entry {
    struct hmap_node node;
    struct in6_addr addr;
    struct in6_addr nexthop;
    unsigned int plen;
    unsigned int priority;
};

const struct sbrec_port_binding *route_exchange_find_port(
    struct ovsdb_idl_index *sbrec_port_binding_by_name,
    const struct sbrec_chassis *chassis,
    const struct sbrec_port_binding *pb,
    const char **dynamic_routing_port_name);
uint32_t advertise_route_hash(const struct in6_addr *dst,
                              const struct in6_addr *nexthop,
                              unsigned int plen);
struct advertise_route_entry
advertise_route_from_route_data(const struct route_data *);
void route_run(struct route_ctx_in *, struct route_ctx_out *);
void route_cleanup(struct hmap *announce_routes);
uint32_t route_get_table_id(const struct sbrec_datapath_binding *);
struct advertise_route_entry *
advertise_route_find(unsigned int priority, const struct in6_addr *prefix,
                     unsigned int plen, const struct in6_addr *nexthop,
                     const struct hmap *advertised_routes);

#endif /* ROUTE_H */