xref: /netbsd-src/sys/net/route.h (revision d90047b5d07facf36e6c01dcc0bded8997ce9cc2)
1 /*	$NetBSD: route.h,v 1.127 2020/03/09 21:20:55 roy Exp $	*/
2 
3 /*
4  * Copyright (c) 1980, 1986, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  *	@(#)route.h	8.5 (Berkeley) 2/8/95
32  */
33 
34 #ifndef _NET_ROUTE_H_
35 #define _NET_ROUTE_H_
36 
37 #include <sys/queue.h>
38 #include <sys/socket.h>
39 #include <sys/types.h>
40 #include <net/if.h>
41 #ifdef _KERNEL
42 #include <sys/rwlock.h>
43 #include <sys/condvar.h>
44 #include <sys/pserialize.h>
45 #include <sys/percpu.h>
46 #endif
47 #include <sys/psref.h>
48 
49 #if !(defined(_KERNEL) || defined(_STANDALONE))
50 #include <stdbool.h>
51 #endif
52 
53 /*
54  * Kernel resident routing tables.
55  *
56  * The routing tables are initialized when interface addresses
57  * are set by making entries for all directly connected interfaces.
58  */
59 
60 /*
61  * A route consists of a destination address and a reference
62  * to a routing entry.  These are often held by protocols
63  * in their control blocks, e.g. inpcb.
64  */
65 struct route {
66 	struct	rtentry		*_ro_rt;
67 	struct	sockaddr	*ro_sa;
68 	uint64_t		ro_rtcache_generation;
69 	struct	psref		ro_psref;
70 	int			ro_bound;
71 };
72 
73 /*
74  * These numbers are used by reliable protocols for determining
75  * retransmission behavior and are included in the routing structure.
76  */
77 struct rt_metrics {
78 	uint64_t rmx_locks;	/* Kernel must leave these values alone */
79 	uint64_t rmx_mtu;	/* MTU for this path */
80 	uint64_t rmx_hopcount;	/* max hops expected */
81 	uint64_t rmx_recvpipe;	/* inbound delay-bandwidth product */
82 	uint64_t rmx_sendpipe;	/* outbound delay-bandwidth product */
83 	uint64_t rmx_ssthresh;	/* outbound gateway buffer limit */
84 	uint64_t rmx_rtt;	/* estimated round trip time */
85 	uint64_t rmx_rttvar;	/* estimated rtt variance */
86 	time_t	rmx_expire;	/* lifetime for route, e.g. redirect */
87 	time_t	rmx_pksent;	/* packets sent using this route */
88 };
89 
90 /*
91  * rmx_rtt and rmx_rttvar are stored as microseconds;
92  * RTTTOPRHZ(rtt) converts to a value suitable for use
93  * by a protocol slowtimo counter.
94  */
95 #define	RTM_RTTUNIT	1000000	/* units for rtt, rttvar, as units per sec */
96 #define	RTTTOPRHZ(r)	((r) / (RTM_RTTUNIT / PR_SLOWHZ))
97 
98 /*
99  * We distinguish between routes to hosts and routes to networks,
100  * preferring the former if available.  For each route we infer
101  * the interface to use from the gateway address supplied when
102  * the route was entered.  Routes that forward packets through
103  * gateways are marked so that the output routines know to address the
104  * gateway rather than the ultimate destination.
105  */
106 #ifndef RNF_NORMAL
107 #include <net/radix.h>
108 #endif
109 struct rtentry {
110 	struct	radix_node rt_nodes[2];	/* tree glue, and other values */
111 #define	rt_mask(r)	((const struct sockaddr *)((r)->rt_nodes->rn_mask))
112 	struct	sockaddr *rt_gateway;	/* value */
113 	int	rt_flags;		/* up/down?, host/net */
114 	int	rt_refcnt;		/* # held references */
115 	uint64_t rt_use;			/* raw # packets forwarded */
116 	struct	ifnet *rt_ifp;		/* the answer: interface to use */
117 	struct	ifaddr *rt_ifa;		/* the answer: interface to use */
118 	uint32_t rt_ifa_seqno;
119 	void *	rt_llinfo;		/* pointer to link level info cache */
120 	struct	rt_metrics rt_rmx;	/* metrics used by rx'ing protocols */
121 	struct	rtentry *rt_gwroute;	/* implied entry for gatewayed routes */
122 	LIST_HEAD(, rttimer) rt_timer;  /* queue of timeouts for misc funcs */
123 	struct	rtentry *rt_parent;	/* parent of cloned route */
124 	struct	sockaddr *_rt_key;
125 	struct	sockaddr *rt_tag;	/* route tagging info */
126 #ifdef _KERNEL
127 	kcondvar_t rt_cv;
128 	struct psref_target rt_psref;
129 	SLIST_ENTRY(rtentry) rt_free;	/* queue of deferred frees */
130 #endif
131 };
132 
133 static __inline const struct sockaddr *
134 rt_getkey(const struct rtentry *rt)
135 {
136 	return rt->_rt_key;
137 }
138 
139 /*
140  * Following structure necessary for 4.3 compatibility;
141  * We should eventually move it to a compat file.
142  */
143 struct ortentry {
144 	uint32_t rt_hash;		/* to speed lookups */
145 	struct	sockaddr rt_dst;	/* key */
146 	struct	sockaddr rt_gateway;	/* value */
147 	int16_t	rt_flags;		/* up/down?, host/net */
148 	int16_t	rt_refcnt;		/* # held references */
149 	uint32_t rt_use;		/* raw # packets forwarded */
150 	struct	ifnet *rt_ifp;		/* the answer: interface to use */
151 };
152 
153 #define	RTF_UP		0x1		/* route usable */
154 #define	RTF_GATEWAY	0x2		/* destination is a gateway */
155 #define	RTF_HOST	0x4		/* host entry (net otherwise) */
156 #define	RTF_REJECT	0x8		/* host or net unreachable */
157 #define	RTF_DYNAMIC	0x10		/* created dynamically (by redirect) */
158 #define	RTF_MODIFIED	0x20		/* modified dynamically (by redirect) */
159 #define RTF_DONE	0x40		/* message confirmed */
160 #define RTF_MASK	0x80		/* subnet mask present */
161 // #define RTF_CLONING	0x100		/* generate new routes on use */
162 #define RTF_CONNECTED	0x100		/* hosts on this route are neighbours */
163 // #define RTF_XRESOLVE	0x200		/* external daemon resolves name */
164 // #define RTF_LLINFO	0x400		/* generated by ARP or NDP */
165 #define RTF_LLDATA	0x400		/* used by apps to add/del L2 entries */
166 #define RTF_STATIC	0x800		/* manually added */
167 #define RTF_BLACKHOLE	0x1000		/* just discard pkts (during updates) */
168 // #define RTF_CLONED	0x2000		/* this is a cloned route */
169 #define RTF_PROTO2	0x4000		/* protocol specific routing flag */
170 #define RTF_PROTO1	0x8000		/* protocol specific routing flag */
171 #define RTF_SRC		0x10000		/* route has fixed source address */
172 #define RTF_ANNOUNCE	0x20000		/* announce new ARP or NDP entry */
173 #define RTF_LOCAL	0x40000		/* route represents a local address */
174 #define RTF_BROADCAST	0x80000		/* route represents a bcast address */
175 #define RTF_UPDATING	0x100000	/* route is updating */
176 /*
177  * The flag is nevert set to rt_flags.  It just tells rtrequest1 to set a passed
178  * ifa to rt_ifa (via rti_ifa) and not replace rt_ifa in ifa_rtrequest.
179  */
180 #define RTF_DONTCHANGEIFA	0x200000	/* suppress rt_ifa replacement */
181 
182 /*
183  * 0x400 is exposed to userland just for backward compatibility. For that
184  * purpose, it should be shown as LLINFO.
185  */
186 #define RTFBITS "\020\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE" \
187     "\010MASK_PRESENT\011CONNECTED\012XRESOLVE\013LLINFO\014STATIC" \
188     "\015BLACKHOLE\016CLONED\017PROTO2\020PROTO1\021SRC\022ANNOUNCE" \
189     "\023LOCAL\024BROADCAST\025UPDATING"
190 
191 
192 /*
193  * Routing statistics.
194  */
195 struct	rtstat {
196 	uint64_t rts_badredirect;	/* bogus redirect calls */
197 	uint64_t rts_dynamic;		/* routes created by redirects */
198 	uint64_t rts_newgateway;	/* routes modified by redirects */
199 	uint64_t rts_unreach;		/* lookups which failed */
200 	uint64_t rts_wildcard;		/* lookups satisfied by a wildcard */
201 };
202 
203 /*
204  * Structures for routing messages.  By forcing the first member to be aligned
205  * at a 64-bit boundary, we also force the size to be a multiple of 64-bits.
206  */
207 
208 #if !defined(_KERNEL) || !defined(COMPAT_RTSOCK)
209 /*
210  * If we aren't being compiled for backwards compatiblity, enforce 64-bit
211  * alignment so any routing message is the same regardless if the kernel
212  * is an ILP32 or LP64 kernel.
213  */
214 #define	__align64	__aligned(sizeof(uint64_t))
215 #else
216 #define	__align64
217 #endif
218 
219 struct rt_msghdr {
220 	u_short	rtm_msglen __align64;
221 				/* to skip over non-understood messages */
222 	u_char	rtm_version;	/* future binary compatibility */
223 	u_char	rtm_type;	/* message type */
224 	u_short	rtm_index;	/* index for associated ifp */
225 	int	rtm_flags;	/* flags, incl. kern & message, e.g. DONE */
226 	int	rtm_addrs;	/* bitmask identifying sockaddrs in msg */
227 	pid_t	rtm_pid;	/* identify sender */
228 	int	rtm_seq;	/* for sender to identify action */
229 	int	rtm_errno;	/* why failed */
230 	int	rtm_use;	/* from rtentry */
231 	int	rtm_inits;	/* which metrics we are initializing */
232 	struct	rt_metrics rtm_rmx __align64;
233 				/* metrics themselves */
234 };
235 
236 #undef __align64
237 
238 #define RTM_VERSION	4	/* Up the ante and ignore older versions */
239 
240 #define RTM_ADD		0x1	/* Add Route */
241 #define RTM_DELETE	0x2	/* Delete Route */
242 #define RTM_CHANGE	0x3	/* Change Metrics or flags */
243 #define RTM_GET		0x4	/* Report Metrics */
244 #define RTM_LOSING	0x5	/* Kernel Suspects Partitioning */
245 #define RTM_REDIRECT	0x6	/* Told to use different route */
246 #define RTM_MISS	0x7	/* Lookup failed on this address */
247 #define RTM_LOCK	0x8	/* fix specified metrics */
248 #define RTM_OLDADD	0x9	/* caused by SIOCADDRT */
249 #define RTM_OLDDEL	0xa	/* caused by SIOCDELRT */
250 // #define RTM_RESOLVE	0xb	/* req to resolve dst to LL addr */
251 #define RTM_ONEWADDR	0xc	/* Old (pre-8.0) RTM_NEWADDR message */
252 #define RTM_ODELADDR	0xd	/* Old (pre-8.0) RTM_DELADDR message */
253 #define RTM_OOIFINFO	0xe	/* Old (pre-1.5) RTM_IFINFO message */
254 #define RTM_OIFINFO	0xf	/* Old (pre-64bit time) RTM_IFINFO message */
255 #define	RTM_IFANNOUNCE	0x10	/* iface arrival/departure */
256 #define	RTM_IEEE80211	0x11	/* IEEE80211 wireless event */
257 #define	RTM_SETGATE	0x12	/* set prototype gateway for clones
258 				 * (see example in arp_rtrequest).
259 				 */
260 #define	RTM_LLINFO_UPD	0x13	/* indication to ARP/NDP/etc. that link-layer
261 				 * address has changed
262 				 */
263 #define RTM_IFINFO	0x14	/* iface/link going up/down etc. */
264 #define RTM_OCHGADDR	0x15	/* Old (pre-8.0) RTM_CHGADDR message */
265 #define RTM_NEWADDR	0x16	/* address being added to iface */
266 #define RTM_DELADDR	0x17	/* address being removed from iface */
267 #define RTM_CHGADDR	0x18	/* address properties changed */
268 
269 /*
270  * setsockopt defines used for the filtering.
271  */
272 #define	RO_MSGFILTER	1	/* array of which rtm_type to send to client */
273 #define	RO_MISSFILTER	2	/* array of sockaddrs to match miss dst */
274 
275 #define	RO_FILTSA_MAX	30	/* maximum number of sockaddrs per filter */
276 
277 #define RTV_MTU		0x1	/* init or lock _mtu */
278 #define RTV_HOPCOUNT	0x2	/* init or lock _hopcount */
279 #define RTV_EXPIRE	0x4	/* init or lock _expire */
280 #define RTV_RPIPE	0x8	/* init or lock _recvpipe */
281 #define RTV_SPIPE	0x10	/* init or lock _sendpipe */
282 #define RTV_SSTHRESH	0x20	/* init or lock _ssthresh */
283 #define RTV_RTT		0x40	/* init or lock _rtt */
284 #define RTV_RTTVAR	0x80	/* init or lock _rttvar */
285 
286 #define RTVBITS "\020\1MTU\2HOPCOUNT\3EXPIRE\4RECVPIPE\5SENDPIPE" \
287     "\6SSTHRESH\7RTT\010RTTVAR"
288 
289 /*
290  * Bitmask values for rtm_addr.
291  */
292 #define RTA_DST		0x1	/* destination sockaddr present */
293 #define RTA_GATEWAY	0x2	/* gateway sockaddr present */
294 #define RTA_NETMASK	0x4	/* netmask sockaddr present */
295 #define RTA_GENMASK	0x8	/* cloning mask sockaddr present */
296 #define RTA_IFP		0x10	/* interface name sockaddr present */
297 #define RTA_IFA		0x20	/* interface addr sockaddr present */
298 #define RTA_AUTHOR	0x40	/* sockaddr for author of redirect */
299 #define RTA_BRD		0x80	/* for NEWADDR, broadcast or p-p dest addr */
300 #define RTA_TAG		0x100	/* route tag */
301 
302 #define RTABITS "\020\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR" \
303     "\010BRD\011TAG"
304 
305 /*
306  * Index offsets for sockaddr array for alternate internal encoding.
307  */
308 #define RTAX_DST	0	/* destination sockaddr present */
309 #define RTAX_GATEWAY	1	/* gateway sockaddr present */
310 #define RTAX_NETMASK	2	/* netmask sockaddr present */
311 #define RTAX_GENMASK	3	/* cloning mask sockaddr present */
312 #define RTAX_IFP	4	/* interface name sockaddr present */
313 #define RTAX_IFA	5	/* interface addr sockaddr present */
314 #define RTAX_AUTHOR	6	/* sockaddr for author of redirect */
315 #define RTAX_BRD	7	/* for NEWADDR, broadcast or p-p dest addr */
316 #define RTAX_TAG	8	/* route tag */
317 #define RTAX_MAX	9	/* size of array to allocate */
318 
319 #define RT_ROUNDUP2(a, n)	((a) > 0 ? (1 + (((a) - 1U) | ((n) - 1))) : (n))
320 #define RT_ROUNDUP(a)		RT_ROUNDUP2((a), sizeof(uint64_t))
321 #define RT_ADVANCE(x, n)	(x += RT_ROUNDUP((n)->sa_len))
322 
323 struct rt_addrinfo {
324 	int	rti_addrs;
325 	const struct	sockaddr *rti_info[RTAX_MAX];
326 	int	rti_flags;
327 	struct	ifaddr *rti_ifa;
328 	struct	ifnet *rti_ifp;
329 };
330 
331 struct route_cb {
332 	int	ip_count;
333 	int	ip6_count;
334 	int	unused1;
335 	int	mpls_count;
336 	int	any_count;
337 };
338 
339 /*
340  * This structure, and the prototypes for the rt_timer_{init,remove_all,
341  * add,timer} functions all used with the kind permission of BSDI.
342  * These allow functions to be called for routes at specific times.
343  */
344 
345 struct rttimer {
346 	TAILQ_ENTRY(rttimer)	rtt_next;  /* entry on timer queue */
347 	LIST_ENTRY(rttimer) 	rtt_link;  /* multiple timers per rtentry */
348 	struct rttimer_queue   *rtt_queue; /* back pointer to queue */
349 	struct rtentry         *rtt_rt;    /* Back pointer to the route */
350 	void		      (*rtt_func)(struct rtentry *, struct rttimer *);
351 	time_t          	rtt_time;  /* When this timer was registered */
352 };
353 
354 struct rttimer_queue {
355 	long				rtq_timeout;
356 	unsigned long			rtq_count;
357 	TAILQ_HEAD(, rttimer)		rtq_head;
358 	LIST_ENTRY(rttimer_queue)	rtq_link;
359 };
360 
361 
362 struct rtbl;
363 typedef struct rtbl rtbl_t;
364 
365 #ifdef _KERNEL
366 
367 struct rtbl {
368 	struct radix_node_head t_rnh;
369 };
370 
371 struct rt_walkarg {
372 	int	w_op;
373 	int	w_arg;
374 	int	w_given;
375 	int	w_needed;
376 	void *	w_where;
377 	int	w_tmemsize;
378 	int	w_tmemneeded;
379 	void *	w_tmem;
380 };
381 
382 #if 0
383 #define	RT_DPRINTF(__fmt, ...)	do { } while (/*CONSTCOND*/0)
384 #else
385 #define	RT_DPRINTF(__fmt, ...)	/* do nothing */
386 #endif
387 
388 struct rtwalk {
389 	int (*rw_f)(struct rtentry *, void *);
390 	void *rw_v;
391 };
392 
393 /*
394  * Global data specific to the routing socket.
395  */
396 struct route_info {
397 	struct sockaddr ri_dst;
398 	struct sockaddr ri_src;
399 	struct route_cb ri_cb;
400 	int ri_maxqlen;
401 	struct ifqueue ri_intrq;
402 	void *ri_sih;
403 };
404 
405 extern	struct	route_info route_info;
406 extern	struct	rtstat	rtstat;
407 
408 struct socket;
409 
410 void	rt_init(void);
411 
412 int	rt_timer_add(struct rtentry *,
413 	    void(*)(struct rtentry *, struct rttimer *),
414 	    struct rttimer_queue *);
415 unsigned long
416 	rt_timer_count(struct rttimer_queue *);
417 void	rt_timer_queue_change(struct rttimer_queue *, long);
418 struct rttimer_queue *
419 	rt_timer_queue_create(u_int);
420 void	rt_timer_queue_destroy(struct rttimer_queue *);
421 
422 void	rt_free(struct rtentry *);
423 void	rt_unref(struct rtentry *);
424 
425 int	rt_update(struct rtentry *, struct rt_addrinfo *, void *);
426 int	rt_update_prepare(struct rtentry *);
427 void	rt_update_finish(struct rtentry *);
428 
429 void	rt_newmsg(const int, const struct rtentry *);
430 struct rtentry *
431 	rtalloc1(const struct sockaddr *, int);
432 int	rtinit(struct ifaddr *, int, int);
433 void	rtredirect(const struct sockaddr *, const struct sockaddr *,
434 	    const struct sockaddr *, int, const struct sockaddr *,
435 	    struct rtentry **);
436 int	rtrequest(int, const struct sockaddr *,
437 	    const struct sockaddr *, const struct sockaddr *, int,
438 	    struct rtentry **);
439 int	rtrequest1(int, struct rt_addrinfo *, struct rtentry **);
440 int	rtrequest_newmsg(const int, const struct sockaddr *,
441 	    const struct sockaddr *, const struct sockaddr *, const int);
442 
443 int	rt_ifa_addlocal(struct ifaddr *);
444 int	rt_ifa_remlocal(struct ifaddr *, struct ifaddr *);
445 struct ifaddr *
446 	rt_get_ifa(struct rtentry *);
447 void	rt_replace_ifa(struct rtentry *, struct ifaddr *);
448 int	rt_setgate(struct rtentry *, const struct sockaddr *);
449 
450 const struct sockaddr *
451 	rt_settag(struct rtentry *, const struct sockaddr *);
452 struct sockaddr *
453 	rt_gettag(const struct rtentry *);
454 
455 int	rt_check_reject_route(const struct rtentry *, const struct ifnet *);
456 void	rt_delete_matched_entries(sa_family_t,
457 	    int (*)(struct rtentry *, void *), void *);
458 int	rt_walktree(sa_family_t, int (*)(struct rtentry *, void *), void *);
459 
460 static __inline void
461 rt_assert_referenced(const struct rtentry *rt)
462 {
463 
464 	KASSERT(rt->rt_refcnt > 0);
465 }
466 
467 void	rtcache_copy(struct route *, struct route *);
468 void	rtcache_free(struct route *);
469 struct rtentry *
470 	rtcache_init(struct route *);
471 struct rtentry *
472 	rtcache_init_noclone(struct route *);
473 struct rtentry *
474 	rtcache_lookup2(struct route *, const struct sockaddr *, int,
475 	    int *);
476 int	rtcache_setdst(struct route *, const struct sockaddr *);
477 struct rtentry *
478 	rtcache_update(struct route *, int);
479 
480 static __inline void
481 rtcache_invariants(const struct route *ro)
482 {
483 
484 	KASSERT(ro->ro_sa != NULL || ro->_ro_rt == NULL);
485 }
486 
487 static __inline struct rtentry *
488 rtcache_lookup1(struct route *ro, const struct sockaddr *dst, int clone)
489 {
490 	int hit;
491 
492 	return rtcache_lookup2(ro, dst, clone, &hit);
493 }
494 
495 static __inline struct rtentry *
496 rtcache_lookup(struct route *ro, const struct sockaddr *dst)
497 {
498 	return rtcache_lookup1(ro, dst, 1);
499 }
500 
501 static __inline const struct sockaddr *
502 rtcache_getdst(const struct route *ro)
503 {
504 
505 	rtcache_invariants(ro);
506 	return ro->ro_sa;
507 }
508 
509 struct rtentry *
510 	rtcache_validate(struct route *);
511 
512 void	rtcache_unref(struct rtentry *, struct route *);
513 
514 percpu_t *
515 	rtcache_percpu_alloc(void);
516 
517 static inline struct route *
518 rtcache_percpu_getref(percpu_t *pc)
519 {
520 
521 	return *(struct route **)percpu_getref(pc);
522 }
523 
524 static inline void
525 rtcache_percpu_putref(percpu_t *pc)
526 {
527 
528 	percpu_putref(pc);
529 }
530 
531 
532 /* rtsock */
533 void	rt_ieee80211msg(struct ifnet *, int, void *, size_t);
534 void	rt_ifannouncemsg(struct ifnet *, int);
535 void	rt_ifmsg(struct ifnet *);
536 void	rt_missmsg(int, const struct rt_addrinfo *, int, int);
537 struct mbuf *
538 	rt_msg1(int, struct rt_addrinfo *, void *, int);
539 int	rt_msg3(int, struct rt_addrinfo *, void *, struct rt_walkarg *, int *);
540 void	rt_addrmsg(int, struct ifaddr *);
541 void	rt_addrmsg_src(int, struct ifaddr *, const struct sockaddr *);
542 void	rt_addrmsg_rt(int, struct ifaddr *, int, struct rtentry *);
543 void	route_enqueue(struct mbuf *, int);
544 
545 struct llentry;
546 void	rt_clonedmsg(int, const struct sockaddr *, const struct sockaddr *,
547 	    const uint8_t *, const struct ifnet *);
548 
549 void	rt_setmetrics(void *, struct rtentry *);
550 
551 /* rtbl */
552 int	rt_addaddr(rtbl_t *, struct rtentry *, const struct sockaddr *);
553 void	rt_assert_inactive(const struct rtentry *);
554 struct rtentry *
555 	rt_deladdr(rtbl_t *, const struct sockaddr *,
556 	    const struct sockaddr *);
557 rtbl_t *rt_gettable(sa_family_t);
558 int	rt_inithead(rtbl_t **, int);
559 struct rtentry *
560 	rt_lookup(rtbl_t *, const struct sockaddr *,
561 	    const struct sockaddr *);
562 struct rtentry *
563 	rt_matchaddr(rtbl_t *, const struct sockaddr *);
564 int	rt_refines(const struct sockaddr *, const struct sockaddr *);
565 int	rtbl_walktree(sa_family_t, int (*)(struct rtentry *, void *), void *);
566 struct rtentry *
567 	rtbl_search_matched_entry(sa_family_t,
568 	    int (*)(struct rtentry *, void *), void *);
569 void	rtbl_init(void);
570 
571 void sysctl_net_route_setup(struct sysctllog **, int, const char *);
572 
573 #endif /* _KERNEL */
574 
575 #endif /* !_NET_ROUTE_H_ */
576