net/core/pktgen.c
Source file repositories/reference/linux-study-clean/net/core/pktgen.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/pktgen.c- Extension
.c- Size
- 103994 bytes
- Lines
- 4135
- 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.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
linux/sys.hlinux/types.hlinux/minmax.hlinux/module.hlinux/moduleparam.hlinux/kernel.hlinux/mutex.hlinux/sched.hlinux/slab.hlinux/vmalloc.hlinux/unistd.hlinux/string.hlinux/ptrace.hlinux/errno.hlinux/hex.hlinux/ioport.hlinux/interrupt.hlinux/capability.hlinux/hrtimer.hlinux/freezer.hlinux/delay.hlinux/timer.hlinux/list.hlinux/init.hlinux/skbuff.hlinux/netdevice.hlinux/inet.hlinux/inetdevice.hlinux/rtnetlink.hlinux/if_arp.hlinux/if_vlan.hlinux/in.h
Detected Declarations
struct imix_pktstruct flow_statestruct pktgen_devstruct pktgen_hdrstruct pktgen_netstruct pktgen_threadenum pkt_flagsfunction pgctrl_showfunction pgctrl_writefunction pgctrl_openfunction pktgen_if_showfunction hex32_argfunction count_trail_charsfunction num_argfunction strn_lenfunction get_imix_entriesfunction get_labelsfunction pktgen_read_flagfunction pktgen_if_writefunction pktgen_if_openfunction pktgen_thread_showfunction pktgen_thread_writefunction pktgen_thread_openfunction list_for_each_entryfunction pktgen_mark_devicefunction pktgen_change_namefunction list_for_each_entryfunction list_for_each_entryfunction pktgen_device_eventfunction pktgen_setup_devfunction pktgen_setup_injectfunction list_for_each_entryfunction spinfunction set_pkt_overheadfunction f_seenfunction f_pickfunction get_ipsec_safunction set_cur_queue_mapfunction mod_cur_headersfunction fill_imix_distributionfunction pktgen_output_ipsecfunction free_SAsfunction process_ipsecfunction mpls_pushfunction build_tcifunction pktgen_finalize_skbfunction pktgen_clear_countersfunction pktgen_run
Annotated Snippet
module_init(pg_init);
module_exit(pg_cleanup);
MODULE_AUTHOR("Robert Olsson <robert.olsson@its.uu.se>");
MODULE_DESCRIPTION("Packet Generator tool");
MODULE_LICENSE("GPL");
MODULE_VERSION(VERSION);
module_param(pg_count_d, int, 0);
MODULE_PARM_DESC(pg_count_d, "Default number of packets to inject");
module_param(pg_delay_d, int, 0);
MODULE_PARM_DESC(pg_delay_d, "Default delay between packets (nanoseconds)");
module_param(pg_clone_skb_d, int, 0);
MODULE_PARM_DESC(pg_clone_skb_d, "Default number of copies of the same packet");
module_param(debug, int, 0);
MODULE_PARM_DESC(debug, "Enable debugging of pktgen module");
Annotation
- Immediate include surface: `linux/sys.h`, `linux/types.h`, `linux/minmax.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/kernel.h`, `linux/mutex.h`, `linux/sched.h`.
- Detected declarations: `struct imix_pkt`, `struct flow_state`, `struct pktgen_dev`, `struct pktgen_hdr`, `struct pktgen_net`, `struct pktgen_thread`, `enum pkt_flags`, `function pgctrl_show`, `function pgctrl_write`, `function pgctrl_open`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.