Skip to content

Commit 590232a

Browse files
author
Arnaldo Carvalho de Melo
committed
[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>
1 parent 54fb7f2 commit 590232a

9 files changed

Lines changed: 232 additions & 31 deletions

File tree

‎include/linux/sysctl.h‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ enum
202202
NET_TR=14,
203203
NET_DECNET=15,
204204
NET_ECONET=16,
205-
NET_SCTP=17,
205+
NET_SCTP=17,
206+
NET_LLC=18,
206207
};
207208

208209
/* /proc/sys/kernel/random */
@@ -522,6 +523,29 @@ enum {
522523
NET_IPX_FORWARDING=2
523524
};
524525

526+
/* /proc/sys/net/llc */
527+
enum {
528+
NET_LLC2=1,
529+
NET_LLC_STATION=2,
530+
};
531+
532+
/* /proc/sys/net/llc/llc2 */
533+
enum {
534+
NET_LLC2_TIMEOUT=1,
535+
};
536+
537+
/* /proc/sys/net/llc/station */
538+
enum {
539+
NET_LLC_STATION_ACK_TIMEOUT=1,
540+
};
541+
542+
/* /proc/sys/net/llc/llc2/timeout */
543+
enum {
544+
NET_LLC2_ACK_TIMEOUT=1,
545+
NET_LLC2_P_TIMEOUT=2,
546+
NET_LLC2_REJ_TIMEOUT=3,
547+
NET_LLC2_BUSY_TIMEOUT=4,
548+
};
525549

526550
/* /proc/sys/net/appletalk */
527551
enum {

‎include/net/llc.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,11 @@ extern void llc_proc_exit(void);
9898
#define llc_proc_init() (0)
9999
#define llc_proc_exit() do { } while(0)
100100
#endif /* CONFIG_PROC_FS */
101+
#ifdef CONFIG_SYSCTL
102+
extern int llc_sysctl_init(void);
103+
extern void llc_sysctl_exit(void);
104+
#else
105+
#define llc_sysctl_init() (0)
106+
#define llc_sysctl_exit() do { } while(0)
107+
#endif /* CONFIG_SYSCTL */
101108
#endif /* LLC_H */

‎include/net/llc_conn.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
#define LLC_EVENT 1
2020
#define LLC_PACKET 2
2121

22-
#define LLC_P_TIME 2
23-
#define LLC_ACK_TIME 1
24-
#define LLC_REJ_TIME 3
25-
#define LLC_BUSY_TIME 3
22+
#define LLC2_P_TIME 2
23+
#define LLC2_ACK_TIME 1
24+
#define LLC2_REJ_TIME 3
25+
#define LLC2_BUSY_TIME 3
2626

2727
struct llc_timer {
2828
struct timer_list timer;
29-
u16 expire; /* timer expire time */
29+
unsigned long expire; /* timer expire time */
3030
};
3131

3232
struct llc_sock {

‎net/llc/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 \
2222
llc_sap.o llc_s_ac.o llc_s_ev.o llc_s_st.o af_llc.o llc_station.o
2323

2424
llc2-$(CONFIG_PROC_FS) += llc_proc.o
25+
llc2-$(CONFIG_SYSCTL) += sysctl_net_llc.o

‎net/llc/af_llc.c‎

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -877,22 +877,22 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname,
877877
case LLC_OPT_ACK_TMR_EXP:
878878
if (opt > LLC_OPT_MAX_ACK_TMR_EXP)
879879
goto out;
880-
llc->ack_timer.expire = opt;
880+
llc->ack_timer.expire = opt * HZ;
881881
break;
882882
case LLC_OPT_P_TMR_EXP:
883883
if (opt > LLC_OPT_MAX_P_TMR_EXP)
884884
goto out;
885-
llc->pf_cycle_timer.expire = opt;
885+
llc->pf_cycle_timer.expire = opt * HZ;
886886
break;
887887
case LLC_OPT_REJ_TMR_EXP:
888888
if (opt > LLC_OPT_MAX_REJ_TMR_EXP)
889889
goto out;
890-
llc->rej_sent_timer.expire = opt;
890+
llc->rej_sent_timer.expire = opt * HZ;
891891
break;
892892
case LLC_OPT_BUSY_TMR_EXP:
893893
if (opt > LLC_OPT_MAX_BUSY_TMR_EXP)
894894
goto out;
895-
llc->busy_state_timer.expire = opt;
895+
llc->busy_state_timer.expire = opt * HZ;
896896
break;
897897
case LLC_OPT_TX_WIN:
898898
if (opt > LLC_OPT_MAX_WIN)
@@ -942,17 +942,17 @@ static int llc_ui_getsockopt(struct socket *sock, int level, int optname,
942942
goto out;
943943
switch (optname) {
944944
case LLC_OPT_RETRY:
945-
val = llc->n2; break;
945+
val = llc->n2; break;
946946
case LLC_OPT_SIZE:
947-
val = llc->n1; break;
947+
val = llc->n1; break;
948948
case LLC_OPT_ACK_TMR_EXP:
949-
val = llc->ack_timer.expire; break;
949+
val = llc->ack_timer.expire / HZ; break;
950950
case LLC_OPT_P_TMR_EXP:
951-
val = llc->pf_cycle_timer.expire; break;
951+
val = llc->pf_cycle_timer.expire / HZ; break;
952952
case LLC_OPT_REJ_TMR_EXP:
953-
val = llc->rej_sent_timer.expire; break;
953+
val = llc->rej_sent_timer.expire / HZ; break;
954954
case LLC_OPT_BUSY_TMR_EXP:
955-
val = llc->busy_state_timer.expire; break;
955+
val = llc->busy_state_timer.expire / HZ; break;
956956
case LLC_OPT_TX_WIN:
957957
val = llc->k; break;
958958
case LLC_OPT_RX_WIN:
@@ -999,6 +999,13 @@ static struct proto_ops llc_ui_ops = {
999999
extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb);
10001000
extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb);
10011001

1002+
static char llc_proc_err_msg[] __initdata =
1003+
KERN_CRIT "LLC: Unable to register the proc_fs entries\n";
1004+
static char llc_sysctl_err_msg[] __initdata =
1005+
KERN_CRIT "LLC: Unable to register the sysctl entries\n";
1006+
static char llc_sock_err_msg[] __initdata =
1007+
KERN_CRIT "LLC: Unable to register the network family\n";
1008+
10021009
static int __init llc2_init(void)
10031010
{
10041011
int rc = proto_register(&llc_proto, 0);
@@ -1010,13 +1017,28 @@ static int __init llc2_init(void)
10101017
llc_station_init();
10111018
llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
10121019
rc = llc_proc_init();
1013-
if (rc != 0)
1020+
if (rc != 0) {
1021+
printk(llc_proc_err_msg);
10141022
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+
}
10161034
llc_add_pack(LLC_DEST_SAP, llc_sap_handler);
10171035
llc_add_pack(LLC_DEST_CONN, llc_conn_handler);
10181036
out:
10191037
return rc;
1038+
out_sysctl:
1039+
llc_sysctl_exit();
1040+
out_proc:
1041+
llc_proc_exit();
10201042
out_unregister_llc_proto:
10211043
proto_unregister(&llc_proto);
10221044
goto out;
@@ -1029,6 +1051,7 @@ static void __exit llc2_exit(void)
10291051
llc_remove_pack(LLC_DEST_CONN);
10301052
sock_unregister(PF_LLC);
10311053
llc_proc_exit();
1054+
llc_sysctl_exit();
10321055
proto_unregister(&llc_proto);
10331056
}
10341057

‎net/llc/llc_c_ac.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ int llc_conn_ac_set_remote_busy(struct sock *sk, struct sk_buff *skb)
620620
if (!llc->remote_busy_flag) {
621621
llc->remote_busy_flag = 1;
622622
mod_timer(&llc->busy_state_timer.timer,
623-
jiffies + llc->busy_state_timer.expire * HZ);
623+
jiffies + llc->busy_state_timer.expire);
624624
}
625625
return 0;
626626
}
@@ -853,7 +853,7 @@ int llc_conn_ac_start_p_timer(struct sock *sk, struct sk_buff *skb)
853853

854854
llc_conn_set_p_flag(sk, 1);
855855
mod_timer(&llc->pf_cycle_timer.timer,
856-
jiffies + llc->pf_cycle_timer.expire * HZ);
856+
jiffies + llc->pf_cycle_timer.expire);
857857
return 0;
858858
}
859859

@@ -1131,7 +1131,7 @@ int llc_conn_ac_start_ack_timer(struct sock *sk, struct sk_buff *skb)
11311131
{
11321132
struct llc_sock *llc = llc_sk(sk);
11331133

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);
11351135
return 0;
11361136
}
11371137

@@ -1140,7 +1140,7 @@ int llc_conn_ac_start_rej_timer(struct sock *sk, struct sk_buff *skb)
11401140
struct llc_sock *llc = llc_sk(sk);
11411141

11421142
mod_timer(&llc->rej_sent_timer.timer,
1143-
jiffies + llc->rej_sent_timer.expire * HZ);
1143+
jiffies + llc->rej_sent_timer.expire);
11441144
return 0;
11451145
}
11461146

@@ -1151,7 +1151,7 @@ int llc_conn_ac_start_ack_tmr_if_not_running(struct sock *sk,
11511151

11521152
if (!timer_pending(&llc->ack_timer.timer))
11531153
mod_timer(&llc->ack_timer.timer,
1154-
jiffies + llc->ack_timer.expire * HZ);
1154+
jiffies + llc->ack_timer.expire);
11551155
return 0;
11561156
}
11571157

@@ -1199,7 +1199,7 @@ int llc_conn_ac_upd_nr_received(struct sock *sk, struct sk_buff *skb)
11991199
}
12001200
if (unacked)
12011201
mod_timer(&llc->ack_timer.timer,
1202-
jiffies + llc->ack_timer.expire * HZ);
1202+
jiffies + llc->ack_timer.expire);
12031203
} else if (llc->failed_data_req) {
12041204
u8 f_bit;
12051205

‎net/llc/llc_conn.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
4040
/* Offset table on connection states transition diagram */
4141
static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV];
4242

43+
int sysctl_llc2_ack_timeout = LLC2_ACK_TIME * HZ;
44+
int sysctl_llc2_p_timeout = LLC2_P_TIME * HZ;
45+
int sysctl_llc2_rej_timeout = LLC2_REJ_TIME * HZ;
46+
int sysctl_llc2_busy_timeout = LLC2_BUSY_TIME * HZ;
47+
4348
/**
4449
* llc_conn_state_process - sends event to connection state machine
4550
* @sk: connection
@@ -799,22 +804,22 @@ static void llc_sk_init(struct sock* sk)
799804
llc->dec_step = llc->connect_step = 1;
800805

801806
init_timer(&llc->ack_timer.timer);
802-
llc->ack_timer.expire = LLC_ACK_TIME;
807+
llc->ack_timer.expire = sysctl_llc2_ack_timeout;
803808
llc->ack_timer.timer.data = (unsigned long)sk;
804809
llc->ack_timer.timer.function = llc_conn_ack_tmr_cb;
805810

806811
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;
808813
llc->pf_cycle_timer.timer.data = (unsigned long)sk;
809814
llc->pf_cycle_timer.timer.function = llc_conn_pf_cycle_tmr_cb;
810815

811816
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;
813818
llc->rej_sent_timer.timer.data = (unsigned long)sk;
814819
llc->rej_sent_timer.timer.function = llc_conn_rej_tmr_cb;
815820

816821
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;
818823
llc->busy_state_timer.timer.data = (unsigned long)sk;
819824
llc->busy_state_timer.timer.function = llc_conn_busy_tmr_cb;
820825

‎net/llc/llc_station.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ struct llc_station {
5050
struct sk_buff_head mac_pdu_q;
5151
};
5252

53+
#define LLC_STATION_ACK_TIME (3 * HZ)
54+
55+
int sysctl_llc_station_ack_timeout = LLC_STATION_ACK_TIME;
56+
5357
/* Types of events (possible values in 'ev->type') */
5458
#define LLC_STATION_EV_TYPE_SIMPLE 1
5559
#define LLC_STATION_EV_TYPE_CONDITION 2
@@ -218,7 +222,8 @@ static void llc_station_send_pdu(struct sk_buff *skb)
218222

219223
static int llc_station_ac_start_ack_timer(struct sk_buff *skb)
220224
{
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);
222227
return 0;
223228
}
224229

@@ -687,15 +692,15 @@ int __init llc_station_init(void)
687692
init_timer(&llc_main_station.ack_timer);
688693
llc_main_station.ack_timer.data = (unsigned long)&llc_main_station;
689694
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;
691697
skb = alloc_skb(0, GFP_ATOMIC);
692698
if (!skb)
693699
goto out;
694700
rc = 0;
695701
llc_set_station_handler(llc_station_rcv);
696702
ev = llc_station_ev(skb);
697703
memset(ev, 0, sizeof(*ev));
698-
llc_main_station.ack_timer.expires = jiffies + 3 * HZ;
699704
llc_main_station.maximum_retry = 1;
700705
llc_main_station.state = LLC_STATION_STATE_DOWN;
701706
ev->type = LLC_STATION_EV_TYPE_SIMPLE;

0 commit comments

Comments
 (0)