| 1 | #ifndef __NET_IPIP_H
|
| 2 | #define __NET_IPIP_H 1
|
| 3 |
|
| 4 | #include <linux/if_tunnel.h>
|
| 5 | #include <net/gro_cells.h>
|
| 6 | #include <net/ip.h>
|
| 7 |
|
| 8 |
|
| 9 | #define IPTUNNEL_ERR_TIMEO (30*HZ)
|
| 10 |
|
| 11 |
|
| 12 | struct ip_tunnel_6rd_parm {
|
| 13 | struct in6_addr prefix;
|
| 14 | __be32 relay_prefix;
|
| 15 | u16 prefixlen;
|
| 16 | u16 relay_prefixlen;
|
| 17 | };
|
| 18 |
|
| 19 | struct ip_tunnel {
|
| 20 | struct ip_tunnel __rcu *next;
|
| 21 | struct net_device *dev;
|
| 22 |
|
| 23 | int err_count;
|
| 24 | unsigned long err_time;
|
| 25 |
|
| 26 |
|
| 27 | __u32 i_seqno;
|
| 28 | __u32 o_seqno;
|
| 29 | int hlen;
|
| 30 | int mlink;
|
| 31 |
|
| 32 | struct ip_tunnel_parm parms;
|
| 33 |
|
| 34 |
|
| 35 | #ifdef CONFIG_IPV6_SIT_6RD
|
| 36 | struct ip_tunnel_6rd_parm ip6rd;
|
| 37 | #endif
|
| 38 | struct ip_tunnel_prl_entry __rcu *prl;
|
| 39 | unsigned int prl_count;
|
| 40 |
|
| 41 | struct gro_cells gro_cells;
|
| 42 | };
|
| 43 |
|
| 44 | struct ip_tunnel_prl_entry {
|
| 45 | struct ip_tunnel_prl_entry __rcu *next;
|
| 46 | __be32 addr;
|
| 47 | u16 flags;
|
| 48 | struct rcu_head rcu_head;
|
| 49 | };
|
| 50 |
|
| 51 | static inline void iptunnel_xmit(struct sk_buff *skb, struct net_device *dev)
|
| 52 | {
|
| 53 | int err;
|
| 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);
|
| 57 |
|
| 58 | nf_reset(skb);
|
| 59 | skb->ip_summed = CHECKSUM_NONE;
|
| 60 | ip_select_ident(iph, skb_dst(skb), NULL);
|
| 61 |
|
| 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;
|
| 66 | tstats->tx_packets++;
|
| 67 | u64_stats_update_end(&tstats->syncp);
|
| 68 | } else {
|
| 69 | dev->stats.tx_errors++;
|
| 70 | dev->stats.tx_aborted_errors++;
|
| 71 | }
|
| 72 | }
|
| 73 |
|
| 74 | static inline void tunnel_ip_select_ident(struct sk_buff *skb,
|
| 75 | const struct iphdr *old_iph,
|
| 76 | struct dst_entry *dst)
|
| 77 | {
|
| 78 | struct iphdr *iph = ip_hdr(skb);
|
| 79 |
|
| 80 |
|
| 81 | if (skb->protocol == htons(ETH_P_IP) && old_iph->id)
|
| 82 | iph->id = old_iph->id;
|
| 83 | else
|
| 84 | __ip_select_ident(iph, dst,
|
| 85 | (skb_shinfo(skb)->gso_segs ?: 1) - 1);
|
| 86 | }
|
| 87 | #endif
|