net/atm/proc.c

Source file repositories/reference/linux-study-clean/net/atm/proc.c

File Facts

System
Linux kernel
Corpus path
net/atm/proc.c
Extension
.c
Size
8027 bytes
Lines
334
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: exported/initcall integration point
Status
integration 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

struct vcc_state {
	int bucket;
	struct sock *sk;
};

static inline int compare_family(struct sock *sk, int family)
{
	return !family || (sk->sk_family == family);
}

static int __vcc_walk(struct sock **sock, int family, int *bucket, loff_t l)
{
	struct sock *sk = *sock;

	if (sk == SEQ_START_TOKEN) {
		for (*bucket = 0; *bucket < VCC_HTABLE_SIZE; ++*bucket) {
			struct hlist_head *head = &vcc_hash[*bucket];

			sk = hlist_empty(head) ? NULL : __sk_head(head);
			if (sk)
				break;
		}
		l--;
	}
try_again:
	for (; sk; sk = sk_next(sk)) {
		l -= compare_family(sk, family);
		if (l < 0)
			goto out;
	}
	if (!sk && ++*bucket < VCC_HTABLE_SIZE) {
		sk = sk_head(&vcc_hash[*bucket]);
		goto try_again;
	}
	sk = SEQ_START_TOKEN;
out:
	*sock = sk;
	return (l < 0);
}

static inline void *vcc_walk(struct seq_file *seq, loff_t l)
{
	struct vcc_state *state = seq->private;
	int family = (uintptr_t)(pde_data(file_inode(seq->file)));

	return __vcc_walk(&state->sk, family, &state->bucket, l) ?
	       state : NULL;
}

static void *vcc_seq_start(struct seq_file *seq, loff_t *pos)
	__acquires(vcc_sklist_lock)
{
	struct vcc_state *state = seq->private;
	loff_t left = *pos;

	read_lock(&vcc_sklist_lock);
	state->sk = SEQ_START_TOKEN;
	return left ? vcc_walk(seq, left) : SEQ_START_TOKEN;
}

static void vcc_seq_stop(struct seq_file *seq, void *v)
	__releases(vcc_sklist_lock)
{
	read_unlock(&vcc_sklist_lock);
}

static void *vcc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
	v = vcc_walk(seq, 1);
	(*pos)++;
	return v;
}

static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc)
{
	static const char *const class_name[] = {
		"off", "UBR", "CBR", "VBR", "ABR"};
	static const char *const aal_name[] = {
		"---",	"1",	"2",	"3/4",	/*  0- 3 */
		"???",	"5",	"???",	"???",	/*  4- 7 */
		"???",	"???",	"???",	"???",	/*  8-11 */
		"???",	"0",	"???",	"???"};	/* 12-15 */

	seq_printf(seq, "%3d %3d %5d %-3s %7d %-5s %7d %-6s",
		   vcc->dev->number, vcc->vpi, vcc->vci,
		   vcc->qos.aal >= ARRAY_SIZE(aal_name) ? "err" :
		   aal_name[vcc->qos.aal], vcc->qos.rxtp.min_pcr,
		   class_name[vcc->qos.rxtp.traffic_class],
		   vcc->qos.txtp.min_pcr,
		   class_name[vcc->qos.txtp.traffic_class]);

Annotation

Implementation Notes