1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2000 Kunihiro Ishiguro
6 #ifndef _QUAGGA_BGP_NEXTHOP_H
7 #define _QUAGGA_BGP_NEXTHOP_H
12 #include "bgp_table.h"
14 #define NEXTHOP_FAMILY(nexthop_len) \
15 (((nexthop_len) == 4 || (nexthop_len) == 12 \
17 : ((nexthop_len) == 16 || (nexthop_len) == 24 \
18 || (nexthop_len) == 32 \
19 || (nexthop_len) == 48 \
23 #define BGP_MP_NEXTHOP_FAMILY NEXTHOP_FAMILY
25 PREDECL_RBTREE_UNIQ(bgp_nexthop_cache
);
27 /* BGP nexthop cache value structure. */
28 struct bgp_nexthop_cache
{
29 /* The ifindex of the outgoing interface *if* it's a v6 LL */
33 struct bgp_nexthop_cache_item entry
;
35 /* IGP route's metric. */
38 /* Nexthop number and nexthop linked list.*/
40 struct nexthop
*nexthop
;
45 * If the nexthop is EVPN gateway IP NH, VALID flag is set only if the nexthop
46 * is RIB reachable as well as MAC/IP is present
48 #define BGP_NEXTHOP_VALID (1 << 0)
49 #define BGP_NEXTHOP_REGISTERED (1 << 1)
50 #define BGP_NEXTHOP_CONNECTED (1 << 2)
51 #define BGP_NEXTHOP_PEER_NOTIFIED (1 << 3)
52 #define BGP_STATIC_ROUTE (1 << 4)
53 #define BGP_STATIC_ROUTE_EXACT_MATCH (1 << 5)
54 #define BGP_NEXTHOP_LABELED_VALID (1 << 6)
57 * This flag is added for EVPN gateway IP nexthops.
58 * If the nexthop is RIB reachable, but a MAC/IP is not yet
59 * resolved, this flag is set.
60 * Following table explains the combination of L3 and L2 reachability w.r.t.
61 * VALID and INCOMPLETE flags
63 * | MACIP resolved | MACIP unresolved
64 *----------------|----------------|------------------
65 * L3 reachable | VALID = 1 | VALID = 0
66 * | INCOMPLETE = 0 | INCOMPLETE = 1
67 * ---------------|----------------|--------------------
68 * L3 unreachable | VALID = 0 | VALID = 0
69 * | INCOMPLETE = 0 | INCOMPLETE = 0
71 #define BGP_NEXTHOP_EVPN_INCOMPLETE (1 << 7)
73 uint16_t change_flags
;
75 #define BGP_NEXTHOP_CHANGED (1 << 0)
76 #define BGP_NEXTHOP_METRIC_CHANGED (1 << 1)
77 #define BGP_NEXTHOP_CONNECTED_CHANGED (1 << 2)
78 #define BGP_NEXTHOP_MACIP_CHANGED (1 << 3)
80 /* Back pointer to the cache tree this entry belongs to. */
81 struct bgp_nexthop_cache_head
*tree
;
85 void *nht_info
; /* In BGP, peer session */
86 LIST_HEAD(path_list
, bgp_path_info
) paths
;
87 unsigned int path_count
;
90 /* This flag is set to TRUE for a bnc that is gateway IP overlay index
93 bool is_evpn_gwip_nexthop
;
96 extern int bgp_nexthop_cache_compare(const struct bgp_nexthop_cache
*a
,
97 const struct bgp_nexthop_cache
*b
);
98 DECLARE_RBTREE_UNIQ(bgp_nexthop_cache
, struct bgp_nexthop_cache
, entry
,
99 bgp_nexthop_cache_compare
);
101 /* Own tunnel-ip address structure */
108 struct in6_addr addrv6
;
109 struct list
*ifp_name_list
;
112 /* Forward declaration(s). */
114 struct update_subgroup
;
118 #define BNC_FLAG_DUMP_SIZE 180
119 extern char *bgp_nexthop_dump_bnc_flags(struct bgp_nexthop_cache
*bnc
,
120 char *buf
, size_t len
);
121 extern char *bgp_nexthop_dump_bnc_change_flags(struct bgp_nexthop_cache
*bnc
,
122 char *buf
, size_t len
);
123 extern void bgp_connected_add(struct bgp
*bgp
, struct connected
*c
);
124 extern void bgp_connected_delete(struct bgp
*bgp
, struct connected
*c
);
125 extern bool bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop
,
126 struct update_subgroup
*subgrp
,
127 struct peer
*exclude
);
128 extern bool bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop
,
129 struct update_subgroup
*subgrp
,
130 struct peer
*exclude
);
131 extern bool bgp_multiaccess_check_v4(struct in_addr nexthop
, struct peer
*peer
);
132 extern bool bgp_multiaccess_check_v6(struct in6_addr nexthop
,
134 extern int bgp_config_write_scan_time(struct vty
*);
135 extern bool bgp_nexthop_self(struct bgp
*bgp
, afi_t afi
, uint8_t type
,
136 uint8_t sub_type
, struct attr
*attr
,
137 struct bgp_dest
*dest
);
138 extern struct bgp_nexthop_cache
*bnc_new(struct bgp_nexthop_cache_head
*tree
,
139 struct prefix
*prefix
,
142 extern bool bnc_existing_for_prefix(struct bgp_nexthop_cache
*bnc
);
143 extern void bnc_free(struct bgp_nexthop_cache
*bnc
);
144 extern struct bgp_nexthop_cache
*bnc_find(struct bgp_nexthop_cache_head
*tree
,
145 struct prefix
*prefix
,
148 extern void bnc_nexthop_free(struct bgp_nexthop_cache
*bnc
);
149 extern void bgp_scan_init(struct bgp
*bgp
);
150 extern void bgp_scan_finish(struct bgp
*bgp
);
151 extern void bgp_scan_vty_init(void);
152 extern void bgp_address_init(struct bgp
*bgp
);
153 extern void bgp_address_destroy(struct bgp
*bgp
);
154 extern bool bgp_tip_add(struct bgp
*bgp
, struct in_addr
*tip
);
155 extern void bgp_tip_del(struct bgp
*bgp
, struct in_addr
*tip
);
156 extern void bgp_tip_hash_init(struct bgp
*bgp
);
157 extern void bgp_tip_hash_destroy(struct bgp
*bgp
);
159 extern void bgp_nexthop_show_address_hash(struct vty
*vty
, struct bgp
*bgp
);
160 #endif /* _QUAGGA_BGP_NEXTHOP_H */