net/core/gro.c
Source file repositories/reference/linux-study-clean/net/core/gro.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/gro.c- Extension
.c- Size
- 20965 bytes
- Lines
- 848
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/psp.hnet/gro.hnet/dst_metadata.hnet/busy_poll.htrace/events/net.hlinux/skbuff_ref.h
Detected Declarations
function handlersfunction dev_add_offloadfunction list_for_each_entryfunction dev_add_offloadfunction skb_gro_receivefunction skb_gro_receive_listfunction gro_completefunction __gro_flush_chainfunction list_for_each_entry_safe_reversefunction __gro_flushfunction gro_list_prepare_tc_extfunction gro_list_preparefunction list_for_each_entryfunction skb_gro_reset_offsetfunction gro_pull_from_frag0function gro_try_pull_from_frag0function gro_flush_oldestfunction dev_gro_receivefunction list_for_each_entry_rcufunction list_for_each_entry_rcufunction gro_skb_finishfunction gro_receive_skbfunction napi_reuse_skbfunction napi_frags_finishfunction napi_gro_fragsfunction napi_gro_fragsfunction __skb_gro_checksum_completefunction gro_initfunction gro_cleanupexport dev_add_offloadexport dev_remove_offloadexport __gro_flushexport gro_find_receive_by_typeexport gro_find_complete_by_typeexport gro_receive_skbexport napi_get_fragsexport napi_gro_fragsexport __skb_gro_checksum_complete
Annotated Snippet
if (po == po1) {
list_del_rcu(&po->list);
goto out;
}
}
pr_warn("dev_remove_offload: %p not found\n", po);
out:
spin_unlock(&offload_lock);
}
/**
* dev_remove_offload - remove packet offload handler
* @po: packet offload declaration
*
* Remove a packet offload handler that was previously added to the kernel
* offload handlers by dev_add_offload(). The passed &offload_type is
* removed from the kernel lists and can be freed or reused once this
* function returns.
*
* This call sleeps to guarantee that no CPU is looking at the packet
* type after return.
*/
void dev_remove_offload(struct packet_offload *po)
{
__dev_remove_offload(po);
synchronize_net();
}
EXPORT_SYMBOL(dev_remove_offload);
int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)
{
struct skb_shared_info *pinfo, *skbinfo = skb_shinfo(skb);
unsigned int offset = skb_gro_offset(skb);
unsigned int headlen = skb_headlen(skb);
unsigned int len = skb_gro_len(skb);
unsigned int delta_truesize;
unsigned int new_truesize;
struct sk_buff *lp;
int segs;
/* Do not splice page pool based packets w/ non-page pool
* packets. This can result in reference count issues as page
* pool pages will not decrement the reference count and will
* instead be immediately returned to the pool or have frag
* count decremented.
*/
if (p->pp_recycle != skb->pp_recycle)
return -ETOOMANYREFS;
if (skb_zcopy(p) || skb_zcopy(skb))
return -ETOOMANYREFS;
if (unlikely(p->len + len >= netif_get_gro_max_size(p->dev, p) ||
NAPI_GRO_CB(skb)->flush))
return -E2BIG;
if (unlikely(p->len + len >= GRO_LEGACY_MAX_SIZE)) {
if (NAPI_GRO_CB(skb)->proto != IPPROTO_TCP ||
p->encapsulation)
return -E2BIG;
}
segs = NAPI_GRO_CB(skb)->count;
lp = NAPI_GRO_CB(p)->last;
pinfo = skb_shinfo(lp);
if (headlen <= offset) {
skb_frag_t *frag;
skb_frag_t *frag2;
int i = skbinfo->nr_frags;
int nr_frags = pinfo->nr_frags + i;
if (nr_frags > MAX_SKB_FRAGS)
goto merge;
offset -= headlen;
pinfo->nr_frags = nr_frags;
skbinfo->nr_frags = 0;
frag = pinfo->frags + nr_frags;
frag2 = skbinfo->frags + i;
do {
*--frag = *--frag2;
} while (--i);
skb_frag_off_add(frag, offset);
skb_frag_size_sub(frag, offset);
Annotation
- Immediate include surface: `net/psp.h`, `net/gro.h`, `net/dst_metadata.h`, `net/busy_poll.h`, `trace/events/net.h`, `linux/skbuff_ref.h`.
- Detected declarations: `function handlers`, `function dev_add_offload`, `function list_for_each_entry`, `function dev_add_offload`, `function skb_gro_receive`, `function skb_gro_receive_list`, `function gro_complete`, `function __gro_flush_chain`, `function list_for_each_entry_safe_reverse`, `function __gro_flush`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.