drivers/net/vxlan/vxlan_core.c
Source file repositories/reference/linux-study-clean/drivers/net/vxlan/vxlan_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/vxlan/vxlan_core.c- Extension
.c- Size
- 129900 bytes
- Lines
- 5027
- 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/kernel.hlinux/module.hlinux/errno.hlinux/slab.hlinux/udp.hlinux/igmp.hlinux/if_ether.hlinux/ethtool.hlinux/rhashtable.hnet/arp.hnet/ndisc.hnet/gro.hnet/ip.hnet/icmp.hnet/rtnetlink.hnet/inet_ecn.hnet/net_namespace.hnet/netns/generic.hnet/netdev_lock.hnet/tun_proto.hnet/vxlan.hnet/nexthop.hnet/ip6_tunnel.hnet/ip6_checksum.hvxlan_private.h
Detected Declarations
struct vxlan_fdb_flush_descfunction vxlan_collect_metadatafunction bindingfunction hlist_for_each_entry_rcufunction hlist_for_each_entry_rcufunction vxlan_fdb_infofunction vxlan_nlmsg_sizefunction __vxlan_fdb_notifyfunction vxlan_fdb_switchdev_notifier_infofunction vxlan_fdb_switchdev_call_notifiersfunction vxlan_fdb_notifyfunction vxlan_ip_missfunction vxlan_fdb_missfunction list_for_each_entryfunction vxlan_fdb_find_ucfunction vxlan_fdb_notify_onefunction vxlan_fdb_replayfunction vxlan_fdb_clear_offloadfunction vxlan_fdb_replacefunction vxlan_fdb_appendfunction vxlan_parse_gpe_protofunction list_for_each_entryfunction vxlan_gro_completefunction vxlan_gpe_gro_completefunction vxlan_fdb_nh_updatefunction vxlan_fdb_createfunction __vxlan_fdb_freefunction list_for_each_entry_safefunction vxlan_fdb_freefunction vxlan_fdb_destroyfunction vxlan_dst_freefunction vxlan_fdb_update_existingfunction is_zero_ether_addrfunction vxlan_fdb_update_createfunction vxlan_fdb_updatefunction vxlan_fdb_dst_destroyfunction vxlan_fdb_parsefunction vxlan_fdb_addfunction __vxlan_fdb_deletefunction vxlan_fdb_deletefunction vxlan_fdb_dumpfunction list_for_each_entry_rcufunction vxlan_fdb_getfunction vxlan_snoopfunction __vxlan_sock_release_prepfunction vxlan_sock_releasefunction vxlan_remcsumfunction vxlan_parse_gbp_hdr
Annotated Snippet
static const struct net_device_ops vxlan_netdev_ether_ops = {
.ndo_init = vxlan_init,
.ndo_uninit = vxlan_uninit,
.ndo_open = vxlan_open,
.ndo_stop = vxlan_stop,
.ndo_start_xmit = vxlan_xmit,
.ndo_set_rx_mode = vxlan_set_multicast_list,
.ndo_change_mtu = vxlan_change_mtu,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
.ndo_fdb_add = vxlan_fdb_add,
.ndo_fdb_del = vxlan_fdb_delete,
.ndo_fdb_del_bulk = vxlan_fdb_delete_bulk,
.ndo_fdb_dump = vxlan_fdb_dump,
.ndo_fdb_get = vxlan_fdb_get,
.ndo_mdb_add = vxlan_mdb_add,
.ndo_mdb_del = vxlan_mdb_del,
.ndo_mdb_del_bulk = vxlan_mdb_del_bulk,
.ndo_mdb_dump = vxlan_mdb_dump,
.ndo_mdb_get = vxlan_mdb_get,
.ndo_fill_metadata_dst = vxlan_fill_metadata_dst,
};
static const struct net_device_ops vxlan_netdev_raw_ops = {
.ndo_init = vxlan_init,
.ndo_uninit = vxlan_uninit,
.ndo_open = vxlan_open,
.ndo_stop = vxlan_stop,
.ndo_start_xmit = vxlan_xmit,
.ndo_change_mtu = vxlan_change_mtu,
.ndo_fill_metadata_dst = vxlan_fill_metadata_dst,
};
/* Info for udev, that this is a virtual tunnel endpoint */
static const struct device_type vxlan_type = {
.name = "vxlan",
};
/* Calls the ndo_udp_tunnel_add of the caller in order to
* supply the listening VXLAN udp ports. Callers are expected
* to implement the ndo_udp_tunnel_add.
*/
static void vxlan_offload_rx_ports(struct net_device *dev, bool push)
{
struct vxlan_sock *vs;
struct net *net = dev_net(dev);
struct vxlan_net *vn = net_generic(net, vxlan_net_id);
unsigned int i;
ASSERT_RTNL();
for (i = 0; i < PORT_HASH_SIZE; ++i) {
hlist_for_each_entry(vs, &vn->sock_list[i], hlist) {
unsigned short type;
if (vs->flags & VXLAN_F_GPE)
type = UDP_TUNNEL_TYPE_VXLAN_GPE;
else
type = UDP_TUNNEL_TYPE_VXLAN;
if (push)
udp_tunnel_push_rx_port(dev, vs->sk, type);
else
udp_tunnel_drop_rx_port(dev, vs->sk, type);
}
}
}
/* Initialize the device structure. */
static void vxlan_setup(struct net_device *dev)
{
struct vxlan_dev *vxlan = netdev_priv(dev);
eth_hw_addr_random(dev);
ether_setup(dev);
dev->needs_free_netdev = true;
SET_NETDEV_DEVTYPE(dev, &vxlan_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->vlan_features = dev->features;
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;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/errno.h`, `linux/slab.h`, `linux/udp.h`, `linux/igmp.h`, `linux/if_ether.h`, `linux/ethtool.h`.
- Detected declarations: `struct vxlan_fdb_flush_desc`, `function vxlan_collect_metadata`, `function binding`, `function hlist_for_each_entry_rcu`, `function hlist_for_each_entry_rcu`, `function vxlan_fdb_info`, `function vxlan_nlmsg_size`, `function __vxlan_fdb_notify`, `function vxlan_fdb_switchdev_notifier_info`, `function vxlan_fdb_switchdev_call_notifiers`.
- 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.