io_uring/cmd_net.c

Source file repositories/reference/linux-study-clean/io_uring/cmd_net.c

File Facts

System
Linux kernel
Corpus path
io_uring/cmd_net.c
Extension
.c
Size
5010 bytes
Lines
193
Domain
Kernel Services
Bucket
io_uring
Inferred role
Kernel Services: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.

Dependency Surface

Detected Declarations

Annotated Snippet

skb_queue_walk_safe(q, skb, tmp) {
			/* don't support skbs with payload */
			if (!skb_has_tx_timestamp(skb, sk) || skb->len)
				continue;
			__skb_unlink(skb, q);
			__skb_queue_tail(&list, skb);
		}
	}

	while (1) {
		skb = skb_peek(&list);
		if (!skb)
			break;
		if (!io_process_timestamp_skb(cmd, sk, skb, issue_flags))
			break;
		__skb_dequeue(&list);
		consume_skb(skb);
	}

	if (!unlikely(skb_queue_empty(&list))) {
		scoped_guard(spinlock_irqsave, &q->lock)
			skb_queue_splice(&list, q);
	}
	return -EAGAIN;
}

static int io_uring_cmd_getsockname(struct socket *sock,
				    struct io_uring_cmd *cmd,
				    unsigned int issue_flags)
{
	const struct io_uring_sqe *sqe = cmd->sqe;
	struct sockaddr __user *uaddr;
	unsigned int peer;
	int __user *ulen;

	if (sqe->ioprio || sqe->__pad1 || sqe->len || sqe->rw_flags)
		return -EINVAL;

	uaddr = u64_to_user_ptr(READ_ONCE(sqe->addr));
	ulen = u64_to_user_ptr(READ_ONCE(sqe->addr3));
	peer = READ_ONCE(sqe->optlen);
	if (peer > 1)
		return -EINVAL;
	return do_getsockname(sock, peer, uaddr, ulen);
}

int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags)
{
	struct socket *sock = cmd->file->private_data;

	switch (cmd->cmd_op) {
	case SOCKET_URING_OP_SIOCINQ:
		return io_uring_cmd_get_sock_ioctl(sock, SIOCINQ);
	case SOCKET_URING_OP_SIOCOUTQ:
		return io_uring_cmd_get_sock_ioctl(sock, SIOCOUTQ);
	case SOCKET_URING_OP_GETSOCKOPT:
		return io_uring_cmd_getsockopt(sock, cmd, issue_flags);
	case SOCKET_URING_OP_SETSOCKOPT:
		return io_uring_cmd_setsockopt(sock, cmd, issue_flags);
	case SOCKET_URING_OP_TX_TIMESTAMP:
		return io_uring_cmd_timestamp(sock, cmd, issue_flags);
	case SOCKET_URING_OP_GETSOCKNAME:
		return io_uring_cmd_getsockname(sock, cmd, issue_flags);
	default:
		return -EOPNOTSUPP;
	}
}
EXPORT_SYMBOL_GPL(io_uring_cmd_sock);

Annotation

Implementation Notes