arch/um/drivers/vector_user.c
Source file repositories/reference/linux-study-clean/arch/um/drivers/vector_user.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/drivers/vector_user.c- Extension
.c- Size
- 22540 bytes
- Lines
- 942
- Domain
- Architecture Layer
- Bucket
- arch/um
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdbool.hstdio.hunistd.hstdarg.herrno.hstddef.hstring.hsys/ioctl.hnet/if.hlinux/if_tun.harpa/inet.hsys/types.hsys/stat.hfcntl.hsys/socket.hsys/un.hnetinet/ip.hlinux/if_ether.hlinux/if_packet.hsys/wait.hsys/uio.hlinux/virtio_net.hnetdb.hstdlib.hos.hlimits.hum_malloc.hvector_user.h
Detected Declarations
function samefunction create_raw_fdfunction strtofdfunction uml_raw_enable_qdisc_bypassfunction uml_raw_enable_vnet_headersfunction uml_tap_enable_vnet_headersfunction uml_vector_sendmsgfunction uml_vector_recvmsgfunction uml_vector_writevfunction uml_vector_sendmmsgfunction uml_vector_recvmmsgfunction uml_vector_attach_bpffunction uml_vector_detach_bpf
Annotated Snippet
if (next_starts) {
if (parsing_token) {
result->tokens[result->numargs] = arg + pos;
} else {
result->values[result->numargs] = arg + pos;
result->numargs++;
}
next_starts = false;
}
if (*(arg + pos) == '=') {
if (parsing_token)
parsing_token = false;
else
goto cleanup;
next_starts = true;
(*(arg + pos)) = '\0';
}
if (*(arg + pos) == ',') {
parsing_token = true;
next_starts = true;
(*(arg + pos)) = '\0';
}
}
return result;
cleanup:
printk(UM_KERN_ERR "vector_setup - Couldn't parse '%s'\n", arg);
kfree(result);
return NULL;
}
/*
* Socket/FD configuration functions. These return an structure
* of rx and tx descriptors to cover cases where these are not
* the same (f.e. read via raw socket and write via tap).
*/
#define PATH_NET_TUN "/dev/net/tun"
static int create_tap_fd(char *iface)
{
struct ifreq ifr;
int fd = -1;
int err = -ENOMEM, offload;
fd = open(PATH_NET_TUN, O_RDWR);
if (fd < 0) {
printk(UM_KERN_ERR "uml_tap: failed to open tun device\n");
goto tap_fd_cleanup;
}
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_VNET_HDR;
strscpy(ifr.ifr_name, iface);
err = ioctl(fd, TUNSETIFF, (void *) &ifr);
if (err != 0) {
printk(UM_KERN_ERR "uml_tap: failed to select tap interface\n");
goto tap_fd_cleanup;
}
offload = TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6;
ioctl(fd, TUNSETOFFLOAD, offload);
return fd;
tap_fd_cleanup:
if (fd >= 0)
os_close_file(fd);
return err;
}
static int create_raw_fd(char *iface, int flags, int proto)
{
struct ifreq ifr;
int fd = -1;
struct sockaddr_ll sock;
int err = -ENOMEM;
fd = socket(AF_PACKET, SOCK_RAW, flags);
if (fd == -1) {
err = -errno;
goto raw_fd_cleanup;
}
memset(&ifr, 0, sizeof(ifr));
strscpy(ifr.ifr_name, iface);
if (ioctl(fd, SIOCGIFINDEX, (void *) &ifr) < 0) {
err = -errno;
goto raw_fd_cleanup;
}
sock.sll_family = AF_PACKET;
sock.sll_protocol = htons(proto);
Annotation
- Immediate include surface: `stdbool.h`, `stdio.h`, `unistd.h`, `stdarg.h`, `errno.h`, `stddef.h`, `string.h`, `sys/ioctl.h`.
- Detected declarations: `function same`, `function create_raw_fd`, `function strtofd`, `function uml_raw_enable_qdisc_bypass`, `function uml_raw_enable_vnet_headers`, `function uml_tap_enable_vnet_headers`, `function uml_vector_sendmsg`, `function uml_vector_recvmsg`, `function uml_vector_writev`, `function uml_vector_sendmmsg`.
- Atlas domain: Architecture Layer / arch/um.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.