ipip.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. struct iphdr *iph = ip_hdr(skb);
  44. int pkt_len = skb->len - skb_transport_offset(skb);
  45. struct pcpu_tstats *tstats = this_cpu_ptr(dev->tstats);
  46. nf_reset(skb);
  47. skb->ip_summed = CHECKSUM_NONE;
  48. ip_select_ident(iph, skb_dst(skb), NULL);
  49. err = ip_local_out(skb);
  50. if (likely(net_xmit_eval(err) == 0)) {
  51. u64_stats_update_begin(&tstats->syncp);
  52. tstats->tx_bytes += pkt_len;
  53. tstats->tx_packets++;
  54. u64_stats_update_end(&tstats->syncp);
  55. } else {
  56. dev->stats.tx_errors++;
  57. dev->stats.tx_aborted_errors++;
  58. }
  59. }
  60. #endif