Thomas Gleixner | e46bd70 | 2019-05-31 01:09:47 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 2 | /* |
| 3 | * net/dccp/sysctl.c |
| 4 | * |
| 5 | * An implementation of the DCCP protocol |
| 6 | * Arnaldo Carvalho de Melo <acme@mandriva.com> |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 7 | */ |
| 8 | |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 9 | #include <linux/mm.h> |
| 10 | #include <linux/sysctl.h> |
Gerrit Renker | 2e2e9e9 | 2006-11-13 13:23:52 -0200 | [diff] [blame] | 11 | #include "dccp.h" |
Ian McDonald | 2a0109a | 2006-08-26 19:15:35 -0700 | [diff] [blame] | 12 | #include "feat.h" |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 13 | |
| 14 | #ifndef CONFIG_SYSCTL |
| 15 | #error This file should not be compiled without CONFIG_SYSCTL defined |
| 16 | #endif |
| 17 | |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 18 | /* Boundary values */ |
Matteo Croce | eec4844 | 2019-07-18 15:58:50 -0700 | [diff] [blame] | 19 | static int u8_max = 0xFF; |
Gerrit Renker | bfbb234 | 2011-01-02 18:15:58 +0100 | [diff] [blame] | 20 | static unsigned long seqw_min = DCCPF_SEQ_WMIN, |
| 21 | seqw_max = 0xFFFFFFFF; /* maximum on 32 bit */ |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 22 | |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 23 | static struct ctl_table dccp_default_table[] = { |
| 24 | { |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 25 | .procname = "seq_window", |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 26 | .data = &sysctl_dccp_sequence_window, |
| 27 | .maxlen = sizeof(sysctl_dccp_sequence_window), |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 28 | .mode = 0644, |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 29 | .proc_handler = proc_doulongvec_minmax, |
| 30 | .extra1 = &seqw_min, /* RFC 4340, 7.5.2 */ |
Gerrit Renker | bfbb234 | 2011-01-02 18:15:58 +0100 | [diff] [blame] | 31 | .extra2 = &seqw_max, |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 32 | }, |
| 33 | { |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 34 | .procname = "rx_ccid", |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 35 | .data = &sysctl_dccp_rx_ccid, |
| 36 | .maxlen = sizeof(sysctl_dccp_rx_ccid), |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 37 | .mode = 0644, |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 38 | .proc_handler = proc_dointvec_minmax, |
Matteo Croce | eec4844 | 2019-07-18 15:58:50 -0700 | [diff] [blame] | 39 | .extra1 = SYSCTL_ZERO, |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 40 | .extra2 = &u8_max, /* RFC 4340, 10. */ |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 41 | }, |
| 42 | { |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 43 | .procname = "tx_ccid", |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 44 | .data = &sysctl_dccp_tx_ccid, |
| 45 | .maxlen = sizeof(sysctl_dccp_tx_ccid), |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 46 | .mode = 0644, |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 47 | .proc_handler = proc_dointvec_minmax, |
Matteo Croce | eec4844 | 2019-07-18 15:58:50 -0700 | [diff] [blame] | 48 | .extra1 = SYSCTL_ZERO, |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 49 | .extra2 = &u8_max, /* RFC 4340, 10. */ |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 50 | }, |
| 51 | { |
Gerrit Renker | 2e2e9e9 | 2006-11-13 13:23:52 -0200 | [diff] [blame] | 52 | .procname = "request_retries", |
| 53 | .data = &sysctl_dccp_request_retries, |
| 54 | .maxlen = sizeof(sysctl_dccp_request_retries), |
| 55 | .mode = 0644, |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 56 | .proc_handler = proc_dointvec_minmax, |
Matteo Croce | eec4844 | 2019-07-18 15:58:50 -0700 | [diff] [blame] | 57 | .extra1 = SYSCTL_ONE, |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 58 | .extra2 = &u8_max, |
Gerrit Renker | 2e2e9e9 | 2006-11-13 13:23:52 -0200 | [diff] [blame] | 59 | }, |
| 60 | { |
Gerrit Renker | 2e2e9e9 | 2006-11-13 13:23:52 -0200 | [diff] [blame] | 61 | .procname = "retries1", |
| 62 | .data = &sysctl_dccp_retries1, |
| 63 | .maxlen = sizeof(sysctl_dccp_retries1), |
| 64 | .mode = 0644, |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 65 | .proc_handler = proc_dointvec_minmax, |
Matteo Croce | eec4844 | 2019-07-18 15:58:50 -0700 | [diff] [blame] | 66 | .extra1 = SYSCTL_ZERO, |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 67 | .extra2 = &u8_max, |
Gerrit Renker | 2e2e9e9 | 2006-11-13 13:23:52 -0200 | [diff] [blame] | 68 | }, |
| 69 | { |
Gerrit Renker | 2e2e9e9 | 2006-11-13 13:23:52 -0200 | [diff] [blame] | 70 | .procname = "retries2", |
| 71 | .data = &sysctl_dccp_retries2, |
| 72 | .maxlen = sizeof(sysctl_dccp_retries2), |
| 73 | .mode = 0644, |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 74 | .proc_handler = proc_dointvec_minmax, |
Matteo Croce | eec4844 | 2019-07-18 15:58:50 -0700 | [diff] [blame] | 75 | .extra1 = SYSCTL_ZERO, |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 76 | .extra2 = &u8_max, |
Gerrit Renker | 2e2e9e9 | 2006-11-13 13:23:52 -0200 | [diff] [blame] | 77 | }, |
Ian McDonald | 82e3ab9 | 2006-11-20 19:19:32 -0200 | [diff] [blame] | 78 | { |
Ian McDonald | 82e3ab9 | 2006-11-20 19:19:32 -0200 | [diff] [blame] | 79 | .procname = "tx_qlen", |
| 80 | .data = &sysctl_dccp_tx_qlen, |
| 81 | .maxlen = sizeof(sysctl_dccp_tx_qlen), |
| 82 | .mode = 0644, |
Gerrit Renker | 883ca83 | 2009-01-16 23:36:32 +0000 | [diff] [blame] | 83 | .proc_handler = proc_dointvec_minmax, |
Matteo Croce | eec4844 | 2019-07-18 15:58:50 -0700 | [diff] [blame] | 84 | .extra1 = SYSCTL_ZERO, |
Ian McDonald | 82e3ab9 | 2006-11-20 19:19:32 -0200 | [diff] [blame] | 85 | }, |
Gerrit Renker | a94f0f9 | 2007-09-26 11:31:49 -0300 | [diff] [blame] | 86 | { |
| 87 | .procname = "sync_ratelimit", |
| 88 | .data = &sysctl_dccp_sync_ratelimit, |
| 89 | .maxlen = sizeof(sysctl_dccp_sync_ratelimit), |
| 90 | .mode = 0644, |
| 91 | .proc_handler = proc_dointvec_ms_jiffies, |
| 92 | }, |
Ian McDonald | 82e3ab9 | 2006-11-20 19:19:32 -0200 | [diff] [blame] | 93 | |
Eric W. Biederman | f8572d8 | 2009-11-05 13:32:03 -0800 | [diff] [blame] | 94 | { } |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 95 | }; |
| 96 | |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 97 | static struct ctl_table_header *dccp_table_header; |
| 98 | |
| 99 | int __init dccp_sysctl_init(void) |
| 100 | { |
Eric W. Biederman | ec8f23c | 2012-04-19 13:44:49 +0000 | [diff] [blame] | 101 | dccp_table_header = register_net_sysctl(&init_net, "net/dccp/default", |
Pavel Emelyanov | b5ccd79 | 2008-01-09 00:30:05 -0800 | [diff] [blame] | 102 | dccp_default_table); |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 103 | |
| 104 | return dccp_table_header != NULL ? 0 : -ENOMEM; |
| 105 | } |
| 106 | |
| 107 | void dccp_sysctl_exit(void) |
| 108 | { |
| 109 | if (dccp_table_header != NULL) { |
Eric W. Biederman | 5dd3df1 | 2012-04-19 13:24:33 +0000 | [diff] [blame] | 110 | unregister_net_sysctl_table(dccp_table_header); |
Arnaldo Carvalho de Melo | e55d912 | 2006-03-20 19:25:02 -0800 | [diff] [blame] | 111 | dccp_table_header = NULL; |
| 112 | } |
| 113 | } |