ipip.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef __NET_IPIP_H
  2. #define __NET_IPIP_H 1
  3. #include <linux/if_tunnel.h>
  4. #include <net/gro_cells.h>
  5. #include <net/ip.h>
  6. /* Keep error state on tunnel for 30 sec */
  7. #define IPTUNNEL_ERR_TIMEO (30*HZ)
  8. /* 6rd prefix/relay information */
  9. struct ip_tunnel_6rd_parm {
  10. struct in6_addr prefix;
  11. __be32 relay_prefix;
  12. u16 prefixlen;
  13. u16 relay_prefixlen;
  14. };
  15. struct ip_tunnel {
  16. struct ip_tunnel __rcu *next;
  17. struct net_device *dev;
  18. int err_count; /* Number of arrived ICMP errors */
  19. unsigned long err_time; /* Time when the last ICMP error arrived */
  20. /* These four fields used only by GRE */
  21. __u32 i_seqno; /* The last seen seqno */
  22. __u32 o_seqno; /* The last output seqno */
  23. int hlen; /* Precalculated GRE header length */
  24. int mlink;
  25. struct ip_tunnel_parm parms;
  26. /* for SIT */
  27. #ifdef CONFIG_IPV6_SIT_6RD
  28. struct ip_tunnel_6rd_parm ip6rd;
  29. #endif
  30. struct ip_tunnel_prl_entry __rcu *prl; /* potential router list */
  31. unsigned int prl_count; /* # of entries in PRL */
  32. struct gro_cells gro_cells;
  33. };
  34. struct ip_tunnel_prl_entry {
  35. struct ip_tunnel_prl_entry __rcu *next;
  36. __be32 addr;
  37. u16 flags;
  38. struct rcu_head rcu_head;
  39. };
  40. static inline void iptunnel_xmit(struct sk_buff *skb, struct net_device *dev)
  41. {
  42. int err;
  43. int pkt_len = skb->len - skb_transport_offset(skb);
  44. struct pcpu_tstats *tstats = this_cpu_ptr(dev->tstats);
  45. nf_reset(skb);
  46. err = ip_local_out(skb);
  47. if (likely(net_xmit_eval(err) == 0)) {
  48. u64_stats_update_begin(&tstats->syncp);
  49. tstats->tx_bytes += pkt_len;
  50. tstats->tx_packets++;
  51. u64_stats_update_end(&tstats->syncp);
  52. } else {
  53. dev->stats.tx_errors++;
  54. dev->stats.tx_aborted_errors++;
  55. }
  56. }
  57. static inline void tunnel_ip_select_ident(struct sk_buff *skb,
  58. const struct iphdr *old_iph,
  59. struct dst_entry *dst)
  60. {
  61. struct iphdr *iph = ip_hdr(skb);
  62. /* Use inner packet iph-id if possible. */
  63. if (skb->protocol == htons(ETH_P_IP) && old_iph->id)
  64. iph->id = old_iph->id;
  65. else
  66. __ip_select_ident(iph, dst,
  67. (skb_shinfo(skb)->gso_segs ?: 1) - 1);
  68. }
  69. #endif