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