Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

+232 -31
+25 -1
include/linux/sysctl.h
··· 202 202 NET_TR=14, 203 203 NET_DECNET=15, 204 204 NET_ECONET=16, 205 - NET_SCTP=17, 205 + NET_SCTP=17, 206 + NET_LLC=18, 206 207 }; 207 208 208 209 /* /proc/sys/kernel/random */ ··· 523 522 NET_IPX_FORWARDING=2 524 523 }; 525 524 525 + /* /proc/sys/net/llc */ 526 + enum { 527 + NET_LLC2=1, 528 + NET_LLC_STATION=2, 529 + }; 530 + 531 + /* /proc/sys/net/llc/llc2 */ 532 + enum { 533 + NET_LLC2_TIMEOUT=1, 534 + }; 535 + 536 + /* /proc/sys/net/llc/station */ 537 + enum { 538 + NET_LLC_STATION_ACK_TIMEOUT=1, 539 + }; 540 + 541 + /* /proc/sys/net/llc/llc2/timeout */ 542 + enum { 543 + NET_LLC2_ACK_TIMEOUT=1, 544 + NET_LLC2_P_TIMEOUT=2, 545 + NET_LLC2_REJ_TIMEOUT=3, 546 + NET_LLC2_BUSY_TIMEOUT=4, 547 + }; 526 548 527 549 /* /proc/sys/net/appletalk */ 528 550 enum {
+7
include/net/llc.h
··· 98 98 #define llc_proc_init() (0) 99 99 #define llc_proc_exit() do { } while(0) 100 100 #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 */ 101 108 #endif /* LLC_H */
+5 -5
include/net/llc_conn.h
··· 19 19 #define LLC_EVENT 1 20 20 #define LLC_PACKET 2 21 21 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 26 26 27 27 struct llc_timer { 28 28 struct timer_list timer; 29 - u16 expire; /* timer expire time */ 29 + unsigned long expire; /* timer expire time */ 30 30 }; 31 31 32 32 struct llc_sock {
+1
net/llc/Makefile
··· 22 22 llc_sap.o llc_s_ac.o llc_s_ev.o llc_s_st.o af_llc.o llc_station.o 23 23 24 24 llc2-$(CONFIG_PROC_FS) += llc_proc.o 25 + llc2-$(CONFIG_SYSCTL) += sysctl_net_llc.o
+35 -12
net/llc/af_llc.c
··· 877 877 case LLC_OPT_ACK_TMR_EXP: 878 878 if (opt > LLC_OPT_MAX_ACK_TMR_EXP) 879 879 goto out; 880 - llc->ack_timer.expire = opt; 880 + llc->ack_timer.expire = opt * HZ; 881 881 break; 882 882 case LLC_OPT_P_TMR_EXP: 883 883 if (opt > LLC_OPT_MAX_P_TMR_EXP) 884 884 goto out; 885 - llc->pf_cycle_timer.expire = opt; 885 + llc->pf_cycle_timer.expire = opt * HZ; 886 886 break; 887 887 case LLC_OPT_REJ_TMR_EXP: 888 888 if (opt > LLC_OPT_MAX_REJ_TMR_EXP) 889 889 goto out; 890 - llc->rej_sent_timer.expire = opt; 890 + llc->rej_sent_timer.expire = opt * HZ; 891 891 break; 892 892 case LLC_OPT_BUSY_TMR_EXP: 893 893 if (opt > LLC_OPT_MAX_BUSY_TMR_EXP) 894 894 goto out; 895 - llc->busy_state_timer.expire = opt; 895 + llc->busy_state_timer.expire = opt * HZ; 896 896 break; 897 897 case LLC_OPT_TX_WIN: 898 898 if (opt > LLC_OPT_MAX_WIN) ··· 942 942 goto out; 943 943 switch (optname) { 944 944 case LLC_OPT_RETRY: 945 - val = llc->n2; break; 945 + val = llc->n2; break; 946 946 case LLC_OPT_SIZE: 947 - val = llc->n1; break; 947 + val = llc->n1; break; 948 948 case LLC_OPT_ACK_TMR_EXP: 949 - val = llc->ack_timer.expire; break; 949 + val = llc->ack_timer.expire / HZ; break; 950 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 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 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 956 case LLC_OPT_TX_WIN: 957 957 val = llc->k; break; 958 958 case LLC_OPT_RX_WIN: ··· 999 999 extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb); 1000 1000 extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb); 1001 1001 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 + 1002 1009 static int __init llc2_init(void) 1003 1010 { 1004 1011 int rc = proto_register(&llc_proto, 0); ··· 1017 1010 llc_station_init(); 1018 1011 llc_ui_sap_last_autoport = LLC_SAP_DYN_START; 1019 1012 rc = llc_proc_init(); 1020 - if (rc != 0) 1013 + if (rc != 0) { 1014 + printk(llc_proc_err_msg); 1021 1015 goto out_unregister_llc_proto; 1022 - sock_register(&llc_ui_family_ops); 1016 + } 1017 + rc = llc_sysctl_init(); 1018 + if (rc) { 1019 + printk(llc_sysctl_err_msg); 1020 + goto out_proc; 1021 + } 1022 + rc = sock_register(&llc_ui_family_ops); 1023 + if (rc) { 1024 + printk(llc_sock_err_msg); 1025 + goto out_sysctl; 1026 + } 1023 1027 llc_add_pack(LLC_DEST_SAP, llc_sap_handler); 1024 1028 llc_add_pack(LLC_DEST_CONN, llc_conn_handler); 1025 1029 out: 1026 1030 return rc; 1031 + out_sysctl: 1032 + llc_sysctl_exit(); 1033 + out_proc: 1034 + llc_proc_exit(); 1027 1035 out_unregister_llc_proto: 1028 1036 proto_unregister(&llc_proto); 1029 1037 goto out; ··· 1051 1029 llc_remove_pack(LLC_DEST_CONN); 1052 1030 sock_unregister(PF_LLC); 1053 1031 llc_proc_exit(); 1032 + llc_sysctl_exit(); 1054 1033 proto_unregister(&llc_proto); 1055 1034 } 1056 1035
+6 -6
net/llc/llc_c_ac.c
··· 620 620 if (!llc->remote_busy_flag) { 621 621 llc->remote_busy_flag = 1; 622 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 625 return 0; 626 626 } ··· 853 853 854 854 llc_conn_set_p_flag(sk, 1); 855 855 mod_timer(&llc->pf_cycle_timer.timer, 856 - jiffies + llc->pf_cycle_timer.expire * HZ); 856 + jiffies + llc->pf_cycle_timer.expire); 857 857 return 0; 858 858 } 859 859 ··· 1131 1131 { 1132 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 1135 return 0; 1136 1136 } 1137 1137 ··· 1140 1140 struct llc_sock *llc = llc_sk(sk); 1141 1141 1142 1142 mod_timer(&llc->rej_sent_timer.timer, 1143 - jiffies + llc->rej_sent_timer.expire * HZ); 1143 + jiffies + llc->rej_sent_timer.expire); 1144 1144 return 0; 1145 1145 } 1146 1146 ··· 1151 1151 1152 1152 if (!timer_pending(&llc->ack_timer.timer)) 1153 1153 mod_timer(&llc->ack_timer.timer, 1154 - jiffies + llc->ack_timer.expire * HZ); 1154 + jiffies + llc->ack_timer.expire); 1155 1155 return 0; 1156 1156 } 1157 1157 ··· 1199 1199 } 1200 1200 if (unacked) 1201 1201 mod_timer(&llc->ack_timer.timer, 1202 - jiffies + llc->ack_timer.expire * HZ); 1202 + jiffies + llc->ack_timer.expire); 1203 1203 } else if (llc->failed_data_req) { 1204 1204 u8 f_bit; 1205 1205
+9 -4
net/llc/llc_conn.c
··· 40 40 /* Offset table on connection states transition diagram */ 41 41 static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV]; 42 42 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 + 43 48 /** 44 49 * llc_conn_state_process - sends event to connection state machine 45 50 * @sk: connection ··· 804 799 llc->dec_step = llc->connect_step = 1; 805 800 806 801 init_timer(&llc->ack_timer.timer); 807 - llc->ack_timer.expire = LLC_ACK_TIME; 802 + llc->ack_timer.expire = sysctl_llc2_ack_timeout; 808 803 llc->ack_timer.timer.data = (unsigned long)sk; 809 804 llc->ack_timer.timer.function = llc_conn_ack_tmr_cb; 810 805 811 806 init_timer(&llc->pf_cycle_timer.timer); 812 - llc->pf_cycle_timer.expire = LLC_P_TIME; 807 + llc->pf_cycle_timer.expire = sysctl_llc2_p_timeout; 813 808 llc->pf_cycle_timer.timer.data = (unsigned long)sk; 814 809 llc->pf_cycle_timer.timer.function = llc_conn_pf_cycle_tmr_cb; 815 810 816 811 init_timer(&llc->rej_sent_timer.timer); 817 - llc->rej_sent_timer.expire = LLC_REJ_TIME; 812 + llc->rej_sent_timer.expire = sysctl_llc2_rej_timeout; 818 813 llc->rej_sent_timer.timer.data = (unsigned long)sk; 819 814 llc->rej_sent_timer.timer.function = llc_conn_rej_tmr_cb; 820 815 821 816 init_timer(&llc->busy_state_timer.timer); 822 - llc->busy_state_timer.expire = LLC_BUSY_TIME; 817 + llc->busy_state_timer.expire = sysctl_llc2_busy_timeout; 823 818 llc->busy_state_timer.timer.data = (unsigned long)sk; 824 819 llc->busy_state_timer.timer.function = llc_conn_busy_tmr_cb; 825 820
+8 -3
net/llc/llc_station.c
··· 50 50 struct sk_buff_head mac_pdu_q; 51 51 }; 52 52 53 + #define LLC_STATION_ACK_TIME (3 * HZ) 54 + 55 + int sysctl_llc_station_ack_timeout = LLC_STATION_ACK_TIME; 56 + 53 57 /* Types of events (possible values in 'ev->type') */ 54 58 #define LLC_STATION_EV_TYPE_SIMPLE 1 55 59 #define LLC_STATION_EV_TYPE_CONDITION 2 ··· 222 218 223 219 static int llc_station_ac_start_ack_timer(struct sk_buff *skb) 224 220 { 225 - mod_timer(&llc_main_station.ack_timer, jiffies + LLC_ACK_TIME * HZ); 221 + mod_timer(&llc_main_station.ack_timer, 222 + jiffies + sysctl_llc_station_ack_timeout); 226 223 return 0; 227 224 } 228 225 ··· 692 687 init_timer(&llc_main_station.ack_timer); 693 688 llc_main_station.ack_timer.data = (unsigned long)&llc_main_station; 694 689 llc_main_station.ack_timer.function = llc_station_ack_tmr_cb; 695 - 690 + llc_main_station.ack_timer.expires = jiffies + 691 + sysctl_llc_station_ack_timeout; 696 692 skb = alloc_skb(0, GFP_ATOMIC); 697 693 if (!skb) 698 694 goto out; ··· 701 695 llc_set_station_handler(llc_station_rcv); 702 696 ev = llc_station_ev(skb); 703 697 memset(ev, 0, sizeof(*ev)); 704 - llc_main_station.ack_timer.expires = jiffies + 3 * HZ; 705 698 llc_main_station.maximum_retry = 1; 706 699 llc_main_station.state = LLC_STATION_STATE_DOWN; 707 700 ev->type = LLC_STATION_EV_TYPE_SIMPLE;
+136
net/llc/sysctl_net_llc.c
··· 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 + 16 + extern int sysctl_llc2_ack_timeout; 17 + extern int sysctl_llc2_busy_timeout; 18 + extern int sysctl_llc2_p_timeout; 19 + extern int sysctl_llc2_rej_timeout; 20 + extern int sysctl_llc_station_ack_timeout; 21 + 22 + static 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 + 62 + static 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 + 75 + static 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 + 85 + static 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 + 101 + static 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 + 111 + static 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 + 121 + static struct ctl_table_header *llc_table_header; 122 + 123 + int __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 + 130 + void llc_sysctl_exit(void) 131 + { 132 + if (llc_table_header) { 133 + unregister_sysctl_table(llc_table_header); 134 + llc_table_header = NULL; 135 + } 136 + }