blob: a93cf6d7e94b160dc2ad1ec061948c05713264ab [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __NET_IPIP_H
2#define __NET_IPIP_H 1
3
4#include <linux/if_tunnel.h>
Herbert Xuc439cb22008-01-11 19:14:00 -08005#include <net/ip.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
7/* Keep error state on tunnel for 30 sec */
8#define IPTUNNEL_ERR_TIMEO (30*HZ)
9
YOSHIFUJI Hideaki / 吉藤英明fa857af2009-09-22 23:43:14 +000010/* 6rd prefix/relay information */
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +000011struct ip_tunnel_6rd_parm {
YOSHIFUJI Hideaki / 吉藤英明fa857af2009-09-22 23:43:14 +000012 struct in6_addr prefix;
13 __be32 relay_prefix;
14 u16 prefixlen;
15 u16 relay_prefixlen;
16};
17
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +000018struct ip_tunnel {
Eric Dumazet6f0bcf12010-10-24 21:33:16 +000019 struct ip_tunnel __rcu *next;
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 struct net_device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 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 Hideaki300aaee2008-03-24 18:28:39 +090032
YOSHIFUJI Hideaki / 吉藤英明fa857af2009-09-22 23:43:14 +000033 /* for SIT */
34#ifdef CONFIG_IPV6_SIT_6RD
35 struct ip_tunnel_6rd_parm ip6rd;
36#endif
Eric Dumazetb33eab02010-10-25 21:01:26 +000037 struct ip_tunnel_prl_entry __rcu *prl; /* potential router list */
YOSHIFUJI Hideaki300aaee2008-03-24 18:28:39 +090038 unsigned int prl_count; /* # of entries in PRL */
Templin, Fred Lfadf6bf2008-03-11 18:35:59 -040039};
40
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +000041struct ip_tunnel_prl_entry {
Eric Dumazetb33eab02010-10-25 21:01:26 +000042 struct ip_tunnel_prl_entry __rcu *next;
YOSHIFUJI Hideaki300aaee2008-03-24 18:28:39 +090043 __be32 addr;
44 u16 flags;
Eric Dumazetef9a9d12009-10-23 17:51:26 +000045 struct rcu_head rcu_head;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046};
47
Eric Dumazet290b8952010-09-27 00:33:35 +000048#define __IPTUNNEL_XMIT(stats1, stats2) do { \
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 int err; \
Herbert Xu64194c32008-10-09 12:03:17 -070050 int pkt_len = skb->len - skb_transport_offset(skb); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 \
52 skb->ip_summed = CHECKSUM_NONE; \
Changli Gaod8d1f302010-06-10 23:31:35 -070053 ip_select_ident(iph, &rt->dst, NULL); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 \
Herbert Xuc439cb22008-01-11 19:14:00 -080055 err = ip_local_out(skb); \
Eric Dumazet0bfbedb2009-10-05 00:11:22 -070056 if (likely(net_xmit_eval(err) == 0)) { \
stephen hemminger87b6d212012-04-12 06:31:16 +000057 u64_stats_update_begin(&(stats1)->syncp); \
Eric Dumazet290b8952010-09-27 00:33:35 +000058 (stats1)->tx_bytes += pkt_len; \
59 (stats1)->tx_packets++; \
stephen hemminger87b6d212012-04-12 06:31:16 +000060 u64_stats_update_end(&(stats1)->syncp); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 } else { \
Eric Dumazet290b8952010-09-27 00:33:35 +000062 (stats2)->tx_errors++; \
63 (stats2)->tx_aborted_errors++; \
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 } \
65} while (0)
66
Eric Dumazet290b8952010-09-27 00:33:35 +000067#define IPTUNNEL_XMIT() __IPTUNNEL_XMIT(txq, stats)
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069#endif