net/ethernet/eth.c
Source file repositories/reference/linux-study-clean/net/ethernet/eth.c
File Facts
- System
- Linux kernel
- Corpus path
net/ethernet/eth.c- Extension
.c- Size
- 17199 bytes
- Lines
- 639
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/types.hlinux/kernel.hlinux/string.hlinux/mm.hlinux/socket.hlinux/in.hlinux/inet.hlinux/ip.hlinux/netdevice.hlinux/nvmem-consumer.hlinux/etherdevice.hlinux/skbuff.hlinux/errno.hlinux/init.hlinux/if_ether.hlinux/of_net.hlinux/pci.hlinux/property.hnet/dst.hnet/arp.hnet/sock.hnet/ipv6.hnet/ip.hnet/dsa.hnet/flow_dissector.hnet/gro.hlinux/uaccess.hnet/pkt_sched.h
Detected Declarations
function eth_headerfunction eth_get_headlenfunction eth_type_transfunction eth_header_parsefunction eth_header_cachefunction eth_header_cache_updatefunction eth_header_parse_protocolfunction eth_prepare_mac_addr_changefunction eth_commit_mac_addr_changefunction eth_mac_addrfunction eth_validate_addrfunction ether_setupfunction sizefunction sysfs_format_macfunction list_for_each_entryfunction eth_gro_completefunction eth_offload_initfunction arch_get_platform_mac_addressfunction eth_platform_get_mac_addressfunction eth_platform_get_mac_addressfunction nvmem_get_mac_addressfunction fwnode_get_mac_addrfunction fwnode_get_mac_addressfunction device_get_mac_addressfunction device_get_mac_addressmodule init eth_offload_initexport eth_headerexport eth_get_headlenexport eth_type_transexport eth_header_parseexport eth_header_cacheexport eth_header_cache_updateexport eth_header_parse_protocolexport eth_prepare_mac_addr_changeexport eth_commit_mac_addr_changeexport eth_mac_addrexport eth_validate_addrexport ether_setupexport alloc_etherdev_mqsexport sysfs_format_macexport eth_gro_receiveexport eth_gro_completeexport eth_platform_get_mac_addressexport platform_get_ethdev_addressexport fwnode_get_mac_addressexport device_get_mac_addressexport device_get_ethdev_address
Annotated Snippet
if (compare_ether_header(eh, eh2)) {
NAPI_GRO_CB(p)->same_flow = 0;
continue;
}
}
type = eh->h_proto;
ptype = gro_find_receive_by_type(type);
if (ptype == NULL) {
flush = 1;
goto out;
}
skb_gro_pull(skb, sizeof(*eh));
skb_gro_postpull_rcsum(skb, eh, sizeof(*eh));
pp = indirect_call_gro_receive_inet(ptype->callbacks.gro_receive,
ipv6_gro_receive, inet_gro_receive,
head, skb);
out:
skb_gro_flush_final(skb, pp, flush);
return pp;
}
EXPORT_SYMBOL(eth_gro_receive);
int eth_gro_complete(struct sk_buff *skb, int nhoff)
{
struct ethhdr *eh = (struct ethhdr *)(skb->data + nhoff);
__be16 type = eh->h_proto;
struct packet_offload *ptype;
int err = -ENOSYS;
if (skb->encapsulation)
skb_set_inner_mac_header(skb, nhoff);
ptype = gro_find_complete_by_type(type);
if (ptype != NULL)
err = INDIRECT_CALL_INET(ptype->callbacks.gro_complete,
ipv6_gro_complete, inet_gro_complete,
skb, nhoff + sizeof(*eh));
return err;
}
EXPORT_SYMBOL(eth_gro_complete);
static struct packet_offload eth_packet_offload __read_mostly = {
.type = cpu_to_be16(ETH_P_TEB),
.priority = 10,
.callbacks = {
.gro_receive = eth_gro_receive,
.gro_complete = eth_gro_complete,
},
};
static int __init eth_offload_init(void)
{
dev_add_offload(ð_packet_offload);
return 0;
}
fs_initcall(eth_offload_init);
unsigned char * __weak arch_get_platform_mac_address(void)
{
return NULL;
}
int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr)
{
unsigned char *addr;
int ret;
ret = of_get_mac_address(dev->of_node, mac_addr);
if (!ret)
return 0;
addr = arch_get_platform_mac_address();
if (!addr)
return -ENODEV;
ether_addr_copy(mac_addr, addr);
return 0;
}
EXPORT_SYMBOL(eth_platform_get_mac_address);
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/kernel.h`, `linux/string.h`, `linux/mm.h`, `linux/socket.h`, `linux/in.h`, `linux/inet.h`.
- Detected declarations: `function eth_header`, `function eth_get_headlen`, `function eth_type_trans`, `function eth_header_parse`, `function eth_header_cache`, `function eth_header_cache_update`, `function eth_header_parse_protocol`, `function eth_prepare_mac_addr_change`, `function eth_commit_mac_addr_change`, `function eth_mac_addr`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.