12 #include <linux/module.h>
13 #include <linux/net.h>
14 #include <linux/slab.h>
16 #include <linux/poll.h>
35 static struct proto rxrpc_proto;
36 static const struct proto_ops rxrpc_rpc_ops;
49 static void rxrpc_sock_destructor(
struct sock *);
54 static inline int rxrpc_writable(
struct sock *
sk)
62 static void rxrpc_write_space(
struct sock *
sk)
66 if (rxrpc_writable(sk)) {
69 if (wq_has_sleeper(wq))
124 struct sock *sk = sock->
sk;
130 _enter(
"%p,%p,%d", rx, saddr, len);
132 ret = rxrpc_validate_address(rx, srx, len);
148 ret = PTR_ERR(local);
157 if (prx->service_id == service_id)
189 struct sock *sk = sock->
sk;
193 _enter(
"%p,%d", rx, backlog);
197 switch (rx->
sk.sk_state) {
224 int addr_len,
int flags,
232 _enter(
"%p,%p,%d,%d", rx, addr, addr_len, flags);
245 return ERR_CAST(peer);
280 _enter(
",,%x,%lx", key_serial(key), user_call_ID);
285 trans = rxrpc_name_to_transport(sock, (
struct sockaddr *) srx,
286 sizeof(*srx), 0, gfp);
288 call = ERR_CAST(trans);
307 if (key && !key->payload.data)
311 if (IS_ERR(bundle)) {
312 call = ERR_CAST(bundle);
372 static int rxrpc_connect(
struct socket *sock,
struct sockaddr *addr,
373 int addr_len,
int flags)
376 struct sock *sk = sock->
sk;
382 _enter(
"%p,%p,%d,%d", rx, addr, addr_len, flags);
384 ret = rxrpc_validate_address(rx, srx, addr_len);
386 _leave(
" = %d [bad addr]", ret);
392 switch (rx->
sk.sk_state) {
397 rx->
srx.srx_service = 0;
404 return PTR_ERR(local);
418 trans = rxrpc_name_to_transport(sock, addr, addr_len, flags,
422 _leave(
" = %ld", PTR_ERR(trans));
423 return PTR_ERR(trans);
450 _enter(
",{%d},,%zu", rx->
sk.sk_state, len);
458 _leave(
" = %d [bad addr]", ret);
468 trans = rxrpc_name_to_transport(sock, m->
msg_name,
471 ret = PTR_ERR(trans);
481 switch (rx->
sk.sk_state) {
512 static int rxrpc_setsockopt(
struct socket *sock,
int level,
int optname,
513 char __user *optval,
unsigned int optlen)
519 _enter(
",%d,%d,,%d", level, optname, optlen);
558 if (optlen !=
sizeof(
unsigned int))
564 (
unsigned int __user *) optval);
588 static unsigned int rxrpc_poll(
struct file *
file,
struct socket *sock,
592 struct sock *sk = sock->
sk;
594 sock_poll_wait(file, sk_sleep(sk), wait);
605 if (rxrpc_writable(sk))
620 _enter(
"%p,%d", sock, protocol);
632 sock->
ops = &rxrpc_rpc_ops;
662 static void rxrpc_sock_destructor(
struct sock *sk)
673 printk(
"Attempt to release alive rxrpc socket: %p\n", sk);
681 static int rxrpc_release_sock(
struct sock *sk)
739 static int rxrpc_release(
struct socket *sock)
741 struct sock *sk = sock->
sk;
743 _enter(
"%p{%p}", sock, sk);
750 return rxrpc_release_sock(sk);
756 static const struct proto_ops rxrpc_rpc_ops = {
759 .release = rxrpc_release,
761 .connect = rxrpc_connect,
767 .listen = rxrpc_listen,
769 .setsockopt = rxrpc_setsockopt,
771 .sendmsg = rxrpc_sendmsg,
777 static struct proto rxrpc_proto = {
786 .create = rxrpc_create,
793 static int __init af_rxrpc_init(
void)
804 "rxrpc_call_jar",
sizeof(
struct rxrpc_call), 0,
812 if (!rxrpc_workqueue) {
814 goto error_work_queue;
838 goto error_key_type_s;
841 #ifdef CONFIG_PROC_FS
864 static void __exit af_rxrpc_exit(
void)
879 _debug(
"flush scheduled work");