summaryrefslogtreecommitdiffstats
path: root/net/ipv6/sysctl_net_ipv6.c
blob: 212bcbc3e1c2f9ffd86e78f9bfdd5663e289c8c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
 * sysctl_net_ipv6.c: sysctl interface to net IPV6 subsystem.
 */

#include <linux/mm.h>
#include <linux/sysctl.h>
#include <linux/config.h>
#include <linux/in6.h>
#include <linux/ipv6.h>
#include <net/ndisc.h>
#include <net/ipv6.h>
#include <net/addrconf.h>

struct ipv6_config ipv6_config =
{
	0,				/* forwarding		*/
	IPV6_DEFAULT_HOPLIMIT,		/* hop limit		*/
	1,				/* accept RAs		*/
	1,				/* accept redirects	*/

	3,				/* nd_max_mcast_solicit	*/
	3,				/* nd_max_ucast_solicit	*/
	RETRANS_TIMER,			/* nd_retrans_time	*/
	RECHABLE_TIME,			/* nd_base_reach_time	*/
	(5 * HZ),			/* nd_delay_probe_time	*/

	1,				/* autoconfiguration	*/
	1,				/* dad transmits	*/
	MAX_RTR_SOLICITATIONS,		/* router solicits	*/
	RTR_SOLICITATION_INTERVAL,	/* rtr solicit interval	*/
	MAX_RTR_SOLICITATION_DELAY,	/* rtr solicit delay	*/

	60*HZ,				/* rt cache timeout	*/
	30*HZ,				/* rt gc period		*/
};

#ifdef CONFIG_SYSCTL

int ipv6_sysctl_forwarding(ctl_table *ctl, int write, struct file * filp,
			   void *buffer, size_t *lenp)
{
	int val = ipv6_config.forwarding;
	int retv;

	retv = proc_dointvec(ctl, write, filp, buffer, lenp);

	if (write) {
		if (ipv6_config.forwarding && val == 0) {
			printk(KERN_DEBUG "sysctl: IPv6 forwarding enabled\n");
			ndisc_forwarding_on();
			addrconf_forwarding_on();		       
		}

		if (ipv6_config.forwarding == 0 && val)
			ndisc_forwarding_off();
	}
	return retv;
}

ctl_table ipv6_table[] = {
        {NET_IPV6_FORWARDING, "forwarding",
         &ipv6_config.forwarding, sizeof(int), 0644, NULL,
         &ipv6_sysctl_forwarding},

	{NET_IPV6_HOPLIMIT, "hop_limit",
         &ipv6_config.hop_limit, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{NET_IPV6_ACCEPT_RA, "accept_ra",
         &ipv6_config.accept_ra, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{NET_IPV6_ACCEPT_REDIRECTS, "accept_redirects",
         &ipv6_config.accept_redirects, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{NET_IPV6_ND_MAX_MCAST_SOLICIT, "nd_max_mcast_solicit",
         &ipv6_config.nd_max_mcast_solicit, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{NET_IPV6_ND_MAX_UCAST_SOLICIT, "nd_max_ucast_solicit",
         &ipv6_config.nd_max_ucast_solicit, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{NET_IPV6_ND_RETRANS_TIME, "nd_retrans_time",
         &ipv6_config.nd_retrans_time, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{NET_IPV6_ND_REACHABLE_TIME, "nd_base_reachble_time",
         &ipv6_config.nd_base_reachable_time, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{NET_IPV6_ND_DELAY_PROBE_TIME, "nd_delay_first_probe_time",
         &ipv6_config.nd_delay_probe_time, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{NET_IPV6_AUTOCONF, "autoconf",
         &ipv6_config.autoconf, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{NET_IPV6_DAD_TRANSMITS, "dad_transmits",
         &ipv6_config.dad_transmits, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{NET_IPV6_RTR_SOLICITS, "router_solicitations",
         &ipv6_config.rtr_solicits, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{NET_IPV6_RTR_SOLICIT_INTERVAL, "router_solicitation_interval",
         &ipv6_config.rtr_solicit_interval, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{NET_IPV6_RTR_SOLICIT_DELAY, "router_solicitation_delay",
         &ipv6_config.rtr_solicit_delay, sizeof(int), 0644, NULL,
         &proc_dointvec},

	{0}
};

#ifdef MODULE
static struct ctl_table_header *ipv6_sysctl_header;
static struct ctl_table ipv6_root_table[];
static struct ctl_table ipv6_net_table[];


ctl_table ipv6_root_table[] = {
	{CTL_NET, "net", NULL, 0, 0555, ipv6_net_table},
        {0}
};

ctl_table ipv6_net_table[] = {
	{NET_IPV6, "ipv6", NULL, 0, 0555, ipv6_table},
        {0}
};

void ipv6_sysctl_register(void)
{
	ipv6_sysctl_header = register_sysctl_table(ipv6_root_table, 0);
}

void ipv6_sysctl_unregister(void)
{
	unregister_sysctl_table(ipv6_sysctl_header);
}
#endif	/* MODULE */

#endif /* CONFIG_SYSCTL */