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.

Dependency Surface

Detected Declarations

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

Implementation Notes