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