]> git.proxmox.com Git - mirror_frr.git/blame - zebra/interface.h
zebra: kernel_socket: read extra attributes
[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. */
63 /* $FRR indent$ */
64 /* clang-format off */
718e3744 65#define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)
66
d62a17ae 67 /* Unsolicited Router Advertisements' interval timer. */
68 int AdvIntervalTimer;
718e3744 69
d62a17ae 70 /* The TRUE/FALSE value to be placed in the "Managed address
71 configuration" flag field in the Router Advertisement. See
72 [ADDRCONF].
718e3744 73
d62a17ae 74 Default: FALSE */
75 int AdvManagedFlag;
718e3744 76
718e3744 77
d62a17ae 78 /* The TRUE/FALSE value to be placed in the "Other stateful
79 configuration" flag field in the Router Advertisement. See
80 [ADDRCONF].
718e3744 81
d62a17ae 82 Default: FALSE */
83 int AdvOtherConfigFlag;
718e3744 84
d62a17ae 85 /* The value to be placed in MTU options sent by the router. A
86 value of zero indicates that no MTU options are sent.
718e3744 87
d62a17ae 88 Default: 0 */
89 int AdvLinkMTU;
718e3744 90
718e3744 91
d62a17ae 92 /* The value to be placed in the Reachable Time field in the Router
93 Advertisement messages sent by the router. The value zero means
94 unspecified (by this router). MUST be no greater than 3,600,000
95 milliseconds (1 hour).
718e3744 96
d62a17ae 97 Default: 0 */
98 u_int32_t AdvReachableTime;
99#define RTADV_MAX_REACHABLE_TIME 3600000
718e3744 100
d62a17ae 101 /* The value to be placed in the Retrans Timer field in the Router
102 Advertisement messages sent by the router. The value zero means
103 unspecified (by this router).
718e3744 104
d62a17ae 105 Default: 0 */
106 int AdvRetransTimer;
718e3744 107
d62a17ae 108 /* The default value to be placed in the Cur Hop Limit field in the
109 Router Advertisement messages sent by the router. The value
110 should be set to that current diameter of the Internet. The
111 value zero means unspecified (by this router).
718e3744 112
d62a17ae 113 Default: The value specified in the "Assigned Numbers" RFC
114 [ASSIGNED] that was in effect at the time of implementation. */
115 int AdvCurHopLimit;
718e3744 116
d62a17ae 117 /* The value to be placed in the Router Lifetime field of Router
118 Advertisements sent from the interface, in seconds. MUST be
119 either zero or between MaxRtrAdvInterval and 9000 seconds. A
120 value of zero indicates that the router is not to be used as a
121 default router.
718e3744 122
d62a17ae 123 Default: 3 * MaxRtrAdvInterval */
124 int AdvDefaultLifetime;
d660f698 125#define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
718e3744 126
d62a17ae 127 /* A list of prefixes to be placed in Prefix Information options in
128 Router Advertisement messages sent from the interface.
718e3744 129
d62a17ae 130 Default: all prefixes that the router advertises via routing
131 protocols as being on-link for the interface from which the
132 advertisement is sent. The link-local prefix SHOULD NOT be
133 included in the list of advertised prefixes. */
134 struct list *AdvPrefixList;
7cee1bb1 135
d62a17ae 136 /* The TRUE/FALSE value to be placed in the "Home agent"
137 flag field in the Router Advertisement. See [RFC6275 7.1].
7cee1bb1 138
d62a17ae 139 Default: FALSE */
140 int AdvHomeAgentFlag;
7cee1bb1 141#ifndef ND_RA_FLAG_HOME_AGENT
142#define ND_RA_FLAG_HOME_AGENT 0x20
143#endif
144
d62a17ae 145 /* The value to be placed in Home Agent Information option if Home
146 Flag is set.
147 Default: 0 */
148 int HomeAgentPreference;
149
150 /* The value to be placed in Home Agent Information option if Home
151 Flag is set. Lifetime (seconds) MUST not be greater than 18.2
152 hours.
153 The value 0 has special meaning: use of AdvDefaultLifetime value.
154
155 Default: 0 */
156 int HomeAgentLifetime;
7cee1bb1 157#define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
158
d62a17ae 159 /* The TRUE/FALSE value to insert or not an Advertisement Interval
160 option. See [RFC 6275 7.3]
7cee1bb1 161
d62a17ae 162 Default: FALSE */
163 int AdvIntervalOption;
b60668d0 164
d62a17ae 165 /* The value to be placed in the Default Router Preference field of
166 a router advertisement. See [RFC 4191 2.1 & 2.2]
b60668d0 167
d62a17ae 168 Default: 0 (medium) */
169 int DefaultPreference;
b60668d0 170#define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
6c9678b4 171
9d303b37
DL
172 u_char inFastRexmit; /* True if we're rexmits faster than usual */
173 u_char configured; /* Has operator configured RA? */
174 int
175 NumFastReXmitsRemain; /* Loaded first with number of fast
176 rexmits to do */
6c9678b4
DD
177
178#define RTADV_FAST_REXMIT_PERIOD 1 /* 1 sec */
179#define RTADV_NUM_FAST_REXMITS 4 /* Fast Rexmit RA 4 times on certain events */
718e3744 180};
181
8da4e946 182#endif /* HAVE_RTADV */
718e3744 183
6675513d 184/* Zebra interface type - ones of interest. */
d62a17ae 185typedef enum {
1a98c087
MK
186 ZEBRA_IF_VXLAN, /* VxLAN interface */
187 ZEBRA_IF_VRF, /* VRF device */
188 ZEBRA_IF_BRIDGE, /* bridge device */
189 ZEBRA_IF_VLAN, /* VLAN sub-interface */
190 ZEBRA_IF_MACVLAN, /* MAC VLAN interface*/
191 ZEBRA_IF_OTHER, /* Anything else */
6675513d 192} zebra_iftype_t;
193
194/* Zebra "slave" interface type */
d62a17ae 195typedef enum {
196 ZEBRA_IF_SLAVE_NONE, /* Not a slave */
197 ZEBRA_IF_SLAVE_VRF, /* Member of a VRF */
198 ZEBRA_IF_SLAVE_BRIDGE, /* Member of a bridge */
199 ZEBRA_IF_SLAVE_OTHER, /* Something else - e.g., bond slave */
6675513d 200} zebra_slave_iftype_t;
201
2eb27eec
DL
202struct irdp_interface;
203
718e3744 204/* `zebra' daemon local interface structure. */
d62a17ae 205struct zebra_if {
206 /* Shutdown configuration. */
207 u_char shutdown;
718e3744 208
d62a17ae 209 /* Multicast configuration. */
210 u_char multicast;
718e3744 211
d62a17ae 212 /* Router advertise configuration. */
213 u_char rtadv_enable;
718e3744 214
d62a17ae 215 /* Installed addresses chains tree. */
216 struct route_table *ipv4_subnets;
eef1fe11 217
d62a17ae 218 /* Information about up/down changes */
219 unsigned int up_count;
220 char up_last[QUAGGA_TIMESTAMP_LEN];
221 unsigned int down_count;
222 char down_last[QUAGGA_TIMESTAMP_LEN];
55ce4d3a 223
8da4e946 224#if defined(HAVE_RTADV)
d62a17ae 225 struct rtadvconf rtadv;
226 unsigned int ra_sent, ra_rcvd;
8da4e946 227#endif /* HAVE_RTADV */
ca776988 228
2eb27eec 229 struct irdp_interface *irdp;
ca776988 230
8ccc7e80 231#ifdef HAVE_STRUCT_SOCKADDR_DL
d62a17ae 232 union {
233 /* note that sdl_storage is never accessed, it only exists to
234 * make space.
235 * all actual uses refer to sdl - but use sizeof(sdl_storage)!
236 * this fits
237 * best with C aliasing rules. */
238 struct sockaddr_dl sdl;
239 struct sockaddr_storage sdl_storage;
240 };
8ccc7e80
TT
241#endif
242
5c78b3d0 243#ifdef SUNOS_5
d62a17ae 244 /* the real IFF_UP state of the primary interface.
245 * need this to differentiate between all interfaces being
246 * down (but primary still plumbed) and primary having gone
247 * ~IFF_UP, and all addresses gone.
248 */
249 u_char primary_state;
5c78b3d0 250#endif /* SUNOS_5 */
986aa00f 251
d62a17ae 252 /* ptm enable configuration */
253 u_char ptm_enable;
6675513d 254
d62a17ae 255 /* Zebra interface and "slave" interface type */
256 zebra_iftype_t zif_type;
257 zebra_slave_iftype_t zif_slave_type;
6675513d 258
d62a17ae 259 /* Additional L2 info, depends on zif_type */
260 union zebra_l2if_info l2info;
6675513d 261
d62a17ae 262 /* For members of a bridge, link to bridge. */
263 /* Note: If additional fields become necessary, this can be modified to
264 * be a pointer to a dynamically allocd struct.
265 */
266 struct zebra_l2info_brslave brslave_info;
6675513d 267
d62a17ae 268 /* Link fields - for sub-interfaces. */
269 ifindex_t link_ifindex;
270 struct interface *link;
718e3744 271};
272
2eb27eec
DL
273DECLARE_HOOK(zebra_if_extra_info, (struct vty *vty, struct interface *ifp),
274 (vty, ifp))
275DECLARE_HOOK(zebra_if_config_wr, (struct vty *vty, struct interface *ifp),
276 (vty, ifp))
277
d62a17ae 278static inline void zebra_if_set_ziftype(struct interface *ifp,
279 zebra_iftype_t zif_type,
280 zebra_slave_iftype_t zif_slave_type)
6675513d 281{
d62a17ae 282 struct zebra_if *zif;
6675513d 283
d62a17ae 284 zif = (struct zebra_if *)ifp->info;
285 zif->zif_type = zif_type;
286 zif->zif_slave_type = zif_slave_type;
6675513d 287}
288
d62a17ae 289#define IS_ZEBRA_IF_VRF(ifp) \
290 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VRF)
291
292#define IS_ZEBRA_IF_BRIDGE(ifp) \
293 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_BRIDGE)
294
295#define IS_ZEBRA_IF_VLAN(ifp) \
296 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VLAN)
297
298#define IS_ZEBRA_IF_VXLAN(ifp) \
299 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VXLAN)
300
1a98c087
MK
301#define IS_ZEBRA_IF_MACVLAN(ifp) \
302 (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_MACVLAN)
303
d62a17ae 304#define IS_ZEBRA_IF_BRIDGE_SLAVE(ifp) \
305 (((struct zebra_if *)(ifp->info))->zif_slave_type \
306 == ZEBRA_IF_SLAVE_BRIDGE)
307
308#define IS_ZEBRA_IF_VRF_SLAVE(ifp) \
309 (((struct zebra_if *)(ifp->info))->zif_slave_type == ZEBRA_IF_SLAVE_VRF)
310
311extern struct interface *if_lookup_by_index_per_ns(struct zebra_ns *,
312 u_int32_t);
313extern struct interface *if_lookup_by_name_per_ns(struct zebra_ns *,
314 const char *);
315extern struct interface *if_link_per_ns(struct zebra_ns *, struct interface *);
316extern const char *ifindex2ifname_per_ns(struct zebra_ns *, unsigned int);
317
318extern void if_unlink_per_ns(struct interface *);
319extern void if_nbr_ipv6ll_to_ipv4ll_neigh_update(struct interface *ifp,
320 struct in6_addr *address,
321 int add);
322extern void if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(struct interface *ifp);
323extern void if_delete_update(struct interface *ifp);
324extern void if_add_update(struct interface *ifp);
325extern void if_up(struct interface *);
326extern void if_down(struct interface *);
327extern void if_refresh(struct interface *);
328extern void if_flags_update(struct interface *, uint64_t);
329extern int if_subnet_add(struct interface *, struct connected *);
330extern int if_subnet_delete(struct interface *, struct connected *);
331extern int ipv6_address_configured(struct interface *ifp);
332extern void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id);
333extern void zebra_if_update_link(struct interface *ifp, ifindex_t link_ifindex);
334
335extern void vrf_add_update(struct vrf *vrfp);
12f6fb97 336
718e3744 337#ifdef HAVE_PROC_NET_DEV
d62a17ae 338extern void ifstat_update_proc(void);
718e3744 339#endif /* HAVE_PROC_NET_DEV */
340#ifdef HAVE_NET_RT_IFLIST
d62a17ae 341extern void ifstat_update_sysctl(void);
718e3744 342
343#endif /* HAVE_NET_RT_IFLIST */
344#ifdef HAVE_PROC_NET_DEV
d62a17ae 345extern int interface_list_proc(void);
718e3744 346#endif /* HAVE_PROC_NET_DEV */
347#ifdef HAVE_PROC_NET_IF_INET6
d62a17ae 348extern int ifaddr_proc_ipv6(void);
718e3744 349#endif /* HAVE_PROC_NET_IF_INET6 */
350
5b73a671 351#endif /* _ZEBRA_INTERFACE_H */