Пример #1
0
int ip_tunnel_init(struct net_device *dev)
{
	struct ip_tunnel *tunnel = netdev_priv(dev);
	struct iphdr *iph = &tunnel->parms.iph;
	int err;

	dev->destructor	= ip_tunnel_dev_free;
	dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
	if (!dev->tstats)
		return -ENOMEM;

	tunnel->dst_cache = alloc_percpu(struct ip_tunnel_dst);
	if (!tunnel->dst_cache) {
		free_percpu(dev->tstats);
		return -ENOMEM;
	}

	err = gro_cells_init(&tunnel->gro_cells, dev);
	if (err) {
		free_percpu(tunnel->dst_cache);
		free_percpu(dev->tstats);
		return err;
	}

	tunnel->dev = dev;
	tunnel->net = dev_net(dev);
	strcpy(tunnel->parms.name, dev->name);
	iph->version		= 4;
	iph->ihl		= 5;

	return 0;
}
Пример #2
0
int ip_tunnel_init(struct net_device *dev)
{
    struct ip_tunnel *tunnel = netdev_priv(dev);
    struct iphdr *iph = &tunnel->parms.iph;
    int i, err;

    dev->destructor	= ip_tunnel_dev_free;
    dev->tstats = alloc_percpu(struct pcpu_sw_netstats);
    if (!dev->tstats)
        return -ENOMEM;

    for_each_possible_cpu(i) {
        struct pcpu_sw_netstats *ipt_stats;
        ipt_stats = per_cpu_ptr(dev->tstats, i);
        u64_stats_init(&ipt_stats->syncp);
    }

    tunnel->dst_cache = alloc_percpu(struct ip_tunnel_dst);
    if (!tunnel->dst_cache) {
        free_percpu(dev->tstats);
        return -ENOMEM;
    }

    err = gro_cells_init(&tunnel->gro_cells, dev);
    if (err) {
        free_percpu(tunnel->dst_cache);
        free_percpu(dev->tstats);
        return err;
    }

    tunnel->dev = dev;
    tunnel->net = dev_net(dev);
    strcpy(tunnel->parms.name, dev->name);
    iph->version		= 4;
    iph->ihl		= 5;

    return 0;
}
Пример #3
0
int ip_tunnel_init(struct net_device *dev)
{
	struct ip_tunnel *tunnel = netdev_priv(dev);
	struct iphdr *iph = &tunnel->parms.iph;
	int err;

	dev->destructor	= ip_tunnel_dev_free;
	dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
	if (!dev->tstats)
		return -ENOMEM;

	err = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL);
	if (err) {
		free_percpu(dev->tstats);
		return err;
	}

	err = gro_cells_init(&tunnel->gro_cells, dev);
	if (err) {
		dst_cache_destroy(&tunnel->dst_cache);
		free_percpu(dev->tstats);
		return err;
	}

	tunnel->dev = dev;
	tunnel->net = dev_net(dev);
	strcpy(tunnel->parms.name, dev->name);
	iph->version		= 4;
	iph->ihl		= 5;

	if (tunnel->collect_md) {
		dev->features |= NETIF_F_NETNS_LOCAL;
		netif_keep_dst(dev);
	}
	return 0;
}