net/ipv6/ip6_vti.c
Source file repositories/reference/linux-study-clean/net/ipv6/ip6_vti.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/ip6_vti.c- Extension
.c- Size
- 32278 bytes
- Lines
- 1327
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/capability.hlinux/errno.hlinux/types.hlinux/sockios.hlinux/icmp.hlinux/if.hlinux/in.hlinux/ip.hlinux/net.hlinux/in6.hlinux/netdevice.hlinux/if_arp.hlinux/icmpv6.hlinux/init.hlinux/route.hlinux/rtnetlink.hlinux/netfilter_ipv6.hlinux/slab.hlinux/hash.hlinux/uaccess.hlinux/atomic.hnet/icmp.hnet/ip.hnet/ip_tunnels.hnet/ipv6.hnet/ip6_route.hnet/addrconf.hnet/ip6_tunnel.hnet/xfrm.hnet/net_namespace.hnet/netns/generic.h
Detected Declarations
struct vti6_netfunction Copyrightfunction vti6_tnl_lookupfunction for_each_vti6_tunnel_rcufunction vti6_tnl_bucketfunction vti6_tnl_linkfunction vti6_tnl_unlinkfunction vti6_tnl_create2function vti6_locatefunction vti6_dev_uninitfunction vti6_input_protofunction vti6_rcvfunction vti6_rcv_cbfunction vti6_addr_conflictfunction vti6_state_checkfunction vti6_xmitfunction vti6_tnl_xmitfunction vti6_errfunction vti6_link_configfunction vti6_tnl_changefunction vti6_updatefunction vti6_parm_from_userfunction vti6_parm_to_userfunction vti6_siocdevprivatefunction vti6_dev_setupfunction vti6_dev_init_genfunction vti6_dev_initfunction vti6_fb_tnl_dev_initfunction vti6_validatefunction vti6_netlink_parmsfunction vti6_newlinkfunction vti6_dellinkfunction vti6_changelinkfunction vti6_get_sizefunction vti6_fill_infofunction vti6_exit_rtnl_netfunction vti6_init_netfunction vti6_rcv_tunnelfunction vti6_tunnel_initfunction vti6_tunnel_cleanupmodule init vti6_tunnel_init
Annotated Snippet
static const struct net_device_ops vti6_netdev_ops = {
.ndo_init = vti6_dev_init,
.ndo_uninit = vti6_dev_uninit,
.ndo_start_xmit = vti6_tnl_xmit,
.ndo_siocdevprivate = vti6_siocdevprivate,
.ndo_get_iflink = ip6_tnl_get_iflink,
};
/**
* vti6_dev_setup - setup virtual tunnel device
* @dev: virtual device associated with tunnel
*
* Description:
* Initialize function pointers and device parameters
**/
static void vti6_dev_setup(struct net_device *dev)
{
dev->netdev_ops = &vti6_netdev_ops;
dev->header_ops = &ip_tunnel_header_ops;
dev->needs_free_netdev = true;
dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
dev->type = ARPHRD_TUNNEL6;
dev->min_mtu = IPV4_MIN_MTU;
dev->max_mtu = IP_MAX_MTU - sizeof(struct ipv6hdr);
dev->flags |= IFF_NOARP;
dev->addr_len = sizeof(struct in6_addr);
netif_keep_dst(dev);
/* This perm addr will be used as interface identifier by IPv6 */
dev->addr_assign_type = NET_ADDR_RANDOM;
eth_random_addr(dev->perm_addr);
}
/**
* vti6_dev_init_gen - general initializer for all tunnel devices
* @dev: virtual device associated with tunnel
**/
static inline int vti6_dev_init_gen(struct net_device *dev)
{
struct ip6_tnl *t = netdev_priv(dev);
t->dev = dev;
netdev_hold(dev, &t->dev_tracker, GFP_KERNEL);
netdev_lockdep_set_classes(dev);
return 0;
}
/**
* vti6_dev_init - initializer for all non fallback tunnel devices
* @dev: virtual device associated with tunnel
**/
static int vti6_dev_init(struct net_device *dev)
{
struct ip6_tnl *t = netdev_priv(dev);
int err = vti6_dev_init_gen(dev);
if (err)
return err;
vti6_link_config(t, true);
return 0;
}
/**
* vti6_fb_tnl_dev_init - initializer for fallback tunnel device
* @dev: fallback device
*
* Return: 0
**/
static int __net_init vti6_fb_tnl_dev_init(struct net_device *dev)
{
struct ip6_tnl *t = netdev_priv(dev);
struct net *net = dev_net(dev);
struct vti6_net *ip6n = net_generic(net, vti6_net_id);
t->net = net;
t->parms.proto = IPPROTO_IPV6;
rcu_assign_pointer(ip6n->tnls_wc[0], t);
return 0;
}
static int vti6_validate(struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack)
{
return 0;
}
static void vti6_netlink_parms(struct nlattr *data[],
struct __ip6_tnl_parm *parms)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/capability.h`, `linux/errno.h`, `linux/types.h`, `linux/sockios.h`, `linux/icmp.h`, `linux/if.h`, `linux/in.h`.
- Detected declarations: `struct vti6_net`, `function Copyright`, `function vti6_tnl_lookup`, `function for_each_vti6_tunnel_rcu`, `function vti6_tnl_bucket`, `function vti6_tnl_link`, `function vti6_tnl_unlink`, `function vti6_tnl_create2`, `function vti6_locate`, `function vti6_dev_uninit`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.