blob: 0159221a85093074f26fcbdbd487f0431504a28a [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
10struct ip_tunnel
11{
12 struct ip_tunnel *next;
13 struct net_device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 int err_count; /* Number of arrived ICMP errors */
16 unsigned long err_time; /* Time when the last ICMP error arrived */
17
18 /* These four fields used only by GRE */
19 __u32 i_seqno; /* The last seen seqno */
20 __u32 o_seqno; /* The last output seqno */
21 int hlen; /* Precalculated GRE header length */
22 int mlink;
23
24 struct ip_tunnel_parm parms;
YOSHIFUJI Hideaki300aaee2008-03-24 18:28:39 +090025
Templin, Fred Lfadf6bf2008-03-11 18:35:59 -040026 struct ip_tunnel_prl_entry *prl; /* potential router list */
YOSHIFUJI Hideaki300aaee2008-03-24 18:28:39 +090027 unsigned int prl_count; /* # of entries in PRL */
Templin, Fred Lfadf6bf2008-03-11 18:35:59 -040028};
29
30struct ip_tunnel_prl_entry
31{
32 struct ip_tunnel_prl_entry *next;
YOSHIFUJI Hideaki300aaee2008-03-24 18:28:39 +090033 __be32 addr;
34 u16 flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035};
36
37#define IPTUNNEL_XMIT() do { \
38 int err; \
Herbert Xu64194c32008-10-09 12:03:17 -070039 int pkt_len = skb->len - skb_transport_offset(skb); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 \
41 skb->ip_summed = CHECKSUM_NONE; \
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ip_select_ident(iph, &rt->u.dst, NULL); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 \
Herbert Xuc439cb22008-01-11 19:14:00 -080044 err = ip_local_out(skb); \
Eric Dumazet0bfbedb2009-10-05 00:11:22 -070045 if (likely(net_xmit_eval(err) == 0)) { \
46 txq->tx_bytes += pkt_len; \
47 txq->tx_packets++; \
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 } else { \
49 stats->tx_errors++; \
50 stats->tx_aborted_errors++; \
51 } \
52} while (0)
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#endif