]> git.proxmox.com Git - mirror_frr.git/blame - zebra/interface.h
vrrpd: add support for VRRPv2
[mirror_frr.git] / zebra / interface.h
CommitLineData
b9368db9 1
718e3744 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 *
896014f4
DL
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
718e3744 20 */
21
5b73a671 22#ifndef _ZEBRA_INTERFACE_H
23#define _ZEBRA_INTERFACE_H
24
25#include "redistribute.h"
12f6fb97 26#include "vrf.h"
2eb27eec 27#include "hook.h"
ca776988 28
6675513d 29#include "zebra/zebra_l2.h"
30
51e94aa7
EDP
31#ifdef __cplusplus
32extern "C" {
33#endif
34
718e3744 35/* For interface multicast configuration. */
36#define IF_ZEBRA_MULTICAST_UNSPEC 0
37#define IF_ZEBRA_MULTICAST_ON 1
38#define IF_ZEBRA_MULTICAST_OFF 2
39
40/* For interface shutdown configuration. */
bfac8dcd 41#define IF_ZEBRA_SHUTDOWN_OFF 0
718e3744 42#define IF_ZEBRA_SHUTDOWN_ON 1
718e3744 43
d62a17ae 44#if defined(HAVE_RTADV)
6eb0c5ab 45/* Router advertisement parameter. From RFC4861, RFC6275 and RFC4191. */
d62a17ae 46struct rtadvconf {
47 /* A flag indicating whether or not the router sends periodic Router
48 Advertisements and responds to Router Solicitations.
49 Default: FALSE */
50 int AdvSendAdvertisements;
51
52 /* The maximum time allowed between sending unsolicited multicast
53 Router Advertisements from the interface, in milliseconds.
54 MUST be no less than 70 ms [RFC6275 7.5] and no greater
55 than 1800000 ms [RFC4861 6.2.1].
56
57 Default: 600000 milliseconds */
58 int MaxRtrAdvInterval;
7cee1bb1 59#define RTADV_MAX_RTR_ADV_INTERVAL 600000
718e3744 60
d62a17ae 61 /* The minimum time allowed between sending unsolicited multicast
62 Router Advertisements from the interface, in milliseconds.
63 MUST be no less than 30 ms [RFC6275 7.5].
64 MUST be no greater than .75 * MaxRtrAdvInterval.
718e3744 65
d62a17ae 66 Default: 0.33 * MaxRtrAdvInterval */
67 int MinRtrAdvInterval; /* This field is currently unused. */
718e3744 68#define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)
69
d62a17ae 70 /* Unsolicited Router Advertisements' interval timer. */
71 int AdvIntervalTimer;
718e3744 72
d62a17ae 73 /* The TRUE/FALSE value to be placed in the "Managed address
74 configuration" flag field in the Router Advertisement. See
75 [ADDRCONF].
718e3744 76
d62a17ae 77 Default: FALSE */
78 int AdvManagedFlag;
718e3744 79
718e3744 80
d62a17ae 81 /* The TRUE/FALSE value to be placed in the "Other stateful
82 configuration" flag field in the Router Advertisement. See
83 [ADDRCONF].
718e3744 84
d62a17ae 85 Default: FALSE */
86 int AdvOtherConfigFlag;
718e3744 87
d62a17ae 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.
718e3744 90
d62a17ae 91 Default: 0 */
92 int AdvLinkMTU;
718e3744 93
718e3744 94
d62a17ae 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).
718e3744 99
d62a17ae 100 Default: 0 */
d7c0a89a 101 uint32_t AdvReachableTime;
d62a17ae 102#define RTADV_MAX_REACHABLE_TIME 3600000
718e3744 103
d62a17ae 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).
718e3744 107
d62a17ae 108 Default: 0 */
109 int AdvRetransTimer;
718e3744 110
d62a17ae 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).
718e3744 115
d62a17ae 116 Default: The value specified in the "Assigned Numbers" RFC
117 [ASSIGNED] that was in effect at the time of implementation. */
118 int AdvCurHopLimit;
718e3744 119
d62a17ae 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.
718e3744 125
d62a17ae 126 Default: 3 * MaxRtrAdvInterval */
127 int AdvDefaultLifetime;
d660f698 128#define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
718e3744 129
d62a17ae 130 /* A list of prefixes to be placed in Prefix Information options in
131 Router Advertisement messages sent from the interface.
718e3744 132
d62a17ae 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;
7cee1bb1 138
d62a17ae 139 /* The TRUE/FALSE value to be placed in the "Home agent"
140 flag field in the Router Advertisement. See [RFC6275 7.1].
7cee1bb1 141
d62a17ae 142 Default: FALSE */
143 int AdvHomeAgentFlag;
7cee1bb1 144#ifndef ND_RA_FLAG_HOME_AGENT
145#define ND_RA_FLAG_HOME_AGENT 0x20
146#endif
147
d62a17ae 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;
7cee1bb1 160#define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
161
d62a17ae 162 /* The TRUE/FALSE value to insert or not an Advertisement Interval
163 option. See [RFC 6275 7.3]
7cee1bb1 164
d62a17ae 165 Default: FALSE */
166 int AdvIntervalOption;
b60668d0 167
d62a17ae 168 /* The value to be placed in the Default Router Preference field of
169 a router advertisement. See [RFC 4191 2.1 & 2.2]
b60668d0 170
d62a17ae 171 Default: 0 (medium) */
172 int DefaultPreference;
b60668d0 173#define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
6c9678b4 174
3eb4fbb0
LS
175 /*
176 * List of recursive DNS servers to include in the RDNSS option.
177 * See [RFC8106 5.1]
178 *
179 * Default: empty list; do not emit RDNSS option
180 */
181 struct list *AdvRDNSSList;
182
183 /*
184 * List of DNS search domains to include in the DNSSL option.
185 * See [RFC8106 5.2]
186 *
187 * Default: empty list; do not emit DNSSL option
188 */
189 struct list *AdvDNSSLList;
190
d7c0a89a 191 uint8_t inFastRexmit; /* True if we're rexmits faster than usual */
3ea48364
DS
192
193 /* Track if RA was configured by BGP or by the Operator or both */
d7c0a89a 194 uint8_t ra_configured; /* Was RA configured? */
3ea48364
DS
195#define BGP_RA_CONFIGURED (1<<0) /* BGP configured RA? */
196#define VTY_RA_CONFIGURED (1<<1) /* Operator configured RA? */
197#define VTY_RA_INTERVAL_CONFIGURED (1<<2) /* Operator configured RA interval */
996c9314
LB
198 int NumFastReXmitsRemain; /* Loaded first with number of fast
199 rexmits to do */
6c9678b4
DD
200
201#define RTADV_FAST_REXMIT_PERIOD 1 /* 1 sec */
202#define RTADV_NUM_FAST_REXMITS 4 /* Fast Rexmit RA 4 times on certain events */
718e3744 203};
204
3eb4fbb0
LS
205struct rtadv_rdnss {
206 /* Address of recursive DNS server to advertise */
207 struct in6_addr addr;
208
209 /*
210 * Lifetime in seconds; all-ones means infinity, zero
211 * stop using it.
212 */
213 uint32_t lifetime;
214
215 /* If lifetime not set, use a default of 3*MaxRtrAdvInterval */
216 int lifetime_set;
217};
218
219/*
220 * [RFC1035 2.3.4] sets the maximum length of a domain name (a sequence of
221 * labels, each prefixed by a length octet) at 255 octets.
222 */
223#define RTADV_MAX_ENCODED_DOMAIN_NAME 255
224
225struct rtadv_dnssl {
226 /* Domain name without trailing root zone dot (NUL-terminated) */
227 char name[RTADV_MAX_ENCODED_DOMAIN_NAME - 1];
228
229 /* Name encoded as in [RFC1035 3.1] */
230 uint8_t encoded_name[RTADV_MAX_ENCODED_DOMAIN_NAME];
231
232 /* Actual length of encoded_name */
233 size_t encoded_len;
234
235 /* Lifetime as for RDNSS */
236 uint32_t lifetime;
237 int lifetime_set;
238};
239
8da4e946 240#endif /* HAVE_RTADV */
718e3744 241
6675513d 242/* Zebra interface type - ones of interest. */
d62a17ae 243typedef enum {
7a38782a
DL
244 ZEBRA_IF_OTHER = 0, /* Anything else */
245 ZEBRA_IF_VXLAN, /* VxLAN interface */
246 ZEBRA_IF_VRF, /* VRF device */
247 ZEBRA_IF_BRIDGE, /* bridge device */
248 ZEBRA_IF_VLAN, /* VLAN sub-interface */
249 ZEBRA_IF_MACVLAN, /* MAC VLAN interface*/
0e4864ea 250 ZEBRA_IF_VETH, /* VETH interface*/
b9368db9
DD
251 ZEBRA_IF_BOND, /* Bond */
252 ZEBRA_IF_BOND_SLAVE, /* Bond */
6675513d 253} zebra_iftype_t;
254
255/* Zebra "slave" interface type */
d62a17ae 256typedef enum {
257 ZEBRA_IF_SLAVE_NONE, /* Not a slave */
258 ZEBRA_IF_SLAVE_VRF, /* Member of a VRF */
259 ZEBRA_IF_SLAVE_BRIDGE, /* Member of a bridge */
b9368db9 260 ZEBRA_IF_SLAVE_BOND, /* Bond member */
d62a17ae 261 ZEBRA_IF_SLAVE_OTHER, /* Something else - e.g., bond slave */
6675513d 262} zebra_slave_iftype_t;
263
2eb27eec
DL
264struct irdp_interface;
265
718e3744 266/* `zebra' daemon local interface structure. */
d62a17ae 267struct zebra_if {
268 /* Shutdown configuration. */
d7c0a89a 269 uint8_t shutdown;
718e3744 270
d62a17ae 271 /* Multicast configuration. */
d7c0a89a 272 uint8_t multicast;
718e3744 273
d62a17ae 274 /* Router advertise configuration. */
d7c0a89a 275 uint8_t rtadv_enable;
718e3744 276
d62a17ae 277 /* Installed addresses chains tree. */
278 struct route_table *ipv4_subnets;
eef1fe11 279
d62a17ae 280 /* Information about up/down changes */
281 unsigned int up_count;
282 char up_last[QUAGGA_TIMESTAMP_LEN];
283 unsigned int down_count;
284 char down_last[QUAGGA_TIMESTAMP_LEN];
55ce4d3a 285
8da4e946 286#if defined(HAVE_RTADV)
d62a17ae 287 struct rtadvconf rtadv;
288 unsigned int ra_sent, ra_rcvd;
8da4e946 289#endif /* HAVE_RTADV */
ca776988 290
2eb27eec 291 struct irdp_interface *irdp;
ca776988 292
8ccc7e80 293#ifdef HAVE_STRUCT_SOCKADDR_DL
d62a17ae 294 union {
295 /* note that sdl_storage is never accessed, it only exists to
296 * make space.
297 * all actual uses refer to sdl - but use sizeof(sdl_storage)!
298 * this fits
299 * best with C aliasing rules. */
300 struct sockaddr_dl sdl;
301 struct sockaddr_storage sdl_storage;
302 };
8ccc7e80
TT
303#endif
304
5c78b3d0 305#ifdef SUNOS_5
d62a17ae 306 /* the real IFF_UP state of the primary interface.
307 * need this to differentiate between all interfaces being
308 * down (but primary still plumbed) and primary having gone
309 * ~IFF_UP, and all addresses gone.
310 */
d7c0a89a 311 uint8_t primary_state;
5c78b3d0 312#endif /* SUNOS_5 */
986aa00f 313
d62a17ae 314 /* ptm enable configuration */
d7c0a89a 315 uint8_t ptm_enable;
6675513d 316
d62a17ae 317 /* Zebra interface and "slave" interface type */
318 zebra_iftype_t zif_type;
319 zebra_slave_iftype_t zif_slave_type;
6675513d 320
d62a17ae 321 /* Additional L2 info, depends on zif_type */
322 union zebra_l2if_info l2info;
6675513d 323
d62a17ae 324 /* For members of a bridge, link to bridge. */
325 /* Note: If additional fields become necessary, this can be modified to
326 * be a pointer to a dynamically allocd struct.
327 */
328 struct zebra_l2info_brslave brslave_info;
6675513d 329
b9368db9
DD
330 struct zebra_l2info_bondslave bondslave_info;
331
d62a17ae 332 /* Link fields - for sub-interfaces. */
333 ifindex_t link_ifindex;
334 struct interface *link;
dc7b3cae
DS
335
336 struct thread *speed_update;
20089ae2
DS
337
338 /*
339 * Does this interface have a v6 to v4 ll neighbor entry
340 * for bgp unnumbered?
341 */
342 bool v6_2_v4_ll_neigh_entry;
ee98d1f1 343 char neigh_mac[6];
20089ae2 344 struct in6_addr v6_2_v4_ll_addr6;
ba5165ec
DS
345
346 /* The description of the interface */
347 char *desc;
718e3744 348};
349
996c9314
LB
350DECLARE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp),
351 (vty, ifp))
352DECLARE_HOOK(zebra_if_config_wr, (struct vty * vty, struct interface *ifp),
353 (vty, ifp))
2eb27eec 354
d62a17ae 355static inline void zebra_if_set_ziftype(struct interface *ifp,
356 zebra_iftype_t zif_type,
357 zebra_slave_iftype_t zif_slave_type)
6675513d 358{
d62a17ae 359 struct zebra_if *zif;
6675513d 360
d62a17ae 361 zif = (struct zebra_if *)ifp->info;
362 zif->zif_type = zif_type;
363 zif->zif_slave_type = zif_slave_type;
6675513d 364}
365
d62a17ae 366#define IS_ZEBRA_IF_VRF(ifp) \
367 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VRF)
368
369#define IS_ZEBRA_IF_BRIDGE(ifp) \
370 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_BRIDGE)
371
372#define IS_ZEBRA_IF_VLAN(ifp) \
373 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VLAN)
374
375#define IS_ZEBRA_IF_VXLAN(ifp) \
376 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VXLAN)
377
1a98c087
MK
378#define IS_ZEBRA_IF_MACVLAN(ifp) \
379 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_MACVLAN)
380
0e4864ea
PG
381#define IS_ZEBRA_IF_VETH(ifp) \
382 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VETH)
383
384#define IS_ZEBRA_IF_BRIDGE_SLAVE(ifp) \
d62a17ae 385 (((struct zebra_if *)(ifp->info))->zif_slave_type \
386 == ZEBRA_IF_SLAVE_BRIDGE)
387
388#define IS_ZEBRA_IF_VRF_SLAVE(ifp) \
389 (((struct zebra_if *)(ifp->info))->zif_slave_type == ZEBRA_IF_SLAVE_VRF)
390
b9368db9
DD
391#define IS_ZEBRA_IF_BOND_SLAVE(ifp) \
392 (((struct zebra_if *)(ifp->info))->zif_slave_type \
393 == ZEBRA_IF_SLAVE_BOND)
394
05f7f5db
DS
395extern void zebra_if_init(void);
396
d7c0a89a 397extern struct interface *if_lookup_by_index_per_ns(struct zebra_ns *, uint32_t);
d62a17ae 398extern struct interface *if_lookup_by_name_per_ns(struct zebra_ns *,
399 const char *);
400extern struct interface *if_link_per_ns(struct zebra_ns *, struct interface *);
401extern const char *ifindex2ifname_per_ns(struct zebra_ns *, unsigned int);
402
403extern void if_unlink_per_ns(struct interface *);
ee98d1f1
DS
404extern void if_nbr_mac_to_ipv4ll_neigh_update(struct interface *fip,
405 char mac[6],
406 struct in6_addr *address,
407 int add);
d62a17ae 408extern void if_nbr_ipv6ll_to_ipv4ll_neigh_update(struct interface *ifp,
409 struct in6_addr *address,
410 int add);
411extern void if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(struct interface *ifp);
412extern void if_delete_update(struct interface *ifp);
413extern void if_add_update(struct interface *ifp);
414extern void if_up(struct interface *);
415extern void if_down(struct interface *);
416extern void if_refresh(struct interface *);
417extern void if_flags_update(struct interface *, uint64_t);
418extern int if_subnet_add(struct interface *, struct connected *);
419extern int if_subnet_delete(struct interface *, struct connected *);
420extern int ipv6_address_configured(struct interface *ifp);
421extern void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id);
680c278f
PG
422extern void zebra_if_update_link(struct interface *ifp, ifindex_t link_ifindex,
423 ns_id_t ns_id);
520ebf72 424extern void zebra_if_update_all_links(void);
d62a17ae 425
426extern void vrf_add_update(struct vrf *vrfp);
12f6fb97 427
718e3744 428#ifdef HAVE_PROC_NET_DEV
d62a17ae 429extern void ifstat_update_proc(void);
718e3744 430#endif /* HAVE_PROC_NET_DEV */
431#ifdef HAVE_NET_RT_IFLIST
d62a17ae 432extern void ifstat_update_sysctl(void);
718e3744 433
434#endif /* HAVE_NET_RT_IFLIST */
435#ifdef HAVE_PROC_NET_DEV
d62a17ae 436extern int interface_list_proc(void);
718e3744 437#endif /* HAVE_PROC_NET_DEV */
438#ifdef HAVE_PROC_NET_IF_INET6
d62a17ae 439extern int ifaddr_proc_ipv6(void);
718e3744 440#endif /* HAVE_PROC_NET_IF_INET6 */
441
51e94aa7
EDP
442#ifdef __cplusplus
443}
444#endif
445
5b73a671 446#endif /* _ZEBRA_INTERFACE_H */