4 #include <linux/if_tunnel.h>
5 #include <net/gro_cells.h>
8 /* Keep error state on tunnel for 30 sec */
9 #define IPTUNNEL_ERR_TIMEO (30*HZ)
11 /* 6rd prefix/relay information */
12 struct ip_tunnel_6rd_parm
{
13 struct in6_addr prefix
;
20 struct ip_tunnel __rcu
*next
;
21 struct net_device
*dev
;
23 int err_count
; /* Number of arrived ICMP errors */
24 unsigned long err_time
; /* Time when the last ICMP error arrived */
26 /* These four fields used only by GRE */
27 __u32 i_seqno
; /* The last seen seqno */
28 __u32 o_seqno
; /* The last output seqno */
29 int hlen
; /* Precalculated GRE header length */
32 struct ip_tunnel_parm parms
;
35 #ifdef CONFIG_IPV6_SIT_6RD
36 struct ip_tunnel_6rd_parm ip6rd
;
38 struct ip_tunnel_prl_entry __rcu
*prl
; /* potential router list */
39 unsigned int prl_count
; /* # of entries in PRL */
41 struct gro_cells gro_cells
;
44 struct ip_tunnel_prl_entry
{
45 struct ip_tunnel_prl_entry __rcu
*next
;
48 struct rcu_head rcu_head
;
51 static inline void iptunnel_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
54 struct iphdr
*iph
= ip_hdr(skb
);
55 int pkt_len
= skb
->len
- skb_transport_offset(skb
);
56 struct pcpu_tstats
*tstats
= this_cpu_ptr(dev
->tstats
);
59 skb
->ip_summed
= CHECKSUM_NONE
;
60 ip_select_ident(iph
, skb_dst(skb
), NULL
);
62 err
= ip_local_out(skb
);
63 if (likely(net_xmit_eval(err
) == 0)) {
64 u64_stats_update_begin(&tstats
->syncp
);
65 tstats
->tx_bytes
+= pkt_len
;
67 u64_stats_update_end(&tstats
->syncp
);
69 dev
->stats
.tx_errors
++;
70 dev
->stats
.tx_aborted_errors
++;
74 static inline void tunnel_ip_select_ident(struct sk_buff
*skb
,
75 const struct iphdr
*old_iph
,
76 struct dst_entry
*dst
)
78 struct iphdr
*iph
= ip_hdr(skb
);
80 if (iph
->frag_off
& htons(IP_DF
))
83 /* Use inner packet iph-id if possible. */
84 if (skb
->protocol
== htons(ETH_P_IP
) && old_iph
->id
)
85 iph
->id
= old_iph
->id
;
87 __ip_select_ident(iph
, dst
,
88 (skb_shinfo(skb
)->gso_segs
?: 1) - 1);