drivers/net/bareudp.c
Source file repositories/reference/linux-study-clean/drivers/net/bareudp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/bareudp.c- Extension
.c- Size
- 21194 bytes
- Lines
- 830
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/etherdevice.hlinux/hash.hnet/dst_metadata.hnet/gro_cells.hnet/rtnetlink.hnet/protocol.hnet/ip6_tunnel.hnet/ip_tunnels.hnet/udp_tunnel.hnet/bareudp.h
Detected Declarations
struct bareudp_netstruct bareudp_confstruct bareudp_devfunction bareudp_udp_encap_recvfunction ipv4_is_multicastfunction bareudp_err_lookupfunction bareudp_initfunction bareudp_uninitfunction bareudp_socket_createfunction bareudp_openfunction bareudp_sock_releasefunction bareudp_stopfunction bareudp_xmit_skbfunction bareudp6_xmit_skbfunction bareudp_proto_validfunction bareudp_xmitfunction bareudp_fill_metadata_dstfunction bareudp_setupfunction bareudp_validatefunction bareudp2infofunction list_for_each_entryfunction bareudp_configurefunction bareudp_link_configfunction bareudp_dellinkfunction bareudp_newlinkfunction bareudp_get_sizefunction bareudp_fill_infofunction bareudp_init_netfunction bareudp_exit_rtnl_netfunction bareudp_init_modulefunction bareudp_cleanup_module
Annotated Snippet
static const struct net_device_ops bareudp_netdev_ops = {
.ndo_init = bareudp_init,
.ndo_uninit = bareudp_uninit,
.ndo_open = bareudp_open,
.ndo_stop = bareudp_stop,
.ndo_start_xmit = bareudp_xmit,
.ndo_fill_metadata_dst = bareudp_fill_metadata_dst,
};
static const struct nla_policy bareudp_policy[IFLA_BAREUDP_MAX + 1] = {
[IFLA_BAREUDP_PORT] = { .type = NLA_U16 },
[IFLA_BAREUDP_ETHERTYPE] = { .type = NLA_U16 },
[IFLA_BAREUDP_SRCPORT_MIN] = { .type = NLA_U16 },
[IFLA_BAREUDP_MULTIPROTO_MODE] = { .type = NLA_FLAG },
};
/* Info for udev, that this is a virtual tunnel endpoint */
static const struct device_type bareudp_type = {
.name = "bareudp",
};
/* Initialize the device structure. */
static void bareudp_setup(struct net_device *dev)
{
dev->netdev_ops = &bareudp_netdev_ops;
dev->needs_free_netdev = true;
SET_NETDEV_DEVTYPE(dev, &bareudp_type);
dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST;
dev->features |= NETIF_F_RXCSUM;
dev->features |= NETIF_F_GSO_SOFTWARE;
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->hard_header_len = 0;
dev->addr_len = 0;
dev->mtu = ETH_DATA_LEN;
dev->min_mtu = IPV4_MIN_MTU;
dev->max_mtu = IP_MAX_MTU - BAREUDP_BASE_HLEN;
dev->type = ARPHRD_NONE;
netif_keep_dst(dev);
dev->priv_flags |= IFF_NO_QUEUE;
dev->lltx = true;
dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
}
static int bareudp_validate(struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack)
{
if (!data) {
NL_SET_ERR_MSG(extack,
"Not enough attributes provided to perform the operation");
return -EINVAL;
}
return 0;
}
static int bareudp2info(struct nlattr *data[], struct bareudp_conf *conf,
struct netlink_ext_ack *extack)
{
memset(conf, 0, sizeof(*conf));
if (!data[IFLA_BAREUDP_PORT]) {
NL_SET_ERR_MSG(extack, "port not specified");
return -EINVAL;
}
if (!data[IFLA_BAREUDP_ETHERTYPE]) {
NL_SET_ERR_MSG(extack, "ethertype not specified");
return -EINVAL;
}
conf->port = nla_get_u16(data[IFLA_BAREUDP_PORT]);
conf->ethertype = nla_get_u16(data[IFLA_BAREUDP_ETHERTYPE]);
if (data[IFLA_BAREUDP_SRCPORT_MIN])
conf->sport_min = nla_get_u16(data[IFLA_BAREUDP_SRCPORT_MIN]);
if (data[IFLA_BAREUDP_MULTIPROTO_MODE])
conf->multi_proto_mode = true;
return 0;
}
static struct bareudp_dev *bareudp_find_dev(struct bareudp_net *bn,
const struct bareudp_conf *conf)
{
struct bareudp_dev *bareudp, *t = NULL;
list_for_each_entry(bareudp, &bn->bareudp_list, next) {
if (conf->port == bareudp->port)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/etherdevice.h`, `linux/hash.h`, `net/dst_metadata.h`, `net/gro_cells.h`, `net/rtnetlink.h`, `net/protocol.h`.
- Detected declarations: `struct bareudp_net`, `struct bareudp_conf`, `struct bareudp_dev`, `function bareudp_udp_encap_recv`, `function ipv4_is_multicast`, `function bareudp_err_lookup`, `function bareudp_init`, `function bareudp_uninit`, `function bareudp_socket_create`, `function bareudp_open`.
- 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.