7fa0b2826a6c9c4426934fb617912ba941fa3511
[openvswitch] / 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,31)
7 #define HAVE_NETDEV_QUEUE_STATS
8 #endif
9
10 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
11
12 #include <linux/if_tunnel.h>
13 #include <net/ip.h>
14
15 /* Keep error state on tunnel for 30 sec */
16 #define IPTUNNEL_ERR_TIMEO      (30*HZ)
17
18 struct ip_tunnel
19 {
20         struct ip_tunnel        *next;
21         struct net_device       *dev;
22 #ifndef HAVE_NETDEV_STATS
23         struct net_device_stats stat;
24 #endif
25
26         int                     err_count;      /* Number of arrived ICMP errors */
27         unsigned long           err_time;       /* Time when the last ICMP error arrived */
28
29         /* These four fields used only by GRE */
30         __u32                   i_seqno;        /* The last seen seqno  */
31         __u32                   o_seqno;        /* The last output seqno */
32         int                     hlen;           /* Precalculated GRE header length */
33         int                     mlink;
34
35         struct ip_tunnel_parm   parms;
36
37         struct ip_tunnel_prl_entry      *prl;           /* potential router list */
38         unsigned int                    prl_count;      /* # of entries in PRL */
39 };
40
41 /* ISATAP: default interval between RS in secondy */
42 #define IPTUNNEL_RS_DEFAULT_DELAY       (900)
43
44 struct ip_tunnel_prl_entry
45 {
46         struct ip_tunnel_prl_entry      *next;
47         __be32                          addr;
48         u16                             flags;
49         unsigned long                   rs_delay;
50         struct timer_list               rs_timer;
51         struct ip_tunnel                *tunnel;
52         spinlock_t                      lock;
53 };
54
55 #ifdef HAVE_NETDEV_QUEUE_STATS
56 #define UPDATE_TX_STATS()                                               \
57         txq->tx_bytes += pkt_len;                                       \
58         txq->tx_packets++;
59 #else
60 #define UPDATE_TX_STATS()                                               \
61         stats->tx_bytes += pkt_len;                                     \
62         stats->tx_packets++;
63 #endif
64
65 #define IPTUNNEL_XMIT() do {                                            \
66         int err;                                                        \
67         int pkt_len = skb->len - skb_transport_offset(skb);             \
68                                                                         \
69         skb->ip_summed = CHECKSUM_NONE;                                 \
70         ip_select_ident(iph, &rt->u.dst, NULL);                         \
71                                                                         \
72         err = ip_local_out(skb);                                        \
73         if (likely(net_xmit_eval(err) == 0)) {                          \
74                 UPDATE_TX_STATS();                                      \
75         } else {                                                        \
76                 stats->tx_errors++;                                     \
77                 stats->tx_aborted_errors++;                             \
78         }                                                               \
79 } while (0)
80
81 #else
82 #include_next <net/ipip.h>
83 #endif /* kernel < 2.6.32 */
84
85 #endif /* net/ipip.h wrapper */