]> git.proxmox.com Git - mirror_frr.git/blob - zebra/interface.h
isisd: implement the 'lsp-too-large' notification
[mirror_frr.git] / zebra / interface.h
1
2 /* Interface function header.
3 * Copyright (C) 1999 Kunihiro Ishiguro
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 along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #ifndef _ZEBRA_INTERFACE_H
23 #define _ZEBRA_INTERFACE_H
24
25 #include "redistribute.h"
26 #include "vrf.h"
27 #include "hook.h"
28
29 #include "zebra/zebra_l2.h"
30
31 /* For interface multicast configuration. */
32 #define IF_ZEBRA_MULTICAST_UNSPEC 0
33 #define IF_ZEBRA_MULTICAST_ON 1
34 #define IF_ZEBRA_MULTICAST_OFF 2
35
36 /* For interface shutdown configuration. */
37 #define IF_ZEBRA_SHUTDOWN_OFF 0
38 #define IF_ZEBRA_SHUTDOWN_ON 1
39
40 #if defined(HAVE_RTADV)
41 /* Router advertisement parameter. From RFC4861, RFC6275 and RFC4191. */
42 struct rtadvconf {
43 /* A flag indicating whether or not the router sends periodic Router
44 Advertisements and responds to Router Solicitations.
45 Default: FALSE */
46 int AdvSendAdvertisements;
47
48 /* The maximum time allowed between sending unsolicited multicast
49 Router Advertisements from the interface, in milliseconds.
50 MUST be no less than 70 ms [RFC6275 7.5] and no greater
51 than 1800000 ms [RFC4861 6.2.1].
52
53 Default: 600000 milliseconds */
54 int MaxRtrAdvInterval;
55 #define RTADV_MAX_RTR_ADV_INTERVAL 600000
56
57 /* The minimum time allowed between sending unsolicited multicast
58 Router Advertisements from the interface, in milliseconds.
59 MUST be no less than 30 ms [RFC6275 7.5].
60 MUST be no greater than .75 * MaxRtrAdvInterval.
61
62 Default: 0.33 * MaxRtrAdvInterval */
63 int MinRtrAdvInterval; /* This field is currently unused. */
64 #define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)
65
66 /* Unsolicited Router Advertisements' interval timer. */
67 int AdvIntervalTimer;
68
69 /* The TRUE/FALSE value to be placed in the "Managed address
70 configuration" flag field in the Router Advertisement. See
71 [ADDRCONF].
72
73 Default: FALSE */
74 int AdvManagedFlag;
75
76
77 /* The TRUE/FALSE value to be placed in the "Other stateful
78 configuration" flag field in the Router Advertisement. See
79 [ADDRCONF].
80
81 Default: FALSE */
82 int AdvOtherConfigFlag;
83
84 /* The value to be placed in MTU options sent by the router. A
85 value of zero indicates that no MTU options are sent.
86
87 Default: 0 */
88 int AdvLinkMTU;
89
90
91 /* The value to be placed in the Reachable Time field in the Router
92 Advertisement messages sent by the router. The value zero means
93 unspecified (by this router). MUST be no greater than 3,600,000
94 milliseconds (1 hour).
95
96 Default: 0 */
97 uint32_t AdvReachableTime;
98 #define RTADV_MAX_REACHABLE_TIME 3600000
99
100 /* The value to be placed in the Retrans Timer field in the Router
101 Advertisement messages sent by the router. The value zero means
102 unspecified (by this router).
103
104 Default: 0 */
105 int AdvRetransTimer;
106
107 /* The default value to be placed in the Cur Hop Limit field in the
108 Router Advertisement messages sent by the router. The value
109 should be set to that current diameter of the Internet. The
110 value zero means unspecified (by this router).
111
112 Default: The value specified in the "Assigned Numbers" RFC
113 [ASSIGNED] that was in effect at the time of implementation. */
114 int AdvCurHopLimit;
115
116 /* The value to be placed in the Router Lifetime field of Router
117 Advertisements sent from the interface, in seconds. MUST be
118 either zero or between MaxRtrAdvInterval and 9000 seconds. A
119 value of zero indicates that the router is not to be used as a
120 default router.
121
122 Default: 3 * MaxRtrAdvInterval */
123 int AdvDefaultLifetime;
124 #define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
125
126 /* A list of prefixes to be placed in Prefix Information options in
127 Router Advertisement messages sent from the interface.
128
129 Default: all prefixes that the router advertises via routing
130 protocols as being on-link for the interface from which the
131 advertisement is sent. The link-local prefix SHOULD NOT be
132 included in the list of advertised prefixes. */
133 struct list *AdvPrefixList;
134
135 /* The TRUE/FALSE value to be placed in the "Home agent"
136 flag field in the Router Advertisement. See [RFC6275 7.1].
137
138 Default: FALSE */
139 int AdvHomeAgentFlag;
140 #ifndef ND_RA_FLAG_HOME_AGENT
141 #define ND_RA_FLAG_HOME_AGENT 0x20
142 #endif
143
144 /* The value to be placed in Home Agent Information option if Home
145 Flag is set.
146 Default: 0 */
147 int HomeAgentPreference;
148
149 /* The value to be placed in Home Agent Information option if Home
150 Flag is set. Lifetime (seconds) MUST not be greater than 18.2
151 hours.
152 The value 0 has special meaning: use of AdvDefaultLifetime value.
153
154 Default: 0 */
155 int HomeAgentLifetime;
156 #define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
157
158 /* The TRUE/FALSE value to insert or not an Advertisement Interval
159 option. See [RFC 6275 7.3]
160
161 Default: FALSE */
162 int AdvIntervalOption;
163
164 /* The value to be placed in the Default Router Preference field of
165 a router advertisement. See [RFC 4191 2.1 & 2.2]
166
167 Default: 0 (medium) */
168 int DefaultPreference;
169 #define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
170
171 uint8_t inFastRexmit; /* True if we're rexmits faster than usual */
172
173 /* Track if RA was configured by BGP or by the Operator or both */
174 uint8_t ra_configured; /* Was RA configured? */
175 #define BGP_RA_CONFIGURED (1<<0) /* BGP configured RA? */
176 #define VTY_RA_CONFIGURED (1<<1) /* Operator configured RA? */
177 #define VTY_RA_INTERVAL_CONFIGURED (1<<2) /* Operator configured RA interval */
178 int NumFastReXmitsRemain; /* Loaded first with number of fast
179 rexmits to do */
180
181 #define RTADV_FAST_REXMIT_PERIOD 1 /* 1 sec */
182 #define RTADV_NUM_FAST_REXMITS 4 /* Fast Rexmit RA 4 times on certain events */
183 };
184
185 #endif /* HAVE_RTADV */
186
187 /* Zebra interface type - ones of interest. */
188 typedef enum {
189 ZEBRA_IF_OTHER = 0, /* Anything else */
190 ZEBRA_IF_VXLAN, /* VxLAN interface */
191 ZEBRA_IF_VRF, /* VRF device */
192 ZEBRA_IF_BRIDGE, /* bridge device */
193 ZEBRA_IF_VLAN, /* VLAN sub-interface */
194 ZEBRA_IF_MACVLAN, /* MAC VLAN interface*/
195 ZEBRA_IF_VETH, /* VETH interface*/
196 ZEBRA_IF_BOND, /* Bond */
197 ZEBRA_IF_BOND_SLAVE, /* Bond */
198 } zebra_iftype_t;
199
200 /* Zebra "slave" interface type */
201 typedef enum {
202 ZEBRA_IF_SLAVE_NONE, /* Not a slave */
203 ZEBRA_IF_SLAVE_VRF, /* Member of a VRF */
204 ZEBRA_IF_SLAVE_BRIDGE, /* Member of a bridge */
205 ZEBRA_IF_SLAVE_BOND, /* Bond member */
206 ZEBRA_IF_SLAVE_OTHER, /* Something else - e.g., bond slave */
207 } zebra_slave_iftype_t;
208
209 struct irdp_interface;
210
211 /* `zebra' daemon local interface structure. */
212 struct zebra_if {
213 /* Shutdown configuration. */
214 uint8_t shutdown;
215
216 /* Multicast configuration. */
217 uint8_t multicast;
218
219 /* Router advertise configuration. */
220 uint8_t rtadv_enable;
221
222 /* Installed addresses chains tree. */
223 struct route_table *ipv4_subnets;
224
225 /* Information about up/down changes */
226 unsigned int up_count;
227 char up_last[QUAGGA_TIMESTAMP_LEN];
228 unsigned int down_count;
229 char down_last[QUAGGA_TIMESTAMP_LEN];
230
231 #if defined(HAVE_RTADV)
232 struct rtadvconf rtadv;
233 unsigned int ra_sent, ra_rcvd;
234 #endif /* HAVE_RTADV */
235
236 struct irdp_interface *irdp;
237
238 #ifdef HAVE_STRUCT_SOCKADDR_DL
239 union {
240 /* note that sdl_storage is never accessed, it only exists to
241 * make space.
242 * all actual uses refer to sdl - but use sizeof(sdl_storage)!
243 * this fits
244 * best with C aliasing rules. */
245 struct sockaddr_dl sdl;
246 struct sockaddr_storage sdl_storage;
247 };
248 #endif
249
250 #ifdef SUNOS_5
251 /* the real IFF_UP state of the primary interface.
252 * need this to differentiate between all interfaces being
253 * down (but primary still plumbed) and primary having gone
254 * ~IFF_UP, and all addresses gone.
255 */
256 uint8_t primary_state;
257 #endif /* SUNOS_5 */
258
259 /* ptm enable configuration */
260 uint8_t ptm_enable;
261
262 /* Zebra interface and "slave" interface type */
263 zebra_iftype_t zif_type;
264 zebra_slave_iftype_t zif_slave_type;
265
266 /* Additional L2 info, depends on zif_type */
267 union zebra_l2if_info l2info;
268
269 /* For members of a bridge, link to bridge. */
270 /* Note: If additional fields become necessary, this can be modified to
271 * be a pointer to a dynamically allocd struct.
272 */
273 struct zebra_l2info_brslave brslave_info;
274
275 struct zebra_l2info_bondslave bondslave_info;
276
277 /* Link fields - for sub-interfaces. */
278 ifindex_t link_ifindex;
279 struct interface *link;
280
281 struct thread *speed_update;
282
283 /*
284 * Does this interface have a v6 to v4 ll neighbor entry
285 * for bgp unnumbered?
286 */
287 bool v6_2_v4_ll_neigh_entry;
288 char neigh_mac[6];
289 struct in6_addr v6_2_v4_ll_addr6;
290 };
291
292 DECLARE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp),
293 (vty, ifp))
294 DECLARE_HOOK(zebra_if_config_wr, (struct vty * vty, struct interface *ifp),
295 (vty, ifp))
296
297 static inline void zebra_if_set_ziftype(struct interface *ifp,
298 zebra_iftype_t zif_type,
299 zebra_slave_iftype_t zif_slave_type)
300 {
301 struct zebra_if *zif;
302
303 zif = (struct zebra_if *)ifp->info;
304 zif->zif_type = zif_type;
305 zif->zif_slave_type = zif_slave_type;
306 }
307
308 #define IS_ZEBRA_IF_VRF(ifp) \
309 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VRF)
310
311 #define IS_ZEBRA_IF_BRIDGE(ifp) \
312 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_BRIDGE)
313
314 #define IS_ZEBRA_IF_VLAN(ifp) \
315 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VLAN)
316
317 #define IS_ZEBRA_IF_VXLAN(ifp) \
318 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VXLAN)
319
320 #define IS_ZEBRA_IF_MACVLAN(ifp) \
321 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_MACVLAN)
322
323 #define IS_ZEBRA_IF_VETH(ifp) \
324 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VETH)
325
326 #define IS_ZEBRA_IF_BRIDGE_SLAVE(ifp) \
327 (((struct zebra_if *)(ifp->info))->zif_slave_type \
328 == ZEBRA_IF_SLAVE_BRIDGE)
329
330 #define IS_ZEBRA_IF_VRF_SLAVE(ifp) \
331 (((struct zebra_if *)(ifp->info))->zif_slave_type == ZEBRA_IF_SLAVE_VRF)
332
333 #define IS_ZEBRA_IF_BOND_SLAVE(ifp) \
334 (((struct zebra_if *)(ifp->info))->zif_slave_type \
335 == ZEBRA_IF_SLAVE_BOND)
336
337 extern void zebra_if_init(void);
338
339 extern struct interface *if_lookup_by_index_per_ns(struct zebra_ns *, uint32_t);
340 extern struct interface *if_lookup_by_name_per_ns(struct zebra_ns *,
341 const char *);
342 extern struct interface *if_link_per_ns(struct zebra_ns *, struct interface *);
343 extern const char *ifindex2ifname_per_ns(struct zebra_ns *, unsigned int);
344
345 extern void if_unlink_per_ns(struct interface *);
346 extern void if_nbr_mac_to_ipv4ll_neigh_update(struct interface *fip,
347 char mac[6],
348 struct in6_addr *address,
349 int add);
350 extern void if_nbr_ipv6ll_to_ipv4ll_neigh_update(struct interface *ifp,
351 struct in6_addr *address,
352 int add);
353 extern void if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(struct interface *ifp);
354 extern void if_delete_update(struct interface *ifp);
355 extern void if_add_update(struct interface *ifp);
356 extern void if_up(struct interface *);
357 extern void if_down(struct interface *);
358 extern void if_refresh(struct interface *);
359 extern void if_flags_update(struct interface *, uint64_t);
360 extern int if_subnet_add(struct interface *, struct connected *);
361 extern int if_subnet_delete(struct interface *, struct connected *);
362 extern int ipv6_address_configured(struct interface *ifp);
363 extern void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id);
364 extern void zebra_if_update_link(struct interface *ifp, ifindex_t link_ifindex,
365 ns_id_t ns_id);
366 extern void zebra_if_update_all_links(void);
367
368 extern void vrf_add_update(struct vrf *vrfp);
369
370 #ifdef HAVE_PROC_NET_DEV
371 extern void ifstat_update_proc(void);
372 #endif /* HAVE_PROC_NET_DEV */
373 #ifdef HAVE_NET_RT_IFLIST
374 extern void ifstat_update_sysctl(void);
375
376 #endif /* HAVE_NET_RT_IFLIST */
377 #ifdef HAVE_PROC_NET_DEV
378 extern int interface_list_proc(void);
379 #endif /* HAVE_PROC_NET_DEV */
380 #ifdef HAVE_PROC_NET_IF_INET6
381 extern int ifaddr_proc_ipv6(void);
382 #endif /* HAVE_PROC_NET_IF_INET6 */
383
384 #endif /* _ZEBRA_INTERFACE_H */