blob: b3db2fd6e61cb177be7e70e5f4b57c29ed24812e [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 */
11struct ip_tunnel_6rd_parm
12{
13 struct in6_addr prefix;
14 __be32 relay_prefix;
15 u16 prefixlen;
16 u16 relay_prefixlen;
17};
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019struct ip_tunnel
20{
21 struct ip_tunnel *next;
22 struct net_device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 int err_count; /* Number of arrived ICMP errors */
25 unsigned long err_time; /* Time when the last ICMP error arrived */
26
27 /* These four fields used only by GRE */
28 __u32 i_seqno; /* The last seen seqno */
29 __u32 o_seqno; /* The last output seqno */
30 int hlen; /* Precalculated GRE header length */
31 int mlink;
32
33 struct ip_tunnel_parm parms;
YOSHIFUJI Hideaki300aaee2008-03-24 18:28:39 +090034
YOSHIFUJI Hideaki / 吉藤英明fa857af2009-09-22 23:43:14 +000035 /* for SIT */
36#ifdef CONFIG_IPV6_SIT_6RD
37 struct ip_tunnel_6rd_parm ip6rd;
38#endif
Templin, Fred Lfadf6bf2008-03-11 18:35:59 -040039 struct ip_tunnel_prl_entry *prl; /* potential router list */
YOSHIFUJI Hideaki300aaee2008-03-24 18:28:39 +090040 unsigned int prl_count; /* # of entries in PRL */
Templin, Fred Lfadf6bf2008-03-11 18:35:59 -040041};
42
43struct ip_tunnel_prl_entry
44{
45 struct ip_tunnel_prl_entry *next;
YOSHIFUJI Hideaki300aaee2008-03-24 18:28:39 +090046 __be32 addr;
47 u16 flags;
Eric Dumazetef9a9d12009-10-23 17:51:26 +000048 struct rcu_head rcu_head;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049};
50
51#define IPTUNNEL_XMIT() do { \
52 int err; \
Herbert Xu64194c32008-10-09 12:03:17 -070053 int pkt_len = skb->len - skb_transport_offset(skb); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 \
55 skb->ip_summed = CHECKSUM_NONE; \
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 ip_select_ident(iph, &rt->u.dst, NULL); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 \
Herbert Xuc439cb22008-01-11 19:14:00 -080058 err = ip_local_out(skb); \
Eric Dumazet0bfbedb2009-10-05 00:11:22 -070059 if (likely(net_xmit_eval(err) == 0)) { \
60 txq->tx_bytes += pkt_len; \
61 txq->tx_packets++; \
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 } else { \
63 stats->tx_errors++; \
64 stats->tx_aborted_errors++; \
65 } \
66} while (0)
67
Linus Torvalds1da177e2005-04-16 15:20:36 -070068#endif