ipip.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef __NET_IPIP_H
  2. #define __NET_IPIP_H 1
  3. #include <linux/if_tunnel.h>
  4. #include <net/ip.h>
  5. #include <net/ip_vs.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. };
  33. struct ip_tunnel_prl_entry {
  34. struct ip_tunnel_prl_entry __rcu *next;
  35. __be32 addr;
  36. u16 flags;
  37. struct rcu_head rcu_head;
  38. };
  39. #define __IPTUNNEL_XMIT(stats1, stats2) do { \
  40. int err; \
  41. int pkt_len = skb->len - skb_transport_offset(skb); \
  42. \
  43. skb->ip_summed = CHECKSUM_NONE; \
  44. ip_select_ident(dev_net(rt->dst.dev), skb, NULL); \
  45. \
  46. err = ip_local_out(skb); \
  47. if (likely(net_xmit_eval(err) == 0)) { \
  48. u64_stats_update_begin(&(stats1)->syncp); \
  49. (stats1)->tx_bytes += pkt_len; \
  50. (stats1)->tx_packets++; \
  51. u64_stats_update_end(&(stats1)->syncp); \
  52. } else { \
  53. (stats2)->tx_errors++; \
  54. (stats2)->tx_aborted_errors++; \
  55. } \
  56. } while (0)
  57. #define IPTUNNEL_XMIT() __IPTUNNEL_XMIT(txq, stats)
  58. #endif