/* * IPv6 over IPv4 tunnel device - Simple Internet Transition (SIT) * Linux INET6 implementation * * Authors: * Pedro Roque <roque@di.fc.ul.pt> * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * * Changes: * Roger Venning <r.venning@telstra.com>: 6to4 support * Nate Thompson <nate@thebog.net>: 6to4 support * Fred Templin <fred.l.templin@boeing.com>: isatap support */#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt#include<linux/module.h>#include<linux/capability.h>#include<linux/errno.h>#include<linux/types.h>#include<linux/socket.h>#include<linux/sockios.h>#include<linux/net.h>#include<linux/in6.h>#include<linux/netdevice.h>#include<linux/if_arp.h>#include<linux/icmp.h>#include<linux/slab.h>#include<asm/uaccess.h>#include<linux/init.h>#include<linux/netfilter_ipv4.h>#include<linux/if_ether.h>#include<net/sock.h>#include<net/snmp.h>#include<net/ipv6.h>#include<net/protocol.h>#include<net/transp_v6.h>#include<net/ip6_fib.h>#include<net/ip6_route.h>#include<net/ndisc.h>#include<net/addrconf.h>#include<net/ip.h>#include<net/udp.h>#include<net/icmp.h>#include<net/ipip.h>#include<net/inet_ecn.h>#include<net/xfrm.h>#include<net/dsfield.h>#include<net/net_namespace.h>#include<net/netns/generic.h>/* This version of net/ipv6/sit.c is cloned of net/ipv4/ip_gre.c For comments look at net/ipv4/ip_gre.c --ANK */#define HASH_SIZE 16#define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF)staticintipip6_tunnel_init(structnet_device*dev);staticvoidipip6_tunnel_setup(structnet_device*dev);staticvoidipip6_dev_free(structnet_device*dev);staticintsit_net_id__read_mostly;structsit_net{structip_tunnel__rcu*tunnels_r_l[HASH_SIZE];structip_tunnel__rcu*tunnels_r[HASH_SIZE];structip_tunnel__rcu*tunnels_l[HASH_SIZE];structip_tunnel__rcu*tunnels_wc[1];structip_tunnel__rcu**tunnels[4];structnet_device*fb_tunnel_dev;};/* * Locking : hash tables are protected by RCU and RTNL */#define for_each_ip_tunnel_rcu(start) \ for (t = rcu_dereference(start); t; t = rcu_dereference(t->next))/* often modified stats are per cpu, other are shared (netdev->stats) */structpcpu_tstats{u64rx_packets;u64rx_bytes;u64tx_packets;u64tx_bytes;structu64_stats_syncsyncp;};staticstructrtnl_link_stats64*ipip6_get_stats64(structnet_device*dev,structrtnl_link_stats64*tot){inti;for_each_possible_cpu(i){conststructpcpu_tstats*tstats=per_cpu_ptr(