]> git.proxmox.com Git - mirror_frr.git/blame - zebra/interface.h
zebra: Fix neighbor update to BGP
[mirror_frr.git] / zebra / interface.h
CommitLineData
718e3744 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 *
896014f4
DL
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
718e3744 19 */
20
5b73a671 21#ifndef _ZEBRA_INTERFACE_H
22#define _ZEBRA_INTERFACE_H
23
24#include "redistribute.h"
12f6fb97 25#include "vrf.h"
2eb27eec 26#include "hook.h"
ca776988 27
6675513d 28#include "zebra/zebra_l2.h"
29
718e3744 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. */
bfac8dcd 36#define IF_ZEBRA_SHUTDOWN_OFF 0
718e3744 37#define IF_ZEBRA_SHUTDOWN_ON 1
718e3744 38
d62a17ae 39#if defined(HAVE_RTADV)
6eb0c5ab 40/* Router advertisement parameter. From RFC4861, RFC6275 and RFC4191. */
d62a17ae 41struct 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;
7cee1bb1 54#define RTADV_MAX_RTR_ADV_INTERVAL 600000
718e3744 55
d62a17ae 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.
718e3744 60
d62a17ae 61 Default: 0.33 * MaxRtrAdvInterval */
62 int MinRtrAdvInterval; /* This field is currently unused. */
718e3744 63#define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)
64
d62a17ae 65 /* Unsolicited Router Advertisements' interval timer. */
66 int AdvIntervalTimer;
718e3744 67
d62a17ae 68 /* The TRUE/FALSE value to be placed in the "Managed address
69 configuration" flag field in the Router Advertisement. See
70 [ADDRCONF].
718e3744 71
d62a17ae 72 Default: FALSE */
73 int AdvManagedFlag;
718e3744 74
718e3744 75
d62a17ae 76 /* The TRUE/FALSE value to be placed in the "Other stateful
77 configuration" flag field in the Router Advertisement. See
78 [ADDRCONF].
718e3744 79
d62a17ae 80 Default: FALSE */
81 int AdvOtherConfigFlag;
718e3744 82
d62a17ae 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.
718e3744 85
d62a17ae 86 Default: 0 */
87 int AdvLinkMTU;
718e3744 88
718e3744 89
d62a17ae 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).
718e3744 94
d62a17ae 95 Default: 0 */
d7c0a89a 96 uint32_t AdvReachableTime;
d62a17ae 97#define RTADV_MAX_REACHABLE_TIME 3600000
718e3744 98
d62a17ae 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).
718e3744 102
d62a17ae 103 Default: 0 */
104 int AdvRetransTimer;
718e3744 105
d62a17ae 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).
718e3744 110
d62a17ae 111 Default: The value specified in the "Assigned Numbers" RFC
112 [ASSIGNED] that was in effect at the time of implementation. */
113 int AdvCurHopLimit;
718e3744 114
d62a17ae 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.
718e3744 120
d62a17ae 121 Default: 3 * MaxRtrAdvInterval */
122 int AdvDefaultLifetime;
d660f698 123#define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
718e3744 124
d62a17ae 125 /* A list of prefixes to be placed in Prefix Information options in
126 Router Advertisement messages sent from the interface.
718e3744 127
d62a17ae 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;
7cee1bb1 133
d62a17ae 134 /* The TRUE/FALSE value to be placed in the "Home agent"
135 flag field in the Router Advertisement. See [RFC6275 7.1].
7cee1bb1 136
d62a17ae 137 Default: FALSE */
138 int AdvHomeAgentFlag;
7cee1bb1 139#ifndef ND_RA_FLAG_HOME_AGENT
140#define ND_RA_FLAG_HOME_AGENT 0x20
141#endif
142
d62a17ae 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;
7cee1bb1 155#define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
156
d62a17ae 157 /* The TRUE/FALSE value to insert or not an Advertisement Interval
158 option. See [RFC 6275 7.3]
7cee1bb1 159
d62a17ae 160 Default: FALSE */
161 int AdvIntervalOption;
b60668d0 162
d62a17ae 163 /* The value to be placed in the Default Router Preference field of
164 a router advertisement. See [RFC 4191 2.1 & 2.2]
b60668d0 165
d62a17ae 166 Default: 0 (medium) */
167 int DefaultPreference;
b60668d0 168#define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
6c9678b4 169
d7c0a89a 170 uint8_t inFastRexmit; /* True if we're rexmits faster than usual */
3ea48364
DS
171
172 /* Track if RA was configured by BGP or by the Operator or both */
d7c0a89a 173 uint8_t ra_configured; /* Was RA configured? */
3ea48364
DS
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 */
996c9314
LB
177 int NumFastReXmitsRemain; /* Loaded first with number of fast
178 rexmits to do */
6c9678b4
DD
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 */
718e3744 182};
183
8da4e946 184#endif /* HAVE_RTADV */
718e3744 185
6675513d 186/* Zebra interface type - ones of interest. */
d62a17ae 187typedef enum {
7a38782a
DL
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*/
0e4864ea 194 ZEBRA_IF_VETH, /* VETH interface*/
6675513d 195} zebra_iftype_t;
196
197/* Zebra "slave" interface type */
d62a17ae 198typedef 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 */
6675513d 203} zebra_slave_iftype_t;
204
2eb27eec
DL
205struct irdp_interface;
206
718e3744 207/* `zebra' daemon local interface structure. */
d62a17ae 208struct zebra_if {
209 /* Shutdown configuration. */
d7c0a89a 210 uint8_t shutdown;
718e3744 211
d62a17ae 212 /* Multicast configuration. */
d7c0a89a 213 uint8_t multicast;
718e3744 214
d62a17ae 215 /* Router advertise configuration. */
d7c0a89a 216 uint8_t rtadv_enable;
718e3744 217
d62a17ae 218 /* Installed addresses chains tree. */
219 struct route_table *ipv4_subnets;
eef1fe11 220
d62a17ae 221 /* Information about up/down changes */
222 unsigned int up_count;
223 char up_last[QUAGGA_TIMESTAMP_LEN];
224 unsigned int down_count;
225 char down_last[QUAGGA_TIMESTAMP_LEN];
55ce4d3a 226
8da4e946 227#if defined(HAVE_RTADV)
d62a17ae 228 struct rtadvconf rtadv;
229 unsigned int ra_sent, ra_rcvd;
8da4e946 230#endif /* HAVE_RTADV */
ca776988 231
2eb27eec 232 struct irdp_interface *irdp;
ca776988 233
8ccc7e80 234#ifdef HAVE_STRUCT_SOCKADDR_DL
d62a17ae 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 };
8ccc7e80
TT
244#endif
245
5c78b3d0 246#ifdef SUNOS_5
d62a17ae 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 */
d7c0a89a 252 uint8_t primary_state;
5c78b3d0 253#endif /* SUNOS_5 */
986aa00f 254
d62a17ae 255 /* ptm enable configuration */
d7c0a89a 256 uint8_t ptm_enable;
6675513d 257
d62a17ae 258 /* Zebra interface and "slave" interface type */
259 zebra_iftype_t zif_type;
260 zebra_slave_iftype_t zif_slave_type;
6675513d 261
d62a17ae 262 /* Additional L2 info, depends on zif_type */
263 union zebra_l2if_info l2info;
6675513d 264
d62a17ae 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;
6675513d 270
d62a17ae 271 /* Link fields - for sub-interfaces. */
272 ifindex_t link_ifindex;
273 struct interface *link;
dc7b3cae
DS
274
275 struct thread *speed_update;
20089ae2
DS
276
277 /*
278 * Does this interface have a v6 to v4 ll neighbor entry
279 * for bgp unnumbered?
280 */
281 bool v6_2_v4_ll_neigh_entry;
282 struct in6_addr v6_2_v4_ll_addr6;
718e3744 283};
284
996c9314
LB
285DECLARE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp),
286 (vty, ifp))
287DECLARE_HOOK(zebra_if_config_wr, (struct vty * vty, struct interface *ifp),
288 (vty, ifp))
2eb27eec 289
d62a17ae 290static inline void zebra_if_set_ziftype(struct interface *ifp,
291 zebra_iftype_t zif_type,
292 zebra_slave_iftype_t zif_slave_type)
6675513d 293{
d62a17ae 294 struct zebra_if *zif;
6675513d 295
d62a17ae 296 zif = (struct zebra_if *)ifp->info;
297 zif->zif_type = zif_type;
298 zif->zif_slave_type = zif_slave_type;
6675513d 299}
300
d62a17ae 301#define IS_ZEBRA_IF_VRF(ifp) \
302 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VRF)
303
304#define IS_ZEBRA_IF_BRIDGE(ifp) \
305 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_BRIDGE)
306
307#define IS_ZEBRA_IF_VLAN(ifp) \
308 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VLAN)
309
310#define IS_ZEBRA_IF_VXLAN(ifp) \
311 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VXLAN)
312
1a98c087
MK
313#define IS_ZEBRA_IF_MACVLAN(ifp) \
314 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_MACVLAN)
315
0e4864ea
PG
316#define IS_ZEBRA_IF_VETH(ifp) \
317 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VETH)
318
319#define IS_ZEBRA_IF_BRIDGE_SLAVE(ifp) \
d62a17ae 320 (((struct zebra_if *)(ifp->info))->zif_slave_type \
321 == ZEBRA_IF_SLAVE_BRIDGE)
322
323#define IS_ZEBRA_IF_VRF_SLAVE(ifp) \
324 (((struct zebra_if *)(ifp->info))->zif_slave_type == ZEBRA_IF_SLAVE_VRF)
325
05f7f5db
DS
326extern void zebra_if_init(void);
327
d7c0a89a 328extern struct interface *if_lookup_by_index_per_ns(struct zebra_ns *, uint32_t);
d62a17ae 329extern struct interface *if_lookup_by_name_per_ns(struct zebra_ns *,
330 const char *);
331extern struct interface *if_link_per_ns(struct zebra_ns *, struct interface *);
332extern const char *ifindex2ifname_per_ns(struct zebra_ns *, unsigned int);
333
334extern void if_unlink_per_ns(struct interface *);
335extern void if_nbr_ipv6ll_to_ipv4ll_neigh_update(struct interface *ifp,
336 struct in6_addr *address,
337 int add);
338extern void if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(struct interface *ifp);
339extern void if_delete_update(struct interface *ifp);
340extern void if_add_update(struct interface *ifp);
341extern void if_up(struct interface *);
342extern void if_down(struct interface *);
343extern void if_refresh(struct interface *);
344extern void if_flags_update(struct interface *, uint64_t);
345extern int if_subnet_add(struct interface *, struct connected *);
346extern int if_subnet_delete(struct interface *, struct connected *);
347extern int ipv6_address_configured(struct interface *ifp);
348extern void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id);
680c278f
PG
349extern void zebra_if_update_link(struct interface *ifp, ifindex_t link_ifindex,
350 ns_id_t ns_id);
d62a17ae 351
352extern void vrf_add_update(struct vrf *vrfp);
12f6fb97 353
718e3744 354#ifdef HAVE_PROC_NET_DEV
d62a17ae 355extern void ifstat_update_proc(void);
718e3744 356#endif /* HAVE_PROC_NET_DEV */
357#ifdef HAVE_NET_RT_IFLIST
d62a17ae 358extern void ifstat_update_sysctl(void);
718e3744 359
360#endif /* HAVE_NET_RT_IFLIST */
361#ifdef HAVE_PROC_NET_DEV
d62a17ae 362extern int interface_list_proc(void);
718e3744 363#endif /* HAVE_PROC_NET_DEV */
364#ifdef HAVE_PROC_NET_IF_INET6
d62a17ae 365extern int ifaddr_proc_ipv6(void);
718e3744 366#endif /* HAVE_PROC_NET_IF_INET6 */
367
5b73a671 368#endif /* _ZEBRA_INTERFACE_H */