drivers/net/ipvlan/ipvlan_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ipvlan/ipvlan_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ipvlan/ipvlan_main.c- Extension
.c- Size
- 29364 bytes
- Lines
- 1107
- 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.hnet/netdev_lock.hipvlan.h
Detected Declarations
function ipvlan_set_port_modefunction list_for_each_entryfunction ipvlan_port_createfunction ipvlan_port_destroyfunction ipvlan_initfunction ipvlan_uninitfunction ipvlan_openfunction ipvlan_stopfunction ipvlan_start_xmitfunction ipvlan_fix_featuresfunction ipvlan_change_rx_flagsfunction ipvlan_set_multicast_mac_filterfunction ipvlan_get_stats64function for_each_possible_cpufunction ipvlan_vlan_rx_add_vidfunction ipvlan_vlan_rx_kill_vidfunction ipvlan_get_iflinkfunction ipvlan_hard_headerfunction ipvlan_adjust_mtufunction netif_is_ipvlanfunction ipvlan_ethtool_get_link_ksettingsfunction ipvlan_ethtool_get_drvinfofunction ipvlan_ethtool_get_msglevelfunction ipvlan_ethtool_set_msglevelfunction ipvlan_nl_changelinkfunction ipvlan_nl_getsizefunction ipvlan_nl_validatefunction ipvlan_nl_fillinfofunction ipvlan_link_newfunction ipvlan_link_deletefunction ipvlan_link_setupfunction ipvlan_link_registerfunction ipvlan_device_eventfunction list_for_each_entryfunction list_for_each_entryfunction list_for_each_entryfunction ipvlan_add_addrfunction ipvlan_del_addrfunction ipvlan_is_valid_devfunction ipvlan_add_addr6function ipvlan_del_addr6function ipvlan_addr6_eventfunction ipvlan_addr6_validator_eventfunction ipvlan_add_addr4function ipvlan_del_addr4function ipvlan_addr4_eventfunction ipvlan_addr4_validator_eventfunction ipvlan_init_module
Annotated Snippet
static const struct net_device_ops ipvlan_netdev_ops = {
.ndo_init = ipvlan_init,
.ndo_uninit = ipvlan_uninit,
.ndo_open = ipvlan_open,
.ndo_stop = ipvlan_stop,
.ndo_start_xmit = ipvlan_start_xmit,
.ndo_fix_features = ipvlan_fix_features,
.ndo_change_rx_flags = ipvlan_change_rx_flags,
.ndo_set_rx_mode = ipvlan_set_multicast_mac_filter,
.ndo_get_stats64 = ipvlan_get_stats64,
.ndo_vlan_rx_add_vid = ipvlan_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = ipvlan_vlan_rx_kill_vid,
.ndo_get_iflink = ipvlan_get_iflink,
};
static int ipvlan_hard_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type, const void *daddr,
const void *saddr, unsigned len)
{
const struct ipvl_dev *ipvlan = netdev_priv(dev);
struct net_device *phy_dev = ipvlan->phy_dev;
/* TODO Probably use a different field than dev_addr so that the
* mac-address on the virtual device is portable and can be carried
* while the packets use the mac-addr on the physical device.
*/
return dev_hard_header(skb, phy_dev, type, daddr,
saddr ? : phy_dev->dev_addr, len);
}
static const struct header_ops ipvlan_header_ops = {
.create = ipvlan_hard_header,
.parse = eth_header_parse,
.cache = eth_header_cache,
.cache_update = eth_header_cache_update,
.parse_protocol = eth_header_parse_protocol,
};
static void ipvlan_adjust_mtu(struct ipvl_dev *ipvlan, struct net_device *dev)
{
ipvlan->dev->mtu = dev->mtu;
}
static bool netif_is_ipvlan(const struct net_device *dev)
{
/* both ipvlan and ipvtap devices use the same netdev_ops */
return dev->netdev_ops == &ipvlan_netdev_ops;
}
static int ipvlan_ethtool_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{
const struct ipvl_dev *ipvlan = netdev_priv(dev);
return __ethtool_get_link_ksettings(ipvlan->phy_dev, cmd);
}
static void ipvlan_ethtool_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *drvinfo)
{
strscpy(drvinfo->driver, IPVLAN_DRV, sizeof(drvinfo->driver));
strscpy(drvinfo->version, IPV_DRV_VER, sizeof(drvinfo->version));
}
static u32 ipvlan_ethtool_get_msglevel(struct net_device *dev)
{
const struct ipvl_dev *ipvlan = netdev_priv(dev);
return ipvlan->msg_enable;
}
static void ipvlan_ethtool_set_msglevel(struct net_device *dev, u32 value)
{
struct ipvl_dev *ipvlan = netdev_priv(dev);
ipvlan->msg_enable = value;
}
static const struct ethtool_ops ipvlan_ethtool_ops = {
.get_link = ethtool_op_get_link,
.get_link_ksettings = ipvlan_ethtool_get_link_ksettings,
.get_drvinfo = ipvlan_ethtool_get_drvinfo,
.get_msglevel = ipvlan_ethtool_get_msglevel,
.set_msglevel = ipvlan_ethtool_set_msglevel,
};
static int ipvlan_nl_changelink(struct net_device *dev,
struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack)
{
Annotation
- Immediate include surface: `linux/ethtool.h`, `net/netdev_lock.h`, `ipvlan.h`.
- Detected declarations: `function ipvlan_set_port_mode`, `function list_for_each_entry`, `function ipvlan_port_create`, `function ipvlan_port_destroy`, `function ipvlan_init`, `function ipvlan_uninit`, `function ipvlan_open`, `function ipvlan_stop`, `function ipvlan_start_xmit`, `function ipvlan_fix_features`.
- 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.