o LLC: now it only uses seq_file for proc stuff

some extra trivial cleanups.
parent 2bcff6c1
......@@ -22,28 +22,12 @@
*/
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <asm/uaccess.h>
#include <asm/ioctls.h>
#include <linux/proc_fs.h>
#include <linux/in.h>
#include <linux/tcp.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/errno.h>
#include <net/sock.h>
#include <net/llc_if.h>
#include <net/llc_sap.h>
#include <net/llc_pdu.h>
#include <net/llc_conn.h>
#include <net/llc_mac.h>
#include <net/llc_main.h>
#include <net/llc_proc.h>
#include <linux/llc.h>
#include <linux/if_arp.h>
#include <linux/rtnetlink.h>
#include <linux/init.h>
......@@ -1058,20 +1042,13 @@ static char llc_ui_banner[] __initdata =
int __init llc_ui_init(void)
{
int rc = llc_proc_init();
if (rc)
goto out;
llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
sock_register(&llc_ui_family_ops);
printk(llc_ui_banner);
rc = 0;
out:
return rc;
return 0;
}
void __exit llc_ui_exit(void)
{
sock_unregister(PF_LLC);
llc_proc_exit();
}
......@@ -3,7 +3,7 @@
* and connections of the LLC.
*
* Copyright (c) 1997 by Procom Technology, Inc.
* 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* 2001, 2002 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
*
* This program can be redistributed or modified under the terms of the
* GNU General Public License as published by the Free Software Foundation.
......@@ -12,14 +12,9 @@
*
* See the GNU General Public License for more details.
*/
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <net/sock.h>
#include <linux/sched.h>
#include <linux/config.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <net/llc_if.h>
#include <net/llc_sap.h>
#include <net/llc_conn.h>
#include <net/llc_main.h>
......@@ -33,7 +28,7 @@
#include <net/llc_s_ev.h>
#include <net/llc_s_st.h>
#include <net/llc_mac.h>
#include <linux/llc.h>
#include <net/llc_proc.h>
/* static function prototypes */
static void llc_station_service_events(struct llc_station *station);
......@@ -527,80 +522,6 @@ struct sk_buff *llc_alloc_frame(void)
return skb;
}
static char *llc_conn_state_names[] = {
[LLC_CONN_STATE_ADM] = "adm",
[LLC_CONN_STATE_SETUP] = "setup",
[LLC_CONN_STATE_NORMAL] = "normal",
[LLC_CONN_STATE_BUSY] = "busy",
[LLC_CONN_STATE_REJ] = "rej",
[LLC_CONN_STATE_AWAIT] = "await",
[LLC_CONN_STATE_AWAIT_BUSY] = "await_busy",
[LLC_CONN_STATE_AWAIT_REJ] = "await_rej",
[LLC_CONN_STATE_D_CONN] = "d_conn",
[LLC_CONN_STATE_RESET] = "reset",
[LLC_CONN_STATE_ERROR] = "error",
[LLC_CONN_STATE_TEMP] = "temp",
};
static int llc_proc_get_info(char *bf, char **start, off_t offset, int length)
{
struct list_head *sap_entry;
struct sock *sk;
off_t begin = 0, pos = 0;
int len = 0;
read_lock_bh(&llc_main_station.sap_list.lock);
list_for_each(sap_entry, &llc_main_station.sap_list.list) {
struct llc_sap *sap = list_entry(sap_entry, struct llc_sap,
node);
len += sprintf(bf + len, "lsap=%02X\n", sap->laddr.lsap);
read_lock_bh(&sap->sk_list.lock);
if (!sap->sk_list.list) {
len += sprintf(bf + len, "no connections\n");
goto unlock;
}
len += sprintf(bf + len, "connection list:\n"
"dsap state retr txw rxw "
"pf ff sf df rs cs "
"tack tpfc trs tbs blog busr\n");
for (sk = sap->sk_list.list; sk; sk = sk->next) {
struct llc_opt *llc = llc_sk(sk);
len += sprintf(bf + len, " %02X %-10s %3d %3d %3d "
"%2d %2d %2d "
"%2d %2d %2d "
"%4d %4d %3d %3d %4d %4d\n",
llc->daddr.lsap,
llc_conn_state_names[llc->state],
llc->retry_count, llc->k, llc->rw,
llc->p_flag, llc->f_flag, llc->s_flag,
llc->data_flag, llc->remote_busy_flag,
llc->cause_flag,
timer_pending(&llc->ack_timer.timer),
timer_pending(&llc->pf_cycle_timer.timer),
timer_pending(&llc->rej_sent_timer.timer),
timer_pending(&llc->busy_state_timer.timer),
!!sk->backlog.tail, sk->lock.users);
}
unlock:
read_unlock_bh(&sap->sk_list.lock);
pos = begin + len;
if (pos < offset) {
len = 0; /* Keep dumping into the buffer start */
begin = pos;
}
if (pos > offset + length) /* We have dumped enough */
break;
}
read_unlock_bh(&llc_main_station.sap_list.lock);
/* The data in question runs from begin to begin + len */
*start = bf + (offset - begin); /* Start of wanted data */
len -= (offset - begin); /* Remove unwanted header data from length */
return len;
}
static struct packet_type llc_packet_type = {
.type = __constant_htons(ETH_P_802_2),
.func = llc_rcv,
......@@ -634,9 +555,11 @@ static int __init llc_init(void)
llc_main_station.ack_timer.data = (unsigned long)&llc_main_station;
llc_main_station.ack_timer.function = llc_station_ack_tmr_cb;
if (llc_proc_init())
goto err;
skb = alloc_skb(0, GFP_ATOMIC);
if (!skb)
goto err;
goto err_skb;
llc_build_offset_table();
ev = llc_station_ev(skb);
memset(ev, 0, sizeof(*ev));
......@@ -651,12 +574,13 @@ static int __init llc_init(void)
ev->type = LLC_STATION_EV_TYPE_SIMPLE;
ev->prim_type = LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK;
rc = llc_station_next_state(&llc_main_station, skb);
proc_net_create("802.2", 0, llc_proc_get_info);
llc_ui_init();
dev_add_pack(&llc_packet_type);
dev_add_pack(&llc_tr_packet_type);
out:
return rc;
err_skb:
llc_proc_exit();
err:
printk(llc_error_msg);
rc = 1;
......@@ -666,9 +590,9 @@ static int __init llc_init(void)
static void __exit llc_exit(void)
{
llc_ui_exit();
llc_proc_exit();
dev_remove_pack(&llc_packet_type);
dev_remove_pack(&llc_tr_packet_type);
proc_net_remove("802.2");
}
module_init(llc_init);
......
......@@ -11,32 +11,21 @@
*
* See the GNU General Public License for more details.
*/
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <asm/uaccess.h>
#include <asm/ioctls.h>
#include <linux/proc_fs.h>
#include <linux/in.h>
#include <linux/tcp.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/seq_file.h>
#include <net/sock.h>
#include <net/llc_if.h>
#include <net/llc_sap.h>
#include <net/llc_pdu.h>
#include <net/llc_c_ac.h>
#include <net/llc_c_ev.h>
#include <net/llc_c_st.h>
#include <net/llc_conn.h>
#include <net/llc_mac.h>
#include <net/llc_main.h>
#include <linux/llc.h>
#include <linux/if_arp.h>
#include <linux/rtnetlink.h>
#include <linux/init.h>
#include <linux/seq_file.h>
#include <net/llc_sap.h>
#ifdef CONFIG_PROC_FS
static void llc_ui_format_mac(struct seq_file *seq, unsigned char *mac)
......@@ -125,7 +114,7 @@ static void llc_seq_stop(struct seq_file *seq, void *v)
read_unlock_bh(&llc_main_station.sap_list.lock);
}
static int llc_seq_show(struct seq_file *seq, void *v)
static int llc_seq_socket_show(struct seq_file *seq, void *v)
{
struct sock* sk;
struct llc_opt *llc;
......@@ -157,16 +146,71 @@ static int llc_seq_show(struct seq_file *seq, void *v)
return 0;
}
struct seq_operations llc_seq_ops = {
static char *llc_conn_state_names[] = {
[LLC_CONN_STATE_ADM] = "adm",
[LLC_CONN_STATE_SETUP] = "setup",
[LLC_CONN_STATE_NORMAL] = "normal",
[LLC_CONN_STATE_BUSY] = "busy",
[LLC_CONN_STATE_REJ] = "rej",
[LLC_CONN_STATE_AWAIT] = "await",
[LLC_CONN_STATE_AWAIT_BUSY] = "await_busy",
[LLC_CONN_STATE_AWAIT_REJ] = "await_rej",
[LLC_CONN_STATE_D_CONN] = "d_conn",
[LLC_CONN_STATE_RESET] = "reset",
[LLC_CONN_STATE_ERROR] = "error",
[LLC_CONN_STATE_TEMP] = "temp",
};
static int llc_seq_core_show(struct seq_file *seq, void *v)
{
struct sock* sk;
struct llc_opt *llc;
if (v == (void *)1) {
seq_puts(seq, "Connection list:\n"
"dsap state retr txw rxw pf ff sf df rs cs "
"tack tpfc trs tbs blog busr\n");
goto out;
}
sk = v;
llc = llc_sk(sk);
seq_printf(seq, " %02X %-10s %3d %3d %3d %2d %2d %2d %2d %2d %2d "
"%4d %4d %3d %3d %4d %4d\n",
llc->daddr.lsap, llc_conn_state_names[llc->state],
llc->retry_count, llc->k, llc->rw, llc->p_flag, llc->f_flag,
llc->s_flag, llc->data_flag, llc->remote_busy_flag,
llc->cause_flag, timer_pending(&llc->ack_timer.timer),
timer_pending(&llc->pf_cycle_timer.timer),
timer_pending(&llc->rej_sent_timer.timer),
timer_pending(&llc->busy_state_timer.timer),
!!sk->backlog.tail, sk->lock.users);
out:
return 0;
}
struct seq_operations llc_seq_socket_ops = {
.start = llc_seq_start,
.next = llc_seq_next,
.stop = llc_seq_stop,
.show = llc_seq_show,
.show = llc_seq_socket_show,
};
static int llc_seq_open(struct inode *inode, struct file *file)
struct seq_operations llc_seq_core_ops = {
.start = llc_seq_start,
.next = llc_seq_next,
.stop = llc_seq_stop,
.show = llc_seq_core_show,
};
static int llc_seq_socket_open(struct inode *inode, struct file *file)
{
return seq_open(file, &llc_seq_ops);
return seq_open(file, &llc_seq_socket_ops);
}
static int llc_seq_core_open(struct inode *inode, struct file *file)
{
return seq_open(file, &llc_seq_core_ops);
}
static int llc_proc_perms(struct inode* inode, int op)
......@@ -174,8 +218,15 @@ static int llc_proc_perms(struct inode* inode, int op)
return 0;
}
static struct file_operations llc_seq_fops = {
.open = llc_seq_open,
static struct file_operations llc_seq_socket_fops = {
.open = llc_seq_socket_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static struct file_operations llc_seq_core_fops = {
.open = llc_seq_core_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
......@@ -200,11 +251,21 @@ int __init llc_proc_init(void)
if (!p)
goto out_socket;
p->proc_fops = &llc_seq_fops;
p->proc_fops = &llc_seq_socket_fops;
p->proc_iops = &llc_seq_inode;
p = create_proc_entry("core", 0, llc_proc_dir);
if (!p)
goto out_core;
p->proc_fops = &llc_seq_core_fops;
p->proc_iops = &llc_seq_inode;
rc = 0;
out:
return rc;
out_core:
remove_proc_entry("socket", llc_proc_dir);
out_socket:
remove_proc_entry("llc", proc_net);
goto out;
......@@ -213,6 +274,7 @@ int __init llc_proc_init(void)
void __exit llc_proc_exit(void)
{
remove_proc_entry("socket", llc_proc_dir);
remove_proc_entry("core", llc_proc_dir);
remove_proc_entry("llc", proc_net);
}
#else /* CONFIG_PROC_FS */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment