Deleted Added
full compact
1/*-
2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 59 unchanged lines hidden (view full) ---

68 * requested.
69 * 2) When such routes lose all their references, it arranges for them
70 * to be deleted in some random collection of circumstances, so that
71 * a large quantity of stale routing data is not kept in kernel memory
72 * indefinitely. See in6_rtqtimo() below for the exact mechanism.
73 */
74
75#include <sys/cdefs.h>
76__FBSDID("$FreeBSD: head/sys/netinet6/in6_rmx.c 191816 2009-05-05 10:56:12Z zec $");
76__FBSDID("$FreeBSD: head/sys/netinet6/in6_rmx.c 193232 2009-06-01 15:49:42Z bz $");
77
78#include "opt_route.h"
79
80#include <sys/param.h>
81#include <sys/systm.h>
82#include <sys/kernel.h>
83#include <sys/lock.h>
84#include <sys/sysctl.h>

--- 199 unchanged lines hidden (view full) ---

284static int rtq_timeout6;
285static struct callout rtq_timer6;
286#endif
287
288static void
289in6_rtqtimo(void *rock)
290{
291 CURVNET_SET_QUIET((struct vnet *) rock);
292 INIT_VNET_NET(curvnet);
292 INIT_VNET_INET6(curvnet);
294 struct radix_node_head *rnh = V_rt_tables[0][AF_INET6];
293 struct radix_node_head *rnh;
294 struct rtqk_arg arg;
295 struct timeval atv;
296 static time_t last_adjusted_timeout = 0;
297
298 rnh = rt_tables_get_rnh(0, AF_INET6);
299 if (rnh == NULL) {
300 CURVNET_RESTORE();
301 return;
302 }
303 arg.found = arg.killed = 0;
304 arg.rnh = rnh;
305 arg.nextstop = time_uptime + V_rtq_timeout6;
306 arg.draining = arg.updating = 0;
307 RADIX_NODE_HEAD_LOCK(rnh);
308 rnh->rnh_walktree(rnh, in6_rtqkill, &arg);
309 RADIX_NODE_HEAD_UNLOCK(rnh);
310

--- 65 unchanged lines hidden (view full) ---

376}
377
378#define MTUTIMO_DEFAULT (60*1)
379
380static void
381in6_mtutimo(void *rock)
382{
383 CURVNET_SET_QUIET((struct vnet *) rock);
380 INIT_VNET_NET(curvnet);
384 INIT_VNET_INET6(curvnet);
382 struct radix_node_head *rnh = V_rt_tables[0][AF_INET6];
385 struct radix_node_head *rnh;
386 struct mtuex_arg arg;
387 struct timeval atv;
388
389 rnh = rt_tables_get_rnh(0, AF_INET6);
390 if (rnh == NULL) {
391 CURVNET_RESTORE();
392 return;
393 }
394 arg.rnh = rnh;
395 arg.nextstop = time_uptime + MTUTIMO_DEFAULT;
396 RADIX_NODE_HEAD_LOCK(rnh);
397 rnh->rnh_walktree(rnh, in6_mtuexpire, &arg);
398 RADIX_NODE_HEAD_UNLOCK(rnh);
399
400 atv.tv_usec = 0;
401 atv.tv_sec = arg.nextstop - time_uptime;

--- 6 unchanged lines hidden (view full) ---

408 CURVNET_RESTORE();
409}
410
411#if 0
412void
413in6_rtqdrain(void)
414{
415 INIT_VNET_NET(curvnet);
408 struct radix_node_head *rnh = V_rt_tables[0][AF_INET6];
416 struct radix_node_head *rnh;
417 struct rtqk_arg arg;
418
419 rnh = rt_tables_get_rnh(0, AF_INET6);
420 if (rnh == NULL)
421 panic("%s: rnh == NULL", __func__);
422 arg.found = arg.killed = 0;
423 arg.rnh = rnh;
424 arg.nextstop = 0;
425 arg.draining = 1;
426 arg.updating = 0;
427 RADIX_NODE_HEAD_LOCK(rnh);
428 rnh->rnh_walktree(rnh, in6_rtqkill, &arg);
429 RADIX_NODE_HEAD_UNLOCK(rnh);

--- 5 unchanged lines hidden (view full) ---

435 * XXX MRT When off == 0, we are being called from vfs_export.c
436 * so just set up their table and leave. (we know what the correct
437 * value should be so just use that).. FIX AFTER RELENG_7 is MFC'd
438 * see also comments in in_inithead() vfs_export.c and domain.h
439 */
440int
441in6_inithead(void **head, int off)
442{
432#ifdef INVARIANTS
433 INIT_VNET_NET(curvnet);
434#endif
443 INIT_VNET_INET6(curvnet);
444 struct radix_node_head *rnh;
445
446 if (!rn_inithead(head, offsetof(struct sockaddr_in6, sin6_addr) << 3))
447 return 0; /* See above */
448
449 if (off == 0) /* See above */
450 return 1; /* only do the rest for the real thing */
451
452 V_rtq_reallyold6 = 60*60; /* one hour is ``really old'' */
453 V_rtq_minreallyold6 = 10; /* never automatically crank down to less */
454 V_rtq_toomany6 = 128; /* 128 cached routes is ``too many'' */
455 V_rtq_timeout6 = RTQ_TIMEOUT;
456
457 rnh = *head;
450 KASSERT(rnh == V_rt_tables[0][AF_INET6], ("rnh?"));
458 KASSERT(rnh == rt_tables_get_rnh(0, AF_INET6), ("rnh?"));
459 rnh->rnh_addaddr = in6_addroute;
460 rnh->rnh_matchaddr = in6_matroute;
461 callout_init(&V_rtq_timer6, CALLOUT_MPSAFE);
462 callout_init(&V_rtq_mtutimer, CALLOUT_MPSAFE);
463 in6_rtqtimo(curvnet); /* kick off timeout first time */
464 in6_mtutimo(curvnet); /* kick off timeout first time */
465 return 1;
466}