|
24 | 24 | #include <net/cipso_ipv4.h>
|
25 | 25 | #include <net/inet_frag.h>
|
26 | 26 | #include <net/ping.h>
|
| 27 | +#include <net/protocol.h> |
27 | 28 |
|
28 | 29 | static int zero;
|
29 | 30 | static int one = 1;
|
@@ -294,6 +295,58 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
|
294 | 295 | return ret;
|
295 | 296 | }
|
296 | 297 |
|
| 298 | +static void proc_configure_early_demux(int enabled, int protocol) |
| 299 | +{ |
| 300 | + struct net_protocol *ipprot; |
| 301 | +#if IS_ENABLED(CONFIG_IPV6) |
| 302 | + struct inet6_protocol *ip6prot; |
| 303 | +#endif |
| 304 | + |
| 305 | + ipprot = rcu_dereference(inet_protos[protocol]); |
| 306 | + if (ipprot) |
| 307 | + ipprot->early_demux = enabled ? ipprot->early_demux_handler : |
| 308 | + NULL; |
| 309 | + |
| 310 | +#if IS_ENABLED(CONFIG_IPV6) |
| 311 | + ip6prot = rcu_dereference(inet6_protos[protocol]); |
| 312 | + if (ip6prot) |
| 313 | + ip6prot->early_demux = enabled ? ip6prot->early_demux_handler : |
| 314 | + NULL; |
| 315 | +#endif |
| 316 | +} |
| 317 | + |
| 318 | +static int proc_tcp_early_demux(struct ctl_table *table, int write, |
| 319 | + void __user *buffer, size_t *lenp, loff_t *ppos) |
| 320 | +{ |
| 321 | + int ret = 0; |
| 322 | + |
| 323 | + ret = proc_dointvec(table, write, buffer, lenp, ppos); |
| 324 | + |
| 325 | + if (write && !ret) { |
| 326 | + int enabled = init_net.ipv4.sysctl_tcp_early_demux; |
| 327 | + |
| 328 | + proc_configure_early_demux(enabled, IPPROTO_TCP); |
| 329 | + } |
| 330 | + |
| 331 | + return ret; |
| 332 | +} |
| 333 | + |
| 334 | +static int proc_udp_early_demux(struct ctl_table *table, int write, |
| 335 | + void __user *buffer, size_t *lenp, loff_t *ppos) |
| 336 | +{ |
| 337 | + int ret = 0; |
| 338 | + |
| 339 | + ret = proc_dointvec(table, write, buffer, lenp, ppos); |
| 340 | + |
| 341 | + if (write && !ret) { |
| 342 | + int enabled = init_net.ipv4.sysctl_udp_early_demux; |
| 343 | + |
| 344 | + proc_configure_early_demux(enabled, IPPROTO_UDP); |
| 345 | + } |
| 346 | + |
| 347 | + return ret; |
| 348 | +} |
| 349 | + |
297 | 350 | static struct ctl_table ipv4_table[] = {
|
298 | 351 | {
|
299 | 352 | .procname = "tcp_timestamps",
|
@@ -749,6 +802,20 @@ static struct ctl_table ipv4_net_table[] = {
|
749 | 802 | .mode = 0644,
|
750 | 803 | .proc_handler = proc_dointvec
|
751 | 804 | },
|
| 805 | + { |
| 806 | + .procname = "udp_early_demux", |
| 807 | + .data = &init_net.ipv4.sysctl_udp_early_demux, |
| 808 | + .maxlen = sizeof(int), |
| 809 | + .mode = 0644, |
| 810 | + .proc_handler = proc_udp_early_demux |
| 811 | + }, |
| 812 | + { |
| 813 | + .procname = "tcp_early_demux", |
| 814 | + .data = &init_net.ipv4.sysctl_tcp_early_demux, |
| 815 | + .maxlen = sizeof(int), |
| 816 | + .mode = 0644, |
| 817 | + .proc_handler = proc_tcp_early_demux |
| 818 | + }, |
752 | 819 | {
|
753 | 820 | .procname = "ip_default_ttl",
|
754 | 821 | .data = &init_net.ipv4.sysctl_ip_default_ttl,
|
|
0 commit comments