]> git.proxmox.com Git - mirror_frr.git/blame - babeld/route.h
Merge pull request #13163 from isabelladeleon12/isis_log_drops
[mirror_frr.git] / babeld / route.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: MIT
ca10883e
DS
2/*
3Copyright (c) 2007, 2008 by Juliusz Chroboczek
4Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
ca10883e
DS
5*/
6
7#ifndef BABEL_ROUTE_H
8#define BABEL_ROUTE_H
9
10#include "babel_interface.h"
11#include "source.h"
12
e33b116c
DS
13enum babel_diversity {
14 DIVERSITY_NONE,
15 DIVERSITY_INTERFACE_1,
16 DIVERSITY_CHANNEL_1,
17 DIVERSITY_CHANNEL,
18};
ca10883e
DS
19
20#define DIVERSITY_HOPS 8
21
22struct babel_route {
23 struct source *src;
24 unsigned short refmetric;
25 unsigned short cost;
26 unsigned short add_metric;
27 unsigned short seqno;
28 struct neighbour *neigh;
29 unsigned char nexthop[16];
30 time_t time;
31 unsigned short hold_time; /* in seconds */
32 unsigned short smoothed_metric; /* for route selection */
33 time_t smoothed_metric_time;
34 short installed;
35 unsigned char channels[DIVERSITY_HOPS];
36 struct babel_route *next;
37};
38
39struct route_stream;
40
41extern struct babel_route **routes;
42extern int kernel_metric;
e33b116c
DS
43extern enum babel_diversity diversity_kind;
44extern int diversity_factor;
ca10883e
DS
45extern int keep_unfeasible;
46extern int smoothing_half_life;
47
48static inline int
49route_metric(const struct babel_route *route)
50{
51 int m = (int)route->refmetric + route->cost + route->add_metric;
52 return MIN(m, INFINITY);
53}
54
55static inline int
56route_metric_noninterfering(const struct babel_route *route)
57{
58 int m =
59 (int)route->refmetric +
60 (diversity_factor * route->cost + 128) / 256 +
61 route->add_metric;
62 m = MAX(m, route->refmetric + 1);
63 return MIN(m, INFINITY);
64}
65
66struct babel_route *find_route(const unsigned char *prefix, unsigned char plen,
67 struct neighbour *neigh, const unsigned char *nexthop);
68struct babel_route *find_installed_route(const unsigned char *prefix,
69 unsigned char plen);
70int installed_routes_estimate(void);
71void flush_route(struct babel_route *route);
72void flush_all_routes(void);
73void flush_neighbour_routes(struct neighbour *neigh);
74void flush_interface_routes(struct interface *ifp, int v4only);
75struct route_stream *route_stream(int installed);
76struct babel_route *route_stream_next(struct route_stream *stream);
77void route_stream_done(struct route_stream *stream);
78void install_route(struct babel_route *route);
79void uninstall_route(struct babel_route *route);
80int route_feasible(struct babel_route *route);
81int route_old(struct babel_route *route);
82int route_expired(struct babel_route *route);
83int route_interferes(struct babel_route *route, struct interface *ifp);
84int update_feasible(struct source *src,
85 unsigned short seqno, unsigned short refmetric);
86void change_smoothing_half_life(int half_life);
87int route_smoothed_metric(struct babel_route *route);
88struct babel_route *find_best_route(const unsigned char *prefix, unsigned char plen,
89 int feasible, struct neighbour *exclude);
90struct babel_route *install_best_route(const unsigned char prefix[16],
91 unsigned char plen);
92void update_neighbour_metric(struct neighbour *neigh, int change);
93void update_interface_metric(struct interface *ifp);
94void update_route_metric(struct babel_route *route);
95struct babel_route *update_route(const unsigned char *id,
96 const unsigned char *prefix, unsigned char plen,
97 unsigned short seqno, unsigned short refmetric,
98 unsigned short interval, struct neighbour *neigh,
99 const unsigned char *nexthop,
100 const unsigned char *channels, int channels_len);
101void retract_neighbour_routes(struct neighbour *neigh);
102void send_unfeasible_request(struct neighbour *neigh, int force,
103 unsigned short seqno, unsigned short metric,
104 struct source *src);
105void send_triggered_update(struct babel_route *route,
106 struct source *oldsrc, unsigned oldmetric);
107void route_changed(struct babel_route *route,
108 struct source *oldsrc, unsigned short oldmetric);
109void route_lost(struct source *src, unsigned oldmetric);
110void expire_routes(void);
111
112#endif