aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2005-09-22 03:30:44 -0400
committerArnaldo Carvalho de Melo <acme@mandriva.com>2005-09-22 03:30:44 -0400
commit590232a7150674b2036291eaefce085f3f9659c8 (patch)
treef14ca696cc9eead769933d24d04105928260f028 /net
parent54fb7f25f19a4539d3ec012e410439913650dc06 (diff)
[LLC]: Add sysctl support for the LLC timeouts
Signed-off-by: Jochen Friedrich <jochen@scram.de> Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net')
-rw-r--r--net/llc/Makefile1
-rw-r--r--net/llc/af_llc.c47
-rw-r--r--net/llc/llc_c_ac.c12
-rw-r--r--net/llc/llc_conn.c13
-rw-r--r--net/llc/llc_station.c11
-rw-r--r--net/llc/sysctl_net_llc.c136
6 files changed, 195 insertions, 25 deletions
diff --git a/net/llc/Makefile b/net/llc/Makefile
index 5ebd4ed2bd42..4e260cff3c5d 100644
--- a/net/llc/Makefile
+++ b/net/llc/Makefile
@@ -22,3 +22,4 @@ llc2-y := llc_if.o llc_c_ev.o llc_c_ac.o llc_conn.o llc_c_st.o llc_pdu.o \
22 llc_sap.o llc_s_ac.o llc_s_ev.o llc_s_st.o af_llc.o llc_station.o 22 llc_sap.o llc_s_ac.o llc_s_ev.o llc_s_st.o af_llc.o llc_station.o
23 23
24llc2-$(CONFIG_PROC_FS) += llc_proc.o 24llc2-$(CONFIG_PROC_FS) += llc_proc.o
25llc2-$(CONFIG_SYSCTL) += sysctl_net_llc.o
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 95444f227510..ef125345a2db 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -877,22 +877,22 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname,
877 case LLC_OPT_ACK_TMR_EXP: 877 case LLC_OPT_ACK_TMR_EXP:
878 if (opt > LLC_OPT_MAX_ACK_TMR_EXP) 878 if (opt > LLC_OPT_MAX_ACK_TMR_EXP)
879 goto out; 879 goto out;
880 llc->ack_timer.expire = opt; 880 llc->ack_timer.expire = opt * HZ;
881 break; 881 break;
882 case LLC_OPT_P_TMR_EXP: 882 case LLC_OPT_P_TMR_EXP:
883 if (opt > LLC_OPT_MAX_P_TMR_EXP) 883 if (opt > LLC_OPT_MAX_P_TMR_EXP)
884 goto out; 884 goto out;
885 llc->pf_cycle_timer.expire = opt; 885 llc->pf_cycle_timer.expire = opt * HZ;
886 break; 886 break;
887 case LLC_OPT_REJ_TMR_EXP: 887 case LLC_OPT_REJ_TMR_EXP:
888 if (opt > LLC_OPT_MAX_REJ_TMR_EXP) 888 if (opt > LLC_OPT_MAX_REJ_TMR_EXP)
889 goto out; 889 goto out;
890 llc->rej_sent_timer.expire = opt; 890 llc->rej_sent_timer.expire = opt * HZ;
891 break; 891 break;
892 case LLC_OPT_BUSY_TMR_EXP: 892 case LLC_OPT_BUSY_TMR_EXP:
893 if (opt > LLC_OPT_MAX_BUSY_TMR_EXP) 893 if (opt > LLC_OPT_MAX_BUSY_TMR_EXP)
894 goto out; 894 goto out;
895 llc->busy_state_timer.expire = opt; 895 llc->busy_state_timer.expire = opt * HZ;
896 break; 896 break;
897 case LLC_OPT_TX_WIN: 897 case LLC_OPT_TX_WIN:
898 if (opt > LLC_OPT_MAX_WIN) 898 if (opt > LLC_OPT_MAX_WIN)
@@ -942,17 +942,17 @@ static int llc_ui_getsockopt(struct socket *sock, int level, int optname,
942 goto out; 942 goto out;
943 switch (optname) { 943 switch (optname) {
944 case LLC_OPT_RETRY: 944 case LLC_OPT_RETRY:
945 val = llc->n2; break; 945 val = llc->n2; break;
946 case LLC_OPT_SIZE: 946 case LLC_OPT_SIZE:
947 val = llc->n1; break; 947 val = llc->n1; break;
948 case LLC_OPT_ACK_TMR_EXP: 948 case LLC_OPT_ACK_TMR_EXP:
949 val = llc->ack_timer.expire; break; 949 val = llc->ack_timer.expire / HZ; break;
950 case LLC_OPT_P_TMR_EXP: 950 case LLC_OPT_P_TMR_EXP:
951 val = llc->pf_cycle_timer.expire; break; 951 val = llc->pf_cycle_timer.expire / HZ; break;
952 case LLC_OPT_REJ_TMR_EXP: 952 case LLC_OPT_REJ_TMR_EXP:
953 val = llc->rej_sent_timer.expire; break; 953 val = llc->rej_sent_timer.expire / HZ; break;
954 case LLC_OPT_BUSY_TMR_EXP: 954 case LLC_OPT_BUSY_TMR_EXP:
955 val = llc->busy_state_timer.expire; break; 955 val = llc->busy_state_timer.expire / HZ; break;
956 case LLC_OPT_TX_WIN: 956 case LLC_OPT_TX_WIN:
957 val = llc->k; break; 957 val = llc->k; break;
958 case LLC_OPT_RX_WIN: 958 case LLC_OPT_RX_WIN:
@@ -999,6 +999,13 @@ static struct proto_ops llc_ui_ops = {
999extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb); 999extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb);
1000extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb); 1000extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb);
1001 1001
1002static char llc_proc_err_msg[] __initdata =
1003 KERN_CRIT "LLC: Unable to register the proc_fs entries\n";
1004static char llc_sysctl_err_msg[] __initdata =
1005 KERN_CRIT "LLC: Unable to register the sysctl entries\n";
1006static char llc_sock_err_msg[] __initdata =
1007 KERN_CRIT "LLC: Unable to register the network family\n";
1008
1002static int __init llc2_init(void) 1009static int __init llc2_init(void)
1003{ 1010{
1004 int rc = proto_register(&llc_proto, 0); 1011 int rc = proto_register(&llc_proto, 0);
@@ -1010,13 +1017,28 @@ static int __init llc2_init(void)
1010 llc_station_init(); 1017 llc_station_init();
1011 llc_ui_sap_last_autoport = LLC_SAP_DYN_START; 1018 llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
1012 rc = llc_proc_init(); 1019 rc = llc_proc_init();
1013 if (rc != 0) 1020 if (rc != 0) {
1021 printk(llc_proc_err_msg);
1014 goto out_unregister_llc_proto; 1022 goto out_unregister_llc_proto;
1015 sock_register(&llc_ui_family_ops); 1023 }
1024 rc = llc_sysctl_init();
1025 if (rc) {
1026 printk(llc_sysctl_err_msg);
1027 goto out_proc;
1028 }
1029 rc = sock_register(&llc_ui_family_ops);
1030 if (rc) {
1031 printk(llc_sock_err_msg);
1032 goto out_sysctl;
1033 }
1016 llc_add_pack(LLC_DEST_SAP, llc_sap_handler); 1034 llc_add_pack(LLC_DEST_SAP, llc_sap_handler);
1017 llc_add_pack(LLC_DEST_CONN, llc_conn_handler); 1035 llc_add_pack(LLC_DEST_CONN, llc_conn_handler);
1018out: 1036out:
1019 return rc; 1037 return rc;
1038out_sysctl:
1039 llc_sysctl_exit();
1040out_proc:
1041 llc_proc_exit();
1020out_unregister_llc_proto: 1042out_unregister_llc_proto:
1021 proto_unregister(&llc_proto); 1043 proto_unregister(&llc_proto);
1022 goto out; 1044 goto out;
@@ -1029,6 +1051,7 @@ static void __exit llc2_exit(void)
1029 llc_remove_pack(LLC_DEST_CONN); 1051 llc_remove_pack(LLC_DEST_CONN);
1030 sock_unregister(PF_LLC); 1052 sock_unregister(PF_LLC);
1031 llc_proc_exit(); 1053 llc_proc_exit();
1054 llc_sysctl_exit();
1032 proto_unregister(&llc_proto); 1055 proto_unregister(&llc_proto);
1033} 1056}
1034 1057
diff --git a/net/llc/llc_c_ac.c b/net/llc/llc_c_ac.c
index 50c827e13a9f..a4daa91003dd 100644
--- a/net/llc/llc_c_ac.c
+++ b/net/llc/llc_c_ac.c
@@ -620,7 +620,7 @@ int llc_conn_ac_set_remote_busy(struct sock *sk, struct sk_buff *skb)
620 if (!llc->remote_busy_flag) { 620 if (!llc->remote_busy_flag) {
621 llc->remote_busy_flag = 1; 621 llc->remote_busy_flag = 1;
622 mod_timer(&llc->busy_state_timer.timer, 622 mod_timer(&llc->busy_state_timer.timer,
623 jiffies + llc->busy_state_timer.expire * HZ); 623 jiffies + llc->busy_state_timer.expire);
624 } 624 }
625 return 0; 625 return 0;
626} 626}
@@ -853,7 +853,7 @@ int llc_conn_ac_start_p_timer(struct sock *sk, struct sk_buff *skb)
853 853
854 llc_conn_set_p_flag(sk, 1); 854 llc_conn_set_p_flag(sk, 1);
855 mod_timer(&llc->pf_cycle_timer.timer, 855 mod_timer(&llc->pf_cycle_timer.timer,
856 jiffies + llc->pf_cycle_timer.expire * HZ); 856 jiffies + llc->pf_cycle_timer.expire);
857 return 0; 857 return 0;
858} 858}
859 859
@@ -1131,7 +1131,7 @@ int llc_conn_ac_start_ack_timer(struct sock *sk, struct sk_buff *skb)
1131{ 1131{
1132 struct llc_sock *llc = llc_sk(sk); 1132 struct llc_sock *llc = llc_sk(sk);
1133 1133
1134 mod_timer(&llc->ack_timer.timer, jiffies + llc->ack_timer.expire * HZ); 1134 mod_timer(&llc->ack_timer.timer, jiffies + llc->ack_timer.expire);
1135 return 0; 1135 return 0;
1136} 1136}
1137 1137
@@ -1140,7 +1140,7 @@ int llc_conn_ac_start_rej_timer(struct sock *sk, struct sk_buff *skb)
1140 struct llc_sock *llc = llc_sk(sk); 1140 struct llc_sock *llc = llc_sk(sk);
1141 1141
1142 mod_timer(&llc->rej_sent_timer.timer, 1142 mod_timer(&llc->rej_sent_timer.timer,
1143 jiffies + llc->rej_sent_timer.expire * HZ); 1143 jiffies + llc->rej_sent_timer.expire);
1144 return 0; 1144 return 0;
1145} 1145}
1146 1146
@@ -1151,7 +1151,7 @@ int llc_conn_ac_start_ack_tmr_if_not_running(struct sock *sk,
1151 1151
1152 if (!timer_pending(&llc->ack_timer.timer)) 1152 if (!timer_pending(&llc->ack_timer.timer))
1153 mod_timer(&llc->ack_timer.timer, 1153 mod_timer(&llc->ack_timer.timer,
1154 jiffies + llc->ack_timer.expire * HZ); 1154 jiffies + llc->ack_timer.expire);
1155 return 0; 1155 return 0;
1156} 1156}
1157 1157
@@ -1199,7 +1199,7 @@ int llc_conn_ac_upd_nr_received(struct sock *sk, struct sk_buff *skb)
1199 } 1199 }
1200 if (unacked) 1200 if (unacked)
1201 mod_timer(&llc->ack_timer.timer, 1201 mod_timer(&llc->ack_timer.timer,
1202 jiffies + llc->ack_timer.expire * HZ); 1202 jiffies + llc->ack_timer.expire);
1203 } else if (llc->failed_data_req) { 1203 } else if (llc->failed_data_req) {
1204 u8 f_bit; 1204 u8 f_bit;
1205 1205
diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c
index ce7b893ed1ab..d3783f8ee481 100644
--- a/net/llc/llc_conn.c
+++ b/net/llc/llc_conn.c
@@ -40,6 +40,11 @@ static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
40/* Offset table on connection states transition diagram */ 40/* Offset table on connection states transition diagram */
41static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV]; 41static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV];
42 42
43int sysctl_llc2_ack_timeout = LLC2_ACK_TIME * HZ;
44int sysctl_llc2_p_timeout = LLC2_P_TIME * HZ;
45int sysctl_llc2_rej_timeout = LLC2_REJ_TIME * HZ;
46int sysctl_llc2_busy_timeout = LLC2_BUSY_TIME * HZ;
47
43/** 48/**
44 * llc_conn_state_process - sends event to connection state machine 49 * llc_conn_state_process - sends event to connection state machine
45 * @sk: connection 50 * @sk: connection
@@ -799,22 +804,22 @@ static void llc_sk_init(struct sock* sk)
799 llc->dec_step = llc->connect_step = 1; 804 llc->dec_step = llc->connect_step = 1;
800 805
801 init_timer(&llc->ack_timer.timer); 806 init_timer(&llc->ack_timer.timer);
802 llc->ack_timer.expire = LLC_ACK_TIME; 807 llc->ack_timer.expire = sysctl_llc2_ack_timeout;
803 llc->ack_timer.timer.data = (unsigned long)sk; 808 llc->ack_timer.timer.data = (unsigned long)sk;
804 llc->ack_timer.timer.function = llc_conn_ack_tmr_cb; 809 llc->ack_timer.timer.function = llc_conn_ack_tmr_cb;
805 810
806 init_timer(&llc->pf_cycle_timer.timer); 811 init_timer(&llc->pf_cycle_timer.timer);
807 llc->pf_cycle_timer.expire = LLC_P_TIME; 812 llc->pf_cycle_timer.expire = sysctl_llc2_p_timeout;
808 llc->pf_cycle_timer.timer.data = (unsigned long)sk; 813 llc->pf_cycle_timer.timer.data = (unsigned long)sk;
809 llc->pf_cycle_timer.timer.function = llc_conn_pf_cycle_tmr_cb; 814 llc->pf_cycle_timer.timer.function = llc_conn_pf_cycle_tmr_cb;
810 815
811 init_timer(&llc->rej_sent_timer.timer); 816 init_timer(&llc->rej_sent_timer.timer);
812 llc->rej_sent_timer.expire = LLC_REJ_TIME; 817 llc->rej_sent_timer.expire = sysctl_llc2_rej_timeout;
813 llc->rej_sent_timer.timer.data = (unsigned long)sk; 818 llc->rej_sent_timer.timer.data = (unsigned long)sk;
814 llc->rej_sent_timer.timer.function = llc_conn_rej_tmr_cb; 819 llc->rej_sent_timer.timer.function = llc_conn_rej_tmr_cb;
815 820
816 init_timer(&llc->busy_state_timer.timer); 821 init_timer(&llc->busy_state_timer.timer);
817 llc->busy_state_timer.expire = LLC_BUSY_TIME; 822 llc->busy_state_timer.expire = sysctl_llc2_busy_timeout;
818 llc->busy_state_timer.timer.data = (unsigned long)sk; 823 llc->busy_state_timer.timer.data = (unsigned long)sk;
819 llc->busy_state_timer.timer.function = llc_conn_busy_tmr_cb; 824 llc->busy_state_timer.timer.function = llc_conn_busy_tmr_cb;
820 825
diff --git a/net/llc/llc_station.c b/net/llc/llc_station.c
index 85a7ac276141..2d764b0382ce 100644
--- a/net/llc/llc_station.c
+++ b/net/llc/llc_station.c
@@ -50,6 +50,10 @@ struct llc_station {
50 struct sk_buff_head mac_pdu_q; 50 struct sk_buff_head mac_pdu_q;
51}; 51};
52 52
53#define LLC_STATION_ACK_TIME (3 * HZ)
54
55int sysctl_llc_station_ack_timeout = LLC_STATION_ACK_TIME;
56
53/* Types of events (possible values in 'ev->type') */ 57/* Types of events (possible values in 'ev->type') */
54#define LLC_STATION_EV_TYPE_SIMPLE 1 58#define LLC_STATION_EV_TYPE_SIMPLE 1
55#define LLC_STATION_EV_TYPE_CONDITION 2 59#define LLC_STATION_EV_TYPE_CONDITION 2
@@ -218,7 +222,8 @@ static void llc_station_send_pdu(struct sk_buff *skb)
218 222
219static int llc_station_ac_start_ack_timer(struct sk_buff *skb) 223static int llc_station_ac_start_ack_timer(struct sk_buff *skb)
220{ 224{
221 mod_timer(&llc_main_station.ack_timer, jiffies + LLC_ACK_TIME * HZ); 225 mod_timer(&llc_main_station.ack_timer,
226 jiffies + sysctl_llc_station_ack_timeout);
222 return 0; 227 return 0;
223} 228}
224 229
@@ -687,7 +692,8 @@ int __init llc_station_init(void)
687 init_timer(&llc_main_station.ack_timer); 692 init_timer(&llc_main_station.ack_timer);
688 llc_main_station.ack_timer.data = (unsigned long)&llc_main_station; 693 llc_main_station.ack_timer.data = (unsigned long)&llc_main_station;
689 llc_main_station.ack_timer.function = llc_station_ack_tmr_cb; 694 llc_main_station.ack_timer.function = llc_station_ack_tmr_cb;
690 695 llc_main_station.ack_timer.expires = jiffies +
696 sysctl_llc_station_ack_timeout;
691 skb = alloc_skb(0, GFP_ATOMIC); 697 skb = alloc_skb(0, GFP_ATOMIC);
692 if (!skb) 698 if (!skb)
693 goto out; 699 goto out;
@@ -695,7 +701,6 @@ int __init llc_station_init(void)
695 llc_set_station_handler(llc_station_rcv); 701 llc_set_station_handler(llc_station_rcv);
696 ev = llc_station_ev(skb); 702 ev = llc_station_ev(skb);
697 memset(ev, 0, sizeof(*ev)); 703 memset(ev, 0, sizeof(*ev));
698 llc_main_station.ack_timer.expires = jiffies + 3 * HZ;
699 llc_main_station.maximum_retry = 1; 704 llc_main_station.maximum_retry = 1;
700 llc_main_station.state = LLC_STATION_STATE_DOWN; 705 llc_main_station.state = LLC_STATION_STATE_DOWN;
701 ev->type = LLC_STATION_EV_TYPE_SIMPLE; 706 ev->type = LLC_STATION_EV_TYPE_SIMPLE;
diff --git a/net/llc/sysctl_net_llc.c b/net/llc/sysctl_net_llc.c
new file mode 100644
index 000000000000..4d99d2f27a21
--- /dev/null
+++ b/net/llc/sysctl_net_llc.c
@@ -0,0 +1,136 @@
1/*
2 * sysctl_net_llc.c: sysctl interface to LLC net subsystem.
3 *
4 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
5 */
6
7#include <linux/config.h>
8#include <linux/mm.h>
9#include <linux/init.h>
10#include <linux/sysctl.h>
11
12#ifndef CONFIG_SYSCTL
13#error This file should not be compiled without CONFIG_SYSCTL defined
14#endif
15
16extern int sysctl_llc2_ack_timeout;
17extern int sysctl_llc2_busy_timeout;
18extern int sysctl_llc2_p_timeout;
19extern int sysctl_llc2_rej_timeout;
20extern int sysctl_llc_station_ack_timeout;
21
22static struct ctl_table llc2_timeout_table[] = {
23 {
24 .ctl_name = NET_LLC2_ACK_TIMEOUT,
25 .procname = "ack",
26 .data = &sysctl_llc2_ack_timeout,
27 .maxlen = sizeof(long),
28 .mode = 0644,
29 .proc_handler = &proc_dointvec_jiffies,
30 .strategy = &sysctl_jiffies,
31 },
32 {
33 .ctl_name = NET_LLC2_BUSY_TIMEOUT,
34 .procname = "busy",
35 .data = &sysctl_llc2_busy_timeout,
36 .maxlen = sizeof(long),
37 .mode = 0644,
38 .proc_handler = &proc_dointvec_jiffies,
39 .strategy = &sysctl_jiffies,
40 },
41 {
42 .ctl_name = NET_LLC2_P_TIMEOUT,
43 .procname = "p",
44 .data = &sysctl_llc2_p_timeout,
45 .maxlen = sizeof(long),
46 .mode = 0644,
47 .proc_handler = &proc_dointvec_jiffies,
48 .strategy = &sysctl_jiffies,
49 },
50 {
51 .ctl_name = NET_LLC2_REJ_TIMEOUT,
52 .procname = "rej",
53 .data = &sysctl_llc2_rej_timeout,
54 .maxlen = sizeof(long),
55 .mode = 0644,
56 .proc_handler = &proc_dointvec_jiffies,
57 .strategy = &sysctl_jiffies,
58 },
59 { 0 },
60};
61
62static struct ctl_table llc_station_table[] = {
63 {
64 .ctl_name = NET_LLC_STATION_ACK_TIMEOUT,
65 .procname = "ack_timeout",
66 .data = &sysctl_llc_station_ack_timeout,
67 .maxlen = sizeof(long),
68 .mode = 0644,
69 .proc_handler = &proc_dointvec_jiffies,
70 .strategy = &sysctl_jiffies,
71 },
72 { 0 },
73};
74
75static struct ctl_table llc2_dir_timeout_table[] = {
76 {
77 .ctl_name = NET_LLC2,
78 .procname = "timeout",
79 .mode = 0555,
80 .child = llc2_timeout_table,
81 },
82 { 0 },
83};
84
85static struct ctl_table llc_table[] = {
86 {
87 .ctl_name = NET_LLC2,
88 .procname = "llc2",
89 .mode = 0555,
90 .child = llc2_dir_timeout_table,
91 },
92 {
93 .ctl_name = NET_LLC_STATION,
94 .procname = "station",
95 .mode = 0555,
96 .child = llc_station_table,
97 },
98 { 0 },
99};
100
101static struct ctl_table llc_dir_table[] = {
102 {
103 .ctl_name = NET_LLC,
104 .procname = "llc",
105 .mode = 0555,
106 .child = llc_table,
107 },
108 { 0 },
109};
110
111static struct ctl_table llc_root_table[] = {
112 {
113 .ctl_name = CTL_NET,
114 .procname = "net",
115 .mode = 0555,
116 .child = llc_dir_table,
117 },
118 { 0 },
119};
120
121static struct ctl_table_header *llc_table_header;
122
123int __init llc_sysctl_init(void)
124{
125 llc_table_header = register_sysctl_table(llc_root_table, 1);
126
127 return llc_table_header ? 0 : -ENOMEM;
128}
129
130void llc_sysctl_exit(void)
131{
132 if (llc_table_header) {
133 unregister_sysctl_table(llc_table_header);
134 llc_table_header = NULL;
135 }
136}