]> git.proxmox.com Git - mirror_frr.git/blame - ldpd/lde.h
ldpd: remove security check to allow operation on unnumbered interfaces
[mirror_frr.git] / ldpd / lde.h
CommitLineData
8429abe0
RW
1/* $OpenBSD$ */
2
3/*
4 * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
5 * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
6 * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
7 *
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21#ifndef _LDE_H_
22#define _LDE_H_
23
eac6e3f0
RW
24#include "openbsd-queue.h"
25#include "openbsd-tree.h"
8429abe0
RW
26
27enum fec_type {
28 FEC_TYPE_IPV4,
29 FEC_TYPE_IPV6,
30 FEC_TYPE_PWID
31};
32
33struct fec {
34 RB_ENTRY(fec) entry;
35 enum fec_type type;
36 union {
37 struct {
38 struct in_addr prefix;
39 uint8_t prefixlen;
40 } ipv4;
41 struct {
42 struct in6_addr prefix;
43 uint8_t prefixlen;
44 } ipv6;
45 struct {
46 uint16_t type;
47 uint32_t pwid;
48 struct in_addr lsr_id;
49 } pwid;
50 } u;
51};
52RB_HEAD(fec_tree, fec);
53RB_PROTOTYPE(fec_tree, fec, entry, fec_compare)
54
55/* request entries */
56struct lde_req {
57 struct fec fec;
58 uint32_t msg_id;
59};
60
61/* mapping entries */
62struct lde_map {
63 struct fec fec;
64 LIST_ENTRY(lde_map) entry;
65 struct lde_nbr *nexthop;
66 struct map map;
67};
68
69/* withdraw entries */
70struct lde_wdraw {
71 struct fec fec;
72 uint32_t label;
73};
74
75/* Addresses belonging to neighbor */
76struct lde_addr {
77 TAILQ_ENTRY(lde_addr) entry;
78 int af;
79 union ldpd_addr addr;
80};
81
82/* just the info LDE needs */
83struct lde_nbr {
84 RB_ENTRY(lde_nbr) entry;
85 uint32_t peerid;
86 struct in_addr id;
87 int v4_enabled; /* announce/process v4 msgs */
88 int v6_enabled; /* announce/process v6 msgs */
89 struct fec_tree recv_req;
90 struct fec_tree sent_req;
91 struct fec_tree recv_map;
92 struct fec_tree sent_map;
93 struct fec_tree sent_wdraw;
94 TAILQ_HEAD(, lde_addr) addr_list;
95};
96RB_HEAD(nbr_tree, lde_nbr);
97RB_PROTOTYPE(nbr_tree, lde_nbr, entry, lde_nbr_compare)
98
99struct fec_nh {
100 LIST_ENTRY(fec_nh) entry;
101 int af;
102 union ldpd_addr nexthop;
103 uint32_t remote_label;
104 uint8_t priority;
134970a2 105 uint8_t flags;
8429abe0 106};
134970a2 107#define F_FEC_NH_NEW 0x01
8429abe0
RW
108
109struct fec_node {
110 struct fec fec;
111
112 LIST_HEAD(, fec_nh) nexthops; /* fib nexthops */
113 LIST_HEAD(, lde_map) downstream; /* recv mappings */
114 LIST_HEAD(, lde_map) upstream; /* sent mappings */
115
116 uint32_t local_label;
117 void *data; /* fec specific data */
118};
119
120#define LDE_GC_INTERVAL 300
121
122extern struct ldpd_conf *ldeconf;
123extern struct fec_tree ft;
124extern struct nbr_tree lde_nbrs;
eac6e3f0 125extern struct thread *gc_timer;
8429abe0
RW
126
127/* lde.c */
eac6e3f0
RW
128void lde(const char *, const char *);
129int lde_imsg_compose_parent(int, pid_t, void *, uint16_t);
8429abe0
RW
130int lde_imsg_compose_ldpe(int, uint32_t, pid_t, void *, uint16_t);
131uint32_t lde_assign_label(void);
132void lde_send_change_klabel(struct fec_node *, struct fec_nh *);
133void lde_send_delete_klabel(struct fec_node *, struct fec_nh *);
134void lde_fec2map(struct fec *, struct map *);
135void lde_map2fec(struct map *, struct in_addr, struct fec *);
136void lde_send_labelmapping(struct lde_nbr *, struct fec_node *,
137 int);
138void lde_send_labelwithdraw(struct lde_nbr *, struct fec_node *,
139 uint32_t, struct status_tlv *);
140void lde_send_labelwithdraw_all(struct fec_node *, uint32_t);
141void lde_send_labelrelease(struct lde_nbr *, struct fec_node *,
142 uint32_t);
143void lde_send_notification(uint32_t, uint32_t, uint32_t, uint16_t);
144struct lde_nbr *lde_nbr_find_by_lsrid(struct in_addr);
145struct lde_nbr *lde_nbr_find_by_addr(int, union ldpd_addr *);
146struct lde_map *lde_map_add(struct lde_nbr *, struct fec_node *, int);
147void lde_map_del(struct lde_nbr *, struct lde_map *, int);
148struct lde_req *lde_req_add(struct lde_nbr *, struct fec *, int);
149void lde_req_del(struct lde_nbr *, struct lde_req *, int);
150struct lde_wdraw *lde_wdraw_add(struct lde_nbr *, struct fec_node *);
151void lde_wdraw_del(struct lde_nbr *, struct lde_wdraw *);
152void lde_change_egress_label(int, int);
153struct lde_addr *lde_address_find(struct lde_nbr *, int,
154 union ldpd_addr *);
155
156/* lde_lib.c */
157void fec_init(struct fec_tree *);
158struct fec *fec_find(struct fec_tree *, struct fec *);
159int fec_insert(struct fec_tree *, struct fec *);
160int fec_remove(struct fec_tree *, struct fec *);
161void fec_clear(struct fec_tree *, void (*)(void *));
162void rt_dump(pid_t);
163void fec_snap(struct lde_nbr *);
164void fec_tree_clear(void);
165struct fec_nh *fec_nh_find(struct fec_node *, int, union ldpd_addr *,
166 uint8_t);
167uint32_t egress_label(enum fec_type);
168void lde_kernel_insert(struct fec *, int, union ldpd_addr *,
169 uint8_t, int, void *);
170void lde_kernel_remove(struct fec *, int, union ldpd_addr *,
171 uint8_t);
134970a2 172void lde_kernel_reevaluate(struct fec *);
8429abe0
RW
173void lde_check_mapping(struct map *, struct lde_nbr *);
174void lde_check_request(struct map *, struct lde_nbr *);
175void lde_check_release(struct map *, struct lde_nbr *);
176void lde_check_release_wcard(struct map *, struct lde_nbr *);
177void lde_check_withdraw(struct map *, struct lde_nbr *);
178void lde_check_withdraw_wcard(struct map *, struct lde_nbr *);
eac6e3f0 179int lde_gc_timer(struct thread *);
8429abe0
RW
180void lde_gc_start_timer(void);
181void lde_gc_stop_timer(void);
182
183/* l2vpn.c */
184struct l2vpn *l2vpn_new(const char *);
185struct l2vpn *l2vpn_find(struct ldpd_conf *, const char *);
186void l2vpn_del(struct l2vpn *);
187void l2vpn_init(struct l2vpn *);
188void l2vpn_exit(struct l2vpn *);
189struct l2vpn_if *l2vpn_if_new(struct l2vpn *, struct kif *);
190struct l2vpn_if *l2vpn_if_find(struct l2vpn *, unsigned int);
eac6e3f0 191struct l2vpn_if *l2vpn_if_find_name(struct l2vpn *, const char *);
8429abe0
RW
192struct l2vpn_pw *l2vpn_pw_new(struct l2vpn *, struct kif *);
193struct l2vpn_pw *l2vpn_pw_find(struct l2vpn *, unsigned int);
eac6e3f0 194struct l2vpn_pw *l2vpn_pw_find_name(struct l2vpn *, const char *);
8429abe0
RW
195void l2vpn_pw_init(struct l2vpn_pw *);
196void l2vpn_pw_exit(struct l2vpn_pw *);
197void l2vpn_pw_reset(struct l2vpn_pw *);
198int l2vpn_pw_ok(struct l2vpn_pw *, struct fec_nh *);
199int l2vpn_pw_negotiate(struct lde_nbr *, struct fec_node *,
200 struct map *);
201void l2vpn_send_pw_status(uint32_t, uint32_t, struct fec *);
202void l2vpn_recv_pw_status(struct lde_nbr *, struct notify_msg *);
203void l2vpn_sync_pws(int, union ldpd_addr *);
204void l2vpn_pw_ctl(pid_t);
205void l2vpn_binding_ctl(pid_t);
206
207#endif /* _LDE_H_ */