Skip to content

Commit cda5f98

Browse files
Daniel Borkmanndavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2690048 commit cda5f98

File tree

7 files changed

+29
-11
lines changed

7 files changed

+29
-11
lines changed

Documentation/networking/ip-sysctl.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,14 @@ sack_timeout - INTEGER
15071507

15081508
Default: 200
15091509

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+
15101518
valid_cookie_life - INTEGER
15111519
The default lifetime of the SCTP cookie (in milliseconds). The cookie
15121520
is used during association establishment.

include/net/netns/sctp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ struct netns_sctp {
129129

130130
/* Threshold for autoclose timeout, in seconds. */
131131
unsigned long max_autoclose;
132+
133+
/* Flag to disable SCTP checksumming. */
134+
int checksum_disable;
132135
};
133136

134137
#endif /* __NETNS_SCTP_H__ */

include/net/sctp/structs.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,6 @@ extern struct sctp_globals {
141141
/* This is the sctp port control hash. */
142142
int port_hashsize;
143143
struct sctp_bind_hashbucket *port_hashtable;
144-
145-
/* Flag to indicate whether computing and verifying checksum
146-
* is disabled. */
147-
bool checksum_disable;
148144
} sctp_globals;
149145

150146
#define sctp_max_instreams (sctp_globals.max_instreams)
@@ -156,7 +152,6 @@ extern struct sctp_globals {
156152
#define sctp_assoc_hashtable (sctp_globals.assoc_hashtable)
157153
#define sctp_port_hashsize (sctp_globals.port_hashsize)
158154
#define sctp_port_hashtable (sctp_globals.port_hashtable)
159-
#define sctp_checksum_disable (sctp_globals.checksum_disable)
160155

161156
/* SCTP Socket type: UDP or TCP style. */
162157
typedef enum {

net/sctp/input.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ int sctp_rcv(struct sk_buff *skb)
140140
__skb_pull(skb, skb_transport_offset(skb));
141141
if (skb->len < sizeof(struct sctphdr))
142142
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)
145145
goto discard_it;
146146

147147
skb_pull(skb, sizeof(struct sctphdr));

net/sctp/output.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
395395
int padding; /* How much padding do we need? */
396396
__u8 has_data = 0;
397397
struct dst_entry *dst = tp->dst;
398+
struct net *net;
398399
unsigned char *auth = NULL; /* pointer to auth in skb data */
399400
__u32 cksum_buf_len = sizeof(struct sctphdr);
400401

@@ -541,7 +542,9 @@ int sctp_packet_transmit(struct sctp_packet *packet)
541542
* Note: Adler-32 is no longer applicable, as has been replaced
542543
* by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>.
543544
*/
544-
if (!sctp_checksum_disable) {
545+
net = dev_net(dst->dev);
546+
547+
if (!net->sctp.checksum_disable) {
545548
if (!(dst->dev->features & NETIF_F_SCTP_CSUM)) {
546549
__u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len);
547550

net/sctp/protocol.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,9 @@ static int __net_init sctp_net_init(struct net *net)
11931193
/* Whether Cookie Preservative is enabled(1) or not(0) */
11941194
net->sctp.cookie_preserve_enable = 1;
11951195

1196+
/* Whether SCTP checksumming is disabled(1) or not(0) */
1197+
net->sctp.checksum_disable = 0;
1198+
11961199
/* Default sctp sockets to use md5 as their hmac alg */
11971200
#if defined (CONFIG_SCTP_DEFAULT_COOKIE_HMAC_MD5)
11981201
net->sctp.sctp_hmac_alg = "md5";
@@ -1549,6 +1552,4 @@ MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-132");
15491552
MODULE_ALIAS("net-pf-" __stringify(PF_INET6) "-proto-132");
15501553
MODULE_AUTHOR("Linux Kernel SCTP developers <[email protected]>");
15511554
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");
15541555
MODULE_LICENSE("GPL");

net/sctp/sysctl.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,15 @@ static struct ctl_table sctp_net_table[] = {
296296
.extra1 = &max_autoclose_min,
297297
.extra2 = &max_autoclose_max,
298298
},
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+
},
300308
{ /* sentinel */ }
301309
};
302310

0 commit comments

Comments
 (0)