]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_mpls.h
Quagga: Static LSP configuration
[mirror_frr.git] / zebra / zebra_mpls.h
1 /*
2 * Zebra MPLS Data structures and definitions
3 * Copyright (C) 2015 Cumulus Networks, Inc.
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23 #ifndef _ZEBRA_MPLS_H
24 #define _ZEBRA_MPLS_H
25
26 #include "prefix.h"
27 #include "table.h"
28 #include "queue.h"
29 #include "hash.h"
30 #include "jhash.h"
31 #include "nexthop.h"
32 #include "vty.h"
33 #include "memory.h"
34 #include "mpls.h"
35 #include "zebra/zserv.h"
36
37
38 /* Definitions and macros. */
39
40 #define NHLFE_FAMILY(nhlfe) \
41 (((nhlfe)->nexthop->type == NEXTHOP_TYPE_IPV6 || \
42 (nhlfe)->nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) ? AF_INET6 : AF_INET)
43
44
45 /* Typedefs */
46
47 typedef struct zebra_ile_t_ zebra_ile_t;
48 typedef struct zebra_snhlfe_t_ zebra_snhlfe_t;
49 typedef struct zebra_slsp_t_ zebra_slsp_t;
50 typedef struct zebra_nhlfe_t_ zebra_nhlfe_t;
51 typedef struct zebra_lsp_t_ zebra_lsp_t;
52
53 /* LSP types. */
54 enum lsp_types_t
55 {
56 ZEBRA_LSP_INVALID = 0, /* Invalid. */
57 ZEBRA_LSP_STATIC = 1, /* Static LSP. */
58 };
59
60 /*
61 * (Outgoing) nexthop label forwarding entry configuration
62 */
63 struct zebra_snhlfe_t_
64 {
65 /* Nexthop information */
66 enum nexthop_types_t gtype;
67 union g_addr gate;
68 char *ifname;
69 ifindex_t ifindex;
70
71 /* Out label. */
72 mpls_label_t out_label;
73
74 /* Backpointer to base entry. */
75 zebra_slsp_t *slsp;
76
77 /* Pointers to more outgoing information for same in-label */
78 zebra_snhlfe_t *next;
79 zebra_snhlfe_t *prev;
80 };
81
82 /*
83 * (Outgoing) nexthop label forwarding entry
84 */
85 struct zebra_nhlfe_t_
86 {
87 /* Type of entry - static etc. */
88 enum lsp_types_t type;
89
90 /* Nexthop information (with outgoing label) */
91 struct nexthop *nexthop;
92
93 /* Backpointer to base entry. */
94 zebra_lsp_t *lsp;
95
96 /* Runtime info - flags, pointers etc. */
97 u_int32_t flags;
98 #define NHLFE_FLAG_CHANGED (1 << 0)
99 #define NHLFE_FLAG_SELECTED (1 << 1)
100 #define NHLFE_FLAG_MULTIPATH (1 << 2)
101 #define NHLFE_FLAG_DELETED (1 << 3)
102 #define NHLFE_FLAG_INSTALLED (1 << 4)
103
104 zebra_nhlfe_t *next;
105 zebra_nhlfe_t *prev;
106 u_char distance;
107 };
108
109 /*
110 * Incoming label entry
111 */
112 struct zebra_ile_t_
113 {
114 mpls_label_t in_label;
115 };
116
117 /*
118 * Label swap entry static configuration.
119 */
120 struct zebra_slsp_t_
121 {
122 /* Incoming label */
123 zebra_ile_t ile;
124
125 /* List of outgoing nexthop static configuration */
126 zebra_snhlfe_t *snhlfe_list;
127
128 };
129
130 /*
131 * Label swap entry (ile -> list of nhlfes)
132 */
133 struct zebra_lsp_t_
134 {
135 /* Incoming label */
136 zebra_ile_t ile;
137
138 /* List of NHLFE, pointer to best and num equal-cost. */
139 zebra_nhlfe_t *nhlfe_list;
140 zebra_nhlfe_t *best_nhlfe;
141 u_int32_t num_ecmp;
142
143 /* Flags */
144 u_int32_t flags;
145 #define LSP_FLAG_SCHEDULED (1 << 0)
146 #define LSP_FLAG_INSTALLED (1 << 1)
147 #define LSP_FLAG_CHANGED (1 << 2)
148
149 /* Address-family of NHLFE - saved here for delete. All NHLFEs */
150 /* have to be of the same AF */
151 u_char addr_family;
152 };
153
154
155 /* Function declarations. */
156
157 /*
158 * Check that the label values used in LSP creation are consistent. The
159 * main criteria is that if there is ECMP, the label operation must still
160 * be consistent - i.e., all paths either do a swap or do PHP. This is due
161 * to current HW restrictions.
162 */
163 int
164 zebra_mpls_lsp_label_consistent (struct zebra_vrf *zvrf, mpls_label_t in_label,
165 mpls_label_t out_label, enum nexthop_types_t gtype,
166 union g_addr *gate, char *ifname, ifindex_t ifindex);
167
168 /*
169 * Add static LSP entry. This may be the first entry for this incoming label
170 * or an additional nexthop; an existing entry may also have outgoing label
171 * changed.
172 * Note: The label operation (swap or PHP) is common for the LSP entry (all
173 * NHLFEs).
174 */
175 int
176 zebra_mpls_static_lsp_add (struct zebra_vrf *zvrf, mpls_label_t in_label,
177 mpls_label_t out_label, enum nexthop_types_t gtype,
178 union g_addr *gate, char *ifname, ifindex_t ifindex);
179
180 /*
181 * Delete static LSP entry. This may be the delete of one particular
182 * NHLFE for this incoming label or the delete of the entire entry (i.e.,
183 * all NHLFEs).
184 * NOTE: Delete of the only NHLFE will also end up deleting the entire
185 * LSP configuration.
186 */
187 int
188 zebra_mpls_static_lsp_del (struct zebra_vrf *zvrf, mpls_label_t in_label,
189 enum nexthop_types_t gtype, union g_addr *gate,
190 char *ifname, ifindex_t ifindex);
191
192 /*
193 * Display MPLS LSP configuration of all static LSPs (VTY command handler).
194 */
195 int
196 zebra_mpls_write_lsp_config (struct vty *vty, struct zebra_vrf *zvrf);
197
198 /*
199 * Allocate MPLS tables for this VRF.
200 * NOTE: Currently supported only for default VRF.
201 */
202 void
203 zebra_mpls_init_tables (struct zebra_vrf *zvrf);
204
205 /*
206 * Global MPLS initialization.
207 */
208 void
209 zebra_mpls_init (void);
210
211 #endif /*_ZEBRA_MPLS_H */