2 * STATICd - static routes header
3 * Copyright (C) 2018 Cumulus Networks, Inc.
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)
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
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
20 #ifndef __STATIC_ROUTES_H__
21 #define __STATIC_ROUTES_H__
25 /* Static route label information */
26 struct static_nh_label
{
29 mpls_label_t label
[MPLS_MAX_LABELS
];
32 enum static_blackhole_type
{
33 STATIC_BLACKHOLE_DROP
= 0,
34 STATIC_BLACKHOLE_NULL
,
35 STATIC_BLACKHOLE_REJECT
41 STATIC_IPV4_GATEWAY_IFNAME
,
44 STATIC_IPV6_GATEWAY_IFNAME
,
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.
60 enum static_install_states
{
67 /* Static route information. */
69 /* For linked list. */
70 struct static_route
*prev
;
71 struct static_route
*next
;
76 char nh_vrfname
[VRF_NAMSIZ
+ 1];
79 * States that we walk the route through
80 * To know where we are.
82 enum static_install_states state
;
84 /* Administrative distance. */
90 /* Flag for this static route's type. */
96 enum static_blackhole_type bh_type
;
102 char ifname
[INTERFACE_NAMSIZ
+ 1];
104 /* Label information */
105 struct static_nh_label snh_label
;
110 * Whether to pretend the nexthop is directly attached to the specified
111 * link. Only meaningful when both a gateway address and interface name
117 extern bool mpls_enabled
;
119 extern struct zebra_privs_t static_privs
;
121 void static_fixup_vrf_ids(struct static_vrf
*svrf
);
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
);
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
,
140 extern void static_cleanup_vrf_ids(struct static_vrf
*disable_svrf
);
142 extern void static_install_intf_nh(struct interface
*ifp
);
144 extern void static_ifindex_update(struct interface
*ifp
, bool up
);