]> git.proxmox.com Git - mirror_frr.git/blame - zebra/interface.h
isisd: implement 'max-area-addresses-mismatch' notification
[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
718e3744 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. */
bfac8dcd 37#define IF_ZEBRA_SHUTDOWN_OFF 0
718e3744 38#define IF_ZEBRA_SHUTDOWN_ON 1
718e3744 39
d62a17ae 40#if defined(HAVE_RTADV)
6eb0c5ab 41/* Router advertisement parameter. From RFC4861, RFC6275 and RFC4191. */
d62a17ae 42struct 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;
7cee1bb1 55#define RTADV_MAX_RTR_ADV_INTERVAL 600000
718e3744 56
d62a17ae 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.
718e3744 61
d62a17ae 62 Default: 0.33 * MaxRtrAdvInterval */
63 int MinRtrAdvInterval; /* This field is currently unused. */
718e3744 64#define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)
65
d62a17ae 66 /* Unsolicited Router Advertisements' interval timer. */
67 int AdvIntervalTimer;
718e3744 68
d62a17ae 69 /* The TRUE/FALSE value to be placed in the "Managed address
70 configuration" flag field in the Router Advertisement. See
71 [ADDRCONF].
718e3744 72
d62a17ae 73 Default: FALSE */
74 int AdvManagedFlag;
718e3744 75
718e3744 76
d62a17ae 77 /* The TRUE/FALSE value to be placed in the "Other stateful
78 configuration" flag field in the Router Advertisement. See
79 [ADDRCONF].
718e3744 80
d62a17ae 81 Default: FALSE */
82 int AdvOtherConfigFlag;
718e3744 83
d62a17ae 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.
718e3744 86
d62a17ae 87 Default: 0 */
88 int AdvLinkMTU;
718e3744 89
718e3744 90
d62a17ae 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).
718e3744 95
d62a17ae 96 Default: 0 */
d7c0a89a 97 uint32_t AdvReachableTime;
d62a17ae 98#define RTADV_MAX_REACHABLE_TIME 3600000
718e3744 99
d62a17ae 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).
718e3744 103
d62a17ae 104 Default: 0 */
105 int AdvRetransTimer;
718e3744 106
d62a17ae 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).
718e3744 111
d62a17ae 112 Default: The value specified in the "Assigned Numbers" RFC
113 [ASSIGNED] that was in effect at the time of implementation. */
114 int AdvCurHopLimit;
718e3744 115
d62a17ae 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.
718e3744 121
d62a17ae 122 Default: 3 * MaxRtrAdvInterval */
123 int AdvDefaultLifetime;
d660f698 124#define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
718e3744 125
d62a17ae 126 /* A list of prefixes to be placed in Prefix Information options in
127 Router Advertisement messages sent from the interface.
718e3744 128
d62a17ae 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;
7cee1bb1 134
d62a17ae 135 /* The TRUE/FALSE value to be placed in the "Home agent"
136 flag field in the Router Advertisement. See [RFC6275 7.1].
7cee1bb1 137
d62a17ae 138 Default: FALSE */
139 int AdvHomeAgentFlag;
7cee1bb1 140#ifndef ND_RA_FLAG_HOME_AGENT
141#define ND_RA_FLAG_HOME_AGENT 0x20
142#endif
143
d62a17ae 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;
7cee1bb1 156#define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
157
d62a17ae 158 /* The TRUE/FALSE value to insert or not an Advertisement Interval
159 option. See [RFC 6275 7.3]
7cee1bb1 160
d62a17ae 161 Default: FALSE */
162 int AdvIntervalOption;
b60668d0 163
d62a17ae 164 /* The value to be placed in the Default Router Preference field of
165 a router advertisement. See [RFC 4191 2.1 & 2.2]
b60668d0 166
d62a17ae 167 Default: 0 (medium) */
168 int DefaultPreference;
b60668d0 169#define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
6c9678b4 170
d7c0a89a 171 uint8_t inFastRexmit; /* True if we're rexmits faster than usual */
3ea48364
DS
172
173 /* Track if RA was configured by BGP or by the Operator or both */
d7c0a89a 174 uint8_t ra_configured; /* Was RA configured? */
3ea48364
DS
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 */
996c9314
LB
178 int NumFastReXmitsRemain; /* Loaded first with number of fast
179 rexmits to do */
6c9678b4
DD
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 */
718e3744 183};
184
8da4e946 185#endif /* HAVE_RTADV */
718e3744 186
6675513d 187/* Zebra interface type - ones of interest. */
d62a17ae 188typedef enum {
7a38782a
DL
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*/
0e4864ea 195 ZEBRA_IF_VETH, /* VETH interface*/
b9368db9
DD
196 ZEBRA_IF_BOND, /* Bond */
197 ZEBRA_IF_BOND_SLAVE, /* Bond */
6675513d 198} zebra_iftype_t;
199
200/* Zebra "slave" interface type */
d62a17ae 201typedef 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 */
b9368db9 205 ZEBRA_IF_SLAVE_BOND, /* Bond member */
d62a17ae 206 ZEBRA_IF_SLAVE_OTHER, /* Something else - e.g., bond slave */
6675513d 207} zebra_slave_iftype_t;
208
2eb27eec
DL
209struct irdp_interface;
210
718e3744 211/* `zebra' daemon local interface structure. */
d62a17ae 212struct zebra_if {
213 /* Shutdown configuration. */
d7c0a89a 214 uint8_t shutdown;
718e3744 215
d62a17ae 216 /* Multicast configuration. */
d7c0a89a 217 uint8_t multicast;
718e3744 218
d62a17ae 219 /* Router advertise configuration. */
d7c0a89a 220 uint8_t rtadv_enable;
718e3744 221
d62a17ae 222 /* Installed addresses chains tree. */
223 struct route_table *ipv4_subnets;
eef1fe11 224
d62a17ae 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];
55ce4d3a 230
8da4e946 231#if defined(HAVE_RTADV)
d62a17ae 232 struct rtadvconf rtadv;
233 unsigned int ra_sent, ra_rcvd;
8da4e946 234#endif /* HAVE_RTADV */
ca776988 235
2eb27eec 236 struct irdp_interface *irdp;
ca776988 237
8ccc7e80 238#ifdef HAVE_STRUCT_SOCKADDR_DL
d62a17ae 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 };
8ccc7e80
TT
248#endif
249
5c78b3d0 250#ifdef SUNOS_5
d62a17ae 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 */
d7c0a89a 256 uint8_t primary_state;
5c78b3d0 257#endif /* SUNOS_5 */
986aa00f 258
d62a17ae 259 /* ptm enable configuration */
d7c0a89a 260 uint8_t ptm_enable;
6675513d 261
d62a17ae 262 /* Zebra interface and "slave" interface type */
263 zebra_iftype_t zif_type;
264 zebra_slave_iftype_t zif_slave_type;
6675513d 265
d62a17ae 266 /* Additional L2 info, depends on zif_type */
267 union zebra_l2if_info l2info;
6675513d 268
d62a17ae 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;
6675513d 274
b9368db9
DD
275 struct zebra_l2info_bondslave bondslave_info;
276
d62a17ae 277 /* Link fields - for sub-interfaces. */
278 ifindex_t link_ifindex;
279 struct interface *link;
dc7b3cae
DS
280
281 struct thread *speed_update;
20089ae2
DS
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;
ee98d1f1 288 char neigh_mac[6];
20089ae2 289 struct in6_addr v6_2_v4_ll_addr6;
718e3744 290};
291
996c9314
LB
292DECLARE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp),
293 (vty, ifp))
294DECLARE_HOOK(zebra_if_config_wr, (struct vty * vty, struct interface *ifp),
295 (vty, ifp))
2eb27eec 296
d62a17ae 297static inline void zebra_if_set_ziftype(struct interface *ifp,
298 zebra_iftype_t zif_type,
299 zebra_slave_iftype_t zif_slave_type)
6675513d 300{
d62a17ae 301 struct zebra_if *zif;
6675513d 302
d62a17ae 303 zif = (struct zebra_if *)ifp->info;
304 zif->zif_type = zif_type;
305 zif->zif_slave_type = zif_slave_type;
6675513d 306}
307
d62a17ae 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
1a98c087
MK
320#define IS_ZEBRA_IF_MACVLAN(ifp) \
321 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_MACVLAN)
322
0e4864ea
PG
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) \
d62a17ae 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
b9368db9
DD
333#define IS_ZEBRA_IF_BOND_SLAVE(ifp) \
334 (((struct zebra_if *)(ifp->info))->zif_slave_type \
335 == ZEBRA_IF_SLAVE_BOND)
336
05f7f5db
DS
337extern void zebra_if_init(void);
338
d7c0a89a 339extern struct interface *if_lookup_by_index_per_ns(struct zebra_ns *, uint32_t);
d62a17ae 340extern struct interface *if_lookup_by_name_per_ns(struct zebra_ns *,
341 const char *);
342extern struct interface *if_link_per_ns(struct zebra_ns *, struct interface *);
343extern const char *ifindex2ifname_per_ns(struct zebra_ns *, unsigned int);
344
345extern void if_unlink_per_ns(struct interface *);
ee98d1f1
DS
346extern void if_nbr_mac_to_ipv4ll_neigh_update(struct interface *fip,
347 char mac[6],
348 struct in6_addr *address,
349 int add);
d62a17ae 350extern void if_nbr_ipv6ll_to_ipv4ll_neigh_update(struct interface *ifp,
351 struct in6_addr *address,
352 int add);
353extern void if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(struct interface *ifp);
354extern void if_delete_update(struct interface *ifp);
355extern void if_add_update(struct interface *ifp);
356extern void if_up(struct interface *);
357extern void if_down(struct interface *);
358extern void if_refresh(struct interface *);
359extern void if_flags_update(struct interface *, uint64_t);
360extern int if_subnet_add(struct interface *, struct connected *);
361extern int if_subnet_delete(struct interface *, struct connected *);
362extern int ipv6_address_configured(struct interface *ifp);
363extern void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id);
680c278f
PG
364extern void zebra_if_update_link(struct interface *ifp, ifindex_t link_ifindex,
365 ns_id_t ns_id);
520ebf72 366extern void zebra_if_update_all_links(void);
d62a17ae 367
368extern void vrf_add_update(struct vrf *vrfp);
12f6fb97 369
718e3744 370#ifdef HAVE_PROC_NET_DEV
d62a17ae 371extern void ifstat_update_proc(void);
718e3744 372#endif /* HAVE_PROC_NET_DEV */
373#ifdef HAVE_NET_RT_IFLIST
d62a17ae 374extern void ifstat_update_sysctl(void);
718e3744 375
376#endif /* HAVE_NET_RT_IFLIST */
377#ifdef HAVE_PROC_NET_DEV
d62a17ae 378extern int interface_list_proc(void);
718e3744 379#endif /* HAVE_PROC_NET_DEV */
380#ifdef HAVE_PROC_NET_IF_INET6
d62a17ae 381extern int ifaddr_proc_ipv6(void);
718e3744 382#endif /* HAVE_PROC_NET_IF_INET6 */
383
5b73a671 384#endif /* _ZEBRA_INTERFACE_H */