aboutsummaryrefslogtreecommitdiffstats
path: root/net/llc
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /net/llc
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'net/llc')
-rw-r--r--net/llc/af_llc.c33
-rw-r--r--net/llc/llc_conn.c2
-rw-r--r--net/llc/llc_input.c22
-rw-r--r--net/llc/llc_output.c4
-rw-r--r--net/llc/llc_proc.c3
-rw-r--r--net/llc/llc_sap.c4
-rw-r--r--net/llc/llc_station.c623
-rw-r--r--net/llc/sysctl_net_llc.c59
8 files changed, 680 insertions, 70 deletions
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 88709882c46..a18e6c3d36e 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -71,7 +71,8 @@ static inline u16 llc_ui_next_link_no(int sap)
71 */ 71 */
72static inline __be16 llc_proto_type(u16 arphrd) 72static inline __be16 llc_proto_type(u16 arphrd)
73{ 73{
74 return htons(ETH_P_802_2); 74 return arphrd == ARPHRD_IEEE802_TR ?
75 htons(ETH_P_TR_802_2) : htons(ETH_P_802_2);
75} 76}
76 77
77/** 78/**
@@ -160,7 +161,7 @@ static int llc_ui_create(struct net *net, struct socket *sock, int protocol,
160 struct sock *sk; 161 struct sock *sk;
161 int rc = -ESOCKTNOSUPPORT; 162 int rc = -ESOCKTNOSUPPORT;
162 163
163 if (!ns_capable(net->user_ns, CAP_NET_RAW)) 164 if (!capable(CAP_NET_RAW))
164 return -EPERM; 165 return -EPERM;
165 166
166 if (!net_eq(net, &init_net)) 167 if (!net_eq(net, &init_net))
@@ -517,7 +518,7 @@ static int llc_ui_listen(struct socket *sock, int backlog)
517 if (sock_flag(sk, SOCK_ZAPPED)) 518 if (sock_flag(sk, SOCK_ZAPPED))
518 goto out; 519 goto out;
519 rc = 0; 520 rc = 0;
520 if (!(unsigned int)backlog) /* BSDism */ 521 if (!(unsigned)backlog) /* BSDism */
521 backlog = 1; 522 backlog = 1;
522 sk->sk_max_ack_backlog = backlog; 523 sk->sk_max_ack_backlog = backlog;
523 if (sk->sk_state != TCP_LISTEN) { 524 if (sk->sk_state != TCP_LISTEN) {
@@ -712,7 +713,6 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
712 struct sk_buff *skb = NULL; 713 struct sk_buff *skb = NULL;
713 struct sock *sk = sock->sk; 714 struct sock *sk = sock->sk;
714 struct llc_sock *llc = llc_sk(sk); 715 struct llc_sock *llc = llc_sk(sk);
715 unsigned long cpu_flags;
716 size_t copied = 0; 716 size_t copied = 0;
717 u32 peek_seq = 0; 717 u32 peek_seq = 0;
718 u32 *seq; 718 u32 *seq;
@@ -805,9 +805,10 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
805 sk_wait_data(sk, &timeo); 805 sk_wait_data(sk, &timeo);
806 806
807 if ((flags & MSG_PEEK) && peek_seq != llc->copied_seq) { 807 if ((flags & MSG_PEEK) && peek_seq != llc->copied_seq) {
808 net_dbg_ratelimited("LLC(%s:%d): Application bug, race in MSG_PEEK\n", 808 if (net_ratelimit())
809 current->comm, 809 printk(KERN_DEBUG "LLC(%s:%d): Application "
810 task_pid_nr(current)); 810 "bug, race in MSG_PEEK.\n",
811 current->comm, task_pid_nr(current));
811 peek_seq = llc->copied_seq; 812 peek_seq = llc->copied_seq;
812 } 813 }
813 continue; 814 continue;
@@ -837,9 +838,7 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
837 goto copy_uaddr; 838 goto copy_uaddr;
838 839
839 if (!(flags & MSG_PEEK)) { 840 if (!(flags & MSG_PEEK)) {
840 spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags); 841 sk_eat_skb(sk, skb, 0);
841 sk_eat_skb(sk, skb, false);
842 spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags);
843 *seq = 0; 842 *seq = 0;
844 } 843 }
845 844
@@ -860,9 +859,7 @@ copy_uaddr:
860 llc_cmsg_rcv(msg, skb); 859 llc_cmsg_rcv(msg, skb);
861 860
862 if (!(flags & MSG_PEEK)) { 861 if (!(flags & MSG_PEEK)) {
863 spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags); 862 sk_eat_skb(sk, skb, 0);
864 sk_eat_skb(sk, skb, false);
865 spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags);
866 *seq = 0; 863 *seq = 0;
867 } 864 }
868 865
@@ -969,13 +966,14 @@ static int llc_ui_getname(struct socket *sock, struct sockaddr *uaddr,
969 struct sockaddr_llc sllc; 966 struct sockaddr_llc sllc;
970 struct sock *sk = sock->sk; 967 struct sock *sk = sock->sk;
971 struct llc_sock *llc = llc_sk(sk); 968 struct llc_sock *llc = llc_sk(sk);
972 int rc = -EBADF; 969 int rc = 0;
973 970
974 memset(&sllc, 0, sizeof(sllc)); 971 memset(&sllc, 0, sizeof(sllc));
975 lock_sock(sk); 972 lock_sock(sk);
976 if (sock_flag(sk, SOCK_ZAPPED)) 973 if (sock_flag(sk, SOCK_ZAPPED))
977 goto out; 974 goto out;
978 *uaddrlen = sizeof(sllc); 975 *uaddrlen = sizeof(sllc);
976 memset(uaddr, 0, *uaddrlen);
979 if (peer) { 977 if (peer) {
980 rc = -ENOTCONN; 978 rc = -ENOTCONN;
981 if (sk->sk_state != TCP_ESTABLISHED) 979 if (sk->sk_state != TCP_ESTABLISHED)
@@ -1023,7 +1021,7 @@ static int llc_ui_ioctl(struct socket *sock, unsigned int cmd,
1023 * @sock: Socket to set options on. 1021 * @sock: Socket to set options on.
1024 * @level: Socket level user is requesting operations on. 1022 * @level: Socket level user is requesting operations on.
1025 * @optname: Operation name. 1023 * @optname: Operation name.
1026 * @optval: User provided operation data. 1024 * @optval User provided operation data.
1027 * @optlen: Length of optval. 1025 * @optlen: Length of optval.
1028 * 1026 *
1029 * Set various connection specific parameters. 1027 * Set various connection specific parameters.
@@ -1205,7 +1203,7 @@ static int __init llc2_init(void)
1205 rc = llc_proc_init(); 1203 rc = llc_proc_init();
1206 if (rc != 0) { 1204 if (rc != 0) {
1207 printk(llc_proc_err_msg); 1205 printk(llc_proc_err_msg);
1208 goto out_station; 1206 goto out_unregister_llc_proto;
1209 } 1207 }
1210 rc = llc_sysctl_init(); 1208 rc = llc_sysctl_init();
1211 if (rc) { 1209 if (rc) {
@@ -1225,8 +1223,7 @@ out_sysctl:
1225 llc_sysctl_exit(); 1223 llc_sysctl_exit();
1226out_proc: 1224out_proc:
1227 llc_proc_exit(); 1225 llc_proc_exit();
1228out_station: 1226out_unregister_llc_proto:
1229 llc_station_exit();
1230 proto_unregister(&llc_proto); 1227 proto_unregister(&llc_proto);
1231 goto out; 1228 goto out;
1232} 1229}
diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c
index 0d0d416dfab..ba137a6a224 100644
--- a/net/llc/llc_conn.c
+++ b/net/llc/llc_conn.c
@@ -828,7 +828,7 @@ void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb)
828 else { 828 else {
829 dprintk("%s: adding to backlog...\n", __func__); 829 dprintk("%s: adding to backlog...\n", __func__);
830 llc_set_backlog_type(skb, LLC_PACKET); 830 llc_set_backlog_type(skb, LLC_PACKET);
831 if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) 831 if (sk_add_backlog(sk, skb))
832 goto drop_unlock; 832 goto drop_unlock;
833 } 833 }
834out: 834out:
diff --git a/net/llc/llc_input.c b/net/llc/llc_input.c
index dd3e83328ad..90324211131 100644
--- a/net/llc/llc_input.c
+++ b/net/llc/llc_input.c
@@ -13,7 +13,6 @@
13 */ 13 */
14#include <linux/netdevice.h> 14#include <linux/netdevice.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/export.h>
17#include <net/net_namespace.h> 16#include <net/net_namespace.h>
18#include <net/llc.h> 17#include <net/llc.h>
19#include <net/llc_pdu.h> 18#include <net/llc_pdu.h>
@@ -42,7 +41,6 @@ static void (*llc_type_handlers[2])(struct llc_sap *sap,
42void llc_add_pack(int type, void (*handler)(struct llc_sap *sap, 41void llc_add_pack(int type, void (*handler)(struct llc_sap *sap,
43 struct sk_buff *skb)) 42 struct sk_buff *skb))
44{ 43{
45 smp_wmb(); /* ensure initialisation is complete before it's called */
46 if (type == LLC_DEST_SAP || type == LLC_DEST_CONN) 44 if (type == LLC_DEST_SAP || type == LLC_DEST_CONN)
47 llc_type_handlers[type - 1] = handler; 45 llc_type_handlers[type - 1] = handler;
48} 46}
@@ -51,19 +49,11 @@ void llc_remove_pack(int type)
51{ 49{
52 if (type == LLC_DEST_SAP || type == LLC_DEST_CONN) 50 if (type == LLC_DEST_SAP || type == LLC_DEST_CONN)
53 llc_type_handlers[type - 1] = NULL; 51 llc_type_handlers[type - 1] = NULL;
54 synchronize_net();
55} 52}
56 53
57void llc_set_station_handler(void (*handler)(struct sk_buff *skb)) 54void llc_set_station_handler(void (*handler)(struct sk_buff *skb))
58{ 55{
59 /* Ensure initialisation is complete before it's called */
60 if (handler)
61 smp_wmb();
62
63 llc_station_handler = handler; 56 llc_station_handler = handler;
64
65 if (!handler)
66 synchronize_net();
67} 57}
68 58
69/** 59/**
@@ -159,8 +149,6 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
159 int dest; 149 int dest;
160 int (*rcv)(struct sk_buff *, struct net_device *, 150 int (*rcv)(struct sk_buff *, struct net_device *,
161 struct packet_type *, struct net_device *); 151 struct packet_type *, struct net_device *);
162 void (*sta_handler)(struct sk_buff *skb);
163 void (*sap_handler)(struct llc_sap *sap, struct sk_buff *skb);
164 152
165 if (!net_eq(dev_net(dev), &init_net)) 153 if (!net_eq(dev_net(dev), &init_net))
166 goto drop; 154 goto drop;
@@ -193,8 +181,7 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
193 */ 181 */
194 rcv = rcu_dereference(sap->rcv_func); 182 rcv = rcu_dereference(sap->rcv_func);
195 dest = llc_pdu_type(skb); 183 dest = llc_pdu_type(skb);
196 sap_handler = dest ? ACCESS_ONCE(llc_type_handlers[dest - 1]) : NULL; 184 if (unlikely(!dest || !llc_type_handlers[dest - 1])) {
197 if (unlikely(!sap_handler)) {
198 if (rcv) 185 if (rcv)
199 rcv(skb, dev, pt, orig_dev); 186 rcv(skb, dev, pt, orig_dev);
200 else 187 else
@@ -205,7 +192,7 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
205 if (cskb) 192 if (cskb)
206 rcv(cskb, dev, pt, orig_dev); 193 rcv(cskb, dev, pt, orig_dev);
207 } 194 }
208 sap_handler(sap, skb); 195 llc_type_handlers[dest - 1](sap, skb);
209 } 196 }
210 llc_sap_put(sap); 197 llc_sap_put(sap);
211out: 198out:
@@ -214,10 +201,9 @@ drop:
214 kfree_skb(skb); 201 kfree_skb(skb);
215 goto out; 202 goto out;
216handle_station: 203handle_station:
217 sta_handler = ACCESS_ONCE(llc_station_handler); 204 if (!llc_station_handler)
218 if (!sta_handler)
219 goto drop; 205 goto drop;
220 sta_handler(skb); 206 llc_station_handler(skb);
221 goto out; 207 goto out;
222} 208}
223 209
diff --git a/net/llc/llc_output.c b/net/llc/llc_output.c
index 2dae8a5df23..b38a1079a98 100644
--- a/net/llc/llc_output.c
+++ b/net/llc/llc_output.c
@@ -14,9 +14,10 @@
14 */ 14 */
15 15
16#include <linux/if_arp.h> 16#include <linux/if_arp.h>
17#include <linux/if_tr.h>
17#include <linux/netdevice.h> 18#include <linux/netdevice.h>
19#include <linux/trdevice.h>
18#include <linux/skbuff.h> 20#include <linux/skbuff.h>
19#include <linux/export.h>
20#include <net/llc.h> 21#include <net/llc.h>
21#include <net/llc_pdu.h> 22#include <net/llc_pdu.h>
22 23
@@ -35,6 +36,7 @@ int llc_mac_hdr_init(struct sk_buff *skb,
35 int rc = -EINVAL; 36 int rc = -EINVAL;
36 37
37 switch (skb->dev->type) { 38 switch (skb->dev->type) {
39 case ARPHRD_IEEE802_TR:
38 case ARPHRD_ETHER: 40 case ARPHRD_ETHER:
39 case ARPHRD_LOOPBACK: 41 case ARPHRD_LOOPBACK:
40 rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa, 42 rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
index 7b4799cfbf8..7af1ff2d1f1 100644
--- a/net/llc/llc_proc.c
+++ b/net/llc/llc_proc.c
@@ -17,7 +17,6 @@
17#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/seq_file.h> 19#include <linux/seq_file.h>
20#include <linux/export.h>
21#include <net/net_namespace.h> 20#include <net/net_namespace.h>
22#include <net/sock.h> 21#include <net/sock.h>
23#include <net/llc.h> 22#include <net/llc.h>
@@ -151,7 +150,7 @@ static int llc_seq_socket_show(struct seq_file *seq, void *v)
151 sk_wmem_alloc_get(sk), 150 sk_wmem_alloc_get(sk),
152 sk_rmem_alloc_get(sk) - llc->copied_seq, 151 sk_rmem_alloc_get(sk) - llc->copied_seq,
153 sk->sk_state, 152 sk->sk_state,
154 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)), 153 sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_uid : -1,
155 llc->link); 154 llc->link);
156out: 155out:
157 return 0; 156 return 0;
diff --git a/net/llc/llc_sap.c b/net/llc/llc_sap.c
index 7c5073badc7..94e7fca75b8 100644
--- a/net/llc/llc_sap.c
+++ b/net/llc/llc_sap.c
@@ -31,6 +31,10 @@ static int llc_mac_header_len(unsigned short devtype)
31 case ARPHRD_ETHER: 31 case ARPHRD_ETHER:
32 case ARPHRD_LOOPBACK: 32 case ARPHRD_LOOPBACK:
33 return sizeof(struct ethhdr); 33 return sizeof(struct ethhdr);
34#if defined(CONFIG_TR) || defined(CONFIG_TR_MODULE)
35 case ARPHRD_IEEE802_TR:
36 return sizeof(struct trh_hdr);
37#endif
34 } 38 }
35 return 0; 39 return 0;
36} 40}
diff --git a/net/llc/llc_station.c b/net/llc/llc_station.c
index 204a8351eff..cf4aea3ba30 100644
--- a/net/llc/llc_station.c
+++ b/net/llc/llc_station.c
@@ -25,26 +25,253 @@
25#include <net/llc_s_st.h> 25#include <net/llc_s_st.h>
26#include <net/llc_pdu.h> 26#include <net/llc_pdu.h>
27 27
28/**
29 * struct llc_station - LLC station component
30 *
31 * SAP and connection resource manager, one per adapter.
32 *
33 * @state - state of station
34 * @xid_r_count - XID response PDU counter
35 * @mac_sa - MAC source address
36 * @sap_list - list of related SAPs
37 * @ev_q - events entering state mach.
38 * @mac_pdu_q - PDUs ready to send to MAC
39 */
40struct llc_station {
41 u8 state;
42 u8 xid_r_count;
43 struct timer_list ack_timer;
44 u8 retry_count;
45 u8 maximum_retry;
46 struct {
47 struct sk_buff_head list;
48 spinlock_t lock;
49 } ev_q;
50 struct sk_buff_head mac_pdu_q;
51};
52
53#define LLC_STATION_ACK_TIME (3 * HZ)
54
55int sysctl_llc_station_ack_timeout = LLC_STATION_ACK_TIME;
56
57/* Types of events (possible values in 'ev->type') */
58#define LLC_STATION_EV_TYPE_SIMPLE 1
59#define LLC_STATION_EV_TYPE_CONDITION 2
60#define LLC_STATION_EV_TYPE_PRIM 3
61#define LLC_STATION_EV_TYPE_PDU 4 /* command/response PDU */
62#define LLC_STATION_EV_TYPE_ACK_TMR 5
63#define LLC_STATION_EV_TYPE_RPT_STATUS 6
64
65/* Events */
66#define LLC_STATION_EV_ENABLE_WITH_DUP_ADDR_CHECK 1
67#define LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK 2
68#define LLC_STATION_EV_ACK_TMR_EXP_LT_RETRY_CNT_MAX_RETRY 3
69#define LLC_STATION_EV_ACK_TMR_EXP_EQ_RETRY_CNT_MAX_RETRY 4
70#define LLC_STATION_EV_RX_NULL_DSAP_XID_C 5
71#define LLC_STATION_EV_RX_NULL_DSAP_0_XID_R_XID_R_CNT_EQ 6
72#define LLC_STATION_EV_RX_NULL_DSAP_1_XID_R_XID_R_CNT_EQ 7
73#define LLC_STATION_EV_RX_NULL_DSAP_TEST_C 8
74#define LLC_STATION_EV_DISABLE_REQ 9
75
76struct llc_station_state_ev {
77 u8 type;
78 u8 prim;
79 u8 prim_type;
80 u8 reason;
81 struct list_head node; /* node in station->ev_q.list */
82};
83
84static __inline__ struct llc_station_state_ev *
85 llc_station_ev(struct sk_buff *skb)
86{
87 return (struct llc_station_state_ev *)skb->cb;
88}
89
90typedef int (*llc_station_ev_t)(struct sk_buff *skb);
91
92#define LLC_STATION_STATE_DOWN 1 /* initial state */
93#define LLC_STATION_STATE_DUP_ADDR_CHK 2
94#define LLC_STATION_STATE_UP 3
95
96#define LLC_NBR_STATION_STATES 3 /* size of state table */
97
98typedef int (*llc_station_action_t)(struct sk_buff *skb);
99
100/* Station component state table structure */
101struct llc_station_state_trans {
102 llc_station_ev_t ev;
103 u8 next_state;
104 llc_station_action_t *ev_actions;
105};
106
107struct llc_station_state {
108 u8 curr_state;
109 struct llc_station_state_trans **transitions;
110};
111
112static struct llc_station llc_main_station;
113
114static int llc_stat_ev_enable_with_dup_addr_check(struct sk_buff *skb)
115{
116 struct llc_station_state_ev *ev = llc_station_ev(skb);
117
118 return ev->type == LLC_STATION_EV_TYPE_SIMPLE &&
119 ev->prim_type ==
120 LLC_STATION_EV_ENABLE_WITH_DUP_ADDR_CHECK ? 0 : 1;
121}
122
123static int llc_stat_ev_enable_without_dup_addr_check(struct sk_buff *skb)
124{
125 struct llc_station_state_ev *ev = llc_station_ev(skb);
126
127 return ev->type == LLC_STATION_EV_TYPE_SIMPLE &&
128 ev->prim_type ==
129 LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK ? 0 : 1;
130}
131
132static int llc_stat_ev_ack_tmr_exp_lt_retry_cnt_max_retry(struct sk_buff *skb)
133{
134 struct llc_station_state_ev *ev = llc_station_ev(skb);
135
136 return ev->type == LLC_STATION_EV_TYPE_ACK_TMR &&
137 llc_main_station.retry_count <
138 llc_main_station.maximum_retry ? 0 : 1;
139}
140
141static int llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry(struct sk_buff *skb)
142{
143 struct llc_station_state_ev *ev = llc_station_ev(skb);
144
145 return ev->type == LLC_STATION_EV_TYPE_ACK_TMR &&
146 llc_main_station.retry_count ==
147 llc_main_station.maximum_retry ? 0 : 1;
148}
149
28static int llc_stat_ev_rx_null_dsap_xid_c(struct sk_buff *skb) 150static int llc_stat_ev_rx_null_dsap_xid_c(struct sk_buff *skb)
29{ 151{
152 struct llc_station_state_ev *ev = llc_station_ev(skb);
30 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 153 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
31 154
32 return LLC_PDU_IS_CMD(pdu) && /* command PDU */ 155 return ev->type == LLC_STATION_EV_TYPE_PDU &&
156 LLC_PDU_IS_CMD(pdu) && /* command PDU */
33 LLC_PDU_TYPE_IS_U(pdu) && /* U type PDU */ 157 LLC_PDU_TYPE_IS_U(pdu) && /* U type PDU */
34 LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_XID && 158 LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_XID &&
35 !pdu->dsap ? 0 : 1; /* NULL DSAP value */ 159 !pdu->dsap ? 0 : 1; /* NULL DSAP value */
36} 160}
37 161
162static int llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq(struct sk_buff *skb)
163{
164 struct llc_station_state_ev *ev = llc_station_ev(skb);
165 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
166
167 return ev->type == LLC_STATION_EV_TYPE_PDU &&
168 LLC_PDU_IS_RSP(pdu) && /* response PDU */
169 LLC_PDU_TYPE_IS_U(pdu) && /* U type PDU */
170 LLC_U_PDU_RSP(pdu) == LLC_1_PDU_CMD_XID &&
171 !pdu->dsap && /* NULL DSAP value */
172 !llc_main_station.xid_r_count ? 0 : 1;
173}
174
175static int llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq(struct sk_buff *skb)
176{
177 struct llc_station_state_ev *ev = llc_station_ev(skb);
178 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
179
180 return ev->type == LLC_STATION_EV_TYPE_PDU &&
181 LLC_PDU_IS_RSP(pdu) && /* response PDU */
182 LLC_PDU_TYPE_IS_U(pdu) && /* U type PDU */
183 LLC_U_PDU_RSP(pdu) == LLC_1_PDU_CMD_XID &&
184 !pdu->dsap && /* NULL DSAP value */
185 llc_main_station.xid_r_count == 1 ? 0 : 1;
186}
187
38static int llc_stat_ev_rx_null_dsap_test_c(struct sk_buff *skb) 188static int llc_stat_ev_rx_null_dsap_test_c(struct sk_buff *skb)
39{ 189{
190 struct llc_station_state_ev *ev = llc_station_ev(skb);
40 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 191 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
41 192
42 return LLC_PDU_IS_CMD(pdu) && /* command PDU */ 193 return ev->type == LLC_STATION_EV_TYPE_PDU &&
194 LLC_PDU_IS_CMD(pdu) && /* command PDU */
43 LLC_PDU_TYPE_IS_U(pdu) && /* U type PDU */ 195 LLC_PDU_TYPE_IS_U(pdu) && /* U type PDU */
44 LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_TEST && 196 LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_TEST &&
45 !pdu->dsap ? 0 : 1; /* NULL DSAP */ 197 !pdu->dsap ? 0 : 1; /* NULL DSAP */
46} 198}
47 199
200static int llc_stat_ev_disable_req(struct sk_buff *skb)
201{
202 struct llc_station_state_ev *ev = llc_station_ev(skb);
203
204 return ev->type == LLC_STATION_EV_TYPE_PRIM &&
205 ev->prim == LLC_DISABLE_PRIM &&
206 ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
207}
208
209/**
210 * llc_station_send_pdu - queues PDU to send
211 * @skb: Address of the PDU
212 *
213 * Queues a PDU to send to the MAC layer.
214 */
215static void llc_station_send_pdu(struct sk_buff *skb)
216{
217 skb_queue_tail(&llc_main_station.mac_pdu_q, skb);
218 while ((skb = skb_dequeue(&llc_main_station.mac_pdu_q)) != NULL)
219 if (dev_queue_xmit(skb))
220 break;
221}
222
223static int llc_station_ac_start_ack_timer(struct sk_buff *skb)
224{
225 mod_timer(&llc_main_station.ack_timer,
226 jiffies + sysctl_llc_station_ack_timeout);
227 return 0;
228}
229
230static int llc_station_ac_set_retry_cnt_0(struct sk_buff *skb)
231{
232 llc_main_station.retry_count = 0;
233 return 0;
234}
235
236static int llc_station_ac_inc_retry_cnt_by_1(struct sk_buff *skb)
237{
238 llc_main_station.retry_count++;
239 return 0;
240}
241
242static int llc_station_ac_set_xid_r_cnt_0(struct sk_buff *skb)
243{
244 llc_main_station.xid_r_count = 0;
245 return 0;
246}
247
248static int llc_station_ac_inc_xid_r_cnt_by_1(struct sk_buff *skb)
249{
250 llc_main_station.xid_r_count++;
251 return 0;
252}
253
254static int llc_station_ac_send_null_dsap_xid_c(struct sk_buff *skb)
255{
256 int rc = 1;
257 struct sk_buff *nskb = llc_alloc_frame(NULL, skb->dev, LLC_PDU_TYPE_U,
258 sizeof(struct llc_xid_info));
259
260 if (!nskb)
261 goto out;
262 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, 0, LLC_PDU_CMD);
263 llc_pdu_init_as_xid_cmd(nskb, LLC_XID_NULL_CLASS_2, 127);
264 rc = llc_mac_hdr_init(nskb, skb->dev->dev_addr, skb->dev->dev_addr);
265 if (unlikely(rc))
266 goto free;
267 llc_station_send_pdu(nskb);
268out:
269 return rc;
270free:
271 kfree_skb(skb);
272 goto out;
273}
274
48static int llc_station_ac_send_xid_r(struct sk_buff *skb) 275static int llc_station_ac_send_xid_r(struct sk_buff *skb)
49{ 276{
50 u8 mac_da[ETH_ALEN], dsap; 277 u8 mac_da[ETH_ALEN], dsap;
@@ -62,11 +289,11 @@ static int llc_station_ac_send_xid_r(struct sk_buff *skb)
62 rc = llc_mac_hdr_init(nskb, skb->dev->dev_addr, mac_da); 289 rc = llc_mac_hdr_init(nskb, skb->dev->dev_addr, mac_da);
63 if (unlikely(rc)) 290 if (unlikely(rc))
64 goto free; 291 goto free;
65 dev_queue_xmit(nskb); 292 llc_station_send_pdu(nskb);
66out: 293out:
67 return rc; 294 return rc;
68free: 295free:
69 kfree_skb(nskb); 296 kfree_skb(skb);
70 goto out; 297 goto out;
71} 298}
72 299
@@ -91,15 +318,361 @@ static int llc_station_ac_send_test_r(struct sk_buff *skb)
91 rc = llc_mac_hdr_init(nskb, skb->dev->dev_addr, mac_da); 318 rc = llc_mac_hdr_init(nskb, skb->dev->dev_addr, mac_da);
92 if (unlikely(rc)) 319 if (unlikely(rc))
93 goto free; 320 goto free;
94 dev_queue_xmit(nskb); 321 llc_station_send_pdu(nskb);
95out: 322out:
96 return rc; 323 return rc;
97free: 324free:
98 kfree_skb(nskb); 325 kfree_skb(skb);
99 goto out; 326 goto out;
100} 327}
101 328
329static int llc_station_ac_report_status(struct sk_buff *skb)
330{
331 return 0;
332}
333
334/* COMMON STATION STATE transitions */
335
336/* dummy last-transition indicator; common to all state transition groups
337 * last entry for this state
338 * all members are zeros, .bss zeroes it
339 */
340static struct llc_station_state_trans llc_stat_state_trans_end;
341
342/* DOWN STATE transitions */
343
344/* state transition for LLC_STATION_EV_ENABLE_WITH_DUP_ADDR_CHECK event */
345static llc_station_action_t llc_stat_down_state_actions_1[] = {
346 [0] = llc_station_ac_start_ack_timer,
347 [1] = llc_station_ac_set_retry_cnt_0,
348 [2] = llc_station_ac_set_xid_r_cnt_0,
349 [3] = llc_station_ac_send_null_dsap_xid_c,
350 [4] = NULL,
351};
352
353static struct llc_station_state_trans llc_stat_down_state_trans_1 = {
354 .ev = llc_stat_ev_enable_with_dup_addr_check,
355 .next_state = LLC_STATION_STATE_DUP_ADDR_CHK,
356 .ev_actions = llc_stat_down_state_actions_1,
357};
358
359/* state transition for LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK event */
360static llc_station_action_t llc_stat_down_state_actions_2[] = {
361 [0] = llc_station_ac_report_status, /* STATION UP */
362 [1] = NULL,
363};
364
365static struct llc_station_state_trans llc_stat_down_state_trans_2 = {
366 .ev = llc_stat_ev_enable_without_dup_addr_check,
367 .next_state = LLC_STATION_STATE_UP,
368 .ev_actions = llc_stat_down_state_actions_2,
369};
370
371/* array of pointers; one to each transition */
372static struct llc_station_state_trans *llc_stat_dwn_state_trans[] = {
373 [0] = &llc_stat_down_state_trans_1,
374 [1] = &llc_stat_down_state_trans_2,
375 [2] = &llc_stat_state_trans_end,
376};
377
378/* UP STATE transitions */
379/* state transition for LLC_STATION_EV_DISABLE_REQ event */
380static llc_station_action_t llc_stat_up_state_actions_1[] = {
381 [0] = llc_station_ac_report_status, /* STATION DOWN */
382 [1] = NULL,
383};
384
385static struct llc_station_state_trans llc_stat_up_state_trans_1 = {
386 .ev = llc_stat_ev_disable_req,
387 .next_state = LLC_STATION_STATE_DOWN,
388 .ev_actions = llc_stat_up_state_actions_1,
389};
390
391/* state transition for LLC_STATION_EV_RX_NULL_DSAP_XID_C event */
392static llc_station_action_t llc_stat_up_state_actions_2[] = {
393 [0] = llc_station_ac_send_xid_r,
394 [1] = NULL,
395};
396
397static struct llc_station_state_trans llc_stat_up_state_trans_2 = {
398 .ev = llc_stat_ev_rx_null_dsap_xid_c,
399 .next_state = LLC_STATION_STATE_UP,
400 .ev_actions = llc_stat_up_state_actions_2,
401};
402
403/* state transition for LLC_STATION_EV_RX_NULL_DSAP_TEST_C event */
404static llc_station_action_t llc_stat_up_state_actions_3[] = {
405 [0] = llc_station_ac_send_test_r,
406 [1] = NULL,
407};
408
409static struct llc_station_state_trans llc_stat_up_state_trans_3 = {
410 .ev = llc_stat_ev_rx_null_dsap_test_c,
411 .next_state = LLC_STATION_STATE_UP,
412 .ev_actions = llc_stat_up_state_actions_3,
413};
414
415/* array of pointers; one to each transition */
416static struct llc_station_state_trans *llc_stat_up_state_trans [] = {
417 [0] = &llc_stat_up_state_trans_1,
418 [1] = &llc_stat_up_state_trans_2,
419 [2] = &llc_stat_up_state_trans_3,
420 [3] = &llc_stat_state_trans_end,
421};
422
423/* DUP ADDR CHK STATE transitions */
424/* state transition for LLC_STATION_EV_RX_NULL_DSAP_0_XID_R_XID_R_CNT_EQ
425 * event
426 */
427static llc_station_action_t llc_stat_dupaddr_state_actions_1[] = {
428 [0] = llc_station_ac_inc_xid_r_cnt_by_1,
429 [1] = NULL,
430};
431
432static struct llc_station_state_trans llc_stat_dupaddr_state_trans_1 = {
433 .ev = llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq,
434 .next_state = LLC_STATION_STATE_DUP_ADDR_CHK,
435 .ev_actions = llc_stat_dupaddr_state_actions_1,
436};
437
438/* state transition for LLC_STATION_EV_RX_NULL_DSAP_1_XID_R_XID_R_CNT_EQ
439 * event
440 */
441static llc_station_action_t llc_stat_dupaddr_state_actions_2[] = {
442 [0] = llc_station_ac_report_status, /* DUPLICATE ADDRESS FOUND */
443 [1] = NULL,
444};
445
446static struct llc_station_state_trans llc_stat_dupaddr_state_trans_2 = {
447 .ev = llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq,
448 .next_state = LLC_STATION_STATE_DOWN,
449 .ev_actions = llc_stat_dupaddr_state_actions_2,
450};
451
452/* state transition for LLC_STATION_EV_RX_NULL_DSAP_XID_C event */
453static llc_station_action_t llc_stat_dupaddr_state_actions_3[] = {
454 [0] = llc_station_ac_send_xid_r,
455 [1] = NULL,
456};
457
458static struct llc_station_state_trans llc_stat_dupaddr_state_trans_3 = {
459 .ev = llc_stat_ev_rx_null_dsap_xid_c,
460 .next_state = LLC_STATION_STATE_DUP_ADDR_CHK,
461 .ev_actions = llc_stat_dupaddr_state_actions_3,
462};
463
464/* state transition for LLC_STATION_EV_ACK_TMR_EXP_LT_RETRY_CNT_MAX_RETRY
465 * event
466 */
467static llc_station_action_t llc_stat_dupaddr_state_actions_4[] = {
468 [0] = llc_station_ac_start_ack_timer,
469 [1] = llc_station_ac_inc_retry_cnt_by_1,
470 [2] = llc_station_ac_set_xid_r_cnt_0,
471 [3] = llc_station_ac_send_null_dsap_xid_c,
472 [4] = NULL,
473};
474
475static struct llc_station_state_trans llc_stat_dupaddr_state_trans_4 = {
476 .ev = llc_stat_ev_ack_tmr_exp_lt_retry_cnt_max_retry,
477 .next_state = LLC_STATION_STATE_DUP_ADDR_CHK,
478 .ev_actions = llc_stat_dupaddr_state_actions_4,
479};
480
481/* state transition for LLC_STATION_EV_ACK_TMR_EXP_EQ_RETRY_CNT_MAX_RETRY
482 * event
483 */
484static llc_station_action_t llc_stat_dupaddr_state_actions_5[] = {
485 [0] = llc_station_ac_report_status, /* STATION UP */
486 [1] = NULL,
487};
488
489static struct llc_station_state_trans llc_stat_dupaddr_state_trans_5 = {
490 .ev = llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry,
491 .next_state = LLC_STATION_STATE_UP,
492 .ev_actions = llc_stat_dupaddr_state_actions_5,
493};
494
495/* state transition for LLC_STATION_EV_DISABLE_REQ event */
496static llc_station_action_t llc_stat_dupaddr_state_actions_6[] = {
497 [0] = llc_station_ac_report_status, /* STATION DOWN */
498 [1] = NULL,
499};
500
501static struct llc_station_state_trans llc_stat_dupaddr_state_trans_6 = {
502 .ev = llc_stat_ev_disable_req,
503 .next_state = LLC_STATION_STATE_DOWN,
504 .ev_actions = llc_stat_dupaddr_state_actions_6,
505};
506
507/* array of pointers; one to each transition */
508static struct llc_station_state_trans *llc_stat_dupaddr_state_trans[] = {
509 [0] = &llc_stat_dupaddr_state_trans_6, /* Request */
510 [1] = &llc_stat_dupaddr_state_trans_4, /* Timer */
511 [2] = &llc_stat_dupaddr_state_trans_5,
512 [3] = &llc_stat_dupaddr_state_trans_1, /* Receive frame */
513 [4] = &llc_stat_dupaddr_state_trans_2,
514 [5] = &llc_stat_dupaddr_state_trans_3,
515 [6] = &llc_stat_state_trans_end,
516};
517
518static struct llc_station_state
519 llc_station_state_table[LLC_NBR_STATION_STATES] = {
520 [LLC_STATION_STATE_DOWN - 1] = {
521 .curr_state = LLC_STATION_STATE_DOWN,
522 .transitions = llc_stat_dwn_state_trans,
523 },
524 [LLC_STATION_STATE_DUP_ADDR_CHK - 1] = {
525 .curr_state = LLC_STATION_STATE_DUP_ADDR_CHK,
526 .transitions = llc_stat_dupaddr_state_trans,
527 },
528 [LLC_STATION_STATE_UP - 1] = {
529 .curr_state = LLC_STATION_STATE_UP,
530 .transitions = llc_stat_up_state_trans,
531 },
532};
533
102/** 534/**
535 * llc_exec_station_trans_actions - executes actions for transition
536 * @trans: Address of the transition
537 * @skb: Address of the event that caused the transition
538 *
539 * Executes actions of a transition of the station state machine. Returns
540 * 0 if all actions complete successfully, nonzero otherwise.
541 */
542static u16 llc_exec_station_trans_actions(struct llc_station_state_trans *trans,
543 struct sk_buff *skb)
544{
545 u16 rc = 0;
546 llc_station_action_t *next_action = trans->ev_actions;
547
548 for (; next_action && *next_action; next_action++)
549 if ((*next_action)(skb))
550 rc = 1;
551 return rc;
552}
553
554/**
555 * llc_find_station_trans - finds transition for this event
556 * @skb: Address of the event
557 *
558 * Search thru events of the current state of the station until list
559 * exhausted or it's obvious that the event is not valid for the current
560 * state. Returns the address of the transition if cound, %NULL otherwise.
561 */
562static struct llc_station_state_trans *
563 llc_find_station_trans(struct sk_buff *skb)
564{
565 int i = 0;
566 struct llc_station_state_trans *rc = NULL;
567 struct llc_station_state_trans **next_trans;
568 struct llc_station_state *curr_state =
569 &llc_station_state_table[llc_main_station.state - 1];
570
571 for (next_trans = curr_state->transitions; next_trans[i]->ev; i++)
572 if (!next_trans[i]->ev(skb)) {
573 rc = next_trans[i];
574 break;
575 }
576 return rc;
577}
578
579/**
580 * llc_station_free_ev - frees an event
581 * @skb: Address of the event
582 *
583 * Frees an event.
584 */
585static void llc_station_free_ev(struct sk_buff *skb)
586{
587 struct llc_station_state_ev *ev = llc_station_ev(skb);
588
589 if (ev->type == LLC_STATION_EV_TYPE_PDU)
590 kfree_skb(skb);
591}
592
593/**
594 * llc_station_next_state - processes event and goes to the next state
595 * @skb: Address of the event
596 *
597 * Processes an event, executes any transitions related to that event and
598 * updates the state of the station.
599 */
600static u16 llc_station_next_state(struct sk_buff *skb)
601{
602 u16 rc = 1;
603 struct llc_station_state_trans *trans;
604
605 if (llc_main_station.state > LLC_NBR_STATION_STATES)
606 goto out;
607 trans = llc_find_station_trans(skb);
608 if (trans) {
609 /* got the state to which we next transition; perform the
610 * actions associated with this transition before actually
611 * transitioning to the next state
612 */
613 rc = llc_exec_station_trans_actions(trans, skb);
614 if (!rc)
615 /* transition station to next state if all actions
616 * execute successfully; done; wait for next event
617 */
618 llc_main_station.state = trans->next_state;
619 } else
620 /* event not recognized in current state; re-queue it for
621 * processing again at a later time; return failure
622 */
623 rc = 0;
624out:
625 llc_station_free_ev(skb);
626 return rc;
627}
628
629/**
630 * llc_station_service_events - service events in the queue
631 *
632 * Get an event from the station event queue (if any); attempt to service
633 * the event; if event serviced, get the next event (if any) on the event
634 * queue; if event not service, re-queue the event on the event queue and
635 * attempt to service the next event; when serviced all events in queue,
636 * finished; if don't transition to different state, just service all
637 * events once; if transition to new state, service all events again.
638 * Caller must hold llc_main_station.ev_q.lock.
639 */
640static void llc_station_service_events(void)
641{
642 struct sk_buff *skb;
643
644 while ((skb = skb_dequeue(&llc_main_station.ev_q.list)) != NULL)
645 llc_station_next_state(skb);
646}
647
648/**
649 * llc_station_state_process: queue event and try to process queue.
650 * @skb: Address of the event
651 *
652 * Queues an event (on the station event queue) for handling by the
653 * station state machine and attempts to process any queued-up events.
654 */
655static void llc_station_state_process(struct sk_buff *skb)
656{
657 spin_lock_bh(&llc_main_station.ev_q.lock);
658 skb_queue_tail(&llc_main_station.ev_q.list, skb);
659 llc_station_service_events();
660 spin_unlock_bh(&llc_main_station.ev_q.lock);
661}
662
663static void llc_station_ack_tmr_cb(unsigned long timeout_data)
664{
665 struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC);
666
667 if (skb) {
668 struct llc_station_state_ev *ev = llc_station_ev(skb);
669
670 ev->type = LLC_STATION_EV_TYPE_ACK_TMR;
671 llc_station_state_process(skb);
672 }
673}
674
675/*
103 * llc_station_rcv - send received pdu to the station state machine 676 * llc_station_rcv - send received pdu to the station state machine
104 * @skb: received frame. 677 * @skb: received frame.
105 * 678 *
@@ -107,19 +680,43 @@ free:
107 */ 680 */
108static void llc_station_rcv(struct sk_buff *skb) 681static void llc_station_rcv(struct sk_buff *skb)
109{ 682{
110 if (llc_stat_ev_rx_null_dsap_xid_c(skb)) 683 struct llc_station_state_ev *ev = llc_station_ev(skb);
111 llc_station_ac_send_xid_r(skb); 684
112 else if (llc_stat_ev_rx_null_dsap_test_c(skb)) 685 ev->type = LLC_STATION_EV_TYPE_PDU;
113 llc_station_ac_send_test_r(skb); 686 ev->reason = 0;
114 kfree_skb(skb); 687 llc_station_state_process(skb);
115} 688}
116 689
117void __init llc_station_init(void) 690int __init llc_station_init(void)
118{ 691{
692 int rc = -ENOBUFS;
693 struct sk_buff *skb;
694 struct llc_station_state_ev *ev;
695
696 skb_queue_head_init(&llc_main_station.mac_pdu_q);
697 skb_queue_head_init(&llc_main_station.ev_q.list);
698 spin_lock_init(&llc_main_station.ev_q.lock);
699 setup_timer(&llc_main_station.ack_timer, llc_station_ack_tmr_cb,
700 (unsigned long)&llc_main_station);
701 llc_main_station.ack_timer.expires = jiffies +
702 sysctl_llc_station_ack_timeout;
703 skb = alloc_skb(0, GFP_ATOMIC);
704 if (!skb)
705 goto out;
706 rc = 0;
119 llc_set_station_handler(llc_station_rcv); 707 llc_set_station_handler(llc_station_rcv);
708 ev = llc_station_ev(skb);
709 memset(ev, 0, sizeof(*ev));
710 llc_main_station.maximum_retry = 1;
711 llc_main_station.state = LLC_STATION_STATE_DOWN;
712 ev->type = LLC_STATION_EV_TYPE_SIMPLE;
713 ev->prim_type = LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK;
714 rc = llc_station_next_state(skb);
715out:
716 return rc;
120} 717}
121 718
122void llc_station_exit(void) 719void __exit llc_station_exit(void)
123{ 720{
124 llc_set_station_handler(NULL); 721 llc_set_station_handler(NULL);
125} 722}
diff --git a/net/llc/sysctl_net_llc.c b/net/llc/sysctl_net_llc.c
index 612a5ddaf93..e2ebe358626 100644
--- a/net/llc/sysctl_net_llc.c
+++ b/net/llc/sysctl_net_llc.c
@@ -7,7 +7,6 @@
7#include <linux/mm.h> 7#include <linux/mm.h>
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/sysctl.h> 9#include <linux/sysctl.h>
10#include <net/net_namespace.h>
11#include <net/llc.h> 10#include <net/llc.h>
12 11
13#ifndef CONFIG_SYSCTL 12#ifndef CONFIG_SYSCTL
@@ -47,32 +46,58 @@ static struct ctl_table llc2_timeout_table[] = {
47}; 46};
48 47
49static struct ctl_table llc_station_table[] = { 48static struct ctl_table llc_station_table[] = {
49 {
50 .procname = "ack_timeout",
51 .data = &sysctl_llc_station_ack_timeout,
52 .maxlen = sizeof(long),
53 .mode = 0644,
54 .proc_handler = proc_dointvec_jiffies,
55 },
50 { }, 56 { },
51}; 57};
52 58
53static struct ctl_table_header *llc2_timeout_header; 59static struct ctl_table llc2_dir_timeout_table[] = {
54static struct ctl_table_header *llc_station_header; 60 {
61 .procname = "timeout",
62 .mode = 0555,
63 .child = llc2_timeout_table,
64 },
65 { },
66};
67
68static struct ctl_table llc_table[] = {
69 {
70 .procname = "llc2",
71 .mode = 0555,
72 .child = llc2_dir_timeout_table,
73 },
74 {
75 .procname = "station",
76 .mode = 0555,
77 .child = llc_station_table,
78 },
79 { },
80};
81
82static struct ctl_path llc_path[] = {
83 { .procname = "net", },
84 { .procname = "llc", },
85 { }
86};
87
88static struct ctl_table_header *llc_table_header;
55 89
56int __init llc_sysctl_init(void) 90int __init llc_sysctl_init(void)
57{ 91{
58 llc2_timeout_header = register_net_sysctl(&init_net, "net/llc/llc2/timeout", llc2_timeout_table); 92 llc_table_header = register_sysctl_paths(llc_path, llc_table);
59 llc_station_header = register_net_sysctl(&init_net, "net/llc/station", llc_station_table);
60 93
61 if (!llc2_timeout_header || !llc_station_header) { 94 return llc_table_header ? 0 : -ENOMEM;
62 llc_sysctl_exit();
63 return -ENOMEM;
64 }
65 return 0;
66} 95}
67 96
68void llc_sysctl_exit(void) 97void llc_sysctl_exit(void)
69{ 98{
70 if (llc2_timeout_header) { 99 if (llc_table_header) {
71 unregister_net_sysctl_table(llc2_timeout_header); 100 unregister_sysctl_table(llc_table_header);
72 llc2_timeout_header = NULL; 101 llc_table_header = NULL;
73 }
74 if (llc_station_header) {
75 unregister_net_sysctl_table(llc_station_header);
76 llc_station_header = NULL;
77 } 102 }
78} 103}