Commit cda5f98e36576596b9230483ec52bff3cc97eb21

Authored by Daniel Borkmann
Committed by David S. Miller
1 parent 2690048c01

net: sctp: convert sctp_checksum_disable module param into sctp sysctl

Get rid of the last module parameter for SCTP and make this
configurable via sysctl for SCTP like all the rest of SCTP's
configuration knobs.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 7 changed files with 29 additions and 11 deletions Side-by-side Diff

Documentation/networking/ip-sysctl.txt
... ... @@ -1507,6 +1507,14 @@
1507 1507  
1508 1508 Default: 200
1509 1509  
  1510 +checksum_disable - BOOLEAN
  1511 + Disable SCTP checksum computing and verification for debugging purpose.
  1512 +
  1513 + 1: Disable checksumming
  1514 + 0: Enable checksumming
  1515 +
  1516 + Default: 0
  1517 +
1510 1518 valid_cookie_life - INTEGER
1511 1519 The default lifetime of the SCTP cookie (in milliseconds). The cookie
1512 1520 is used during association establishment.
include/net/netns/sctp.h
... ... @@ -129,6 +129,9 @@
129 129  
130 130 /* Threshold for autoclose timeout, in seconds. */
131 131 unsigned long max_autoclose;
  132 +
  133 + /* Flag to disable SCTP checksumming. */
  134 + int checksum_disable;
132 135 };
133 136  
134 137 #endif /* __NETNS_SCTP_H__ */
include/net/sctp/structs.h
... ... @@ -141,10 +141,6 @@
141 141 /* This is the sctp port control hash. */
142 142 int port_hashsize;
143 143 struct sctp_bind_hashbucket *port_hashtable;
144   -
145   - /* Flag to indicate whether computing and verifying checksum
146   - * is disabled. */
147   - bool checksum_disable;
148 144 } sctp_globals;
149 145  
150 146 #define sctp_max_instreams (sctp_globals.max_instreams)
... ... @@ -156,7 +152,6 @@
156 152 #define sctp_assoc_hashtable (sctp_globals.assoc_hashtable)
157 153 #define sctp_port_hashsize (sctp_globals.port_hashsize)
158 154 #define sctp_port_hashtable (sctp_globals.port_hashtable)
159   -#define sctp_checksum_disable (sctp_globals.checksum_disable)
160 155  
161 156 /* SCTP Socket type: UDP or TCP style. */
162 157 typedef enum {
... ... @@ -140,8 +140,8 @@
140 140 __skb_pull(skb, skb_transport_offset(skb));
141 141 if (skb->len < sizeof(struct sctphdr))
142 142 goto discard_it;
143   - if (!sctp_checksum_disable && !skb_csum_unnecessary(skb) &&
144   - sctp_rcv_checksum(net, skb) < 0)
  143 + if (!net->sctp.checksum_disable && !skb_csum_unnecessary(skb) &&
  144 + sctp_rcv_checksum(net, skb) < 0)
145 145 goto discard_it;
146 146  
147 147 skb_pull(skb, sizeof(struct sctphdr));
... ... @@ -395,6 +395,7 @@
395 395 int padding; /* How much padding do we need? */
396 396 __u8 has_data = 0;
397 397 struct dst_entry *dst = tp->dst;
  398 + struct net *net;
398 399 unsigned char *auth = NULL; /* pointer to auth in skb data */
399 400 __u32 cksum_buf_len = sizeof(struct sctphdr);
400 401  
... ... @@ -541,7 +542,9 @@
541 542 * Note: Adler-32 is no longer applicable, as has been replaced
542 543 * by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>.
543 544 */
544   - if (!sctp_checksum_disable) {
  545 + net = dev_net(dst->dev);
  546 +
  547 + if (!net->sctp.checksum_disable) {
545 548 if (!(dst->dev->features & NETIF_F_SCTP_CSUM)) {
546 549 __u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len);
547 550  
... ... @@ -1193,6 +1193,9 @@
1193 1193 /* Whether Cookie Preservative is enabled(1) or not(0) */
1194 1194 net->sctp.cookie_preserve_enable = 1;
1195 1195  
  1196 + /* Whether SCTP checksumming is disabled(1) or not(0) */
  1197 + net->sctp.checksum_disable = 0;
  1198 +
1196 1199 /* Default sctp sockets to use md5 as their hmac alg */
1197 1200 #if defined (CONFIG_SCTP_DEFAULT_COOKIE_HMAC_MD5)
1198 1201 net->sctp.sctp_hmac_alg = "md5";
... ... @@ -1549,7 +1552,5 @@
1549 1552 MODULE_ALIAS("net-pf-" __stringify(PF_INET6) "-proto-132");
1550 1553 MODULE_AUTHOR("Linux Kernel SCTP developers <linux-sctp@vger.kernel.org>");
1551 1554 MODULE_DESCRIPTION("Support for the SCTP protocol (RFC2960)");
1552   -module_param_named(no_checksums, sctp_checksum_disable, bool, 0644);
1553   -MODULE_PARM_DESC(no_checksums, "Disable checksums computing and verification");
1554 1555 MODULE_LICENSE("GPL");
... ... @@ -296,7 +296,15 @@
296 296 .extra1 = &max_autoclose_min,
297 297 .extra2 = &max_autoclose_max,
298 298 },
299   -
  299 + {
  300 + .procname = "checksum_disable",
  301 + .data = &init_net.sctp.checksum_disable,
  302 + .maxlen = sizeof(int),
  303 + .mode = 0644,
  304 + .proc_handler = proc_dointvec_minmax,
  305 + .extra1 = &zero,
  306 + .extra2 = &one,
  307 + },
300 308 { /* sentinel */ }
301 309 };
302 310