skb collector provides insights into the struct sk_buff kernel data structure, which holds metadata and data for networking packets.
Overview
Theskb collector is one of the most fundamental collectors in Retis. It extracts detailed information from socket buffers (skbs), which are the primary data structure used by the Linux kernel for packet processing.
What Data is Retrieved
Theskb collector retrieves:
- Packet data: Raw packet content (always included)
- VLAN information: Hardware-accelerated VLAN metadata (always included)
- Metadata: Length, hash, priority, and flags (optional)
- Data reference: Clone information, user counts, reference counts (optional)
- GSO information: Generic Segmentation Offload details (optional)
Probe Installation
The
skb collector does not install any probes itself. It only retrieves data when a struct sk_buff * is available in probe arguments.skb collector is enabled and a probe is added (manually, by a profile, or by another collector) on kfree_skb_reason, the skb collector will generate events with data from the skb given as an argument to that function.
Command-Line Options
--skb-sections
Comma-separated list of extra information to collect from skbs.
Control which parts of the skb metadata to retrieve and export in events.Supported values:
meta: Include skb metadata information (len, data_len, hash, etc.)dataref: Include data & refcnt information (cloned, users, data refs, etc.)gso: Include Generic Segmentation Offload (GSO) informationall: All of the above
- Packet section (raw packet data)
- VLAN offloading metadata
eth,arp,ip,tcp,udp,icmp: These are part of the raw packetdev,ns: These are now separate collectors
Event Sections Produced
Theskb collector produces the following event sections:
skb Event Section
- VLAN hardware acceleration: Displays VLAN metadata that’s accelerated (not in packet)
- Metadata: Checksum status, hash, lengths, priority, flags
- Data reference: Clone status, user count, reference counts
- GSO information: Type, flags, fragments, segments, size
packet Event Section
Contains the parsed packet data including:- Layer 2 (Ethernet) information
- Layer 3 (IP/ARP/IPv6) information
- Layer 4 (TCP/UDP/ICMP) information
Usage Examples
Basic Usage
Collect with default skb sections (packet + VLAN):Include Metadata
Collect skb metadata in addition to packet data:Include All Information
Collect all available skb information:Multiple Sections
Select specific sections:With Custom Probes
Add probes to specific functions:With Filtering
Combine with packet filters:Example Output
Here’s an example of output with metadata enabled:- Tracking ID:
#b81253ea5defffff977be5ec6f80 - SKB address:
18446629157470561024 - Interface:
178 (p1_r) - Packet info: ICMP echo request from 172.200.0.2 to 172.200.0.3
- SKB metadata: Checksum status, hash, priority
Integration with Other Collectors
Theskb collector works well with:
skb-tracking
Track packets through the stack:skb-drop
Investigate packet drops:ct (Conntrack)
See connection tracking state:nft (Netfilter)
Trace packets through firewall rules:dev
Include network device information:ns
Track packets across namespaces:Understanding SKB Metadata
Checksum Status
The collector reports checksum information in different formats:csum none: No checksum computedcsum unnecessary: Checksum verified by hardwarecsum partial: Partial checksum (needs completion)csum complete: Full checksum available
Flags
Common flags reported:cloned: SKB has been clonednohdr: No header references
Data References
With--skb-sections dataref:
fclone: Fast clone countusers: Number of users holding referencesdataref: Reference count for data buffer
GSO Information
With--skb-sections gso:
type: GSO type (seeSKBFL_*in kernel’sskbuff.h)flags: GSO flags (seeSKB_GSO_*)frags: Number of fragmentssegs: Number of segmentssize: GSO segment size
Technical Details
Kernel Types
Theskb collector activates when these types appear in probe arguments:
struct sk_buff *
eBPF Implementation
The collector uses eBPF hooks that:- Detect
struct sk_buff *in probe arguments - Read configured sections from a config map
- Extract requested data from the skb structure
- Generate raw event sections for userspace processing
Source Code References
- Collector implementation:
retis/src/collect/collector/skb/skb.rs - eBPF hook:
retis/src/collect/collector/skb/bpf/skb_hook.bpf.c - Event factory:
retis/src/collect/collector/skb/bpf.rs
Best Practices
- Start minimal: Use default sections first, add more only when needed
- Combine with filtering: Large packet captures can be overwhelming
- Use with tracking: Enable
skb-trackingto follow packets through the stack - Consider performance: More sections mean more data extracted and stored
- Match your investigation: Choose sections based on what you’re debugging
Common Use Cases
Debugging Packet Drops
Performance Analysis
Connection Tracking Issues
Namespace Debugging
See Also
- skb-tracking collector - Track packets through the stack
- skb-drop collector - Investigate packet drops
- skb event format - Detailed event format
- packet event format - Packet data format
