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