Skip to content

Commit 86c0bf4

Browse files
kaberdavem330
authored andcommitted
[NETFILTER]: nf_conntrack_sctp: remove timeout indirection
Instead of keeping pointers to the timeout values in a table, simply put the timeout values in the table directly. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9b1c2cf commit 86c0bf4

1 file changed

Lines changed: 24 additions & 33 deletions

File tree

‎net/netfilter/nf_conntrack_proto_sctp.c‎

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,15 @@ static const char *sctp_conntrack_names[] = {
4949
#define HOURS * 60 MINS
5050
#define DAYS * 24 HOURS
5151

52-
static unsigned int nf_ct_sctp_timeout_closed __read_mostly = 10 SECS;
53-
static unsigned int nf_ct_sctp_timeout_cookie_wait __read_mostly = 3 SECS;
54-
static unsigned int nf_ct_sctp_timeout_cookie_echoed __read_mostly = 3 SECS;
55-
static unsigned int nf_ct_sctp_timeout_established __read_mostly = 5 DAYS;
56-
static unsigned int nf_ct_sctp_timeout_shutdown_sent __read_mostly = 300 SECS / 1000;
57-
static unsigned int nf_ct_sctp_timeout_shutdown_recd __read_mostly = 300 SECS / 1000;
58-
static unsigned int nf_ct_sctp_timeout_shutdown_ack_sent __read_mostly = 3 SECS;
59-
60-
static unsigned int * sctp_timeouts[]
61-
= { NULL, /* SCTP_CONNTRACK_NONE */
62-
&nf_ct_sctp_timeout_closed, /* SCTP_CONNTRACK_CLOSED */
63-
&nf_ct_sctp_timeout_cookie_wait, /* SCTP_CONNTRACK_COOKIE_WAIT */
64-
&nf_ct_sctp_timeout_cookie_echoed, /* SCTP_CONNTRACK_COOKIE_ECHOED */
65-
&nf_ct_sctp_timeout_established, /* SCTP_CONNTRACK_ESTABLISHED */
66-
&nf_ct_sctp_timeout_shutdown_sent, /* SCTP_CONNTRACK_SHUTDOWN_SENT */
67-
&nf_ct_sctp_timeout_shutdown_recd, /* SCTP_CONNTRACK_SHUTDOWN_RECD */
68-
&nf_ct_sctp_timeout_shutdown_ack_sent /* SCTP_CONNTRACK_SHUTDOWN_ACK_SENT */
69-
};
52+
static unsigned int sctp_timeouts[SCTP_CONNTRACK_MAX] __read_mostly = {
53+
[SCTP_CONNTRACK_CLOSED] = 10 SECS,
54+
[SCTP_CONNTRACK_COOKIE_WAIT] = 3 SECS,
55+
[SCTP_CONNTRACK_COOKIE_ECHOED] = 3 SECS,
56+
[SCTP_CONNTRACK_ESTABLISHED] = 5 DAYS,
57+
[SCTP_CONNTRACK_SHUTDOWN_SENT] = 300 SECS / 1000,
58+
[SCTP_CONNTRACK_SHUTDOWN_RECD] = 300 SECS / 1000,
59+
[SCTP_CONNTRACK_SHUTDOWN_ACK_SENT] = 3 SECS,
60+
};
7061

7162
#define sNO SCTP_CONNTRACK_NONE
7263
#define sCL SCTP_CONNTRACK_CLOSED
@@ -380,7 +371,7 @@ static int sctp_packet(struct nf_conn *ct,
380371
}
381372
write_unlock_bh(&sctp_lock);
382373

383-
nf_ct_refresh_acct(ct, ctinfo, skb, *sctp_timeouts[new_state]);
374+
nf_ct_refresh_acct(ct, ctinfo, skb, sctp_timeouts[new_state]);
384375

385376
if (old_state == SCTP_CONNTRACK_COOKIE_ECHOED &&
386377
dir == IP_CT_DIR_REPLY &&
@@ -474,49 +465,49 @@ static struct ctl_table_header *sctp_sysctl_header;
474465
static struct ctl_table sctp_sysctl_table[] = {
475466
{
476467
.procname = "nf_conntrack_sctp_timeout_closed",
477-
.data = &nf_ct_sctp_timeout_closed,
468+
.data = &sctp_timeouts[SCTP_CONNTRACK_CLOSED],
478469
.maxlen = sizeof(unsigned int),
479470
.mode = 0644,
480471
.proc_handler = &proc_dointvec_jiffies,
481472
},
482473
{
483474
.procname = "nf_conntrack_sctp_timeout_cookie_wait",
484-
.data = &nf_ct_sctp_timeout_cookie_wait,
475+
.data = &sctp_timeouts[SCTP_CONNTRACK_COOKIE_WAIT],
485476
.maxlen = sizeof(unsigned int),
486477
.mode = 0644,
487478
.proc_handler = &proc_dointvec_jiffies,
488479
},
489480
{
490481
.procname = "nf_conntrack_sctp_timeout_cookie_echoed",
491-
.data = &nf_ct_sctp_timeout_cookie_echoed,
482+
.data = &sctp_timeouts[SCTP_CONNTRACK_COOKIE_ECHOED],
492483
.maxlen = sizeof(unsigned int),
493484
.mode = 0644,
494485
.proc_handler = &proc_dointvec_jiffies,
495486
},
496487
{
497488
.procname = "nf_conntrack_sctp_timeout_established",
498-
.data = &nf_ct_sctp_timeout_established,
489+
.data = &sctp_timeouts[SCTP_CONNTRACK_ESTABLISHED],
499490
.maxlen = sizeof(unsigned int),
500491
.mode = 0644,
501492
.proc_handler = &proc_dointvec_jiffies,
502493
},
503494
{
504495
.procname = "nf_conntrack_sctp_timeout_shutdown_sent",
505-
.data = &nf_ct_sctp_timeout_shutdown_sent,
496+
.data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_SENT],
506497
.maxlen = sizeof(unsigned int),
507498
.mode = 0644,
508499
.proc_handler = &proc_dointvec_jiffies,
509500
},
510501
{
511502
.procname = "nf_conntrack_sctp_timeout_shutdown_recd",
512-
.data = &nf_ct_sctp_timeout_shutdown_recd,
503+
.data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_RECD],
513504
.maxlen = sizeof(unsigned int),
514505
.mode = 0644,
515506
.proc_handler = &proc_dointvec_jiffies,
516507
},
517508
{
518509
.procname = "nf_conntrack_sctp_timeout_shutdown_ack_sent",
519-
.data = &nf_ct_sctp_timeout_shutdown_ack_sent,
510+
.data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_ACK_SENT],
520511
.maxlen = sizeof(unsigned int),
521512
.mode = 0644,
522513
.proc_handler = &proc_dointvec_jiffies,
@@ -530,49 +521,49 @@ static struct ctl_table sctp_sysctl_table[] = {
530521
static struct ctl_table sctp_compat_sysctl_table[] = {
531522
{
532523
.procname = "ip_conntrack_sctp_timeout_closed",
533-
.data = &nf_ct_sctp_timeout_closed,
524+
.data = &sctp_timeouts[SCTP_CONNTRACK_CLOSED],
534525
.maxlen = sizeof(unsigned int),
535526
.mode = 0644,
536527
.proc_handler = &proc_dointvec_jiffies,
537528
},
538529
{
539530
.procname = "ip_conntrack_sctp_timeout_cookie_wait",
540-
.data = &nf_ct_sctp_timeout_cookie_wait,
531+
.data = &sctp_timeouts[SCTP_CONNTRACK_COOKIE_WAIT],
541532
.maxlen = sizeof(unsigned int),
542533
.mode = 0644,
543534
.proc_handler = &proc_dointvec_jiffies,
544535
},
545536
{
546537
.procname = "ip_conntrack_sctp_timeout_cookie_echoed",
547-
.data = &nf_ct_sctp_timeout_cookie_echoed,
538+
.data = &sctp_timeouts[SCTP_CONNTRACK_COOKIE_ECHOED],
548539
.maxlen = sizeof(unsigned int),
549540
.mode = 0644,
550541
.proc_handler = &proc_dointvec_jiffies,
551542
},
552543
{
553544
.procname = "ip_conntrack_sctp_timeout_established",
554-
.data = &nf_ct_sctp_timeout_established,
545+
.data = &sctp_timeouts[SCTP_CONNTRACK_ESTABLISHED],
555546
.maxlen = sizeof(unsigned int),
556547
.mode = 0644,
557548
.proc_handler = &proc_dointvec_jiffies,
558549
},
559550
{
560551
.procname = "ip_conntrack_sctp_timeout_shutdown_sent",
561-
.data = &nf_ct_sctp_timeout_shutdown_sent,
552+
.data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_SENT],
562553
.maxlen = sizeof(unsigned int),
563554
.mode = 0644,
564555
.proc_handler = &proc_dointvec_jiffies,
565556
},
566557
{
567558
.procname = "ip_conntrack_sctp_timeout_shutdown_recd",
568-
.data = &nf_ct_sctp_timeout_shutdown_recd,
559+
.data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_RECD],
569560
.maxlen = sizeof(unsigned int),
570561
.mode = 0644,
571562
.proc_handler = &proc_dointvec_jiffies,
572563
},
573564
{
574565
.procname = "ip_conntrack_sctp_timeout_shutdown_ack_sent",
575-
.data = &nf_ct_sctp_timeout_shutdown_ack_sent,
566+
.data = &sctp_timeouts[SCTP_CONNTRACK_SHUTDOWN_ACK_SENT],
576567
.maxlen = sizeof(unsigned int),
577568
.mode = 0644,
578569
.proc_handler = &proc_dointvec_jiffies,

0 commit comments

Comments
 (0)