Bluetooth: Added /proc/net/l2cap via bt_procfs_init()
Added /proc/net/l2cap via bt_procfs_init(). Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
This commit is contained in:
parent
5c6ad8eee0
commit
5b28d95c13
1 changed files with 18 additions and 2 deletions
|
@ -34,6 +34,10 @@
|
||||||
#include <net/bluetooth/l2cap.h>
|
#include <net/bluetooth/l2cap.h>
|
||||||
#include <net/bluetooth/smp.h>
|
#include <net/bluetooth/smp.h>
|
||||||
|
|
||||||
|
static struct bt_sock_list l2cap_sk_list = {
|
||||||
|
.lock = __RW_LOCK_UNLOCKED(l2cap_sk_list.lock)
|
||||||
|
};
|
||||||
|
|
||||||
static const struct proto_ops l2cap_sock_ops;
|
static const struct proto_ops l2cap_sock_ops;
|
||||||
static void l2cap_sock_init(struct sock *sk, struct sock *parent);
|
static void l2cap_sock_init(struct sock *sk, struct sock *parent);
|
||||||
static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio);
|
static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio);
|
||||||
|
@ -886,6 +890,8 @@ static int l2cap_sock_release(struct socket *sock)
|
||||||
if (!sk)
|
if (!sk)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
bt_sock_unlink(&l2cap_sk_list, sk);
|
||||||
|
|
||||||
err = l2cap_sock_shutdown(sock, 2);
|
err = l2cap_sock_shutdown(sock, 2);
|
||||||
|
|
||||||
sock_orphan(sk);
|
sock_orphan(sk);
|
||||||
|
@ -1210,6 +1216,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
l2cap_sock_init(sk, NULL);
|
l2cap_sock_init(sk, NULL);
|
||||||
|
bt_sock_link(&l2cap_sk_list, sk);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1248,21 +1255,30 @@ int __init l2cap_init_sockets(void)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops);
|
err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops);
|
||||||
if (err < 0)
|
if (err < 0) {
|
||||||
|
BT_ERR("L2CAP socket registration failed");
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list, NULL);
|
||||||
|
if (err < 0) {
|
||||||
|
BT_ERR("Failed to create L2CAP proc file");
|
||||||
|
bt_sock_unregister(BTPROTO_L2CAP);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
BT_INFO("L2CAP socket layer initialized");
|
BT_INFO("L2CAP socket layer initialized");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
BT_ERR("L2CAP socket registration failed");
|
|
||||||
proto_unregister(&l2cap_proto);
|
proto_unregister(&l2cap_proto);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void l2cap_cleanup_sockets(void)
|
void l2cap_cleanup_sockets(void)
|
||||||
{
|
{
|
||||||
|
bt_procfs_cleanup(&init_net, "l2cap");
|
||||||
if (bt_sock_unregister(BTPROTO_L2CAP) < 0)
|
if (bt_sock_unregister(BTPROTO_L2CAP) < 0)
|
||||||
BT_ERR("L2CAP socket unregistration failed");
|
BT_ERR("L2CAP socket unregistration failed");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue