]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_route.h
Debian: Fixup build issues with switch to 3.0
[mirror_frr.git] / bgpd / bgp_route.h
CommitLineData
718e3744 1/* BGP routing information base
2 Copyright (C) 1996, 97, 98, 2000 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
00d252cb 21#ifndef _QUAGGA_BGP_ROUTE_H
22#define _QUAGGA_BGP_ROUTE_H
23
fb018d25 24#include "queue.h"
200df115 25#include "bgp_table.h"
26
fb018d25
DS
27struct bgp_nexthop_cache;
28
3f9c7369
DS
29#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
30 "h history, * valid, > best, = multipath,%s"\
31 " i internal, r RIB-failure, S Stale, R Removed%s"
32#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
33#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
34
fb982c25
PJ
35/* Ancillary information to struct bgp_info,
36 * used for uncommonly used data (aggregation, MPLS, etc.)
37 * and lazily allocated to save memory.
38 */
39struct bgp_info_extra
40{
41 /* Pointer to dampening structure. */
42 struct bgp_damp_info *damp_info;
43
44 /* This route is suppressed with aggregation. */
45 int suppress;
46
47 /* Nexthop reachability check. */
48 u_int32_t igpmetric;
49
50 /* MPLS label. */
51 u_char tag[3];
52};
53
718e3744 54struct bgp_info
55{
56 /* For linked list. */
57 struct bgp_info *next;
58 struct bgp_info *prev;
fb018d25
DS
59
60 /* For nexthop linked list */
61 LIST_ENTRY(bgp_info) nh_thread;
62
63 /* Back pointer to the prefix node */
64 struct bgp_node *net;
65
66 /* Back pointer to the nexthop structure */
67 struct bgp_nexthop_cache *nexthop;
68
cbdfbaa5
PJ
69 /* Peer structure. */
70 struct peer *peer;
71
72 /* Attribute structure. */
73 struct attr *attr;
fb982c25
PJ
74
75 /* Extra information */
76 struct bgp_info_extra *extra;
77
de8d5dff
JB
78
79 /* Multipath information */
80 struct bgp_info_mpath *mpath;
81
cbdfbaa5
PJ
82 /* Uptime. */
83 time_t uptime;
84
200df115 85 /* reference count */
228da428 86 int lock;
200df115 87
718e3744 88 /* BGP information status. */
93406d87 89 u_int16_t flags;
718e3744 90#define BGP_INFO_IGP_CHANGED (1 << 0)
91#define BGP_INFO_DAMPED (1 << 1)
92#define BGP_INFO_HISTORY (1 << 2)
93#define BGP_INFO_SELECTED (1 << 3)
94#define BGP_INFO_VALID (1 << 4)
95#define BGP_INFO_ATTR_CHANGED (1 << 5)
96#define BGP_INFO_DMED_CHECK (1 << 6)
97#define BGP_INFO_DMED_SELECTED (1 << 7)
93406d87 98#define BGP_INFO_STALE (1 << 8)
b40d939b 99#define BGP_INFO_REMOVED (1 << 9)
902212c3 100#define BGP_INFO_COUNTED (1 << 10)
de8d5dff
JB
101#define BGP_INFO_MULTIPATH (1 << 11)
102#define BGP_INFO_MULTIPATH_CHG (1 << 12)
718e3744 103
cbdfbaa5
PJ
104 /* BGP route type. This can be static, RIP, OSPF, BGP etc. */
105 u_char type;
106
107 /* When above type is BGP. This sub type specify BGP sub type
108 information. */
109 u_char sub_type;
110#define BGP_ROUTE_NORMAL 0
111#define BGP_ROUTE_STATIC 1
112#define BGP_ROUTE_AGGREGATE 2
113#define BGP_ROUTE_REDISTRIBUTE 3
7c8ff89e
DS
114
115 u_short instance;
116
a82478b9
DS
117 /* Addpath identifiers */
118 u_int32_t addpath_rx_id;
119 u_int32_t addpath_tx_id;
120
718e3744 121};
122
123/* BGP static route configuration. */
124struct bgp_static
125{
126 /* Backdoor configuration. */
127 int backdoor;
128
129 /* Import check status. */
130 u_char valid;
131
132 /* IGP metric. */
133 u_int32_t igpmetric;
134
135 /* IGP nexthop. */
136 struct in_addr igpnexthop;
137
41367172
PJ
138 /* Atomic set reference count (ie cause of pathlimit) */
139 u_int32_t atomic;
140
718e3744 141 /* BGP redistribute route-map. */
142 struct
143 {
144 char *name;
145 struct route_map *map;
146 } rmap;
147
148 /* MPLS label. */
149 u_char tag[3];
150};
151
8a92a8a0
DS
152#define BGP_ATTR_NEXTHOP_AFI_IP6(attr) \
153 (! CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)) && \
154 (attr)->extra && ((attr)->extra->mp_nexthop_len == 16 || \
155 (attr)->extra->mp_nexthop_len == 32))
80e0ad24
DS
156#define BGP_INFO_COUNTABLE(BI) \
157 (! CHECK_FLAG ((BI)->flags, BGP_INFO_HISTORY) \
158 && ! CHECK_FLAG ((BI)->flags, BGP_INFO_REMOVED))
159
1a392d46
PJ
160/* Flags which indicate a route is unuseable in some form */
161#define BGP_INFO_UNUSEABLE \
162 (BGP_INFO_HISTORY|BGP_INFO_DAMPED|BGP_INFO_REMOVED)
163/* Macro to check BGP information is alive or not. Sadly,
164 * not equivalent to just checking previous, because of the
165 * sense of the additional VALID flag.
166 */
167#define BGP_INFO_HOLDDOWN(BI) \
168 (! CHECK_FLAG ((BI)->flags, BGP_INFO_VALID) \
169 || CHECK_FLAG ((BI)->flags, BGP_INFO_UNUSEABLE))
170
718e3744 171#define DISTRIBUTE_IN_NAME(F) ((F)->dlist[FILTER_IN].name)
172#define DISTRIBUTE_IN(F) ((F)->dlist[FILTER_IN].alist)
173#define DISTRIBUTE_OUT_NAME(F) ((F)->dlist[FILTER_OUT].name)
174#define DISTRIBUTE_OUT(F) ((F)->dlist[FILTER_OUT].alist)
175
176#define PREFIX_LIST_IN_NAME(F) ((F)->plist[FILTER_IN].name)
177#define PREFIX_LIST_IN(F) ((F)->plist[FILTER_IN].plist)
178#define PREFIX_LIST_OUT_NAME(F) ((F)->plist[FILTER_OUT].name)
179#define PREFIX_LIST_OUT(F) ((F)->plist[FILTER_OUT].plist)
180
181#define FILTER_LIST_IN_NAME(F) ((F)->aslist[FILTER_IN].name)
182#define FILTER_LIST_IN(F) ((F)->aslist[FILTER_IN].aslist)
183#define FILTER_LIST_OUT_NAME(F) ((F)->aslist[FILTER_OUT].name)
184#define FILTER_LIST_OUT(F) ((F)->aslist[FILTER_OUT].aslist)
185
fee0f4c6 186#define ROUTE_MAP_IN_NAME(F) ((F)->map[RMAP_IN].name)
187#define ROUTE_MAP_IN(F) ((F)->map[RMAP_IN].map)
188#define ROUTE_MAP_OUT_NAME(F) ((F)->map[RMAP_OUT].name)
189#define ROUTE_MAP_OUT(F) ((F)->map[RMAP_OUT].map)
190
718e3744 191#define UNSUPPRESS_MAP_NAME(F) ((F)->usmap.name)
192#define UNSUPPRESS_MAP(F) ((F)->usmap.map)
193
4092b06c
DS
194enum bgp_path_type
195{
196 BGP_PATH_ALL,
197 BGP_PATH_BESTPATH,
198 BGP_PATH_MULTIPATH
199};
200
3f9c7369
DS
201static inline void
202bgp_bump_version (struct bgp_node *node)
203{
204 node->version = bgp_table_next_version(bgp_node_table(node));
205}
206
718e3744 207/* Prototypes. */
f188f2c4 208extern void bgp_process_queue_init (void);
94f2b392 209extern void bgp_route_init (void);
228da428 210extern void bgp_route_finish (void);
94f2b392 211extern void bgp_cleanup_routes (void);
212extern void bgp_announce_route (struct peer *, afi_t, safi_t);
3f9c7369 213extern void bgp_stop_announce_route_timer(struct peer_af *paf);
94f2b392 214extern void bgp_announce_route_all (struct peer *);
215extern void bgp_default_originate (struct peer *, afi_t, safi_t, int);
216extern void bgp_soft_reconfig_in (struct peer *, afi_t, safi_t);
2a3d5731 217extern void bgp_clear_route (struct peer *, afi_t, safi_t);
94f2b392 218extern void bgp_clear_route_all (struct peer *);
219extern void bgp_clear_adj_in (struct peer *, afi_t, safi_t);
220extern void bgp_clear_stale_route (struct peer *, afi_t, safi_t);
718e3744 221
4125bb67
DS
222extern struct bgp_node *bgp_afi_node_get (struct bgp_table *table, afi_t afi,
223 safi_t safi, struct prefix *p,
224 struct prefix_rd *prd);
200df115 225extern struct bgp_info *bgp_info_lock (struct bgp_info *);
226extern struct bgp_info *bgp_info_unlock (struct bgp_info *);
227extern void bgp_info_add (struct bgp_node *rn, struct bgp_info *ri);
228extern void bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri);
fb982c25 229extern struct bgp_info_extra *bgp_info_extra_get (struct bgp_info *);
1a392d46
PJ
230extern void bgp_info_set_flag (struct bgp_node *, struct bgp_info *, u_int32_t);
231extern void bgp_info_unset_flag (struct bgp_node *, struct bgp_info *, u_int32_t);
200df115 232
a82478b9 233extern int bgp_nlri_sanity_check (struct peer *, int, safi_t, u_char *, bgp_size_t, int *);
94f2b392 234extern int bgp_nlri_parse (struct peer *, struct attr *, struct bgp_nlri *);
718e3744 235
94f2b392 236extern int bgp_maximum_prefix_overflow (struct peer *, afi_t, safi_t, int);
718e3744 237
f04a80a5 238extern void bgp_redistribute_add (struct prefix *, const struct in_addr *,
bc413143 239 const struct in6_addr *, unsigned int ifindex,
7c8ff89e
DS
240 u_int32_t, u_char, u_short, u_short);
241extern void bgp_redistribute_delete (struct prefix *, u_char, u_short);
242extern void bgp_redistribute_withdraw (struct bgp *, afi_t, int, u_short);
718e3744 243
94f2b392 244extern void bgp_static_delete (struct bgp *);
078430f6 245extern void bgp_static_redo_import_check (struct bgp *);
94f2b392 246extern void bgp_static_update (struct bgp *, struct prefix *, struct bgp_static *,
718e3744 247 afi_t, safi_t);
94f2b392 248extern void bgp_static_withdraw (struct bgp *, struct prefix *, afi_t, safi_t);
718e3744 249
94f2b392 250extern int bgp_static_set_vpnv4 (struct vty *vty, const char *,
fd79ac91 251 const char *, const char *);
718e3744 252
94f2b392 253extern int bgp_static_unset_vpnv4 (struct vty *, const char *,
fd79ac91 254 const char *, const char *);
718e3744 255
94f2b392 256/* this is primarily for MPLS-VPN */
a82478b9 257extern int bgp_update (struct peer *, struct prefix *, u_int32_t, struct attr *,
94f2b392 258 afi_t, safi_t, int, int, struct prefix_rd *,
259 u_char *, int);
a82478b9 260extern int bgp_withdraw (struct peer *, struct prefix *, u_int32_t, struct attr *,
94f2b392 261 afi_t, safi_t, int, int, struct prefix_rd *, u_char *);
718e3744 262
94f2b392 263/* for bgp_nexthop and bgp_damp */
264extern void bgp_process (struct bgp *, struct bgp_node *, afi_t, safi_t);
cb1faec9
DS
265
266/*
267 * Add an end-of-initial-update marker to the process queue. This is just a
268 * queue element with NULL bgp node.
269 */
2a3d5731 270extern void bgp_add_eoiu_mark (struct bgp *);
73ac8160
DS
271extern int bgp_config_write_table_map (struct vty *, struct bgp *, afi_t, safi_t,
272 int *);
94f2b392 273extern int bgp_config_write_network (struct vty *, struct bgp *, afi_t, safi_t, int *);
274extern int bgp_config_write_distance (struct vty *, struct bgp *);
275
276extern void bgp_aggregate_increment (struct bgp *, struct prefix *, struct bgp_info *,
718e3744 277 afi_t, safi_t);
94f2b392 278extern void bgp_aggregate_decrement (struct bgp *, struct prefix *, struct bgp_info *,
718e3744 279 afi_t, safi_t);
280
94f2b392 281extern u_char bgp_distance_apply (struct prefix *, struct bgp_info *, struct bgp *);
718e3744 282
94f2b392 283extern afi_t bgp_node_afi (struct vty *);
284extern safi_t bgp_node_safi (struct vty *);
5a646650 285
b05a1c8b 286extern void route_vty_out (struct vty *, struct prefix *, struct bgp_info *, int, safi_t, json_object *);
856ca177
MS
287extern void route_vty_out_tag (struct vty *, struct prefix *, struct bgp_info *, int, safi_t, json_object *);
288extern void route_vty_out_tmp (struct vty *, struct prefix *, struct attr *, safi_t, u_char, json_object *);
00d252cb 289
3f9c7369
DS
290extern int
291subgroup_process_announce_selected (struct update_subgroup *subgrp,
292 struct bgp_info *selected,
adbac85e
DW
293 struct bgp_node *rn,
294 u_int32_t addpath_tx_id);
3f9c7369
DS
295
296extern int subgroup_announce_check(struct bgp_info *ri,
297 struct update_subgroup *subgrp,
298 struct prefix *p, struct attr *attr);
299
00d252cb 300#endif /* _QUAGGA_BGP_ROUTE_H */