drivers/net/geneve.c
Source file repositories/reference/linux-study-clean/drivers/net/geneve.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/geneve.c- Extension
.c- Size
- 70604 bytes
- Lines
- 2668
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/ethtool.hlinux/kernel.hlinux/module.hlinux/etherdevice.hlinux/hash.hnet/dst_metadata.hnet/gro_cells.hnet/rtnetlink.hnet/geneve.hnet/gro.hnet/netdev_lock.hnet/protocol.h
Detected Declarations
struct geneve_opt_gro_hintstruct geneve_skb_cbstruct geneve_netstruct geneve_dev_nodestruct geneve_configstruct geneve_devstruct geneve_sockfunction proto_to_idfunction geneve_net_vni_hashfunction vni_to_tunnel_idfunction tunnel_id_to_vnifunction eq_tun_id_and_vnifunction geneve_get_sk_familyfunction geneve_rxfunction geneve_initfunction geneve_uninitfunction geneve_hlenfunction geneve_opt_gro_hint_offfunction geneve_opt_gro_hintfunction geneve_sk_gro_hint_offfunction geneve_opt_gro_hint_validatefunction geneve_opt_gro_hint_validate_csumfunction geneve_post_decap_hintfunction geneve_udp_encap_recvfunction geneve_udp_encap_err_lookupfunction geneve_hdr_matchfunction list_for_each_entryfunction geneve_gro_completefunction __geneve_sock_releasefunction geneve_sock_releasefunction list_for_each_entryfunction geneve_sock_addfunction geneve_openfunction geneve_stopfunction geneve_build_headerfunction geneve_build_gro_hint_optfunction geneve_put_gro_hint_optfunction geneve_build_skbfunction geneve_get_dsfieldfunction geneve_xmit_skbfunction geneve6_xmit_skbfunction geneve_xmitfunction geneve_change_mtufunction geneve_fill_metadata_dstfunction geneve_get_drvinfofunction geneve_offload_rx_portsfunction list_for_each_entryfunction geneve_setup
Annotated Snippet
static const struct net_device_ops geneve_netdev_ops = {
.ndo_init = geneve_init,
.ndo_uninit = geneve_uninit,
.ndo_open = geneve_open,
.ndo_stop = geneve_stop,
.ndo_start_xmit = geneve_xmit,
.ndo_change_mtu = geneve_change_mtu,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
.ndo_fill_metadata_dst = geneve_fill_metadata_dst,
};
static void geneve_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *drvinfo)
{
strscpy(drvinfo->version, GENEVE_NETDEV_VER, sizeof(drvinfo->version));
strscpy(drvinfo->driver, "geneve", sizeof(drvinfo->driver));
}
static const struct ethtool_ops geneve_ethtool_ops = {
.get_drvinfo = geneve_get_drvinfo,
.get_link = ethtool_op_get_link,
};
/* Info for udev, that this is a virtual tunnel endpoint */
static const struct device_type geneve_type = {
.name = "geneve",
};
/* Calls the ndo_udp_tunnel_add of the caller in order to
* supply the listening GENEVE udp ports. Callers are expected
* to implement the ndo_udp_tunnel_add.
*/
static void geneve_offload_rx_ports(struct net_device *dev, bool push)
{
struct net *net = dev_net(dev);
struct geneve_net *gn = net_generic(net, geneve_net_id);
struct geneve_sock *gs;
ASSERT_RTNL();
list_for_each_entry(gs, &gn->sock_list, list) {
if (push) {
udp_tunnel_push_rx_port(dev, gs->sk,
UDP_TUNNEL_TYPE_GENEVE);
} else {
udp_tunnel_drop_rx_port(dev, gs->sk,
UDP_TUNNEL_TYPE_GENEVE);
}
}
}
/* Initialize the device structure. */
static void geneve_setup(struct net_device *dev)
{
ether_setup(dev);
dev->netdev_ops = &geneve_netdev_ops;
dev->ethtool_ops = &geneve_ethtool_ops;
dev->needs_free_netdev = true;
SET_NETDEV_DEVTYPE(dev, &geneve_type);
dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST;
dev->features |= NETIF_F_RXCSUM;
dev->features |= NETIF_F_GSO_SOFTWARE;
/* Partial features are disabled by default. */
dev->hw_features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST;
dev->hw_features |= NETIF_F_RXCSUM;
dev->hw_features |= NETIF_F_GSO_SOFTWARE;
dev->hw_features |= UDP_TUNNEL_PARTIAL_FEATURES;
dev->hw_features |= NETIF_F_GSO_PARTIAL;
dev->hw_enc_features = dev->hw_features;
dev->gso_partial_features = UDP_TUNNEL_PARTIAL_FEATURES;
dev->mangleid_features = NETIF_F_GSO_PARTIAL;
dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
/* MTU range: 68 - (something less than 65535) */
dev->min_mtu = ETH_MIN_MTU;
/* The max_mtu calculation does not take account of GENEVE
* options, to avoid excluding potentially valid
* configurations. This will be further reduced by IPvX hdr size.
*/
dev->max_mtu = IP_MAX_MTU - GENEVE_BASE_HLEN - dev->hard_header_len;
netif_keep_dst(dev);
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE;
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/kernel.h`, `linux/module.h`, `linux/etherdevice.h`, `linux/hash.h`, `net/dst_metadata.h`, `net/gro_cells.h`, `net/rtnetlink.h`.
- Detected declarations: `struct geneve_opt_gro_hint`, `struct geneve_skb_cb`, `struct geneve_net`, `struct geneve_dev_node`, `struct geneve_config`, `struct geneve_dev`, `struct geneve_sock`, `function proto_to_id`, `function geneve_net_vni_hash`, `function vni_to_tunnel_id`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.