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