net/core/skmsg.c

Source file repositories/reference/linux-study-clean/net/core/skmsg.c

File Facts

System
Linux kernel
Corpus path
net/core/skmsg.c
Extension
.c
Size
31076 bytes
Lines
1278
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

const struct proto_ops *ops = NULL;
	struct sk_psock *psock;
	struct socket *sock;
	int copied;

	trace_sk_data_ready(sk);

	rcu_read_lock();
	sock = READ_ONCE(sk->sk_socket);
	if (likely(sock))
		ops = READ_ONCE(sock->ops);
	rcu_read_unlock();
	if (!ops || !ops->read_skb)
		return;

	copied = ops->read_skb(sk, sk_psock_verdict_recv);
	if (copied >= 0) {
		rcu_read_lock();
		psock = sk_psock(sk);
		if (psock)
			sk_psock_data_ready(sk, psock);
		rcu_read_unlock();
	}
}

void sk_psock_start_verdict(struct sock *sk, struct sk_psock *psock)
{
	if (psock->saved_data_ready)
		return;

	psock->saved_data_ready = sk->sk_data_ready;
	WRITE_ONCE(sk->sk_data_ready, sk_psock_verdict_data_ready);
	WRITE_ONCE(sk->sk_write_space, sk_psock_write_space);
}

void sk_psock_stop_verdict(struct sock *sk, struct sk_psock *psock)
{
	psock_set_prog(&psock->progs.stream_verdict, NULL);
	psock_set_prog(&psock->progs.skb_verdict, NULL);

	if (!psock->saved_data_ready)
		return;

	WRITE_ONCE(sk->sk_data_ready, psock->saved_data_ready);
	psock->saved_data_ready = NULL;
}

Annotation

Implementation Notes