Lines Matching refs:sock
99 #include <net/sock.h>
342 * and file struct implicitly stored in sock->file.
354 static int sock_alloc_file(struct socket *sock, struct file **f, int flags)
373 d_instantiate(path.dentry, SOCK_INODE(sock));
374 SOCK_INODE(sock)->i_fop = &socket_file_ops;
386 sock->file = file;
389 file->private_data = sock;
395 int sock_map_fd(struct socket *sock, int flags)
398 int fd = sock_alloc_file(sock, &newfile, flags);
432 struct socket *sock;
440 sock = sock_from_file(file, err);
441 if (!sock)
443 return sock;
450 struct socket *sock;
455 sock = sock_from_file(file, err);
456 if (sock)
457 return sock;
474 struct socket *sock;
480 sock = SOCKET_I(inode);
482 kmemcheck_annotate_bitfield(sock, type);
488 return sock;
509 * @sock: socket to close
516 void sock_release(struct socket *sock)
518 if (sock->ops) {
519 struct module *owner = sock->ops->owner;
521 sock->ops->release(sock);
522 sock->ops = NULL;
526 if (sock->wq->fasync_list)
530 if (!sock->file) {
531 iput(SOCK_INODE(sock));
534 sock->file = NULL;
538 int sock_tx_timestamp(struct msghdr *msg, struct sock *sk,
550 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
556 sock_update_classid(sock->sk);
558 si->sock = sock;
563 err = security_socket_sendmsg(sock, msg, size);
567 return sock->ops->sendmsg(iocb, sock, msg, size);
570 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
578 ret = __sock_sendmsg(&iocb, sock, msg, size);
585 int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
598 result = sock_sendmsg(sock, msg, size);
617 void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
665 inline void sock_recv_drops(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
672 void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
680 static inline int __sock_recvmsg_nosec(struct kiocb *iocb, struct socket *sock,
685 sock_update_classid(sock->sk);
687 si->sock = sock;
693 return sock->ops->recvmsg(iocb, sock, msg, size, flags);
696 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
699 int err = security_socket_recvmsg(sock, msg, size, flags);
701 return err ?: __sock_recvmsg_nosec(iocb, sock, msg, size, flags);
704 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
713 ret = __sock_recvmsg(&iocb, sock, msg, size, flags);
720 static int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
729 ret = __sock_recvmsg_nosec(&iocb, sock, msg, size, flags);
735 int kernel_recvmsg(struct socket *sock, struct msghdr *msg,
747 result = sock_recvmsg(sock, msg, size, flags);
761 struct socket *sock;
764 sock = file->private_data;
770 return kernel_sendpage(sock, page, offset, size, flags);
777 struct socket *sock = file->private_data;
779 if (unlikely(!sock->ops->splice_read))
782 sock_update_classid(sock->sk);
784 return sock->ops->splice_read(sock, ppos, pipe, len, flags);
806 struct socket *sock = file->private_data;
821 return __sock_recvmsg(iocb, sock, msg, size, msg->msg_flags);
846 struct socket *sock = file->private_data;
860 if (sock->type == SOCK_SEQPACKET)
863 return __sock_sendmsg(iocb, sock, msg, size);
919 static long sock_do_ioctl(struct net *net, struct socket *sock,
925 err = sock->ops->ioctl(sock, cmd, arg);
944 struct socket *sock;
945 struct sock *sk;
950 sock = file->private_data;
951 sk = sock->sk;
967 err = f_setown(sock->file, pid, 1);
971 err = put_user(f_getown(sock->file),
1010 err = sock_do_ioctl(net, sock, cmd, arg);
1019 struct socket *sock = NULL;
1025 sock = sock_alloc();
1026 if (!sock) {
1031 sock->type = type;
1032 err = security_socket_post_create(sock, family, type, protocol, 1);
1037 *res = sock;
1040 sock_release(sock);
1041 sock = NULL;
1049 struct socket *sock;
1054 sock = file->private_data;
1055 return sock->ops->poll(file, sock, wait);
1060 struct socket *sock = file->private_data;
1062 return sock->ops->mmap(file, sock, vma);
1093 struct socket *sock = filp->private_data;
1094 struct sock *sk = sock->sk;
1101 fasync_helper(fd, filp, on, &sock->wq->fasync_list);
1103 if (!sock->wq->fasync_list)
1114 int sock_wake_async(struct socket *sock, int how, int band)
1118 if (!sock)
1121 wq = rcu_dereference(sock->wq);
1128 if (test_bit(SOCK_ASYNC_WAITDATA, &sock->flags))
1132 if (!test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags))
1151 struct socket *sock;
1186 sock = sock_alloc();
1187 if (!sock) {
1194 sock->type = type;
1223 err = pf->create(net, sock, protocol, kern);
1231 if (!try_module_get(sock->ops->owner))
1239 err = security_socket_post_create(sock, family, type, protocol, kern);
1242 *res = sock;
1249 sock->ops = NULL;
1252 sock_release(sock);
1275 struct socket *sock;
1292 retval = sock_create(family, type, protocol, &sock);
1296 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
1305 sock_release(sock);
1396 struct socket *sock;
1400 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1401 if (sock) {
1404 err = security_socket_bind(sock,
1408 err = sock->ops->bind(sock,
1412 fput_light(sock->file, fput_needed);
1425 struct socket *sock;
1429 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1430 if (sock) {
1431 somaxconn = sock_net(sock->sk)->core.sysctl_somaxconn;
1435 err = security_socket_listen(sock, backlog);
1437 err = sock->ops->listen(sock, backlog);
1439 fput_light(sock->file, fput_needed);
1459 struct socket *sock, *newsock;
1470 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1471 if (!sock)
1479 newsock->type = sock->type;
1480 newsock->ops = sock->ops;
1483 * We don't need try_module_get here, as the listening socket (sock)
1484 * has the protocol module (sock->ops->owner) held.
1495 err = security_socket_accept(sock, newsock);
1499 err = sock->ops->accept(sock, newsock, sock->file->f_flags);
1521 fput_light(sock->file, fput_needed);
1551 struct socket *sock;
1555 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1556 if (!sock)
1563 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
1567 err = sock->ops->connect(sock, (struct sockaddr *)&address, addrlen,
1568 sock->file->f_flags);
1570 fput_light(sock->file, fput_needed);
1583 struct socket *sock;
1587 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1588 if (!sock)
1591 err = security_socket_getsockname(sock);
1595 err = sock->ops->getname(sock, (struct sockaddr *)&address, &len, 0);
1601 fput_light(sock->file, fput_needed);
1614 struct socket *sock;
1618 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1619 if (sock != NULL) {
1620 err = security_socket_getpeername(sock);
1622 fput_light(sock->file, fput_needed);
1627 sock->ops->getname(sock, (struct sockaddr *)&address, &len,
1632 fput_light(sock->file, fput_needed);
1647 struct socket *sock;
1656 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1657 if (!sock)
1675 if (sock->file->f_flags & O_NONBLOCK)
1678 err = sock_sendmsg(sock, &msg, len);
1681 fput_light(sock->file, fput_needed);
1706 struct socket *sock;
1715 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1716 if (!sock)
1727 if (sock->file->f_flags & O_NONBLOCK)
1729 err = sock_recvmsg(sock, &msg, size, flags);
1738 fput_light(sock->file, fput_needed);
1762 struct socket *sock;
1767 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1768 if (sock != NULL) {
1769 err = security_socket_setsockopt(sock, level, optname);
1775 sock_setsockopt(sock, level, optname, optval,
1779 sock->ops->setsockopt(sock, level, optname, optval,
1782 fput_light(sock->file, fput_needed);
1796 struct socket *sock;
1798 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1799 if (sock != NULL) {
1800 err = security_socket_getsockopt(sock, level, optname);
1806 sock_getsockopt(sock, level, optname, optval,
1810 sock->ops->getsockopt(sock, level, optname, optval,
1813 fput_light(sock->file, fput_needed);
1825 struct socket *sock;
1827 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1828 if (sock != NULL) {
1829 err = security_socket_shutdown(sock, how);
1831 err = sock->ops->shutdown(sock, how);
1832 fput_light(sock->file, fput_needed);
1852 struct socket *sock;
1870 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1871 if (!sock)
1883 iov = sock_kmalloc(sock->sk, iov_size, GFP_KERNEL);
1908 cmsghdr_from_user_compat_to_kern(&msg_sys, sock->sk, ctl,
1916 ctl_buf = sock_kmalloc(sock->sk, ctl_len, GFP_KERNEL);
1933 if (sock->file->f_flags & O_NONBLOCK)
1935 err = sock_sendmsg(sock, &msg_sys, total_len);
1939 sock_kfree_s(sock->sk, ctl_buf, ctl_len);
1942 sock_kfree_s(sock->sk, iov, iov_size);
1944 fput_light(sock->file, fput_needed);
1949 static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
1980 iov = sock_kmalloc(sock->sk, iov_size, GFP_KERNEL);
2007 if (sock->file->f_flags & O_NONBLOCK)
2009 err = (nosec ? sock_recvmsg_nosec : sock_recvmsg)(sock, msg_sys,
2038 sock_kfree_s(sock->sk, iov, iov_size);
2052 struct socket *sock = sockfd_lookup_light(fd, &err, &fput_needed);
2054 if (!sock)
2057 err = __sys_recvmsg(sock, msg, &msg_sys, flags, 0);
2059 fput_light(sock->file, fput_needed);
2072 struct socket *sock;
2085 sock = sockfd_lookup_light(fd, &err, &fput_needed);
2086 if (!sock)
2089 err = sock_error(sock->sk);
2101 err = __sys_recvmsg(sock, (struct msghdr __user *)compat_entry,
2108 err = __sys_recvmsg(sock, (struct msghdr __user *)entry,
2143 fput_light(sock->file, fput_needed);
2151 * sock is non block and there aren't enough datagrams...
2160 sock->sk->sk_err = -err;
2376 * Initialize sock SLAB cache.
2428 static int do_siocgstamp(struct net *net, struct socket *sock,
2436 err = sock_do_ioctl(net, sock, cmd, (unsigned long)&ktv);
2445 static int do_siocgstampns(struct net *net, struct socket *sock,
2453 err = sock_do_ioctl(net, sock, cmd, (unsigned long)&kts);
2664 static int dev_ifsioc(struct net *net, struct socket *sock,
2674 err = sock_do_ioctl(net, sock, cmd, (unsigned long)uifr);
2790 static int routing_ioctl(struct net *net, struct socket *sock,
2801 if (sock && sock->sk && sock->sk->sk_family == AF_INET6) { /* ipv6 */
2839 ret = sock_do_ioctl(net, sock, cmd, (unsigned long) r);
2861 static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
2865 struct sock *sk = sock->sk;
2895 return routing_ioctl(net, sock, cmd, argp);
2897 return do_siocgstamp(net, sock, cmd, argp);
2899 return do_siocgstampns(net, sock, cmd, argp);
2948 return dev_ifsioc(net, sock, cmd, argp);
2954 return sock_do_ioctl(net, sock, cmd, arg);
2977 struct socket *sock = file->private_data;
2979 struct sock *sk;
2982 sk = sock->sk;
2985 if (sock->ops->compat_ioctl)
2986 ret = sock->ops->compat_ioctl(sock, cmd, arg);
2993 ret = compat_sock_ioctl_trans(file, sock, cmd, arg);
2999 int kernel_bind(struct socket *sock, struct sockaddr *addr, int addrlen)
3001 return sock->ops->bind(sock, addr, addrlen);
3005 int kernel_listen(struct socket *sock, int backlog)
3007 return sock->ops->listen(sock, backlog);
3011 int kernel_accept(struct socket *sock, struct socket **newsock, int flags)
3013 struct sock *sk = sock->sk;
3021 err = sock->ops->accept(sock, *newsock, flags);
3028 (*newsock)->ops = sock->ops;
3036 int kernel_connect(struct socket *sock, struct sockaddr *addr, int addrlen,
3039 return sock->ops->connect(sock, addr, addrlen, flags);
3043 int kernel_getsockname(struct socket *sock, struct sockaddr *addr,
3046 return sock->ops->getname(sock, addr, addrlen, 0);
3050 int kernel_getpeername(struct socket *sock, struct sockaddr *addr,
3053 return sock->ops->getname(sock, addr, addrlen, 1);
3057 int kernel_getsockopt(struct socket *sock, int level, int optname,
3065 err = sock_getsockopt(sock, level, optname, optval, optlen);
3067 err = sock->ops->getsockopt(sock, level, optname, optval,
3074 int kernel_setsockopt(struct socket *sock, int level, int optname,
3082 err = sock_setsockopt(sock, level, optname, optval, optlen);
3084 err = sock->ops->setsockopt(sock, level, optname, optval,
3091 int kernel_sendpage(struct socket *sock, struct page *page, int offset,
3094 sock_update_classid(sock->sk);
3096 if (sock->ops->sendpage)
3097 return sock->ops->sendpage(sock, page, offset, size, flags);
3099 return sock_no_sendpage(sock, page, offset, size, flags);
3103 int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg)
3109 err = sock->ops->ioctl(sock, cmd, arg);
3116 int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how)
3118 return sock->ops->shutdown(sock, how);