ip6_tunnel.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef _NET_IP6_TUNNEL_H
  2. #define _NET_IP6_TUNNEL_H
  3. #include <linux/ipv6.h>
  4. #include <linux/netdevice.h>
  5. #include <linux/if_tunnel.h>
  6. #include <linux/ip6_tunnel.h>
  7. #define IP6TUNNEL_ERR_TIMEO (30*HZ)
  8. /* capable of sending packets */
  9. #define IP6_TNL_F_CAP_XMIT 0x10000
  10. /* capable of receiving packets */
  11. #define IP6_TNL_F_CAP_RCV 0x20000
  12. /* determine capability on a per-packet basis */
  13. #define IP6_TNL_F_CAP_PER_PACKET 0x40000
  14. struct __ip6_tnl_parm {
  15. char name[IFNAMSIZ]; /* name of tunnel device */
  16. int link; /* ifindex of underlying L2 interface */
  17. __u8 proto; /* tunnel protocol */
  18. __u8 encap_limit; /* encapsulation limit for tunnel */
  19. __u8 hop_limit; /* hop limit for tunnel */
  20. __be32 flowinfo; /* traffic class and flowlabel for tunnel */
  21. __u32 flags; /* tunnel flags */
  22. struct in6_addr laddr; /* local tunnel end-point address */
  23. struct in6_addr raddr; /* remote tunnel end-point address */
  24. __be16 i_flags;
  25. __be16 o_flags;
  26. __be32 i_key;
  27. __be32 o_key;
  28. };
  29. /* IPv6 tunnel */
  30. struct ip6_tnl {
  31. struct ip6_tnl __rcu *next; /* next tunnel in list */
  32. struct net_device *dev; /* virtual device associated with tunnel */
  33. struct net *net; /* netns for packet i/o */
  34. struct __ip6_tnl_parm parms; /* tunnel configuration parameters */
  35. struct flowi fl; /* flowi template for xmit */
  36. struct dst_entry *dst_cache; /* cached dst */
  37. u32 dst_cookie;
  38. int err_count;
  39. unsigned long err_time;
  40. /* These fields used only by GRE */
  41. __u32 i_seqno; /* The last seen seqno */
  42. __u32 o_seqno; /* The last output seqno */
  43. int hlen; /* Precalculated GRE header length */
  44. int mlink;
  45. };
  46. /* Tunnel encapsulation limit destination sub-option */
  47. struct ipv6_tlv_tnl_enc_lim {
  48. __u8 type; /* type-code for option */
  49. __u8 length; /* option length */
  50. __u8 encap_limit; /* tunnel encapsulation limit */
  51. } __packed;
  52. struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t);
  53. void ip6_tnl_dst_reset(struct ip6_tnl *t);
  54. void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst);
  55. int ip6_tnl_rcv_ctl(struct ip6_tnl *t, const struct in6_addr *laddr,
  56. const struct in6_addr *raddr);
  57. int ip6_tnl_xmit_ctl(struct ip6_tnl *t);
  58. __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw);
  59. __u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr,
  60. const struct in6_addr *raddr);
  61. static inline void ip6tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
  62. {
  63. struct net_device_stats *stats = &dev->stats;
  64. int pkt_len, err;
  65. nf_reset(skb);
  66. pkt_len = skb->len;
  67. err = ip6_local_out(skb);
  68. if (net_xmit_eval(err) == 0) {
  69. struct pcpu_tstats *tstats = this_cpu_ptr(dev->tstats);
  70. u64_stats_update_begin(&tstats->syncp);
  71. tstats->tx_bytes += pkt_len;
  72. tstats->tx_packets++;
  73. u64_stats_update_end(&tstats->syncp);
  74. } else {
  75. stats->tx_errors++;
  76. stats->tx_aborted_errors++;
  77. }
  78. }
  79. #endif