Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __NET_IPIP_H |
| 2 | #define __NET_IPIP_H 1 |
| 3 | |
| 4 | #include <linux/if_tunnel.h> |
Herbert Xu | c439cb2 | 2008-01-11 19:14:00 -0800 | [diff] [blame] | 5 | #include <net/ip.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
| 7 | /* Keep error state on tunnel for 30 sec */ |
| 8 | #define IPTUNNEL_ERR_TIMEO (30*HZ) |
| 9 | |
YOSHIFUJI Hideaki / 吉藤英明 | fa857af | 2009-09-22 23:43:14 +0000 | [diff] [blame] | 10 | /* 6rd prefix/relay information */ |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 11 | struct ip_tunnel_6rd_parm { |
YOSHIFUJI Hideaki / 吉藤英明 | fa857af | 2009-09-22 23:43:14 +0000 | [diff] [blame] | 12 | struct in6_addr prefix; |
| 13 | __be32 relay_prefix; |
| 14 | u16 prefixlen; |
| 15 | u16 relay_prefixlen; |
| 16 | }; |
| 17 | |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 18 | struct ip_tunnel { |
Eric Dumazet | 6f0bcf1 | 2010-10-24 21:33:16 +0000 | [diff] [blame] | 19 | struct ip_tunnel __rcu *next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | struct net_device *dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | int err_count; /* Number of arrived ICMP errors */ |
| 23 | unsigned long err_time; /* Time when the last ICMP error arrived */ |
| 24 | |
| 25 | /* These four fields used only by GRE */ |
| 26 | __u32 i_seqno; /* The last seen seqno */ |
| 27 | __u32 o_seqno; /* The last output seqno */ |
| 28 | int hlen; /* Precalculated GRE header length */ |
| 29 | int mlink; |
| 30 | |
| 31 | struct ip_tunnel_parm parms; |
YOSHIFUJI Hideaki | 300aaee | 2008-03-24 18:28:39 +0900 | [diff] [blame] | 32 | |
YOSHIFUJI Hideaki / 吉藤英明 | fa857af | 2009-09-22 23:43:14 +0000 | [diff] [blame] | 33 | /* for SIT */ |
| 34 | #ifdef CONFIG_IPV6_SIT_6RD |
| 35 | struct ip_tunnel_6rd_parm ip6rd; |
| 36 | #endif |
Eric Dumazet | b33eab0 | 2010-10-25 21:01:26 +0000 | [diff] [blame] | 37 | struct ip_tunnel_prl_entry __rcu *prl; /* potential router list */ |
YOSHIFUJI Hideaki | 300aaee | 2008-03-24 18:28:39 +0900 | [diff] [blame] | 38 | unsigned int prl_count; /* # of entries in PRL */ |
Templin, Fred L | fadf6bf | 2008-03-11 18:35:59 -0400 | [diff] [blame] | 39 | }; |
| 40 | |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 41 | struct ip_tunnel_prl_entry { |
Eric Dumazet | b33eab0 | 2010-10-25 21:01:26 +0000 | [diff] [blame] | 42 | struct ip_tunnel_prl_entry __rcu *next; |
YOSHIFUJI Hideaki | 300aaee | 2008-03-24 18:28:39 +0900 | [diff] [blame] | 43 | __be32 addr; |
| 44 | u16 flags; |
Eric Dumazet | ef9a9d1 | 2009-10-23 17:51:26 +0000 | [diff] [blame] | 45 | struct rcu_head rcu_head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | }; |
| 47 | |
Eric Dumazet | 290b895 | 2010-09-27 00:33:35 +0000 | [diff] [blame] | 48 | #define __IPTUNNEL_XMIT(stats1, stats2) do { \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | int err; \ |
Herbert Xu | 64194c3 | 2008-10-09 12:03:17 -0700 | [diff] [blame] | 50 | int pkt_len = skb->len - skb_transport_offset(skb); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | \ |
| 52 | skb->ip_summed = CHECKSUM_NONE; \ |
Changli Gao | d8d1f30 | 2010-06-10 23:31:35 -0700 | [diff] [blame] | 53 | ip_select_ident(iph, &rt->dst, NULL); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | \ |
Herbert Xu | c439cb2 | 2008-01-11 19:14:00 -0800 | [diff] [blame] | 55 | err = ip_local_out(skb); \ |
Eric Dumazet | 0bfbedb | 2009-10-05 00:11:22 -0700 | [diff] [blame] | 56 | if (likely(net_xmit_eval(err) == 0)) { \ |
stephen hemminger | 87b6d21 | 2012-04-12 06:31:16 +0000 | [diff] [blame] | 57 | u64_stats_update_begin(&(stats1)->syncp); \ |
Eric Dumazet | 290b895 | 2010-09-27 00:33:35 +0000 | [diff] [blame] | 58 | (stats1)->tx_bytes += pkt_len; \ |
| 59 | (stats1)->tx_packets++; \ |
stephen hemminger | 87b6d21 | 2012-04-12 06:31:16 +0000 | [diff] [blame] | 60 | u64_stats_update_end(&(stats1)->syncp); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | } else { \ |
Eric Dumazet | 290b895 | 2010-09-27 00:33:35 +0000 | [diff] [blame] | 62 | (stats2)->tx_errors++; \ |
| 63 | (stats2)->tx_aborted_errors++; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | } \ |
| 65 | } while (0) |
| 66 | |
Eric Dumazet | 290b895 | 2010-09-27 00:33:35 +0000 | [diff] [blame] | 67 | #define IPTUNNEL_XMIT() __IPTUNNEL_XMIT(txq, stats) |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #endif |