Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipv4: Namespacify ip_dynaddr sysctl knob

Signed-off-by: Nikolay Borisov <kernel@kyup.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Nikolay Borisov and committed by
David S. Miller
287b7f38 dcd87999

+12 -18
-3
include/net/ip.h
··· 248 248 /* From ip_input.c */ 249 249 extern int sysctl_ip_early_demux; 250 250 251 - /* From ip_output.c */ 252 - extern int sysctl_ip_dynaddr; 253 - 254 251 void ipfrag_init(void); 255 252 256 253 void ip_static_sysctl_init(void);
+2
include/net/netns/ipv4.h
··· 84 84 int sysctl_ip_no_pmtu_disc; 85 85 int sysctl_ip_fwd_use_pmtu; 86 86 int sysctl_ip_nonlocal_bind; 87 + /* Shall we try to damage output packets if routing dev changes? */ 88 + int sysctl_ip_dynaddr; 87 89 88 90 int sysctl_fwmark_reflect; 89 91 int sysctl_tcp_fwmark_accept;
+2 -8
net/ipv4/af_inet.c
··· 1095 1095 } 1096 1096 EXPORT_SYMBOL(inet_unregister_protosw); 1097 1097 1098 - /* 1099 - * Shall we try to damage output packets if routing dev changes? 1100 - */ 1101 - 1102 - int sysctl_ip_dynaddr __read_mostly; 1103 - 1104 1098 static int inet_sk_reselect_saddr(struct sock *sk) 1105 1099 { 1106 1100 struct inet_sock *inet = inet_sk(sk); ··· 1125 1131 if (new_saddr == old_saddr) 1126 1132 return 0; 1127 1133 1128 - if (sysctl_ip_dynaddr > 1) { 1134 + if (sock_net(sk)->ipv4.sysctl_ip_dynaddr > 1) { 1129 1135 pr_info("%s(): shifting inet->saddr from %pI4 to %pI4\n", 1130 1136 __func__, &old_saddr, &new_saddr); 1131 1137 } ··· 1180 1186 * Other protocols have to map its equivalent state to TCP_SYN_SENT. 1181 1187 * DCCP maps its DCCP_REQUESTING state to TCP_SYN_SENT. -acme 1182 1188 */ 1183 - if (!sysctl_ip_dynaddr || 1189 + if (!sock_net(sk)->ipv4.sysctl_ip_dynaddr || 1184 1190 sk->sk_state != TCP_SYN_SENT || 1185 1191 (sk->sk_userlocks & SOCK_BINDADDR_LOCK) || 1186 1192 (err = inet_sk_reselect_saddr(sk)) != 0)
+8 -7
net/ipv4/sysctl_net_ipv4.c
··· 304 304 .proc_handler = proc_dointvec 305 305 }, 306 306 { 307 - .procname = "ip_dynaddr", 308 - .data = &sysctl_ip_dynaddr, 309 - .maxlen = sizeof(int), 310 - .mode = 0644, 311 - .proc_handler = proc_dointvec 312 - }, 313 - { 314 307 .procname = "tcp_fastopen", 315 308 .data = &sysctl_tcp_fastopen, 316 309 .maxlen = sizeof(int), ··· 737 744 .proc_handler = proc_dointvec 738 745 }, 739 746 { 747 + .procname = "ip_dynaddr", 748 + .data = &init_net.ipv4.sysctl_ip_dynaddr, 749 + .maxlen = sizeof(int), 750 + .mode = 0644, 751 + .proc_handler = proc_dointvec 752 + }, 753 + { 740 754 .procname = "ip_default_ttl", 741 755 .data = &init_net.ipv4.sysctl_ip_default_ttl, 742 756 .maxlen = sizeof(int), ··· 989 989 goto err_ports; 990 990 991 991 net->ipv4.sysctl_ip_default_ttl = IPDEFTTL; 992 + net->ipv4.sysctl_ip_dynaddr = 0; 992 993 993 994 return 0; 994 995