1 // SPDX-License-Identifier: ISC
5 * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
6 * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
7 * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
14 #include "openbsd-tree.h"
28 struct in_addr prefix
;
32 struct in6_addr prefix
;
38 struct in_addr lsr_id
;
42 RB_HEAD(fec_tree
, fec
);
43 RB_PROTOTYPE(fec_tree
, fec
, entry
, fec_compare
)
54 struct lde_map_head
*head
; /* fec_node's upstream/downstream */
55 RB_ENTRY(lde_map
) entry
;
56 struct lde_nbr
*nexthop
;
59 RB_HEAD(lde_map_head
, lde_map
);
60 RB_PROTOTYPE(lde_map_head
, lde_map
, entry
, lde_map_cmp
);
62 /* withdraw entries */
68 /* Addresses belonging to neighbor */
70 TAILQ_ENTRY(lde_addr
) entry
;
75 /* just the info LDE needs */
77 RB_ENTRY(lde_nbr
) entry
;
80 int v4_enabled
; /* announce/process v4 msgs */
81 int v6_enabled
; /* announce/process v6 msgs */
82 int flags
; /* capabilities */
83 struct fec_tree recv_req
;
84 struct fec_tree sent_req
;
85 struct fec_tree recv_map
;
86 struct fec_tree sent_map
;
87 struct fec_tree sent_map_pending
;
88 struct fec_tree sent_wdraw
;
89 TAILQ_HEAD(, lde_addr
) addr_list
;
91 RB_HEAD(nbr_tree
, lde_nbr
);
92 RB_PROTOTYPE(nbr_tree
, lde_nbr
, entry
, lde_nbr_compare
)
95 LIST_ENTRY(fec_nh
) entry
;
97 union ldpd_addr nexthop
;
99 uint32_t remote_label
;
101 unsigned short route_instance
;
104 #define F_FEC_NH_NEW 0x01
105 #define F_FEC_NH_CONNECTED 0x02
106 #define F_FEC_NH_DEFER 0x04 /* running ordered control */
107 #define F_FEC_NH_NO_LDP 0x08 /* no ldp on this interface */
112 LIST_HEAD(, fec_nh
) nexthops
; /* fib nexthops */
113 struct lde_map_head downstream
; /* recv mappings */
114 struct lde_map_head upstream
; /* sent mappings */
116 uint32_t local_label
;
118 uint32_t pw_remote_status
;
120 void *data
; /* fec specific data */
123 #define CHUNK_SIZE 64
130 #define LDE_GC_INTERVAL 300
132 extern struct ldpd_conf
*ldeconf
;
133 extern struct fec_tree ft
;
134 extern struct nbr_tree lde_nbrs
;
135 extern struct event
*gc_timer
;
139 void lde_init(struct ldpd_init
*);
140 int lde_imsg_compose_parent(int, pid_t
, void *, uint16_t);
141 void lde_imsg_compose_parent_sync(int, pid_t
, void *, uint16_t);
142 int lde_imsg_compose_ldpe(int, uint32_t, pid_t
, void *, uint16_t);
143 int lde_acl_check(char *, int, union ldpd_addr
*, uint8_t);
144 uint32_t lde_update_label(struct fec_node
*);
145 void lde_free_label(uint32_t label
);
146 void lde_send_change_klabel(struct fec_node
*, struct fec_nh
*);
147 void lde_send_delete_klabel(struct fec_node
*, struct fec_nh
*);
148 void lde_fec2prefix(const struct fec
*fec
, struct prefix
*prefix
);
149 void lde_prefix2fec(const struct prefix
*prefix
, struct fec
*fec
);
150 void lde_fec2map(struct fec
*, struct map
*);
151 void lde_map2fec(struct map
*, struct in_addr
, struct fec
*);
152 void lde_send_labelmapping(struct lde_nbr
*, struct fec_node
*,
154 void lde_send_labelwithdraw(struct lde_nbr
*, struct fec_node
*,
155 struct map
*, struct status_tlv
*);
156 void lde_send_labelwithdraw_wcard(struct lde_nbr
*, uint32_t);
157 void lde_send_labelwithdraw_twcard_prefix(struct lde_nbr
*,
159 void lde_send_labelwithdraw_twcard_pwid(struct lde_nbr
*, uint16_t,
161 void lde_send_labelwithdraw_pwid_wcard(struct lde_nbr
*, uint16_t,
163 void lde_send_labelrelease(struct lde_nbr
*, struct fec_node
*,
164 struct map
*, uint32_t);
165 void lde_send_labelrequest(struct lde_nbr
*, struct fec_node
*,
167 void lde_send_labelrequest_wcard(struct lde_nbr
*, uint16_t af
);
168 void lde_send_notification(struct lde_nbr
*, uint32_t, uint32_t,
170 void lde_send_notification_eol_prefix(struct lde_nbr
*, int);
171 void lde_send_notification_eol_pwid(struct lde_nbr
*, uint16_t);
172 struct lde_nbr
*lde_nbr_find_by_lsrid(struct in_addr
);
173 struct lde_nbr
*lde_nbr_find_by_addr(int, union ldpd_addr
*);
174 struct lde_map
*lde_map_add(struct lde_nbr
*, struct fec_node
*, int);
175 void lde_map_del(struct lde_nbr
*, struct lde_map
*, int);
176 struct fec
*lde_map_pending_add(struct lde_nbr
*, struct fec_node
*);
177 void lde_map_pending_del(struct lde_nbr
*, struct fec
*);
178 struct lde_req
*lde_req_add(struct lde_nbr
*, struct fec
*, int);
179 void lde_req_del(struct lde_nbr
*, struct lde_req
*, int);
180 struct lde_wdraw
*lde_wdraw_add(struct lde_nbr
*, struct fec_node
*);
181 void lde_wdraw_del(struct lde_nbr
*, struct lde_wdraw
*);
182 void lde_change_egress_label(int);
183 void lde_change_allocate_filter(int);
184 void lde_change_advertise_filter(int);
185 void lde_change_accept_filter(int);
186 void lde_change_expnull_for_filter(int);
187 void lde_route_update(struct iface
*, int);
188 void lde_route_update_release(struct iface
*, int);
189 void lde_route_update_release_all(int);
190 struct lde_addr
*lde_address_find(struct lde_nbr
*, int,
192 void lde_allow_broken_lsp_update(int new_config
);
195 void fec_init(struct fec_tree
*);
196 struct fec
*fec_find(struct fec_tree
*, struct fec
*);
197 int fec_insert(struct fec_tree
*, struct fec
*);
198 int fec_remove(struct fec_tree
*, struct fec
*);
199 void fec_clear(struct fec_tree
*, void (*)(void *));
201 void fec_snap(struct lde_nbr
*);
202 void fec_tree_clear(void);
203 struct fec_nh
*fec_nh_find(struct fec_node
*, int, union ldpd_addr
*,
204 ifindex_t
, uint8_t, unsigned short);
205 void lde_kernel_insert(struct fec
*, int, union ldpd_addr
*,
206 ifindex_t
, uint8_t, unsigned short, int, void *);
207 void lde_kernel_remove(struct fec
*, int, union ldpd_addr
*,
208 ifindex_t
, uint8_t, unsigned short);
209 void lde_kernel_update(struct fec
*);
210 void lde_check_mapping(struct map
*, struct lde_nbr
*, int);
211 void lde_check_request(struct map
*, struct lde_nbr
*);
212 void lde_check_request_wcard(struct map
*, struct lde_nbr
*);
213 void lde_check_release(struct map
*, struct lde_nbr
*);
214 void lde_check_release_wcard(struct map
*, struct lde_nbr
*);
215 void lde_check_withdraw(struct map
*, struct lde_nbr
*);
216 void lde_check_withdraw_wcard(struct map
*, struct lde_nbr
*);
217 int lde_wildcard_apply(struct map
*, struct fec
*,
219 void lde_gc_timer(struct event
*thread
);
220 void lde_gc_start_timer(void);
221 void lde_gc_stop_timer(void);
224 struct l2vpn
*l2vpn_new(const char *);
225 struct l2vpn
*l2vpn_find(struct ldpd_conf
*, const char *);
226 void l2vpn_del(struct l2vpn
*);
227 void l2vpn_init(struct l2vpn
*);
228 void l2vpn_exit(struct l2vpn
*);
229 struct l2vpn_if
*l2vpn_if_new(struct l2vpn
*, const char *);
230 struct l2vpn_if
*l2vpn_if_find(struct l2vpn
*, const char *);
231 void l2vpn_if_update_info(struct l2vpn_if
*, struct kif
*);
232 void l2vpn_if_update(struct l2vpn_if
*);
233 struct l2vpn_pw
*l2vpn_pw_new(struct l2vpn
*, const char *);
234 struct l2vpn_pw
*l2vpn_pw_find(struct l2vpn
*, const char *);
235 struct l2vpn_pw
*l2vpn_pw_find_active(struct l2vpn
*, const char *);
236 struct l2vpn_pw
*l2vpn_pw_find_inactive(struct l2vpn
*, const char *);
237 void l2vpn_pw_update_info(struct l2vpn_pw
*, struct kif
*);
238 void l2vpn_pw_init(struct l2vpn_pw
*);
239 void l2vpn_pw_exit(struct l2vpn_pw
*);
240 void l2vpn_pw_reset(struct l2vpn_pw
*);
241 int l2vpn_pw_ok(struct l2vpn_pw
*, struct fec_nh
*);
242 int l2vpn_pw_negotiate(struct lde_nbr
*, struct fec_node
*,
244 void l2vpn_send_pw_status(struct lde_nbr
*, uint32_t, struct fec
*);
245 void l2vpn_send_pw_status_wcard(struct lde_nbr
*, uint32_t,
247 void l2vpn_recv_pw_status(struct lde_nbr
*, struct notify_msg
*);
248 void l2vpn_recv_pw_status_wcard(struct lde_nbr
*,
249 struct notify_msg
*);
250 int l2vpn_pw_status_update(struct zapi_pw_status
*);
251 void l2vpn_pw_ctl(pid_t
);
252 void l2vpn_binding_ctl(pid_t
);