]>
Commit | Line | Data |
---|---|---|
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" |
ce5160c0 | 28 | #include "bitfield.h" |
ca776988 | 29 | |
6675513d | 30 | #include "zebra/zebra_l2.h" |
5948f013 | 31 | #include "zebra/zebra_nhg_private.h" |
c36e442c | 32 | #include "zebra/zebra_router.h" |
7ca9c407 | 33 | #include "zebra/rtadv.h" |
6675513d | 34 | |
51e94aa7 EDP |
35 | #ifdef __cplusplus |
36 | extern "C" { | |
37 | #endif | |
38 | ||
e63831f1 DS |
39 | /* For interface configuration. */ |
40 | #define IF_ZEBRA_DATA_UNSPEC 0 | |
41 | #define IF_ZEBRA_DATA_ON 1 | |
42 | #define IF_ZEBRA_DATA_OFF 2 | |
718e3744 | 43 | |
ce5160c0 AK |
44 | #define IF_VLAN_BITMAP_MAX 4096 |
45 | ||
6675513d | 46 | /* Zebra interface type - ones of interest. */ |
e6f2bec0 | 47 | enum zebra_iftype { |
7a38782a DL |
48 | ZEBRA_IF_OTHER = 0, /* Anything else */ |
49 | ZEBRA_IF_VXLAN, /* VxLAN interface */ | |
50 | ZEBRA_IF_VRF, /* VRF device */ | |
51 | ZEBRA_IF_BRIDGE, /* bridge device */ | |
52 | ZEBRA_IF_VLAN, /* VLAN sub-interface */ | |
53 | ZEBRA_IF_MACVLAN, /* MAC VLAN interface*/ | |
0e4864ea | 54 | ZEBRA_IF_VETH, /* VETH interface*/ |
b9368db9 DD |
55 | ZEBRA_IF_BOND, /* Bond */ |
56 | ZEBRA_IF_BOND_SLAVE, /* Bond */ | |
077c07cc | 57 | ZEBRA_IF_GRE, /* GRE interface */ |
e6f2bec0 | 58 | }; |
6675513d | 59 | |
60 | /* Zebra "slave" interface type */ | |
a81982fa | 61 | enum zebra_slave_iftype { |
d62a17ae | 62 | ZEBRA_IF_SLAVE_NONE, /* Not a slave */ |
63 | ZEBRA_IF_SLAVE_VRF, /* Member of a VRF */ | |
64 | ZEBRA_IF_SLAVE_BRIDGE, /* Member of a bridge */ | |
b9368db9 | 65 | ZEBRA_IF_SLAVE_BOND, /* Bond member */ |
d62a17ae | 66 | ZEBRA_IF_SLAVE_OTHER, /* Something else - e.g., bond slave */ |
a81982fa | 67 | }; |
6675513d | 68 | |
2eb27eec DL |
69 | struct irdp_interface; |
70 | ||
ce5160c0 AK |
71 | /* Ethernet segment info used for setting up EVPN multihoming */ |
72 | struct zebra_evpn_es; | |
73 | struct zebra_es_if_info { | |
325d694b | 74 | /* type-3 esi config */ |
ce5160c0 AK |
75 | struct ethaddr sysmac; |
76 | uint32_t lid; /* local-id; has to be unique per-ES-sysmac */ | |
325d694b AK |
77 | |
78 | esi_t esi; | |
79 | ||
1103c5c6 | 80 | uint16_t df_pref; |
00a7710c AK |
81 | uint8_t flags; |
82 | #define ZIF_CFG_ES_FLAG_BYPASS (1 << 0) | |
83 | ||
ce5160c0 AK |
84 | struct zebra_evpn_es *es; /* local ES */ |
85 | }; | |
86 | ||
c36e442c AK |
87 | enum zebra_if_flags { |
88 | /* device has been configured as an uplink for | |
89 | * EVPN multihoming | |
90 | */ | |
91 | ZIF_FLAG_EVPN_MH_UPLINK = (1 << 0), | |
92 | ZIF_FLAG_EVPN_MH_UPLINK_OPER_UP = (1 << 1), | |
93 | ||
94 | /* Dataplane protodown-on */ | |
00a7710c | 95 | ZIF_FLAG_PROTODOWN = (1 << 2), |
71ef5cbb SW |
96 | /* Dataplane protodown-on Queued to the dplane */ |
97 | ZIF_FLAG_SET_PROTODOWN = (1 << 3), | |
98 | /* Dataplane protodown-off Queued to the dplane */ | |
99 | ZIF_FLAG_UNSET_PROTODOWN = (1 << 4), | |
00a7710c AK |
100 | |
101 | /* LACP bypass state is set by the dataplane on a bond member | |
102 | * and inherited by the bond (if one or more bond members are in | |
103 | * a bypass state the bond is placed in a bypass state) | |
104 | */ | |
71ef5cbb | 105 | ZIF_FLAG_LACP_BYPASS = (1 << 5) |
c36e442c AK |
106 | }; |
107 | ||
ddfea8a2 | 108 | #define ZEBRA_IF_IS_PROTODOWN(zif) ((zif)->flags & ZIF_FLAG_PROTODOWN) |
0dcd8506 | 109 | #define ZEBRA_IF_IS_PROTODOWN_ONLY_EXTERNAL(zif) \ |
ddfea8a2 | 110 | ((zif)->protodown_rc == ZEBRA_PROTODOWN_EXTERNAL) |
0dcd8506 | 111 | |
718e3744 | 112 | /* `zebra' daemon local interface structure. */ |
d62a17ae | 113 | struct zebra_if { |
ce5160c0 AK |
114 | /* back pointer to the interface */ |
115 | struct interface *ifp; | |
116 | ||
c36e442c AK |
117 | enum zebra_if_flags flags; |
118 | ||
d62a17ae | 119 | /* Shutdown configuration. */ |
d7c0a89a | 120 | uint8_t shutdown; |
718e3744 | 121 | |
d62a17ae | 122 | /* Multicast configuration. */ |
d7c0a89a | 123 | uint8_t multicast; |
718e3744 | 124 | |
b6beb700 MS |
125 | /* MPLS status. */ |
126 | bool mpls; | |
127 | ||
3689905d | 128 | /* Linkdown status */ |
d53dc9bd | 129 | bool linkdown, linkdownv6; |
3689905d | 130 | |
4c84aa5e | 131 | /* Is Multicast Forwarding on? */ |
d53dc9bd | 132 | bool v4mcast_on, v6mcast_on; |
4c84aa5e | 133 | |
d62a17ae | 134 | /* Router advertise configuration. */ |
d7c0a89a | 135 | uint8_t rtadv_enable; |
718e3744 | 136 | |
d62a17ae | 137 | /* Installed addresses chains tree. */ |
138 | struct route_table *ipv4_subnets; | |
eef1fe11 | 139 | |
fe593b78 | 140 | /* Nexthops pointing to this interface */ |
602fea61 SW |
141 | /** |
142 | * Any nexthop that we get should have an | |
143 | * interface. When an interface goes down, | |
144 | * we will use this list to update the nexthops | |
145 | * pointing to it with that info. | |
146 | */ | |
37c6708b | 147 | struct nhg_connected_tree_head nhg_dependents; |
602fea61 | 148 | |
d62a17ae | 149 | /* Information about up/down changes */ |
150 | unsigned int up_count; | |
e36f61b5 | 151 | char up_last[FRR_TIMESTAMP_LEN]; |
d62a17ae | 152 | unsigned int down_count; |
e36f61b5 | 153 | char down_last[FRR_TIMESTAMP_LEN]; |
55ce4d3a | 154 | |
d62a17ae | 155 | struct rtadvconf rtadv; |
156 | unsigned int ra_sent, ra_rcvd; | |
ca776988 | 157 | |
2eb27eec | 158 | struct irdp_interface *irdp; |
ca776988 | 159 | |
8ccc7e80 | 160 | #ifdef HAVE_STRUCT_SOCKADDR_DL |
d62a17ae | 161 | union { |
162 | /* note that sdl_storage is never accessed, it only exists to | |
163 | * make space. | |
164 | * all actual uses refer to sdl - but use sizeof(sdl_storage)! | |
165 | * this fits | |
166 | * best with C aliasing rules. */ | |
167 | struct sockaddr_dl sdl; | |
168 | struct sockaddr_storage sdl_storage; | |
169 | }; | |
8ccc7e80 TT |
170 | #endif |
171 | ||
d62a17ae | 172 | /* ptm enable configuration */ |
d7c0a89a | 173 | uint8_t ptm_enable; |
6675513d | 174 | |
d62a17ae | 175 | /* Zebra interface and "slave" interface type */ |
e6f2bec0 | 176 | enum zebra_iftype zif_type; |
a81982fa | 177 | enum zebra_slave_iftype zif_slave_type; |
6675513d | 178 | |
d62a17ae | 179 | /* Additional L2 info, depends on zif_type */ |
180 | union zebra_l2if_info l2info; | |
6675513d | 181 | |
d62a17ae | 182 | /* For members of a bridge, link to bridge. */ |
183 | /* Note: If additional fields become necessary, this can be modified to | |
184 | * be a pointer to a dynamically allocd struct. | |
185 | */ | |
186 | struct zebra_l2info_brslave brslave_info; | |
6675513d | 187 | |
b9368db9 | 188 | struct zebra_l2info_bondslave bondslave_info; |
c36e442c | 189 | struct zebra_l2info_bond bond_info; |
b9368db9 | 190 | |
ce5160c0 AK |
191 | /* ethernet segment */ |
192 | struct zebra_es_if_info es_info; | |
193 | ||
194 | /* bitmap of vlans associated with this interface */ | |
195 | bitfield_t vlan_bitmap; | |
196 | ||
c36e442c AK |
197 | /* An interface can be error-disabled if a protocol (such as EVPN or |
198 | * VRRP) detects a problem with keeping it operationally-up. | |
199 | * If any of the protodown bits are set protodown-on is programmed | |
200 | * in the dataplane. This results in a carrier/L1 down on the | |
201 | * physical device. | |
202 | */ | |
5d414138 | 203 | uint32_t protodown_rc; |
c36e442c | 204 | |
8b07f173 AK |
205 | /* list of zebra_mac entries using this interface as destination */ |
206 | struct list *mac_list; | |
207 | ||
d62a17ae | 208 | /* Link fields - for sub-interfaces. */ |
209 | ifindex_t link_ifindex; | |
210 | struct interface *link; | |
dc7b3cae | 211 | |
fbc83b9a | 212 | uint8_t speed_update_count; |
dc7b3cae | 213 | struct thread *speed_update; |
20089ae2 DS |
214 | |
215 | /* | |
216 | * Does this interface have a v6 to v4 ll neighbor entry | |
217 | * for bgp unnumbered? | |
218 | */ | |
219 | bool v6_2_v4_ll_neigh_entry; | |
ee98d1f1 | 220 | char neigh_mac[6]; |
20089ae2 | 221 | struct in6_addr v6_2_v4_ll_addr6; |
ba5165ec DS |
222 | |
223 | /* The description of the interface */ | |
224 | char *desc; | |
718e3744 | 225 | }; |
226 | ||
996c9314 | 227 | DECLARE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp), |
8451921b | 228 | (vty, ifp)); |
996c9314 | 229 | DECLARE_HOOK(zebra_if_config_wr, (struct vty * vty, struct interface *ifp), |
8451921b | 230 | (vty, ifp)); |
2eb27eec | 231 | |
d62a17ae | 232 | #define IS_ZEBRA_IF_VRF(ifp) \ |
233 | (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VRF) | |
234 | ||
235 | #define IS_ZEBRA_IF_BRIDGE(ifp) \ | |
236 | (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_BRIDGE) | |
237 | ||
238 | #define IS_ZEBRA_IF_VLAN(ifp) \ | |
239 | (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VLAN) | |
240 | ||
241 | #define IS_ZEBRA_IF_VXLAN(ifp) \ | |
242 | (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VXLAN) | |
243 | ||
1a98c087 MK |
244 | #define IS_ZEBRA_IF_MACVLAN(ifp) \ |
245 | (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_MACVLAN) | |
246 | ||
0e4864ea PG |
247 | #define IS_ZEBRA_IF_VETH(ifp) \ |
248 | (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VETH) | |
249 | ||
c36e442c AK |
250 | #define IS_ZEBRA_IF_BOND(ifp) \ |
251 | (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_BOND) | |
252 | ||
077c07cc PG |
253 | #define IS_ZEBRA_IF_GRE(ifp) \ |
254 | (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_GRE) | |
255 | ||
0e4864ea | 256 | #define IS_ZEBRA_IF_BRIDGE_SLAVE(ifp) \ |
d62a17ae | 257 | (((struct zebra_if *)(ifp->info))->zif_slave_type \ |
258 | == ZEBRA_IF_SLAVE_BRIDGE) | |
259 | ||
260 | #define IS_ZEBRA_IF_VRF_SLAVE(ifp) \ | |
261 | (((struct zebra_if *)(ifp->info))->zif_slave_type == ZEBRA_IF_SLAVE_VRF) | |
262 | ||
b9368db9 DD |
263 | #define IS_ZEBRA_IF_BOND_SLAVE(ifp) \ |
264 | (((struct zebra_if *)(ifp->info))->zif_slave_type \ | |
265 | == ZEBRA_IF_SLAVE_BOND) | |
266 | ||
05f7f5db DS |
267 | extern void zebra_if_init(void); |
268 | ||
d7c0a89a | 269 | extern struct interface *if_lookup_by_index_per_ns(struct zebra_ns *, uint32_t); |
d62a17ae | 270 | extern struct interface *if_lookup_by_name_per_ns(struct zebra_ns *, |
271 | const char *); | |
272 | extern struct interface *if_link_per_ns(struct zebra_ns *, struct interface *); | |
273 | extern const char *ifindex2ifname_per_ns(struct zebra_ns *, unsigned int); | |
274 | ||
275 | extern void if_unlink_per_ns(struct interface *); | |
ee98d1f1 DS |
276 | extern void if_nbr_mac_to_ipv4ll_neigh_update(struct interface *fip, |
277 | char mac[6], | |
278 | struct in6_addr *address, | |
279 | int add); | |
d62a17ae | 280 | extern void if_nbr_ipv6ll_to_ipv4ll_neigh_update(struct interface *ifp, |
281 | struct in6_addr *address, | |
282 | int add); | |
283 | extern void if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(struct interface *ifp); | |
d0438da6 | 284 | extern void if_delete_update(struct interface **ifp); |
d62a17ae | 285 | extern void if_add_update(struct interface *ifp); |
8b48cdb9 | 286 | extern void if_up(struct interface *ifp, bool install_connected); |
d62a17ae | 287 | extern void if_down(struct interface *); |
288 | extern void if_refresh(struct interface *); | |
289 | extern void if_flags_update(struct interface *, uint64_t); | |
290 | extern int if_subnet_add(struct interface *, struct connected *); | |
291 | extern int if_subnet_delete(struct interface *, struct connected *); | |
292 | extern int ipv6_address_configured(struct interface *ifp); | |
293 | extern void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id); | |
680c278f PG |
294 | extern void zebra_if_update_link(struct interface *ifp, ifindex_t link_ifindex, |
295 | ns_id_t ns_id); | |
357b150d | 296 | extern void zebra_if_update_all_links(struct zebra_ns *zns); |
321c80d6 SW |
297 | /** |
298 | * Directly update entire protodown & reason code bitfield. | |
299 | */ | |
300 | extern int zebra_if_update_protodown_rc(struct interface *ifp, bool new_down, | |
301 | uint32_t new_protodown_rc); | |
302 | /** | |
303 | * Set protodown with single reason. | |
304 | */ | |
5d414138 SW |
305 | extern int zebra_if_set_protodown(struct interface *ifp, bool down, |
306 | enum protodown_reasons new_reason); | |
09268680 CS |
307 | extern int if_ip_address_install(struct interface *ifp, struct prefix *prefix, |
308 | const char *label, struct prefix *pp); | |
309 | extern int if_ipv6_address_install(struct interface *ifp, struct prefix *prefix, | |
310 | const char *label); | |
311 | extern int if_ip_address_uinstall(struct interface *ifp, struct prefix *prefix); | |
312 | extern int if_shutdown(struct interface *ifp); | |
313 | extern int if_no_shutdown(struct interface *ifp); | |
314 | extern int if_multicast_set(struct interface *ifp); | |
315 | extern int if_multicast_unset(struct interface *ifp); | |
316 | extern int if_linkdetect(struct interface *ifp, bool detect); | |
317 | extern void if_addr_wakeup(struct interface *ifp); | |
d62a17ae | 318 | |
fe593b78 SW |
319 | /* Nexthop group connected functions */ |
320 | extern void if_nhg_dependents_add(struct interface *ifp, | |
321 | struct nhg_hash_entry *nhe); | |
322 | extern void if_nhg_dependents_del(struct interface *ifp, | |
323 | struct nhg_hash_entry *nhe); | |
324 | extern unsigned int if_nhg_dependents_count(const struct interface *ifp); | |
325 | extern bool if_nhg_dependents_is_empty(const struct interface *ifp); | |
602fea61 | 326 | |
d62a17ae | 327 | extern void vrf_add_update(struct vrf *vrfp); |
c36e442c AK |
328 | extern void zebra_l2_map_slave_to_bond(struct zebra_if *zif, vrf_id_t vrf); |
329 | extern void zebra_l2_unmap_slave_from_bond(struct zebra_if *zif); | |
5d414138 SW |
330 | extern const char *zebra_protodown_rc_str(uint32_t protodown_rc, char *pd_buf, |
331 | uint32_t pd_buf_len); | |
332 | void zebra_if_dplane_result(struct zebra_dplane_ctx *ctx); | |
12f6fb97 | 333 | |
718e3744 | 334 | #ifdef HAVE_PROC_NET_DEV |
d62a17ae | 335 | extern void ifstat_update_proc(void); |
718e3744 | 336 | #endif /* HAVE_PROC_NET_DEV */ |
337 | #ifdef HAVE_NET_RT_IFLIST | |
d62a17ae | 338 | extern void ifstat_update_sysctl(void); |
718e3744 | 339 | |
340 | #endif /* HAVE_NET_RT_IFLIST */ | |
341 | #ifdef HAVE_PROC_NET_DEV | |
d62a17ae | 342 | extern int interface_list_proc(void); |
718e3744 | 343 | #endif /* HAVE_PROC_NET_DEV */ |
344 | #ifdef HAVE_PROC_NET_IF_INET6 | |
d62a17ae | 345 | extern int ifaddr_proc_ipv6(void); |
718e3744 | 346 | #endif /* HAVE_PROC_NET_IF_INET6 */ |
347 | ||
51e94aa7 EDP |
348 | #ifdef __cplusplus |
349 | } | |
350 | #endif | |
351 | ||
5b73a671 | 352 | #endif /* _ZEBRA_INTERFACE_H */ |