Lines Matching full:socket

2  * net/tipc/socket.c: TIPC socket API
43 #define SS_LISTENING -1 /* socket is listening */
44 #define SS_READY -2 /* socket is connectionless */
77 * Revised TIPC socket locking policy:
79 * Most socket operations take the standard socket lock when they start
81 * this lock grants the owner exclusive access to the fields of the socket
82 * data structures, with the exception of the backlog queue. A few socket
83 * operations can be done without taking the socket lock because they only
84 * read socket information that never changes during the life of the socket.
86 * Socket operations may acquire the lock for the associated TIPC port if they
88 * both the socket lock and the port lock it must take the socket lock first
91 * The dispatcher handling incoming messages cannot grab the socket lock in
93 * Instead, it checks to see if the socket lock is currently owned by someone,
94 * and either handles the message itself or adds it to the socket's backlog
96 * owning the socket lock releases it.
98 * NOTE: Releasing the socket lock while an operation is sleeping overcomes
99 * the problem of a blocked socket operation preventing any other operations
101 * multiple threads trying to send (or receive) on the same socket, as these
107 * NOTE: Releasing the socket lock while an operation is sleeping also ensures
111 * NOTE: This code assumes that certain fields of a port/socket pair are
113 * the socket lock and/or port lock, and do not need to be re-read even
115 * - socket type
116 * - pointer to socket sk structure (aka tipc_sock structure)
122 * advance_rx_queue - discard first buffer in socket receive queue
124 * Caller must hold socket lock
134 * discard_rx_queue - discard all buffers in socket receive queue
136 * Caller must hold socket lock
150 * reject_rx_queue - reject all buffers in socket receive queue
152 * Caller must hold socket lock
166 * tipc_create - create a TIPC socket
168 * @sock: pre-allocated socket structure
172 * This routine creates additional data structures used by the TIPC socket,
178 static int tipc_create(struct net *net, struct socket *sock, int protocol, in tipc_create()
209 /* Allocate socket's protocol area */ in tipc_create()
215 /* Allocate TIPC port for socket to use */ in tipc_create()
224 /* Finish initializing socket data structures */ in tipc_create()
246 * release - destroy a TIPC socket
247 * @sock: socket to destroy
249 * This routine cleans up any messages that are still queued on the socket.
250 * For DGRAM and RDM socket types, all queued messages are rejected.
251 * For SEQPACKET and STREAM socket types, the first message is rejected
252 * and any others are discarded. (If the first message on a STREAM socket
262 static int release(struct socket *sock) in release()
270 * Exit if socket isn't fully initialized (occurs when a failed accept() in release()
271 * releases a pre-allocated child socket that was never used) in release()
325 * bind - associate or disassocate TIPC name(s) with a socket
326 * @sock: socket structure
327 * @uaddr: socket address describing name(s) and desired operation
328 * @uaddr_len: size of socket address data structure
332 * (i.e. a socket address length of 0) unbinds all names from the socket.
336 * NOTE: This routine doesn't need to take the socket lock since it doesn't
337 * access any non-constant socket information.
340 static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len) in bind()
364 * get_name - get port ID of socket or peer socket
365 * @sock: socket structure
366 * @uaddr: area for returned socket address
367 * @uaddr_len: area for returned length of socket address
372 * NOTE: This routine doesn't need to take the socket lock since it only
373 * accesses socket information that is unchanging (or which changes in
377 static int get_name(struct socket *sock, struct sockaddr *uaddr, in get_name()
406 * @file: file structure associated with the socket
407 * @sock: socket for which to calculate the poll bits
413 * It appears that the usual socket locking mechanisms are not useful here
420 * socket state flags set
445 static unsigned int poll(struct file *file, struct socket *sock, in poll()
506 * @iocb: if NULL, indicates that socket lock is already held
507 * @sock: socket structure
519 static int send_msg(struct kiocb *iocb, struct socket *sock, in send_msg()
622 * @iocb: if NULL, indicates that socket lock is already held
623 * @sock: socket structure
632 static int send_packet(struct kiocb *iocb, struct socket *sock, in send_packet()
686 * @sock: socket structure
696 static int send_stream(struct kiocb *iocb, struct socket *sock, in send_stream()
791 * @sock: socket structure
797 static int auto_connect(struct socket *sock, struct tipc_msg *msg) in auto_connect()
924 static int recv_msg(struct kiocb *iocb, struct socket *sock, in recv_msg()
1047 static int recv_stream(struct kiocb *iocb, struct socket *sock, in recv_stream()
1204 * @sk: socket
1208 * disconnect indication for a connected socket.
1210 * Called with socket lock already taken; port lock may also be taken.
1217 struct socket *sock = sk->sk_socket; in filter_rcv()
1221 /* Reject message if it is wrong sort of message for socket */ in filter_rcv()
1285 * @sk: socket
1288 * Caller must hold socket lock, but not port lock.
1319 * Process message if socket is unlocked; otherwise add to backlog queue in dispatch()
1356 * @sock: socket structure
1357 * @dest: socket address for destination port
1358 * @destlen: size of socket address data structure
1359 * @flags: file-related flags associated with socket
1364 static int connect(struct socket *sock, struct sockaddr *dest, int destlen, in connect()
1391 /* Issue Posix-compliant error code if socket is in the wrong state */ in connect()
1470 * listen - allow socket to listen for incoming connections
1471 * @sock: socket structure
1477 static int listen(struct socket *sock, int len) in listen()
1497 * @sock: listening socket
1498 * @newsock: new socket that is to be connected
1499 * @flags: file-related flags associated with socket
1504 static int accept(struct socket *sock, struct socket *new_sock, int flags) in accept()
1543 * Reject any stray messages received by new socket in accept()
1544 * before the socket lock was taken (very, very unlikely) in accept()
1549 /* Connect new socket to it's peer */ in accept()
1564 * Respond to 'SYN+' by queuing it on new socket. in accept()
1584 * shutdown - shutdown socket connection
1585 * @sock: socket structure
1588 * Terminates connection (if necessary), then purges socket's receive queue.
1593 static int shutdown(struct socket *sock, int how) in shutdown()
1647 * setsockopt - set socket option
1648 * @sock: socket structure
1660 static int setsockopt(struct socket *sock, in setsockopt()
1707 * getsockopt - get socket option
1708 * @sock: socket structure
1720 static int getsockopt(struct socket *sock, in getsockopt()
1857 * tipc_socket_init - initialize TIPC socket interface
1873 err("Failed to register TIPC socket type\n"); in tipc_socket_init()
1884 * tipc_socket_stop - stop TIPC socket interface