diff options
Diffstat (limited to 'net/bluetooth/l2cap.c')
| -rw-r--r-- | net/bluetooth/l2cap.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 400efa26ddba..7794a2e2adce 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
| @@ -40,6 +40,8 @@ | |||
| 40 | #include <linux/skbuff.h> | 40 | #include <linux/skbuff.h> |
| 41 | #include <linux/list.h> | 41 | #include <linux/list.h> |
| 42 | #include <linux/device.h> | 42 | #include <linux/device.h> |
| 43 | #include <linux/debugfs.h> | ||
| 44 | #include <linux/seq_file.h> | ||
| 43 | #include <linux/uaccess.h> | 45 | #include <linux/uaccess.h> |
| 44 | #include <linux/crc16.h> | 46 | #include <linux/crc16.h> |
| 45 | #include <net/sock.h> | 47 | #include <net/sock.h> |
| @@ -2830,6 +2832,11 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
| 2830 | int len = cmd->len - sizeof(*rsp); | 2832 | int len = cmd->len - sizeof(*rsp); |
| 2831 | char req[64]; | 2833 | char req[64]; |
| 2832 | 2834 | ||
| 2835 | if (len > sizeof(req) - sizeof(struct l2cap_conf_req)) { | ||
| 2836 | l2cap_send_disconn_req(conn, sk); | ||
| 2837 | goto done; | ||
| 2838 | } | ||
| 2839 | |||
| 2833 | /* throw out any old stored conf requests */ | 2840 | /* throw out any old stored conf requests */ |
| 2834 | result = L2CAP_CONF_SUCCESS; | 2841 | result = L2CAP_CONF_SUCCESS; |
| 2835 | len = l2cap_parse_conf_rsp(sk, rsp->data, | 2842 | len = l2cap_parse_conf_rsp(sk, rsp->data, |
| @@ -3937,29 +3944,42 @@ drop: | |||
| 3937 | return 0; | 3944 | return 0; |
| 3938 | } | 3945 | } |
| 3939 | 3946 | ||
| 3940 | static ssize_t l2cap_sysfs_show(struct class *dev, char *buf) | 3947 | static int l2cap_debugfs_show(struct seq_file *f, void *p) |
| 3941 | { | 3948 | { |
| 3942 | struct sock *sk; | 3949 | struct sock *sk; |
| 3943 | struct hlist_node *node; | 3950 | struct hlist_node *node; |
| 3944 | char *str = buf; | ||
| 3945 | 3951 | ||
| 3946 | read_lock_bh(&l2cap_sk_list.lock); | 3952 | read_lock_bh(&l2cap_sk_list.lock); |
| 3947 | 3953 | ||
| 3948 | sk_for_each(sk, node, &l2cap_sk_list.head) { | 3954 | sk_for_each(sk, node, &l2cap_sk_list.head) { |
| 3949 | struct l2cap_pinfo *pi = l2cap_pi(sk); | 3955 | struct l2cap_pinfo *pi = l2cap_pi(sk); |
| 3950 | 3956 | ||
| 3951 | str += sprintf(str, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n", | 3957 | seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n", |
| 3952 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), | 3958 | batostr(&bt_sk(sk)->src), |
| 3953 | sk->sk_state, __le16_to_cpu(pi->psm), pi->scid, | 3959 | batostr(&bt_sk(sk)->dst), |
| 3954 | pi->dcid, pi->imtu, pi->omtu, pi->sec_level); | 3960 | sk->sk_state, __le16_to_cpu(pi->psm), |
| 3961 | pi->scid, pi->dcid, | ||
| 3962 | pi->imtu, pi->omtu, pi->sec_level); | ||
| 3955 | } | 3963 | } |
| 3956 | 3964 | ||
| 3957 | read_unlock_bh(&l2cap_sk_list.lock); | 3965 | read_unlock_bh(&l2cap_sk_list.lock); |
| 3958 | 3966 | ||
| 3959 | return str - buf; | 3967 | return 0; |
| 3960 | } | 3968 | } |
| 3961 | 3969 | ||
| 3962 | static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL); | 3970 | static int l2cap_debugfs_open(struct inode *inode, struct file *file) |
| 3971 | { | ||
| 3972 | return single_open(file, l2cap_debugfs_show, inode->i_private); | ||
| 3973 | } | ||
| 3974 | |||
| 3975 | static const struct file_operations l2cap_debugfs_fops = { | ||
| 3976 | .open = l2cap_debugfs_open, | ||
| 3977 | .read = seq_read, | ||
| 3978 | .llseek = seq_lseek, | ||
| 3979 | .release = single_release, | ||
| 3980 | }; | ||
| 3981 | |||
| 3982 | static struct dentry *l2cap_debugfs; | ||
| 3963 | 3983 | ||
| 3964 | static const struct proto_ops l2cap_sock_ops = { | 3984 | static const struct proto_ops l2cap_sock_ops = { |
| 3965 | .family = PF_BLUETOOTH, | 3985 | .family = PF_BLUETOOTH, |
| @@ -4019,8 +4039,12 @@ static int __init l2cap_init(void) | |||
| 4019 | goto error; | 4039 | goto error; |
| 4020 | } | 4040 | } |
| 4021 | 4041 | ||
| 4022 | if (class_create_file(bt_class, &class_attr_l2cap) < 0) | 4042 | if (bt_debugfs) { |
| 4023 | BT_ERR("Failed to create L2CAP info file"); | 4043 | l2cap_debugfs = debugfs_create_file("l2cap", 0444, |
| 4044 | bt_debugfs, NULL, &l2cap_debugfs_fops); | ||
| 4045 | if (!l2cap_debugfs) | ||
| 4046 | BT_ERR("Failed to create L2CAP debug file"); | ||
| 4047 | } | ||
| 4024 | 4048 | ||
| 4025 | BT_INFO("L2CAP ver %s", VERSION); | 4049 | BT_INFO("L2CAP ver %s", VERSION); |
| 4026 | BT_INFO("L2CAP socket layer initialized"); | 4050 | BT_INFO("L2CAP socket layer initialized"); |
| @@ -4034,7 +4058,7 @@ error: | |||
| 4034 | 4058 | ||
| 4035 | static void __exit l2cap_exit(void) | 4059 | static void __exit l2cap_exit(void) |
| 4036 | { | 4060 | { |
| 4037 | class_remove_file(bt_class, &class_attr_l2cap); | 4061 | debugfs_remove(l2cap_debugfs); |
| 4038 | 4062 | ||
| 4039 | if (bt_sock_unregister(BTPROTO_L2CAP) < 0) | 4063 | if (bt_sock_unregister(BTPROTO_L2CAP) < 0) |
| 4040 | BT_ERR("L2CAP socket unregistration failed"); | 4064 | BT_ERR("L2CAP socket unregistration failed"); |
