aboutsummaryrefslogtreecommitdiffstats
path: root/net/llc/llc_proc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /net/llc/llc_proc.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'net/llc/llc_proc.c')
-rw-r--r--net/llc/llc_proc.c267
1 files changed, 267 insertions, 0 deletions
diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
new file mode 100644
index 000000000000..36e8db3fa1a2
--- /dev/null
+++ b/net/llc/llc_proc.c
@@ -0,0 +1,267 @@
1/*
2 * proc_llc.c - proc interface for LLC
3 *
4 * Copyright (c) 2001 by Jay Schulist <jschlst@samba.org>
5 * 2002-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
6 *
7 * This program can be redistributed or modified under the terms of the
8 * GNU General Public License as published by the Free Software Foundation.
9 * This program is distributed without any warranty or implied warranty
10 * of merchantability or fitness for a particular purpose.
11 *
12 * See the GNU General Public License for more details.
13 */
14
15#include <linux/config.h>
16#include <linux/init.h>
17#include <linux/kernel.h>
18#include <linux/proc_fs.h>
19#include <linux/errno.h>
20#include <linux/seq_file.h>
21#include <net/sock.h>
22#include <net/llc.h>
23#include <net/llc_c_ac.h>
24#include <net/llc_c_ev.h>
25#include <net/llc_c_st.h>
26#include <net/llc_conn.h>
27
28static void llc_ui_format_mac(struct seq_file *seq, unsigned char *mac)
29{
30 seq_printf(seq, "%02X:%02X:%02X:%02X:%02X:%02X",
31 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
32}
33
34static struct sock *llc_get_sk_idx(loff_t pos)
35{
36 struct list_head *sap_entry;
37 struct llc_sap *sap;
38 struct hlist_node *node;
39 struct sock *sk = NULL;
40
41 list_for_each(sap_entry, &llc_sap_list) {
42 sap = list_entry(sap_entry, struct llc_sap, node);
43
44 read_lock_bh(&sap->sk_list.lock);
45 sk_for_each(sk, node, &sap->sk_list.list) {
46 if (!pos)
47 goto found;
48 --pos;
49 }
50 read_unlock_bh(&sap->sk_list.lock);
51 }
52 sk = NULL;
53found:
54 return sk;
55}
56
57static void *llc_seq_start(struct seq_file *seq, loff_t *pos)
58{
59 loff_t l = *pos;
60
61 read_lock_bh(&llc_sap_list_lock);
62 return l ? llc_get_sk_idx(--l) : SEQ_START_TOKEN;
63}
64
65static void *llc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
66{
67 struct sock* sk, *next;
68 struct llc_sock *llc;
69 struct llc_sap *sap;
70
71 ++*pos;
72 if (v == SEQ_START_TOKEN) {
73 sk = llc_get_sk_idx(0);
74 goto out;
75 }
76 sk = v;
77 next = sk_next(sk);
78 if (next) {
79 sk = next;
80 goto out;
81 }
82 llc = llc_sk(sk);
83 sap = llc->sap;
84 read_unlock_bh(&sap->sk_list.lock);
85 sk = NULL;
86 for (;;) {
87 if (sap->node.next == &llc_sap_list)
88 break;
89 sap = list_entry(sap->node.next, struct llc_sap, node);
90 read_lock_bh(&sap->sk_list.lock);
91 if (!hlist_empty(&sap->sk_list.list)) {
92 sk = sk_head(&sap->sk_list.list);
93 break;
94 }
95 read_unlock_bh(&sap->sk_list.lock);
96 }
97out:
98 return sk;
99}
100
101static void llc_seq_stop(struct seq_file *seq, void *v)
102{
103 if (v && v != SEQ_START_TOKEN) {
104 struct sock *sk = v;
105 struct llc_sock *llc = llc_sk(sk);
106 struct llc_sap *sap = llc->sap;
107
108 read_unlock_bh(&sap->sk_list.lock);
109 }
110 read_unlock_bh(&llc_sap_list_lock);
111}
112
113static int llc_seq_socket_show(struct seq_file *seq, void *v)
114{
115 struct sock* sk;
116 struct llc_sock *llc;
117
118 if (v == SEQ_START_TOKEN) {
119 seq_puts(seq, "SKt Mc local_mac_sap remote_mac_sap "
120 " tx_queue rx_queue st uid link\n");
121 goto out;
122 }
123 sk = v;
124 llc = llc_sk(sk);
125
126 /* FIXME: check if the address is multicast */
127 seq_printf(seq, "%2X %2X ", sk->sk_type, 0);
128
129 if (llc->dev)
130 llc_ui_format_mac(seq, llc->dev->dev_addr);
131 else
132 seq_printf(seq, "00:00:00:00:00:00");
133 seq_printf(seq, "@%02X ", llc->sap->laddr.lsap);
134 llc_ui_format_mac(seq, llc->daddr.mac);
135 seq_printf(seq, "@%02X %8d %8d %2d %3d %4d\n", llc->daddr.lsap,
136 atomic_read(&sk->sk_wmem_alloc),
137 atomic_read(&sk->sk_rmem_alloc),
138 sk->sk_state,
139 sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_uid : -1,
140 llc->link);
141out:
142 return 0;
143}
144
145static char *llc_conn_state_names[] = {
146 [LLC_CONN_STATE_ADM] = "adm",
147 [LLC_CONN_STATE_SETUP] = "setup",
148 [LLC_CONN_STATE_NORMAL] = "normal",
149 [LLC_CONN_STATE_BUSY] = "busy",
150 [LLC_CONN_STATE_REJ] = "rej",
151 [LLC_CONN_STATE_AWAIT] = "await",
152 [LLC_CONN_STATE_AWAIT_BUSY] = "await_busy",
153 [LLC_CONN_STATE_AWAIT_REJ] = "await_rej",
154 [LLC_CONN_STATE_D_CONN] = "d_conn",
155 [LLC_CONN_STATE_RESET] = "reset",
156 [LLC_CONN_STATE_ERROR] = "error",
157 [LLC_CONN_STATE_TEMP] = "temp",
158};
159
160static int llc_seq_core_show(struct seq_file *seq, void *v)
161{
162 struct sock* sk;
163 struct llc_sock *llc;
164
165 if (v == SEQ_START_TOKEN) {
166 seq_puts(seq, "Connection list:\n"
167 "dsap state retr txw rxw pf ff sf df rs cs "
168 "tack tpfc trs tbs blog busr\n");
169 goto out;
170 }
171 sk = v;
172 llc = llc_sk(sk);
173
174 seq_printf(seq, " %02X %-10s %3d %3d %3d %2d %2d %2d %2d %2d %2d "
175 "%4d %4d %3d %3d %4d %4d\n",
176 llc->daddr.lsap, llc_conn_state_names[llc->state],
177 llc->retry_count, llc->k, llc->rw, llc->p_flag, llc->f_flag,
178 llc->s_flag, llc->data_flag, llc->remote_busy_flag,
179 llc->cause_flag, timer_pending(&llc->ack_timer.timer),
180 timer_pending(&llc->pf_cycle_timer.timer),
181 timer_pending(&llc->rej_sent_timer.timer),
182 timer_pending(&llc->busy_state_timer.timer),
183 !!sk->sk_backlog.tail, !!sock_owned_by_user(sk));
184out:
185 return 0;
186}
187
188static struct seq_operations llc_seq_socket_ops = {
189 .start = llc_seq_start,
190 .next = llc_seq_next,
191 .stop = llc_seq_stop,
192 .show = llc_seq_socket_show,
193};
194
195static struct seq_operations llc_seq_core_ops = {
196 .start = llc_seq_start,
197 .next = llc_seq_next,
198 .stop = llc_seq_stop,
199 .show = llc_seq_core_show,
200};
201
202static int llc_seq_socket_open(struct inode *inode, struct file *file)
203{
204 return seq_open(file, &llc_seq_socket_ops);
205}
206
207static int llc_seq_core_open(struct inode *inode, struct file *file)
208{
209 return seq_open(file, &llc_seq_core_ops);
210}
211
212static struct file_operations llc_seq_socket_fops = {
213 .owner = THIS_MODULE,
214 .open = llc_seq_socket_open,
215 .read = seq_read,
216 .llseek = seq_lseek,
217 .release = seq_release,
218};
219
220static struct file_operations llc_seq_core_fops = {
221 .owner = THIS_MODULE,
222 .open = llc_seq_core_open,
223 .read = seq_read,
224 .llseek = seq_lseek,
225 .release = seq_release,
226};
227
228static struct proc_dir_entry *llc_proc_dir;
229
230int __init llc_proc_init(void)
231{
232 int rc = -ENOMEM;
233 struct proc_dir_entry *p;
234
235 llc_proc_dir = proc_mkdir("llc", proc_net);
236 if (!llc_proc_dir)
237 goto out;
238 llc_proc_dir->owner = THIS_MODULE;
239
240 p = create_proc_entry("socket", S_IRUGO, llc_proc_dir);
241 if (!p)
242 goto out_socket;
243
244 p->proc_fops = &llc_seq_socket_fops;
245
246 p = create_proc_entry("core", S_IRUGO, llc_proc_dir);
247 if (!p)
248 goto out_core;
249
250 p->proc_fops = &llc_seq_core_fops;
251
252 rc = 0;
253out:
254 return rc;
255out_core:
256 remove_proc_entry("socket", llc_proc_dir);
257out_socket:
258 remove_proc_entry("llc", proc_net);
259 goto out;
260}
261
262void llc_proc_exit(void)
263{
264 remove_proc_entry("socket", llc_proc_dir);
265 remove_proc_entry("core", llc_proc_dir);
266 remove_proc_entry("llc", proc_net);
267}