xref: /freebsd/sys/net/route/nhop.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1a6663252SAlexander V. Chernikov /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3a6663252SAlexander V. Chernikov  *
4a6663252SAlexander V. Chernikov  * Copyright (c) 2020 Alexander V. Chernikov
5a6663252SAlexander V. Chernikov  *
6a6663252SAlexander V. Chernikov  * Redistribution and use in source and binary forms, with or without
7a6663252SAlexander V. Chernikov  * modification, are permitted provided that the following conditions
8a6663252SAlexander V. Chernikov  * are met:
9a6663252SAlexander V. Chernikov  * 1. Redistributions of source code must retain the above copyright
10a6663252SAlexander V. Chernikov  *    notice, this list of conditions and the following disclaimer.
11a6663252SAlexander V. Chernikov  * 2. Redistributions in binary form must reproduce the above copyright
12a6663252SAlexander V. Chernikov  *    notice, this list of conditions and the following disclaimer in the
13a6663252SAlexander V. Chernikov  *    documentation and/or other materials provided with the distribution.
14a6663252SAlexander V. Chernikov  *
15a6663252SAlexander V. Chernikov  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16a6663252SAlexander V. Chernikov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17a6663252SAlexander V. Chernikov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18a6663252SAlexander V. Chernikov  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19a6663252SAlexander V. Chernikov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20a6663252SAlexander V. Chernikov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21a6663252SAlexander V. Chernikov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22a6663252SAlexander V. Chernikov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23a6663252SAlexander V. Chernikov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24a6663252SAlexander V. Chernikov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25a6663252SAlexander V. Chernikov  * SUCH DAMAGE.
26a6663252SAlexander V. Chernikov  */
27a6663252SAlexander V. Chernikov 
28a6663252SAlexander V. Chernikov /*
29a6663252SAlexander V. Chernikov  * This header file contains public definitions for the nexthop routing subsystem.
30a6663252SAlexander V. Chernikov  */
31a6663252SAlexander V. Chernikov 
32a6663252SAlexander V. Chernikov #ifndef	_NET_ROUTE_NHOP_H_
33a6663252SAlexander V. Chernikov #define	_NET_ROUTE_NHOP_H_
34a6663252SAlexander V. Chernikov 
35a6663252SAlexander V. Chernikov #include <netinet/in.h>			/* sockaddr_in && sockaddr_in6 */
36a6663252SAlexander V. Chernikov 
37a6663252SAlexander V. Chernikov #include <sys/counter.h>
38a6663252SAlexander V. Chernikov 
39a6663252SAlexander V. Chernikov enum nhop_type {
40a6663252SAlexander V. Chernikov 	NH_TYPE_IPV4_ETHER_RSLV = 1,	/* IPv4 ethernet without GW */
41a6663252SAlexander V. Chernikov 	NH_TYPE_IPV4_ETHER_NHOP = 2,	/* IPv4 with pre-calculated ethernet encap */
42a6663252SAlexander V. Chernikov 	NH_TYPE_IPV6_ETHER_RSLV = 3,	/* IPv6 ethernet, without GW */
43a6663252SAlexander V. Chernikov 	NH_TYPE_IPV6_ETHER_NHOP = 4	/* IPv6 with pre-calculated ethernet encap*/
44a6663252SAlexander V. Chernikov };
45a6663252SAlexander V. Chernikov 
46a6663252SAlexander V. Chernikov #ifdef _KERNEL
47a6663252SAlexander V. Chernikov 
48a6663252SAlexander V. Chernikov /*
49a6663252SAlexander V. Chernikov  * Define shorter version of AF_LINK sockaddr.
50a6663252SAlexander V. Chernikov  *
51a6663252SAlexander V. Chernikov  * Currently the only use case of AF_LINK gateway is storing
52a6663252SAlexander V. Chernikov  * interface index of the interface of the source IPv6 address.
53a6663252SAlexander V. Chernikov  * This is used by the IPv6 code for the connections over loopback
54a6663252SAlexander V. Chernikov  * interface.
55a6663252SAlexander V. Chernikov  *
56a6663252SAlexander V. Chernikov  * The structure below copies 'struct sockaddr_dl', reducing the
57a6663252SAlexander V. Chernikov  * size of sdl_data buffer, as it is not used. This change
58a6663252SAlexander V. Chernikov  * allows to store the AF_LINK gateways in the nhop gateway itself,
59a6663252SAlexander V. Chernikov  * simplifying control plane handling.
60a6663252SAlexander V. Chernikov  */
61a6663252SAlexander V. Chernikov struct sockaddr_dl_short {
62a6663252SAlexander V. Chernikov 	u_char	sdl_len;	/* Total length of sockaddr */
63a6663252SAlexander V. Chernikov 	u_char	sdl_family;	/* AF_LINK */
64a6663252SAlexander V. Chernikov 	u_short	sdl_index;	/* if != 0, system given index for interface */
65a6663252SAlexander V. Chernikov 	u_char	sdl_type;	/* interface type */
66a6663252SAlexander V. Chernikov 	u_char	sdl_nlen;	/* interface name length, no trailing 0 reqd. */
67a6663252SAlexander V. Chernikov 	u_char	sdl_alen;	/* link level address length */
68a6663252SAlexander V. Chernikov 	u_char	sdl_slen;	/* link layer selector length */
69a6663252SAlexander V. Chernikov 	char	sdl_data[8];	/* unused */
70a6663252SAlexander V. Chernikov };
71a6663252SAlexander V. Chernikov 
72a6663252SAlexander V. Chernikov #define	NHOP_RELATED_FLAGS	\
73a6663252SAlexander V. Chernikov 	(RTF_GATEWAY | RTF_HOST | RTF_REJECT | RTF_BLACKHOLE | \
74a6663252SAlexander V. Chernikov 	 RTF_FIXEDMTU | RTF_LOCAL | RTF_BROADCAST | RTF_MULTICAST)
75a6663252SAlexander V. Chernikov 
76a6663252SAlexander V. Chernikov struct nh_control;
77a6663252SAlexander V. Chernikov struct nhop_priv;
78a6663252SAlexander V. Chernikov 
79a6663252SAlexander V. Chernikov /*
80a6663252SAlexander V. Chernikov  * Struct 'nhop_object' field description:
81a6663252SAlexander V. Chernikov  *
82a6663252SAlexander V. Chernikov  * nh_flags: NHF_ flags used in the dataplane code. NHF_GATEWAY or NHF_BLACKHOLE
83a6663252SAlexander V. Chernikov  *   can be examples of such flags.
84a6663252SAlexander V. Chernikov  * nh_mtu: ready-to-use nexthop mtu. Already accounts for the link-level header,
85a6663252SAlexander V. Chernikov  *   interface MTU and protocol-specific limitations.
86a6663252SAlexander V. Chernikov  * nh_prepend_len: link-level prepend length. Currently unused.
87a6663252SAlexander V. Chernikov  * nh_ifp: logical transmit interface. The one from which if_transmit() will be
88a6663252SAlexander V. Chernikov  *   called. Guaranteed to be non-NULL.
89a6663252SAlexander V. Chernikov  * nh_aifp: ifnet of the source address. Same as nh_ifp except IPv6 loopback
90a6663252SAlexander V. Chernikov  *   routes. See the example below.
91a6663252SAlexander V. Chernikov  * nh_ifa: interface address to use. Guaranteed to be non-NULL.
92a6663252SAlexander V. Chernikov  * nh_pksent: counter(9) reflecting the number of packets transmitted.
93a6663252SAlexander V. Chernikov  *
94a6663252SAlexander V. Chernikov  * gw_: storage suitable to hold AF_INET, AF_INET6 or AF_LINK gateway. More
95a6663252SAlexander V. Chernikov  *   details ara available in the examples below.
96a6663252SAlexander V. Chernikov  *
97a6663252SAlexander V. Chernikov  * Examples:
98a6663252SAlexander V. Chernikov  *
99a6663252SAlexander V. Chernikov  * Direct routes (routes w/o gateway):
100a6663252SAlexander V. Chernikov  *  NHF_GATEWAY is NOT set.
101a6663252SAlexander V. Chernikov  *  nh_ifp denotes the logical transmit interface ().
102a6663252SAlexander V. Chernikov  *  nh_aifp is the same as nh_ifp
103a6663252SAlexander V. Chernikov  *  gw_sa contains AF_LINK sa with nh_aifp ifindex (compat)
104a6663252SAlexander V. Chernikov  * Loopback routes:
105a6663252SAlexander V. Chernikov  *  NHF_GATEWAY is NOT set.
106a6663252SAlexander V. Chernikov  *  nh_ifp points to the loopback interface (lo0).
107a6663252SAlexander V. Chernikov  *  nh_aifp points to the interface where the destination address belongs to.
108a6663252SAlexander V. Chernikov  *    This is useful in IPv6 link-local-over-loopback communications.
109a6663252SAlexander V. Chernikov  *  gw_sa contains AF_LINK sa with nh_aifp ifindex (compat)
110a6663252SAlexander V. Chernikov  * GW routes:
111a6663252SAlexander V. Chernikov  *  NHF_GATEWAY is set.
112a6663252SAlexander V. Chernikov  *  nh_ifp denotes the logical transmit interface.
113a6663252SAlexander V. Chernikov  *  nh_aifp is the same as nh_ifp
114a6663252SAlexander V. Chernikov  *  gw_sa contains L3 address (either AF_INET or AF_INET6).
115a6663252SAlexander V. Chernikov  *
116a6663252SAlexander V. Chernikov  *
117a6663252SAlexander V. Chernikov  * Note: struct nhop_object fields are ordered in a way that
118a6663252SAlexander V. Chernikov  *  supports memcmp-based comparisons.
119a6663252SAlexander V. Chernikov  *
120a6663252SAlexander V. Chernikov  */
121a6663252SAlexander V. Chernikov #define	NHOP_END_CMP	(__offsetof(struct nhop_object, nh_pksent))
122a6663252SAlexander V. Chernikov 
123a6663252SAlexander V. Chernikov struct nhop_object {
124a6663252SAlexander V. Chernikov 	uint16_t		nh_flags;	/* nhop flags */
125a6663252SAlexander V. Chernikov 	uint16_t		nh_mtu;		/* nexthop mtu */
126a6663252SAlexander V. Chernikov 	union {
127a6663252SAlexander V. Chernikov 		struct sockaddr_in		gw4_sa;	/* GW accessor as IPv4 */
128a6663252SAlexander V. Chernikov 		struct sockaddr_in6		gw6_sa; /* GW accessor as IPv6 */
129a6663252SAlexander V. Chernikov 		struct sockaddr			gw_sa;
130a6663252SAlexander V. Chernikov 		struct sockaddr_dl_short	gwl_sa; /* AF_LINK gw (compat) */
131a6663252SAlexander V. Chernikov 		char				gw_buf[28];
132a6663252SAlexander V. Chernikov 	};
133a6663252SAlexander V. Chernikov 	struct ifnet		*nh_ifp;	/* Logical egress interface. Always != NULL */
134a6663252SAlexander V. Chernikov 	struct ifaddr		*nh_ifa;	/* interface address to use. Always != NULL */
135a6663252SAlexander V. Chernikov 	struct ifnet		*nh_aifp;	/* ifnet of the source address. Always != NULL */
136a6663252SAlexander V. Chernikov 	counter_u64_t		nh_pksent;	/* packets sent using this nhop */
137a6663252SAlexander V. Chernikov 	/* 32 bytes + 4xPTR == 64(amd64) / 48(i386)  */
138a6663252SAlexander V. Chernikov 	uint8_t			nh_prepend_len;	/* length of prepend data */
139a6663252SAlexander V. Chernikov 	uint8_t			spare[3];
140a6663252SAlexander V. Chernikov 	uint32_t		spare1;		/* alignment */
141a6663252SAlexander V. Chernikov 	char			nh_prepend[48];	/* L2 prepend */
142a6663252SAlexander V. Chernikov 	struct nhop_priv	*nh_priv;	/* control plane data */
143a6663252SAlexander V. Chernikov 	/* -- 128 bytes -- */
144a6663252SAlexander V. Chernikov };
145a6663252SAlexander V. Chernikov 
146a6663252SAlexander V. Chernikov /*
147a6663252SAlexander V. Chernikov  * Nhop validness.
148a6663252SAlexander V. Chernikov  *
149a6663252SAlexander V. Chernikov  * Currently we verify whether link is up or not on every packet, which can be
150a6663252SAlexander V. Chernikov  *   quite costy.
151a6663252SAlexander V. Chernikov  * TODO: subscribe for the interface notifications and update the nexthops
152a6663252SAlexander V. Chernikov  *  with NHF_INVALID flag.
153a6663252SAlexander V. Chernikov  */
154a6663252SAlexander V. Chernikov 
155a6663252SAlexander V. Chernikov #define	NH_IS_VALID(_nh)	RT_LINK_IS_UP((_nh)->nh_ifp)
156fedeb08bSAlexander V. Chernikov #define	NH_IS_NHGRP(_nh)	((_nh)->nh_flags & NHF_MULTIPATH)
157a6663252SAlexander V. Chernikov 
158a6663252SAlexander V. Chernikov #define	NH_FREE(_nh) do {					\
159a6663252SAlexander V. Chernikov 	nhop_free(_nh);	\
160a6663252SAlexander V. Chernikov 	/* guard against invalid refs */			\
161a6663252SAlexander V. Chernikov 	_nh = NULL;						\
162a6663252SAlexander V. Chernikov } while (0)
163a6663252SAlexander V. Chernikov 
164fedeb08bSAlexander V. Chernikov struct weightened_nhop {
165fedeb08bSAlexander V. Chernikov 	struct nhop_object	*nh;
166fedeb08bSAlexander V. Chernikov 	uint32_t		weight;
16776f1ab8eSAlexander V. Chernikov 	uint32_t		storage;
168fedeb08bSAlexander V. Chernikov };
169fedeb08bSAlexander V. Chernikov 
170a6663252SAlexander V. Chernikov void nhop_free(struct nhop_object *nh);
171a6663252SAlexander V. Chernikov 
172a6663252SAlexander V. Chernikov struct sysctl_req;
173a6663252SAlexander V. Chernikov struct sockaddr_dl;
174a6663252SAlexander V. Chernikov struct rib_head;
175a6663252SAlexander V. Chernikov 
176800c6846SAlexander V. Chernikov /* flags that can be set using nhop_set_rtflags() */
177800c6846SAlexander V. Chernikov #define	RT_SET_RTFLAGS_MASK     (RTF_PROTO1 | RTF_PROTO2 | RTF_PROTO3 | RTF_STATIC)
178800c6846SAlexander V. Chernikov #define	RT_CHANGE_RTFLAGS_MASK	RT_SET_RTFLAGS_MASK
179800c6846SAlexander V. Chernikov 
180800c6846SAlexander V. Chernikov struct nhop_object *nhop_alloc(uint32_t fibnum, int family);
181800c6846SAlexander V. Chernikov void nhop_copy(struct nhop_object *nh, const struct nhop_object *nh_orig);
182800c6846SAlexander V. Chernikov struct nhop_object *nhop_get_nhop(struct nhop_object *nh, int *perror);
183fe05d1ddSAlexander V. Chernikov int nhop_get_unlinked(struct nhop_object *nh);
184800c6846SAlexander V. Chernikov 
185800c6846SAlexander V. Chernikov void nhop_set_direct_gw(struct nhop_object *nh, struct ifnet *ifp);
186800c6846SAlexander V. Chernikov bool nhop_set_gw(struct nhop_object *nh, const struct sockaddr *sa, bool is_gw);
187800c6846SAlexander V. Chernikov 
188800c6846SAlexander V. Chernikov 
189800c6846SAlexander V. Chernikov void nhop_set_mtu(struct nhop_object *nh, uint32_t mtu, bool from_user);
190800c6846SAlexander V. Chernikov void nhop_set_rtflags(struct nhop_object *nh, int rt_flags);
191800c6846SAlexander V. Chernikov void nhop_set_pxtype_flag(struct nhop_object *nh, int nh_flag);
192800c6846SAlexander V. Chernikov void nhop_set_broadcast(struct nhop_object *nh, bool is_broadcast);
193800c6846SAlexander V. Chernikov void nhop_set_blackhole(struct nhop_object *nh, int blackhole_rt_flag);
194800c6846SAlexander V. Chernikov void nhop_set_pinned(struct nhop_object *nh, bool is_pinned);
195800c6846SAlexander V. Chernikov void nhop_set_redirect(struct nhop_object *nh, bool is_redirect);
196800c6846SAlexander V. Chernikov void nhop_set_type(struct nhop_object *nh, enum nhop_type nh_type);
197800c6846SAlexander V. Chernikov void nhop_set_src(struct nhop_object *nh, struct ifaddr *ifa);
198800c6846SAlexander V. Chernikov void nhop_set_transmit_ifp(struct nhop_object *nh, struct ifnet *ifp);
199800c6846SAlexander V. Chernikov 
200000250beSAlexander V. Chernikov #define	NH_ORIGIN_UNSPEC	0 /* not set */
201000250beSAlexander V. Chernikov #define	NH_ORIGIN_REDIRECT	1 /* kernel-originated redirect */
202000250beSAlexander V. Chernikov #define	NH_ORIGIN_KERNEL	2 /* kernel (interface) routes */
203000250beSAlexander V. Chernikov #define	NH_ORIGIN_BOOT		3 /* kernel-originated routes at boot */
204000250beSAlexander V. Chernikov #define	NH_ORIGIN_STATIC	4 /* route(8) routes */
205000250beSAlexander V. Chernikov void nhop_set_origin(struct nhop_object *nh, uint8_t origin);
206e7624170SAlexander V. Chernikov uint8_t nhop_get_origin(const struct nhop_object *nh);
207000250beSAlexander V. Chernikov 
208a6663252SAlexander V. Chernikov uint32_t nhop_get_idx(const struct nhop_object *nh);
209db4ca190SAlexander V. Chernikov uint32_t nhop_get_uidx(const struct nhop_object *nh);
210db4ca190SAlexander V. Chernikov void nhop_set_uidx(struct nhop_object *nh, uint32_t uidx);
211a6663252SAlexander V. Chernikov enum nhop_type nhop_get_type(const struct nhop_object *nh);
212a6663252SAlexander V. Chernikov int nhop_get_rtflags(const struct nhop_object *nh);
2132bbab0afSAlexander V. Chernikov struct vnet *nhop_get_vnet(const struct nhop_object *nh);
2144e19e0d9SAlexander V. Chernikov struct nhop_object *nhop_select_func(struct nhop_object *nh, uint32_t flowid);
215823a08d7SAlexander V. Chernikov int nhop_get_upper_family(const struct nhop_object *nh);
216fe05d1ddSAlexander V. Chernikov bool nhop_set_upper_family(struct nhop_object *nh, int family);
217823a08d7SAlexander V. Chernikov int nhop_get_neigh_family(const struct nhop_object *nh);
218823a08d7SAlexander V. Chernikov uint32_t nhop_get_fibnum(const struct nhop_object *nh);
21940503b79SAlexander V. Chernikov void nhop_set_fibnum(struct nhop_object *nh, uint32_t fibnum);
2202717e958SAlexander V. Chernikov uint32_t nhop_get_expire(const struct nhop_object *nh);
2212717e958SAlexander V. Chernikov void nhop_set_expire(struct nhop_object *nh, uint32_t expire);
222fe05d1ddSAlexander V. Chernikov struct rib_head *nhop_get_rh(const struct nhop_object *nh);
223a6663252SAlexander V. Chernikov 
224db4ca190SAlexander V. Chernikov struct nhgrp_object;
22542f8123aSAlexander V. Chernikov struct nhgrp_object *nhgrp_alloc(uint32_t fibnum, int family,
22642f8123aSAlexander V. Chernikov     struct weightened_nhop *wn, int num_nhops, int *perror);
22742f8123aSAlexander V. Chernikov struct nhgrp_object *nhgrp_get_nhgrp(struct nhgrp_object *nhg, int *perror);
22842f8123aSAlexander V. Chernikov void nhgrp_set_uidx(struct nhgrp_object *nhg, uint32_t uidx);
229db4ca190SAlexander V. Chernikov uint32_t nhgrp_get_uidx(const struct nhgrp_object *nhg);
230e7624170SAlexander V. Chernikov uint8_t nhgrp_get_origin(const struct nhgrp_object *nhg);
231000250beSAlexander V. Chernikov void nhgrp_set_origin(struct nhgrp_object *nhg, uint8_t origin);
232a6663252SAlexander V. Chernikov #endif /* _KERNEL */
233a6663252SAlexander V. Chernikov 
234a6663252SAlexander V. Chernikov /* Kernel <> userland structures */
235a6663252SAlexander V. Chernikov 
236a6663252SAlexander V. Chernikov /* Structure usage and layout are described in dump_nhop_entry() */
237a6663252SAlexander V. Chernikov struct nhop_external {
238a6663252SAlexander V. Chernikov 	uint32_t	nh_len;		/* length of the datastructure */
239a6663252SAlexander V. Chernikov 	uint32_t	nh_idx;		/* Nexthop index */
240a6663252SAlexander V. Chernikov 	uint32_t	nh_fib;		/* Fib nexhop is attached to */
241a6663252SAlexander V. Chernikov 	uint32_t	ifindex;	/* transmit interface ifindex */
242a6663252SAlexander V. Chernikov 	uint32_t	aifindex;	/* address ifindex */
243a6663252SAlexander V. Chernikov 	uint8_t		prepend_len;	/* length of the prepend */
244a6663252SAlexander V. Chernikov 	uint8_t		nh_family;	/* address family */
245a6663252SAlexander V. Chernikov 	uint16_t	nh_type;	/* nexthop type */
246a6663252SAlexander V. Chernikov 	uint16_t	nh_mtu;		/* nexthop mtu */
247a6663252SAlexander V. Chernikov 
248a6663252SAlexander V. Chernikov 	uint16_t	nh_flags;	/* nhop flags */
249a6663252SAlexander V. Chernikov 	struct in_addr	nh_addr;	/* GW/DST IPv4 address */
250a6663252SAlexander V. Chernikov 	struct in_addr	nh_src;		/* default source IPv4 address */
251a6663252SAlexander V. Chernikov 	uint64_t	nh_pksent;
252a6663252SAlexander V. Chernikov 	/* control plane */
253a6663252SAlexander V. Chernikov 	/* lookup key: address, family, type */
254a6663252SAlexander V. Chernikov 	char		nh_prepend[64];	/* L2 prepend */
255a6663252SAlexander V. Chernikov 	uint64_t	nh_refcount;	/* number of references */
256a6663252SAlexander V. Chernikov };
257a6663252SAlexander V. Chernikov 
258a6663252SAlexander V. Chernikov struct nhop_addrs {
259a6663252SAlexander V. Chernikov 	uint32_t	na_len;		/* length of the datastructure */
260a6663252SAlexander V. Chernikov 	uint16_t	gw_sa_off;	/* offset of gateway SA */
261a6663252SAlexander V. Chernikov 	uint16_t	src_sa_off;	/* offset of src address SA */
262a6663252SAlexander V. Chernikov };
263a6663252SAlexander V. Chernikov 
264fedeb08bSAlexander V. Chernikov #define	NHG_C_TYPE_CNHOPS	0x1	/* Control plane nhops list */
265fedeb08bSAlexander V. Chernikov #define	NHG_C_TYPE_DNHOPS	0x2	/* Dataplane nhops list */
266fedeb08bSAlexander V. Chernikov struct nhgrp_container {
267fedeb08bSAlexander V. Chernikov 	uint32_t	nhgc_len;	/* container length */
268fedeb08bSAlexander V. Chernikov 	uint16_t	nhgc_count;	/* number of items */
269fedeb08bSAlexander V. Chernikov 	uint8_t		nhgc_type;	/* container type */
270fedeb08bSAlexander V. Chernikov 	uint8_t		nhgc_subtype;	/* container subtype */
271fedeb08bSAlexander V. Chernikov };
272fedeb08bSAlexander V. Chernikov 
273fedeb08bSAlexander V. Chernikov struct nhgrp_nhop_external {
274a6663252SAlexander V. Chernikov 	uint32_t	nh_idx;
275a6663252SAlexander V. Chernikov 	uint32_t	nh_weight;
276a6663252SAlexander V. Chernikov };
277a6663252SAlexander V. Chernikov 
278fedeb08bSAlexander V. Chernikov /*
279fedeb08bSAlexander V. Chernikov  * Layout:
280fedeb08bSAlexander V. Chernikov  * - nhgrp_external
281fedeb08bSAlexander V. Chernikov  * - nhgrp_container (control plane nhops list)
282fedeb08bSAlexander V. Chernikov  *   - nhgrp_nhop_external
283fedeb08bSAlexander V. Chernikov  *   - nhgrp_nhop_external
284fedeb08bSAlexander V. Chernikov  *   ..
285fedeb08bSAlexander V. Chernikov  * - nhgrp_container (dataplane nhops list)
286fedeb08bSAlexander V. Chernikov  *   - nhgrp_nhop_external
287fedeb08bSAlexander V. Chernikov  *   - nhgrp_nhop_external
288fedeb08bSAlexander V. Chernikov  */
289fedeb08bSAlexander V. Chernikov struct nhgrp_external {
290fedeb08bSAlexander V. Chernikov 	uint32_t	nhg_idx;	/* Nexthop group index */
291fedeb08bSAlexander V. Chernikov 	uint32_t	nhg_refcount;	/* number of references */
292a6663252SAlexander V. Chernikov };
293a6663252SAlexander V. Chernikov 
294a6663252SAlexander V. Chernikov #endif
295