2 /* Interface function header.
3 * Copyright (C) 1999 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
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
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.
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
22 #ifndef _ZEBRA_INTERFACE_H
23 #define _ZEBRA_INTERFACE_H
25 #include "redistribute.h"
29 #include "zebra/zebra_l2.h"
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
36 /* For interface shutdown configuration. */
37 #define IF_ZEBRA_SHUTDOWN_OFF 0
38 #define IF_ZEBRA_SHUTDOWN_ON 1
40 #if defined(HAVE_RTADV)
41 /* Router advertisement parameter. From RFC4861, RFC6275 and RFC4191. */
43 /* A flag indicating whether or not the router sends periodic Router
44 Advertisements and responds to Router Solicitations.
46 int AdvSendAdvertisements
;
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].
53 Default: 600000 milliseconds */
54 int MaxRtrAdvInterval
;
55 #define RTADV_MAX_RTR_ADV_INTERVAL 600000
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.
62 Default: 0.33 * MaxRtrAdvInterval */
63 int MinRtrAdvInterval
; /* This field is currently unused. */
64 #define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)
66 /* Unsolicited Router Advertisements' interval timer. */
69 /* The TRUE/FALSE value to be placed in the "Managed address
70 configuration" flag field in the Router Advertisement. See
77 /* The TRUE/FALSE value to be placed in the "Other stateful
78 configuration" flag field in the Router Advertisement. See
82 int AdvOtherConfigFlag
;
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.
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).
97 uint32_t AdvReachableTime
;
98 #define RTADV_MAX_REACHABLE_TIME 3600000
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).
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).
112 Default: The value specified in the "Assigned Numbers" RFC
113 [ASSIGNED] that was in effect at the time of implementation. */
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
122 Default: 3 * MaxRtrAdvInterval */
123 int AdvDefaultLifetime
;
124 #define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
126 /* A list of prefixes to be placed in Prefix Information options in
127 Router Advertisement messages sent from the interface.
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
;
135 /* The TRUE/FALSE value to be placed in the "Home agent"
136 flag field in the Router Advertisement. See [RFC6275 7.1].
139 int AdvHomeAgentFlag
;
140 #ifndef ND_RA_FLAG_HOME_AGENT
141 #define ND_RA_FLAG_HOME_AGENT 0x20
144 /* The value to be placed in Home Agent Information option if Home
147 int HomeAgentPreference
;
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
152 The value 0 has special meaning: use of AdvDefaultLifetime value.
155 int HomeAgentLifetime
;
156 #define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
158 /* The TRUE/FALSE value to insert or not an Advertisement Interval
159 option. See [RFC 6275 7.3]
162 int AdvIntervalOption
;
164 /* The value to be placed in the Default Router Preference field of
165 a router advertisement. See [RFC 4191 2.1 & 2.2]
167 Default: 0 (medium) */
168 int DefaultPreference
;
169 #define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
171 uint8_t inFastRexmit
; /* True if we're rexmits faster than usual */
173 /* Track if RA was configured by BGP or by the Operator or both */
174 uint8_t ra_configured
; /* Was RA configured? */
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 */
178 int NumFastReXmitsRemain
; /* Loaded first with number of fast
181 #define RTADV_FAST_REXMIT_PERIOD 1 /* 1 sec */
182 #define RTADV_NUM_FAST_REXMITS 4 /* Fast Rexmit RA 4 times on certain events */
185 #endif /* HAVE_RTADV */
187 /* Zebra interface type - ones of interest. */
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*/
195 ZEBRA_IF_VETH
, /* VETH interface*/
196 ZEBRA_IF_BOND
, /* Bond */
197 ZEBRA_IF_BOND_SLAVE
, /* Bond */
200 /* Zebra "slave" interface type */
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 */
205 ZEBRA_IF_SLAVE_BOND
, /* Bond member */
206 ZEBRA_IF_SLAVE_OTHER
, /* Something else - e.g., bond slave */
207 } zebra_slave_iftype_t
;
209 struct irdp_interface
;
211 /* `zebra' daemon local interface structure. */
213 /* Shutdown configuration. */
216 /* Multicast configuration. */
219 /* Router advertise configuration. */
220 uint8_t rtadv_enable
;
222 /* Installed addresses chains tree. */
223 struct route_table
*ipv4_subnets
;
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
];
231 #if defined(HAVE_RTADV)
232 struct rtadvconf rtadv
;
233 unsigned int ra_sent
, ra_rcvd
;
234 #endif /* HAVE_RTADV */
236 struct irdp_interface
*irdp
;
238 #ifdef HAVE_STRUCT_SOCKADDR_DL
240 /* note that sdl_storage is never accessed, it only exists to
242 * all actual uses refer to sdl - but use sizeof(sdl_storage)!
244 * best with C aliasing rules. */
245 struct sockaddr_dl sdl
;
246 struct sockaddr_storage sdl_storage
;
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.
256 uint8_t primary_state
;
259 /* ptm enable configuration */
262 /* Zebra interface and "slave" interface type */
263 zebra_iftype_t zif_type
;
264 zebra_slave_iftype_t zif_slave_type
;
266 /* Additional L2 info, depends on zif_type */
267 union zebra_l2if_info l2info
;
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.
273 struct zebra_l2info_brslave brslave_info
;
275 struct zebra_l2info_bondslave bondslave_info
;
277 /* Link fields - for sub-interfaces. */
278 ifindex_t link_ifindex
;
279 struct interface
*link
;
281 struct thread
*speed_update
;
284 * Does this interface have a v6 to v4 ll neighbor entry
285 * for bgp unnumbered?
287 bool v6_2_v4_ll_neigh_entry
;
289 struct in6_addr v6_2_v4_ll_addr6
;
292 DECLARE_HOOK(zebra_if_extra_info
, (struct vty
* vty
, struct interface
*ifp
),
294 DECLARE_HOOK(zebra_if_config_wr
, (struct vty
* vty
, struct interface
*ifp
),
297 static inline void zebra_if_set_ziftype(struct interface
*ifp
,
298 zebra_iftype_t zif_type
,
299 zebra_slave_iftype_t zif_slave_type
)
301 struct zebra_if
*zif
;
303 zif
= (struct zebra_if
*)ifp
->info
;
304 zif
->zif_type
= zif_type
;
305 zif
->zif_slave_type
= zif_slave_type
;
308 #define IS_ZEBRA_IF_VRF(ifp) \
309 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VRF)
311 #define IS_ZEBRA_IF_BRIDGE(ifp) \
312 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_BRIDGE)
314 #define IS_ZEBRA_IF_VLAN(ifp) \
315 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VLAN)
317 #define IS_ZEBRA_IF_VXLAN(ifp) \
318 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VXLAN)
320 #define IS_ZEBRA_IF_MACVLAN(ifp) \
321 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_MACVLAN)
323 #define IS_ZEBRA_IF_VETH(ifp) \
324 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VETH)
326 #define IS_ZEBRA_IF_BRIDGE_SLAVE(ifp) \
327 (((struct zebra_if *)(ifp->info))->zif_slave_type \
328 == ZEBRA_IF_SLAVE_BRIDGE)
330 #define IS_ZEBRA_IF_VRF_SLAVE(ifp) \
331 (((struct zebra_if *)(ifp->info))->zif_slave_type == ZEBRA_IF_SLAVE_VRF)
333 #define IS_ZEBRA_IF_BOND_SLAVE(ifp) \
334 (((struct zebra_if *)(ifp->info))->zif_slave_type \
335 == ZEBRA_IF_SLAVE_BOND)
337 extern void zebra_if_init(void);
339 extern struct interface
*if_lookup_by_index_per_ns(struct zebra_ns
*, uint32_t);
340 extern struct interface
*if_lookup_by_name_per_ns(struct zebra_ns
*,
342 extern struct interface
*if_link_per_ns(struct zebra_ns
*, struct interface
*);
343 extern const char *ifindex2ifname_per_ns(struct zebra_ns
*, unsigned int);
345 extern void if_unlink_per_ns(struct interface
*);
346 extern void if_nbr_mac_to_ipv4ll_neigh_update(struct interface
*fip
,
348 struct in6_addr
*address
,
350 extern void if_nbr_ipv6ll_to_ipv4ll_neigh_update(struct interface
*ifp
,
351 struct in6_addr
*address
,
353 extern void if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(struct interface
*ifp
);
354 extern void if_delete_update(struct interface
*ifp
);
355 extern void if_add_update(struct interface
*ifp
);
356 extern void if_up(struct interface
*);
357 extern void if_down(struct interface
*);
358 extern void if_refresh(struct interface
*);
359 extern void if_flags_update(struct interface
*, uint64_t);
360 extern int if_subnet_add(struct interface
*, struct connected
*);
361 extern int if_subnet_delete(struct interface
*, struct connected
*);
362 extern int ipv6_address_configured(struct interface
*ifp
);
363 extern void if_handle_vrf_change(struct interface
*ifp
, vrf_id_t vrf_id
);
364 extern void zebra_if_update_link(struct interface
*ifp
, ifindex_t link_ifindex
,
366 extern void zebra_if_update_all_links(void);
368 extern void vrf_add_update(struct vrf
*vrfp
);
370 #ifdef HAVE_PROC_NET_DEV
371 extern void ifstat_update_proc(void);
372 #endif /* HAVE_PROC_NET_DEV */
373 #ifdef HAVE_NET_RT_IFLIST
374 extern void ifstat_update_sysctl(void);
376 #endif /* HAVE_NET_RT_IFLIST */
377 #ifdef HAVE_PROC_NET_DEV
378 extern int interface_list_proc(void);
379 #endif /* HAVE_PROC_NET_DEV */
380 #ifdef HAVE_PROC_NET_IF_INET6
381 extern int ifaddr_proc_ipv6(void);
382 #endif /* HAVE_PROC_NET_IF_INET6 */
384 #endif /* _ZEBRA_INTERFACE_H */