提交 cda5f98e 编写于 作者: D Daniel Borkmann 提交者: David S. Miller

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: NDaniel Borkmann <dborkman@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 2690048c
...@@ -1507,6 +1507,14 @@ sack_timeout - INTEGER ...@@ -1507,6 +1507,14 @@ sack_timeout - INTEGER
Default: 200 Default: 200
checksum_disable - BOOLEAN
Disable SCTP checksum computing and verification for debugging purpose.
1: Disable checksumming
0: Enable checksumming
Default: 0
valid_cookie_life - INTEGER valid_cookie_life - INTEGER
The default lifetime of the SCTP cookie (in milliseconds). The cookie The default lifetime of the SCTP cookie (in milliseconds). The cookie
is used during association establishment. is used during association establishment.
......
...@@ -129,6 +129,9 @@ struct netns_sctp { ...@@ -129,6 +129,9 @@ struct netns_sctp {
/* Threshold for autoclose timeout, in seconds. */ /* Threshold for autoclose timeout, in seconds. */
unsigned long max_autoclose; unsigned long max_autoclose;
/* Flag to disable SCTP checksumming. */
int checksum_disable;
}; };
#endif /* __NETNS_SCTP_H__ */ #endif /* __NETNS_SCTP_H__ */
...@@ -141,10 +141,6 @@ extern struct sctp_globals { ...@@ -141,10 +141,6 @@ extern struct sctp_globals {
/* This is the sctp port control hash. */ /* This is the sctp port control hash. */
int port_hashsize; int port_hashsize;
struct sctp_bind_hashbucket *port_hashtable; struct sctp_bind_hashbucket *port_hashtable;
/* Flag to indicate whether computing and verifying checksum
* is disabled. */
bool checksum_disable;
} sctp_globals; } sctp_globals;
#define sctp_max_instreams (sctp_globals.max_instreams) #define sctp_max_instreams (sctp_globals.max_instreams)
...@@ -156,7 +152,6 @@ extern struct sctp_globals { ...@@ -156,7 +152,6 @@ extern struct sctp_globals {
#define sctp_assoc_hashtable (sctp_globals.assoc_hashtable) #define sctp_assoc_hashtable (sctp_globals.assoc_hashtable)
#define sctp_port_hashsize (sctp_globals.port_hashsize) #define sctp_port_hashsize (sctp_globals.port_hashsize)
#define sctp_port_hashtable (sctp_globals.port_hashtable) #define sctp_port_hashtable (sctp_globals.port_hashtable)
#define sctp_checksum_disable (sctp_globals.checksum_disable)
/* SCTP Socket type: UDP or TCP style. */ /* SCTP Socket type: UDP or TCP style. */
typedef enum { typedef enum {
......
...@@ -140,7 +140,7 @@ int sctp_rcv(struct sk_buff *skb) ...@@ -140,7 +140,7 @@ int sctp_rcv(struct sk_buff *skb)
__skb_pull(skb, skb_transport_offset(skb)); __skb_pull(skb, skb_transport_offset(skb));
if (skb->len < sizeof(struct sctphdr)) if (skb->len < sizeof(struct sctphdr))
goto discard_it; goto discard_it;
if (!sctp_checksum_disable && !skb_csum_unnecessary(skb) && if (!net->sctp.checksum_disable && !skb_csum_unnecessary(skb) &&
sctp_rcv_checksum(net, skb) < 0) sctp_rcv_checksum(net, skb) < 0)
goto discard_it; goto discard_it;
......
...@@ -395,6 +395,7 @@ int sctp_packet_transmit(struct sctp_packet *packet) ...@@ -395,6 +395,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
int padding; /* How much padding do we need? */ int padding; /* How much padding do we need? */
__u8 has_data = 0; __u8 has_data = 0;
struct dst_entry *dst = tp->dst; struct dst_entry *dst = tp->dst;
struct net *net;
unsigned char *auth = NULL; /* pointer to auth in skb data */ unsigned char *auth = NULL; /* pointer to auth in skb data */
__u32 cksum_buf_len = sizeof(struct sctphdr); __u32 cksum_buf_len = sizeof(struct sctphdr);
...@@ -541,7 +542,9 @@ int sctp_packet_transmit(struct sctp_packet *packet) ...@@ -541,7 +542,9 @@ int sctp_packet_transmit(struct sctp_packet *packet)
* Note: Adler-32 is no longer applicable, as has been replaced * Note: Adler-32 is no longer applicable, as has been replaced
* by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>. * by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>.
*/ */
if (!sctp_checksum_disable) { net = dev_net(dst->dev);
if (!net->sctp.checksum_disable) {
if (!(dst->dev->features & NETIF_F_SCTP_CSUM)) { if (!(dst->dev->features & NETIF_F_SCTP_CSUM)) {
__u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len); __u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len);
......
...@@ -1193,6 +1193,9 @@ static int __net_init sctp_net_init(struct net *net) ...@@ -1193,6 +1193,9 @@ static int __net_init sctp_net_init(struct net *net)
/* Whether Cookie Preservative is enabled(1) or not(0) */ /* Whether Cookie Preservative is enabled(1) or not(0) */
net->sctp.cookie_preserve_enable = 1; net->sctp.cookie_preserve_enable = 1;
/* Whether SCTP checksumming is disabled(1) or not(0) */
net->sctp.checksum_disable = 0;
/* Default sctp sockets to use md5 as their hmac alg */ /* Default sctp sockets to use md5 as their hmac alg */
#if defined (CONFIG_SCTP_DEFAULT_COOKIE_HMAC_MD5) #if defined (CONFIG_SCTP_DEFAULT_COOKIE_HMAC_MD5)
net->sctp.sctp_hmac_alg = "md5"; net->sctp.sctp_hmac_alg = "md5";
...@@ -1549,6 +1552,4 @@ MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-132"); ...@@ -1549,6 +1552,4 @@ MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-132");
MODULE_ALIAS("net-pf-" __stringify(PF_INET6) "-proto-132"); MODULE_ALIAS("net-pf-" __stringify(PF_INET6) "-proto-132");
MODULE_AUTHOR("Linux Kernel SCTP developers <linux-sctp@vger.kernel.org>"); MODULE_AUTHOR("Linux Kernel SCTP developers <linux-sctp@vger.kernel.org>");
MODULE_DESCRIPTION("Support for the SCTP protocol (RFC2960)"); MODULE_DESCRIPTION("Support for the SCTP protocol (RFC2960)");
module_param_named(no_checksums, sctp_checksum_disable, bool, 0644);
MODULE_PARM_DESC(no_checksums, "Disable checksums computing and verification");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -296,7 +296,15 @@ static struct ctl_table sctp_net_table[] = { ...@@ -296,7 +296,15 @@ static struct ctl_table sctp_net_table[] = {
.extra1 = &max_autoclose_min, .extra1 = &max_autoclose_min,
.extra2 = &max_autoclose_max, .extra2 = &max_autoclose_max,
}, },
{
.procname = "checksum_disable",
.data = &init_net.sctp.checksum_disable,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
},
{ /* sentinel */ } { /* sentinel */ }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册