Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * sysctl_net_ipv6.c: sysctl interface to net IPV6 subsystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Changes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * YOSHIFUJI Hideaki @USAGI:	added icmp sysctl table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/sysctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/in6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/ipv6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <net/ndisc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <net/ipv6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <net/addrconf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <net/inet_frag.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <net/netevent.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #ifdef CONFIG_NETLABEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <net/calipso.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static int two = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) static int flowlabel_reflect_max = 0x7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) static int auto_flowlabels_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static int auto_flowlabels_max = IP6_AUTO_FLOW_LABEL_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) static int proc_rt6_multipath_hash_policy(struct ctl_table *table, int write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 					  void *buffer, size_t *lenp, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct net *net;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	net = container_of(table->data, struct net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 			   ipv6.sysctl.multipath_hash_policy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	if (write && ret == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		call_netevent_notifiers(NETEVENT_IPV6_MPATH_HASH_UPDATE, net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static struct ctl_table ipv6_table_template[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		.procname	= "bindv6only",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		.data		= &init_net.ipv6.sysctl.bindv6only,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		.proc_handler	= proc_dointvec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		.procname	= "anycast_src_echo_reply",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		.data		= &init_net.ipv6.sysctl.anycast_src_echo_reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		.proc_handler	= proc_dointvec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		.procname	= "flowlabel_consistency",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		.data		= &init_net.ipv6.sysctl.flowlabel_consistency,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		.proc_handler	= proc_dointvec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		.procname	= "auto_flowlabels",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		.data		= &init_net.ipv6.sysctl.auto_flowlabels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		.proc_handler	= proc_dointvec_minmax,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		.extra1		= &auto_flowlabels_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		.extra2		= &auto_flowlabels_max
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		.procname	= "fwmark_reflect",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		.data		= &init_net.ipv6.sysctl.fwmark_reflect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		.proc_handler	= proc_dointvec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		.procname	= "idgen_retries",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		.data		= &init_net.ipv6.sysctl.idgen_retries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		.proc_handler	= proc_dointvec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		.procname	= "idgen_delay",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		.data		= &init_net.ipv6.sysctl.idgen_delay,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		.proc_handler	= proc_dointvec_jiffies,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		.procname	= "flowlabel_state_ranges",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		.data		= &init_net.ipv6.sysctl.flowlabel_state_ranges,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		.proc_handler	= proc_dointvec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		.procname	= "ip_nonlocal_bind",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		.data		= &init_net.ipv6.sysctl.ip_nonlocal_bind,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		.proc_handler	= proc_dointvec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		.procname	= "flowlabel_reflect",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		.data		= &init_net.ipv6.sysctl.flowlabel_reflect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		.proc_handler	= proc_dointvec_minmax,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		.extra1		= SYSCTL_ZERO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		.extra2		= &flowlabel_reflect_max,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		.procname	= "max_dst_opts_number",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		.data		= &init_net.ipv6.sysctl.max_dst_opts_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		.proc_handler	= proc_dointvec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		.procname	= "max_hbh_opts_number",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		.data		= &init_net.ipv6.sysctl.max_hbh_opts_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		.proc_handler	= proc_dointvec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		.procname	= "max_dst_opts_length",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		.data		= &init_net.ipv6.sysctl.max_dst_opts_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		.proc_handler	= proc_dointvec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		.procname	= "max_hbh_length",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		.data		= &init_net.ipv6.sysctl.max_hbh_opts_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		.proc_handler	= proc_dointvec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		.procname	= "fib_multipath_hash_policy",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		.data		= &init_net.ipv6.sysctl.multipath_hash_policy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		.proc_handler   = proc_rt6_multipath_hash_policy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		.extra1		= SYSCTL_ZERO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		.extra2		= &two,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		.procname	= "seg6_flowlabel",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		.data		= &init_net.ipv6.sysctl.seg6_flowlabel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		.proc_handler	= proc_dointvec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static struct ctl_table ipv6_rotable[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		.procname	= "mld_max_msf",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		.data		= &sysctl_mld_max_msf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		.proc_handler	= proc_dointvec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		.procname	= "mld_qrv",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		.data		= &sysctl_mld_qrv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		.proc_handler	= proc_dointvec_minmax,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		.extra1		= SYSCTL_ONE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #ifdef CONFIG_NETLABEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		.procname	= "calipso_cache_enable",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		.data		= &calipso_cache_enabled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		.proc_handler	= proc_dointvec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		.procname	= "calipso_cache_bucket_size",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		.data		= &calipso_cache_bucketsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		.maxlen		= sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		.mode		= 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		.proc_handler	= proc_dointvec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #endif /* CONFIG_NETLABEL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static int __net_init ipv6_sysctl_net_init(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	struct ctl_table *ipv6_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	struct ctl_table *ipv6_route_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	struct ctl_table *ipv6_icmp_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	int err, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	ipv6_table = kmemdup(ipv6_table_template, sizeof(ipv6_table_template),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			     GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	if (!ipv6_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	/* Update the variables to point into the current struct net */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	for (i = 0; i < ARRAY_SIZE(ipv6_table_template) - 1; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		ipv6_table[i].data += (void *)net - (void *)&init_net;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	ipv6_route_table = ipv6_route_sysctl_init(net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	if (!ipv6_route_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		goto out_ipv6_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	ipv6_icmp_table = ipv6_icmp_sysctl_init(net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	if (!ipv6_icmp_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		goto out_ipv6_route_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	net->ipv6.sysctl.hdr = register_net_sysctl(net, "net/ipv6", ipv6_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	if (!net->ipv6.sysctl.hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		goto out_ipv6_icmp_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	net->ipv6.sysctl.route_hdr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		register_net_sysctl(net, "net/ipv6/route", ipv6_route_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	if (!net->ipv6.sysctl.route_hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		goto out_unregister_ipv6_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	net->ipv6.sysctl.icmp_hdr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		register_net_sysctl(net, "net/ipv6/icmp", ipv6_icmp_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	if (!net->ipv6.sysctl.icmp_hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		goto out_unregister_route_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) out_unregister_route_table:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	unregister_net_sysctl_table(net->ipv6.sysctl.route_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) out_unregister_ipv6_table:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	unregister_net_sysctl_table(net->ipv6.sysctl.hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) out_ipv6_icmp_table:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	kfree(ipv6_icmp_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) out_ipv6_route_table:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	kfree(ipv6_route_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) out_ipv6_table:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	kfree(ipv6_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static void __net_exit ipv6_sysctl_net_exit(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	struct ctl_table *ipv6_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	struct ctl_table *ipv6_route_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	struct ctl_table *ipv6_icmp_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	ipv6_table = net->ipv6.sysctl.hdr->ctl_table_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	ipv6_route_table = net->ipv6.sysctl.route_hdr->ctl_table_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	ipv6_icmp_table = net->ipv6.sysctl.icmp_hdr->ctl_table_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	unregister_net_sysctl_table(net->ipv6.sysctl.icmp_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	unregister_net_sysctl_table(net->ipv6.sysctl.route_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	unregister_net_sysctl_table(net->ipv6.sysctl.hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	kfree(ipv6_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	kfree(ipv6_route_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	kfree(ipv6_icmp_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) static struct pernet_operations ipv6_sysctl_net_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	.init = ipv6_sysctl_net_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	.exit = ipv6_sysctl_net_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) static struct ctl_table_header *ip6_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) int ipv6_sysctl_register(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	int err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	ip6_header = register_net_sysctl(&init_net, "net/ipv6", ipv6_rotable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	if (!ip6_header)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	err = register_pernet_subsys(&ipv6_sysctl_net_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		goto err_pernet;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) err_pernet:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	unregister_net_sysctl_table(ip6_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) void ipv6_sysctl_unregister(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	unregister_net_sysctl_table(ip6_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	unregister_pernet_subsys(&ipv6_sysctl_net_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) }