Merge branch 'master' into next
[sliver-openvswitch.git] / datapath / linux-2.6 / compat-2.6 / include / net / ipip.h
1 #ifndef __NET_IPIP_WRAPPER_H
2 #define __NET_IPIP_WRAPPER_H 1
3
4 #include <linux/version.h>
5
6 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
7
8 #include <linux/if_tunnel.h>
9 #include <net/ip.h>
10
11 /* Keep error state on tunnel for 30 sec */
12 #define IPTUNNEL_ERR_TIMEO      (30*HZ)
13
14 struct ip_tunnel
15 {
16         struct ip_tunnel        *next;
17         struct net_device       *dev;
18 #ifndef HAVE_NETDEV_STATS
19         struct net_device_stats stat;
20 #endif
21
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;
32
33         struct ip_tunnel_prl_entry      *prl;           /* potential router list */
34         unsigned int                    prl_count;      /* # of entries in PRL */
35 };
36
37 /* ISATAP: default interval between RS in secondy */
38 #define IPTUNNEL_RS_DEFAULT_DELAY       (900)
39
40 struct ip_tunnel_prl_entry
41 {
42         struct ip_tunnel_prl_entry      *next;
43         __be32                          addr;
44         u16                             flags;
45         unsigned long                   rs_delay;
46         struct timer_list               rs_timer;
47         struct ip_tunnel                *tunnel;
48         spinlock_t                      lock;
49 };
50
51 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
52 #define IPTUNNEL_XMIT() do {                                            \
53         int err;                                                        \
54         int pkt_len = skb->len - skb_transport_offset(skb);             \
55                                                                         \
56         skb->ip_summed = CHECKSUM_NONE;                                 \
57         iph->tot_len = htons(skb->len);                                 \
58         ip_select_ident(iph, &rt->u.dst, NULL);                         \
59         ip_send_check(iph);                                             \
60                                                                         \
61         err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev, dst_output);\
62         if (err == NET_XMIT_SUCCESS || err == NET_XMIT_CN) {            \
63                 stats->tx_bytes += pkt_len;                             \
64                 stats->tx_packets++;                                    \
65         } else {                                                        \
66                 stats->tx_errors++;                                     \
67                 stats->tx_aborted_errors++;                             \
68         }                                                               \
69 } while (0)
70 #else
71 #define IPTUNNEL_XMIT() do {                                            \
72         int err;                                                        \
73         int pkt_len = skb->len;                                         \
74                                                                         \
75         skb->ip_summed = CHECKSUM_NONE;                                 \
76         ip_select_ident(iph, &rt->u.dst, NULL);                         \
77                                                                         \
78         err = ip_local_out(skb);                                        \
79         if (net_xmit_eval(err) == 0) {                                  \
80                 stats->tx_bytes += pkt_len;                             \
81                 stats->tx_packets++;                                    \
82         } else {                                                        \
83                 stats->tx_errors++;                                     \
84                 stats->tx_aborted_errors++;                             \
85         }                                                               \
86 } while (0)
87 #endif
88
89 #else
90 #include_next <net/ipip.h>
91 #endif /* kernel < 2.6.32 */
92
93 #endif /* net/ipip.h wrapper */