rtsock.c revision 1.238.2.20 1 /* $NetBSD: rtsock.c,v 1.238.2.20 2019/01/15 03:40:35 pgoyette Exp $ */
2
3 /*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * 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 project 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 PROJECT 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 PROJECT 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
32 /*
33 * Copyright (c) 1988, 1991, 1993
34 * The Regents of the University of California. All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * @(#)rtsock.c 8.7 (Berkeley) 10/12/95
61 */
62
63 #include <sys/cdefs.h>
64 __KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.238.2.20 2019/01/15 03:40:35 pgoyette Exp $");
65
66 #ifdef _KERNEL_OPT
67 #include "opt_inet.h"
68 #include "opt_mpls.h"
69 #include "opt_compat_netbsd.h"
70 #include "opt_sctp.h"
71 #include "opt_net_mpsafe.h"
72 #endif
73
74 #include <sys/param.h>
75 #include <sys/systm.h>
76 #include <sys/proc.h>
77 #include <sys/socket.h>
78 #include <sys/socketvar.h>
79 #include <sys/domain.h>
80 #include <sys/protosw.h>
81 #include <sys/sysctl.h>
82 #include <sys/kauth.h>
83 #include <sys/kmem.h>
84 #include <sys/intr.h>
85 #include <sys/condvar.h>
86 #include <sys/compat_stub.h>
87
88 #include <net/if.h>
89 #include <net/if_llatbl.h>
90 #include <net/if_types.h>
91 #include <net/route.h>
92 #include <net/raw_cb.h>
93
94 #include <netinet/in_var.h>
95 #include <netinet/if_inarp.h>
96
97 #include <netmpls/mpls.h>
98
99 #ifdef SCTP
100 extern void sctp_add_ip_address(struct ifaddr *);
101 extern void sctp_delete_ip_address(struct ifaddr *);
102 #endif
103
104 #include <compat/net/if.h>
105 #include <compat/net/route.h>
106
107 #ifdef COMPAT_RTSOCK
108 #undef COMPAT_RTSOCK
109 #endif
110
111 static int if_addrflags(struct ifaddr *);
112 static void sysctl_net_route_setup(struct sysctllog **);
113
114 #include <net/rtsock_shared.c>
115
116 /*
117 * Compat linkage
118 */
119 static int stub_70_rt_newaddrmsg1(int cmd, struct ifaddr *ifa)
120 {
121
122 return 0;
123 }
124
125 /*
126 * XXX avoid using void * once msghdr compat disappears.
127 */
128 void
129 rt_setmetrics(void *in, struct rtentry *out)
130 {
131 const struct rt_xmsghdr *rtm = in;
132
133 _rt_setmetrics(rtm->rtm_inits, rtm, out);
134 }
135
136 int
137 rt_msg3(int type, struct rt_addrinfo *rtinfo, void *cpv, struct rt_walkarg *w,
138 int *lenp)
139 {
140 return rt_msg2(type, rtinfo, cpv, w, lenp);
141 }
142
143 /*
144 * MODULE_HOOK glue for rtsock_14_oifmsg and rtsock_14_iflist
145 */
146 MODULE_CALL_VOID_HOOK_DECL(rtsock_14_oifmsg_hook, (struct ifnet *ifp));
147 MODULE_CALL_VOID_HOOK(rtsock_14_oifmsg_hook, (struct ifnet *ifp), (ifp),
148 __nothing);
149
150 MODULE_CALL_INT_HOOK_DECL(rtsock_14_iflist_hook,
151 (struct ifnet *ifp, struct rt_walkarg *w, struct rt_addrinfo *info,
152 size_t len));
153 MODULE_CALL_INT_HOOK(rtsock_14_iflist_hook,
154 (struct ifnet *ifp, struct rt_walkarg *w, struct rt_addrinfo *info,
155 size_t len),
156 (ifp, w, info, len),
157 enosys());
158
159 /*
160 * MODULE_HOOK glue for rtsock_50 ifaddr_list and various message routines
161 */
162 MODULE_CALL_INT_HOOK_DECL(rtsock_50_iflist_hook,
163 (struct ifnet *ifp, struct rt_walkarg *w, struct rt_addrinfo *info,
164 size_t len));
165 MODULE_CALL_INT_HOOK(rtsock_50_iflist_hook,
166 (struct ifnet *ifp, struct rt_walkarg *w, struct rt_addrinfo *info,
167 size_t len),
168 (ifp, w, info, len),
169 enosys());
170
171 MODULE_CALL_VOID_HOOK_DECL(rtsock_50_rt_missmsg_hook,
172 (int, const struct rt_addrinfo *, int, int));
173 MODULE_CALL_VOID_HOOK(rtsock_50_rt_missmsg_hook,
174 (int type, const struct rt_addrinfo *rtinfo, int flags, int error),
175 (type, rtinfo, flags, error), __nothing);
176
177 MODULE_CALL_VOID_HOOK_DECL(rtsock_50_rt_ifmsg_hook, (struct ifnet *));
178 MODULE_CALL_VOID_HOOK(rtsock_50_rt_ifmsg_hook, (struct ifnet *ifp), (ifp),
179 __nothing);
180
181 MODULE_CALL_VOID_HOOK_DECL(rtsock_50_rt_newaddrmsg_hook,
182 (int, struct ifaddr *, int, struct rtentry *));
183 MODULE_CALL_VOID_HOOK(rtsock_50_rt_newaddrmsg_hook,
184 (int cmd, struct ifaddr *ifa, int error, struct rtentry *rt),
185 (cmd, ifa, error, rt), __nothing);
186
187 MODULE_CALL_VOID_HOOK_DECL(rtsock_50_rt_ifannouncemsg_hook,
188 (struct ifnet *, int what));
189 MODULE_CALL_VOID_HOOK(rtsock_50_rt_ifannouncemsg_hook,
190 (struct ifnet *ifp, int what), (ifp, what), __nothing);
191
192 MODULE_CALL_VOID_HOOK_DECL(rtsock_50_rt_ieee80211msg_hook,
193 (struct ifnet *, int, void *, size_t));
194 MODULE_CALL_VOID_HOOK(rtsock_50_rt_ieee80211msg_hook,
195 (struct ifnet *ifp, int what, void *data, size_t data_len),
196 (ifp, what, data, data_len), __nothing);
197
198 MODULE_CALL_VOID_HOOK_DECL(rtsock_50_oifmsg_hook, (struct ifnet *ifp));
199 MODULE_CALL_VOID_HOOK(rtsock_50_oifmsg_hook, (struct ifnet *ifp), (ifp),
200 __nothing);
201
202 /*
203 * MODULE_HOOK glue for rtsock70_newaddrmsg1, rtsock70_ifaddr_listaddr,
204 * and rtsock70_ifaddr_listif
205 */
206 MODULE_CALL_VOID_HOOK_DECL(rtsock_70_newaddr_hook, (int, struct ifaddr *));
207 MODULE_CALL_VOID_HOOK(rtsock_70_newaddr_hook, (int cmd, struct ifaddr *ifa),
208 (cmd, ifa), stub_70_rt_newaddrmsg1(cmd, ifa));
209
210 MODULE_CALL_INT_HOOK_DECL(rtsock_70_iflist_hook,
211 (struct rt_walkarg *, struct ifaddr *, struct rt_addrinfo *));
212 MODULE_CALL_INT_HOOK(rtsock_70_iflist_hook,
213 (struct rt_walkarg *w, struct ifaddr *ifa, struct rt_addrinfo *info),
214 (w, ifa, info),
215 enosys());
216
217
218 static int
219 if_addrflags(struct ifaddr *ifa)
220 {
221
222 switch (ifa->ifa_addr->sa_family) {
223 #ifdef INET
224 case AF_INET:
225 return ((struct in_ifaddr *)ifa)->ia4_flags;
226 #endif
227 #ifdef INET6
228 case AF_INET6:
229 return ((struct in6_ifaddr *)ifa)->ia6_flags;
230 #endif
231 default:
232 return 0;
233 }
234 }
235
236
237 /*
238 * Send a routing message as mimicing that a cloned route is added.
239 */
240 void
241 rt_clonedmsg(const struct sockaddr *dst, const struct ifnet *ifp,
242 const struct rtentry *rt)
243 {
244 struct rt_addrinfo info;
245 /* Mimic flags exactly */
246 #define RTF_LLINFO 0x400
247 #define RTF_CLONED 0x2000
248 int flags = RTF_UP | RTF_HOST | RTF_DONE | RTF_LLINFO | RTF_CLONED;
249 union {
250 struct sockaddr sa;
251 struct sockaddr_storage ss;
252 struct sockaddr_dl sdl;
253 } u;
254 uint8_t namelen = strlen(ifp->if_xname);
255 uint8_t addrlen = ifp->if_addrlen;
256
257 if (rt == NULL)
258 return; /* XXX */
259
260 memset(&info, 0, sizeof(info));
261 info.rti_info[RTAX_DST] = dst;
262 sockaddr_dl_init(&u.sdl, sizeof(u.ss), ifp->if_index, ifp->if_type,
263 NULL, namelen, NULL, addrlen);
264 info.rti_info[RTAX_GATEWAY] = &u.sa;
265
266 rt_missmsg(RTM_ADD, &info, flags, 0);
267 #undef RTF_LLINFO
268 #undef RTF_CLONED
269 }
270
271
272 /*
273 * The remaining code implements the routing-table sysctl node. It is
274 * compiled only for the non-COMPAT case.
275 */
276
277 /*
278 * This is used in dumping the kernel table via sysctl().
279 */
280 static int
281 sysctl_dumpentry(struct rtentry *rt, void *v)
282 {
283 struct rt_walkarg *w = v;
284 int error = 0, size;
285 struct rt_addrinfo info;
286
287 if (w->w_op == NET_RT_FLAGS && !(rt->rt_flags & w->w_arg))
288 return 0;
289 memset(&info, 0, sizeof(info));
290 info.rti_info[RTAX_DST] = rt_getkey(rt);
291 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
292 info.rti_info[RTAX_NETMASK] = rt_mask(rt);
293 info.rti_info[RTAX_TAG] = rt_gettag(rt);
294 if (rt->rt_ifp) {
295 const struct ifaddr *rtifa;
296 info.rti_info[RTAX_IFP] = rt->rt_ifp->if_dl->ifa_addr;
297 /* rtifa used to be simply rt->rt_ifa. If rt->rt_ifa != NULL,
298 * then rt_get_ifa() != NULL. So this ought to still be safe.
299 * --dyoung
300 */
301 rtifa = rt_get_ifa(rt);
302 info.rti_info[RTAX_IFA] = rtifa->ifa_addr;
303 if (rt->rt_ifp->if_flags & IFF_POINTOPOINT)
304 info.rti_info[RTAX_BRD] = rtifa->ifa_dstaddr;
305 }
306 if ((error = rt_msg2(RTM_GET, &info, 0, w, &size)))
307 return error;
308 if (w->w_where && w->w_tmem && w->w_needed <= 0) {
309 struct rt_xmsghdr *rtm = (struct rt_xmsghdr *)w->w_tmem;
310
311 rtm->rtm_flags = rt->rt_flags;
312 rtm->rtm_use = rt->rt_use;
313 rtm_setmetrics(rt, rtm);
314 KASSERT(rt->rt_ifp != NULL);
315 rtm->rtm_index = rt->rt_ifp->if_index;
316 rtm->rtm_errno = rtm->rtm_pid = rtm->rtm_seq = 0;
317 rtm->rtm_addrs = info.rti_addrs;
318 if ((error = copyout(rtm, w->w_where, size)) != 0)
319 w->w_where = NULL;
320 else
321 w->w_where = (char *)w->w_where + size;
322 }
323 return error;
324 }
325
326 static int
327 sysctl_iflist_if(struct ifnet *ifp, struct rt_walkarg *w,
328 struct rt_addrinfo *info, size_t len)
329 {
330 struct if_xmsghdr *ifm;
331 int error;
332
333 ifm = (struct if_xmsghdr *)w->w_tmem;
334 ifm->ifm_index = ifp->if_index;
335 ifm->ifm_flags = ifp->if_flags;
336 ifm->ifm_data = ifp->if_data;
337 ifm->ifm_addrs = info->rti_addrs;
338 if ((error = copyout(ifm, w->w_where, len)) == 0)
339 w->w_where = (char *)w->w_where + len;
340 return error;
341 }
342
343 static int
344 sysctl_iflist_addr(struct rt_walkarg *w, struct ifaddr *ifa,
345 struct rt_addrinfo *info)
346 {
347 int len, error;
348
349 if ((error = rt_msg2(RTM_XNEWADDR, info, 0, w, &len)))
350 return error;
351 if (w->w_where && w->w_tmem && w->w_needed <= 0) {
352 struct ifa_xmsghdr *ifam;
353
354 ifam = (struct ifa_xmsghdr *)w->w_tmem;
355 ifam->ifam_index = ifa->ifa_ifp->if_index;
356 ifam->ifam_flags = ifa->ifa_flags;
357 ifam->ifam_metric = ifa->ifa_metric;
358 ifam->ifam_addrs = info->rti_addrs;
359 ifam->ifam_pid = 0;
360 ifam->ifam_addrflags = if_addrflags(ifa);
361 if ((error = copyout(w->w_tmem, w->w_where, len)) == 0)
362 w->w_where = (char *)w->w_where + len;
363 }
364 return error;
365 }
366
367 static int
368 sysctl_iflist(int af, struct rt_walkarg *w, int type)
369 {
370 struct ifnet *ifp;
371 struct ifaddr *ifa;
372 struct rt_addrinfo info;
373 int cmd, len, error = 0;
374 int s;
375 struct psref psref;
376 int bound;
377
378 switch (type) {
379 case NET_RT_IFLIST:
380 cmd = RTM_IFINFO;
381 break;
382 case NET_RT_OOOIFLIST:
383 cmd = RTM_OOIFINFO;
384 break;
385 case NET_RT_OOIFLIST:
386 cmd = RTM_OIFINFO;
387 break;
388 case NET_RT_OIFLIST:
389 cmd = RTM_IFINFO;
390 break;
391 default:
392 #ifdef RTSOCK_DEBUG
393 printf("%s: unsupported IFLIST type %d\n", __func__, type);
394 #endif
395 return EINVAL;
396 }
397
398 memset(&info, 0, sizeof(info));
399
400 bound = curlwp_bind();
401 s = pserialize_read_enter();
402 IFNET_READER_FOREACH(ifp) {
403 int _s;
404 if (w->w_arg && w->w_arg != ifp->if_index)
405 continue;
406 if (IFADDR_READER_EMPTY(ifp))
407 continue;
408
409 if_acquire(ifp, &psref);
410 pserialize_read_exit(s);
411
412 info.rti_info[RTAX_IFP] = ifp->if_dl->ifa_addr;
413 if ((error = rt_msg2(cmd, &info, NULL, w, &len)) != 0)
414 goto release_exit;
415 info.rti_info[RTAX_IFP] = NULL;
416 if (w->w_where && w->w_tmem && w->w_needed <= 0) {
417 switch (type) {
418 case NET_RT_OIFLIST: /* old _70 */
419 if (!rtsock_70_iflist_hook.hooked) {
420 error = EINVAL;
421 break;
422 }
423 /* FALLTHROUGH */
424 case NET_RT_IFLIST: /* current */
425 error = sysctl_iflist_if(ifp, w, &info, len);
426 break;
427 case NET_RT_OOIFLIST: /* old _50 */
428 error = rtsock_50_iflist_hook_call(ifp, w, &info,
429 len);
430 break;
431 case NET_RT_OOOIFLIST: /* old _14 */
432 error = rtsock_14_iflist_hook_call(ifp, w,
433 &info, len);
434 break;
435 default:
436 error = EINVAL;
437 }
438 if (error != 0) {
439 if (error == ENOSYS)
440 error = EINVAL;
441 goto release_exit;
442 }
443 }
444 _s = pserialize_read_enter();
445 IFADDR_READER_FOREACH(ifa, ifp) {
446 struct psref _psref;
447 if (af && af != ifa->ifa_addr->sa_family)
448 continue;
449 ifa_acquire(ifa, &_psref);
450 pserialize_read_exit(_s);
451
452 info.rti_info[RTAX_IFA] = ifa->ifa_addr;
453 info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
454 info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr;
455 switch (type) {
456 case NET_RT_IFLIST:
457 error = sysctl_iflist_addr(w, ifa, &info);
458 break;
459 case NET_RT_OIFLIST:
460 case NET_RT_OOIFLIST:
461 case NET_RT_OOOIFLIST:
462 error = rtsock_70_iflist_hook_call(w, ifa,
463 &info);
464 break;
465 default:
466 error = EINVAL;
467 }
468
469 _s = pserialize_read_enter();
470 ifa_release(ifa, &_psref);
471 if (error != 0) {
472 pserialize_read_exit(_s);
473 goto release_exit;
474 }
475 }
476 pserialize_read_exit(_s);
477 info.rti_info[RTAX_IFA] = info.rti_info[RTAX_NETMASK] =
478 info.rti_info[RTAX_BRD] = NULL;
479
480 s = pserialize_read_enter();
481 if_release(ifp, &psref);
482 }
483 pserialize_read_exit(s);
484 curlwp_bindx(bound);
485
486 return 0;
487
488 release_exit:
489 if_release(ifp, &psref);
490 curlwp_bindx(bound);
491 return error;
492 }
493
494 static int
495 sysctl_rtable(SYSCTLFN_ARGS)
496 {
497 void *where = oldp;
498 size_t *given = oldlenp;
499 int i, s, error = EINVAL;
500 u_char af;
501 struct rt_walkarg w;
502
503 if (namelen == 1 && name[0] == CTL_QUERY)
504 return sysctl_query(SYSCTLFN_CALL(rnode));
505
506 if (newp)
507 return EPERM;
508 if (namelen != 3)
509 return EINVAL;
510 af = name[0];
511 w.w_tmemneeded = 0;
512 w.w_tmemsize = 0;
513 w.w_tmem = NULL;
514 again:
515 /* we may return here if a later [re]alloc of the t_mem buffer fails */
516 if (w.w_tmemneeded) {
517 w.w_tmem = kmem_zalloc(w.w_tmemneeded, KM_SLEEP);
518 w.w_tmemsize = w.w_tmemneeded;
519 w.w_tmemneeded = 0;
520 }
521 w.w_op = name[1];
522 w.w_arg = name[2];
523 w.w_given = *given;
524 w.w_needed = 0 - w.w_given;
525 w.w_where = where;
526
527 s = splsoftnet();
528 switch (w.w_op) {
529
530 case NET_RT_DUMP:
531 case NET_RT_FLAGS:
532 #if defined(INET) || defined(INET6)
533 /*
534 * take care of llinfo entries, the caller must
535 * specify an AF
536 */
537 if (w.w_op == NET_RT_FLAGS &&
538 (w.w_arg == 0 || w.w_arg & RTF_LLDATA)) {
539 if (af != 0)
540 error = lltable_sysctl_dump(af, &w);
541 else
542 error = EINVAL;
543 break;
544 }
545 #endif
546
547 for (i = 1; i <= AF_MAX; i++) {
548 if (af == 0 || af == i) {
549 error = rt_walktree(i, sysctl_dumpentry, &w);
550 if (error != 0)
551 break;
552 #if defined(INET) || defined(INET6)
553 /*
554 * Return ARP/NDP entries too for
555 * backward compatibility.
556 */
557 error = lltable_sysctl_dump(i, &w);
558 if (error != 0)
559 break;
560 #endif
561 }
562 }
563 break;
564
565 case NET_RT_OOOIFLIST: /* compat_14 */
566 case NET_RT_OOIFLIST: /* compat_50 */
567 case NET_RT_OIFLIST: /* compat_70 */
568 case NET_RT_IFLIST: /* current */
569 error = sysctl_iflist(af, &w, w.w_op);
570 break;
571 }
572 splx(s);
573
574 /* check to see if we couldn't allocate memory with NOWAIT */
575 if (error == ENOBUFS && w.w_tmem == 0 && w.w_tmemneeded)
576 goto again;
577
578 if (w.w_tmem)
579 kmem_free(w.w_tmem, w.w_tmemsize);
580 w.w_needed += w.w_given;
581 if (where) {
582 *given = (char *)w.w_where - (char *)where;
583 if (*given < w.w_needed)
584 return ENOMEM;
585 } else {
586 *given = (11 * w.w_needed) / 10;
587 }
588 return error;
589 }
590
591 static void
592 sysctl_net_route_setup(struct sysctllog **clog)
593 {
594 const struct sysctlnode *rnode = NULL;
595
596 sysctl_createv(clog, 0, NULL, &rnode,
597 CTLFLAG_PERMANENT,
598 CTLTYPE_NODE, DOMAINNAME,
599 SYSCTL_DESCR("PF_ROUTE information"),
600 NULL, 0, NULL, 0,
601 CTL_NET, PF_XROUTE, CTL_EOL);
602
603 sysctl_createv(clog, 0, NULL, NULL,
604 CTLFLAG_PERMANENT,
605 CTLTYPE_NODE, "rtable",
606 SYSCTL_DESCR("Routing table information"),
607 sysctl_rtable, 0, NULL, 0,
608 CTL_NET, PF_XROUTE, 0 /* any protocol */, CTL_EOL);
609
610 sysctl_createv(clog, 0, &rnode, NULL,
611 CTLFLAG_PERMANENT,
612 CTLTYPE_STRUCT, "stats",
613 SYSCTL_DESCR("Routing statistics"),
614 NULL, 0, &rtstat, sizeof(rtstat),
615 CTL_CREATE, CTL_EOL);
616 }
617