net/ipv4/ip_vti.c
Source file repositories/reference/linux-study-clean/net/ipv4/ip_vti.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv4/ip_vti.c- Extension
.c- Size
- 18355 bytes
- Lines
- 745
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/capability.hlinux/module.hlinux/types.hlinux/kernel.hlinux/uaccess.hlinux/skbuff.hlinux/netdevice.hlinux/in.hlinux/tcp.hlinux/udp.hlinux/if_arp.hlinux/init.hlinux/netfilter_ipv4.hlinux/if_ether.hlinux/icmpv6.hnet/sock.hnet/ip.hnet/icmp.hnet/ip_tunnels.hnet/inet_ecn.hnet/xfrm.hnet/net_namespace.hnet/netns/generic.h
Detected Declarations
function vti_inputfunction vti_input_protofunction vti_rcvfunction vti_rcv_protofunction vti_rcv_cbfunction vti_state_checkfunction vti_xmitfunction vti_tunnel_xmitfunction vti4_errfunction vti_tunnel_ctlfunction vti_tunnel_setupfunction vti_tunnel_initfunction vti_fb_tunnel_initfunction vti_rcv_tunnelfunction vti_init_netfunction vti_exit_rtnlfunction vti_tunnel_validatefunction vti_netlink_parmsfunction vti_newlinkfunction vti_changelinkfunction vti_get_sizefunction vti_fill_infofunction vti_initfunction vti_finimodule init vti_init
Annotated Snippet
static const struct net_device_ops vti_netdev_ops = {
.ndo_init = vti_tunnel_init,
.ndo_uninit = ip_tunnel_uninit,
.ndo_start_xmit = vti_tunnel_xmit,
.ndo_siocdevprivate = ip_tunnel_siocdevprivate,
.ndo_change_mtu = ip_tunnel_change_mtu,
.ndo_get_stats64 = dev_get_tstats64,
.ndo_get_iflink = ip_tunnel_get_iflink,
.ndo_tunnel_ctl = vti_tunnel_ctl,
};
static void vti_tunnel_setup(struct net_device *dev)
{
dev->netdev_ops = &vti_netdev_ops;
dev->header_ops = &ip_tunnel_header_ops;
dev->type = ARPHRD_TUNNEL;
ip_tunnel_setup(dev, vti_net_id);
}
static int vti_tunnel_init(struct net_device *dev)
{
struct ip_tunnel *tunnel = netdev_priv(dev);
struct iphdr *iph = &tunnel->parms.iph;
__dev_addr_set(dev, &iph->saddr, 4);
memcpy(dev->broadcast, &iph->daddr, 4);
dev->flags = IFF_NOARP;
dev->addr_len = 4;
dev->lltx = true;
netif_keep_dst(dev);
return ip_tunnel_init(dev);
}
static void __net_init vti_fb_tunnel_init(struct net_device *dev)
{
struct ip_tunnel *tunnel = netdev_priv(dev);
struct iphdr *iph = &tunnel->parms.iph;
iph->version = 4;
iph->protocol = IPPROTO_IPIP;
iph->ihl = 5;
}
static struct xfrm4_protocol vti_esp4_protocol __read_mostly = {
.handler = vti_rcv_proto,
.input_handler = vti_input_proto,
.cb_handler = vti_rcv_cb,
.err_handler = vti4_err,
.priority = 100,
};
static struct xfrm4_protocol vti_ah4_protocol __read_mostly = {
.handler = vti_rcv_proto,
.input_handler = vti_input_proto,
.cb_handler = vti_rcv_cb,
.err_handler = vti4_err,
.priority = 100,
};
static struct xfrm4_protocol vti_ipcomp4_protocol __read_mostly = {
.handler = vti_rcv_proto,
.input_handler = vti_input_proto,
.cb_handler = vti_rcv_cb,
.err_handler = vti4_err,
.priority = 100,
};
#if IS_ENABLED(CONFIG_INET_XFRM_TUNNEL)
static int vti_rcv_tunnel(struct sk_buff *skb)
{
XFRM_SPI_SKB_CB(skb)->family = AF_INET;
XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct iphdr, daddr);
return vti_input(skb, IPPROTO_IPIP, ip_hdr(skb)->saddr, 0, false);
}
static struct xfrm_tunnel vti_ipip_handler __read_mostly = {
.handler = vti_rcv_tunnel,
.cb_handler = vti_rcv_cb,
.err_handler = vti4_err,
.priority = 0,
};
#if IS_ENABLED(CONFIG_IPV6)
static struct xfrm_tunnel vti_ipip6_handler __read_mostly = {
.handler = vti_rcv_tunnel,
.cb_handler = vti_rcv_cb,
.err_handler = vti4_err,
Annotation
- Immediate include surface: `linux/capability.h`, `linux/module.h`, `linux/types.h`, `linux/kernel.h`, `linux/uaccess.h`, `linux/skbuff.h`, `linux/netdevice.h`, `linux/in.h`.
- Detected declarations: `function vti_input`, `function vti_input_proto`, `function vti_rcv`, `function vti_rcv_proto`, `function vti_rcv_cb`, `function vti_state_check`, `function vti_xmit`, `function vti_tunnel_xmit`, `function vti4_err`, `function vti_tunnel_ctl`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
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.