tools/testing/selftests/bpf/progs/bpf_iter_unix.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/bpf_iter_unix.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/bpf_iter_unix.c
Extension
.c
Size
2269 bytes
Lines
91
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if (unix_sk->addr->name->sun_path[0]) {
			BPF_SEQ_PRINTF(seq, " %s", unix_sk->addr->name->sun_path);
		} else {
			/* The name of the abstract UNIX domain socket starts
			 * with '\0' and can contain '\0'.  The null bytes
			 * should be escaped as done in unix_seq_show().
			 */
			__u64 i, len;

			len = unix_sk->addr->len - sizeof(short);

			BPF_SEQ_PRINTF(seq, " @");

			for (i = 1; i < len; i++) {
				/* unix_validate_addr() tests this upper bound. */
				if (i >= sizeof(struct sockaddr_un))
					break;

				BPF_SEQ_PRINTF(seq, "%c",
					       unix_sk->addr->name->sun_path[i] ?:
					       '@');
			}
		}
	}

	BPF_SEQ_PRINTF(seq, "\n");

	/* Test for deadlock. */
	bpf_map_update_elem(&sockmap, &(int){0}, sk, 0);

	return 0;
}

Annotation

Implementation Notes