samples/bpf/tc_l2_redirect_user.c
Source file repositories/reference/linux-study-clean/samples/bpf/tc_l2_redirect_user.c
File Facts
- System
- Linux kernel
- Corpus path
samples/bpf/tc_l2_redirect_user.c- Extension
.c- Size
- 1345 bytes
- Lines
- 71
- Domain
- Support Tooling And Documentation
- Bucket
- samples
- 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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
linux/unistd.hlinux/bpf.hstdlib.hstdio.hunistd.hstring.herrno.hbpf/bpf.h
Detected Declarations
function usagefunction main
Annotated Snippet
switch (opt) {
/* General args */
case 'U':
pinned_file = optarg;
break;
case 'i':
ifindex = atoi(optarg);
break;
default:
usage();
goto out;
}
}
if (ifindex < 0 || !pinned_file) {
usage();
goto out;
}
array_fd = bpf_obj_get(pinned_file);
if (array_fd < 0) {
fprintf(stderr, "bpf_obj_get(%s): %s(%d)\n",
pinned_file, strerror(errno), errno);
goto out;
}
/* bpf_tunnel_key.remote_ipv4 expects host byte orders */
ret = bpf_map_update_elem(array_fd, &array_key, &ifindex, 0);
if (ret) {
perror("bpf_map_update_elem");
goto out;
}
out:
if (array_fd != -1)
close(array_fd);
return ret;
}
Annotation
- Immediate include surface: `linux/unistd.h`, `linux/bpf.h`, `stdlib.h`, `stdio.h`, `unistd.h`, `string.h`, `errno.h`, `bpf/bpf.h`.
- Detected declarations: `function usage`, `function main`.
- Atlas domain: Support Tooling And Documentation / samples.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.