]> git.proxmox.com Git - mirror_frr.git/blob - staticd/static_routes.h
Merge pull request #5793 from ton31337/fix/formatting_show_bgp_summary_failed
[mirror_frr.git] / staticd / static_routes.h
1 /*
2 * STATICd - static routes header
3 * Copyright (C) 2018 Cumulus Networks, Inc.
4 * Donald Sharp
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 #ifndef __STATIC_ROUTES_H__
21 #define __STATIC_ROUTES_H__
22
23 #include "lib/mpls.h"
24
25 /* Static route label information */
26 struct static_nh_label {
27 uint8_t num_labels;
28 uint8_t reserved[3];
29 mpls_label_t label[MPLS_MAX_LABELS];
30 };
31
32 enum static_blackhole_type {
33 STATIC_BLACKHOLE_DROP = 0,
34 STATIC_BLACKHOLE_NULL,
35 STATIC_BLACKHOLE_REJECT
36 };
37
38 typedef enum {
39 STATIC_IFNAME,
40 STATIC_IPV4_GATEWAY,
41 STATIC_IPV4_GATEWAY_IFNAME,
42 STATIC_BLACKHOLE,
43 STATIC_IPV6_GATEWAY,
44 STATIC_IPV6_GATEWAY_IFNAME,
45 } static_types;
46
47 /*
48 * Route Creation gives us:
49 * START -> Initial State, only exit is when we send the route to
50 * zebra for installation
51 * When we send the route to Zebra move to SENT_TO_ZEBRA
52 * SENT_TO_ZEBRA -> A way to notice that we've sent the route to zebra
53 * But have not received a response on it's status yet
54 * After The response from zebra we move to INSTALLED or FAILED
55 * INSTALLED -> Route was accepted
56 * FAILED -> Route was rejected
57 * When we receive notification about a nexthop that a route uses
58 * We move the route back to START and initiate the process again.
59 */
60 enum static_install_states {
61 STATIC_START,
62 STATIC_SENT_TO_ZEBRA,
63 STATIC_INSTALLED,
64 STATIC_NOT_INSTALLED,
65 };
66
67 /* Static route information. */
68 struct static_route {
69 /* For linked list. */
70 struct static_route *prev;
71 struct static_route *next;
72
73 /* VRF identifier. */
74 vrf_id_t vrf_id;
75 vrf_id_t nh_vrf_id;
76 char nh_vrfname[VRF_NAMSIZ + 1];
77
78 /*
79 * States that we walk the route through
80 * To know where we are.
81 */
82 enum static_install_states state;
83
84 /* Administrative distance. */
85 uint8_t distance;
86
87 /* Tag */
88 route_tag_t tag;
89
90 /* Flag for this static route's type. */
91 static_types type;
92
93 /*
94 * Nexthop value.
95 */
96 enum static_blackhole_type bh_type;
97 union g_addr addr;
98 ifindex_t ifindex;
99 bool nh_registered;
100 bool nh_valid;
101
102 char ifname[INTERFACE_NAMSIZ + 1];
103
104 /* Label information */
105 struct static_nh_label snh_label;
106
107 uint32_t table_id;
108
109 /*
110 * Whether to pretend the nexthop is directly attached to the specified
111 * link. Only meaningful when both a gateway address and interface name
112 * are specified.
113 */
114 bool onlink;
115 };
116
117 extern bool mpls_enabled;
118
119 extern struct zebra_privs_t static_privs;
120
121 void static_fixup_vrf_ids(struct static_vrf *svrf);
122
123 extern int static_add_route(afi_t afi, safi_t safi, uint8_t type,
124 struct prefix *p, struct prefix_ipv6 *src_p,
125 union g_addr *gate, const char *ifname,
126 enum static_blackhole_type bh_type, route_tag_t tag,
127 uint8_t distance, struct static_vrf *svrf,
128 struct static_vrf *nh_svrf,
129 struct static_nh_label *snh_label,
130 uint32_t table_id, bool onlink);
131
132 extern int static_delete_route(afi_t afi, safi_t safi, uint8_t type,
133 struct prefix *p, struct prefix_ipv6 *src_p,
134 union g_addr *gate, const char *ifname,
135 route_tag_t tag, uint8_t distance,
136 struct static_vrf *svrf,
137 struct static_nh_label *snh_label,
138 uint32_t table_id);
139
140 extern void static_cleanup_vrf_ids(struct static_vrf *disable_svrf);
141
142 extern void static_install_intf_nh(struct interface *ifp);
143
144 extern void static_ifindex_update(struct interface *ifp, bool up);
145 #endif