ip6_tunnel.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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, const struct in6_addr *laddr,
  58. const struct in6_addr *raddr);
  59. __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw);
  60. __u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr,
  61. const struct in6_addr *raddr);
  62. struct net *ip6_tnl_get_link_net(const struct net_device *dev);
  63. int ip6_tnl_get_iflink(const struct net_device *dev);
  64. static inline void ip6tunnel_xmit(struct sock *sk, struct sk_buff *skb,
  65. struct net_device *dev)
  66. {
  67. struct net_device_stats *stats = &dev->stats;
  68. int pkt_len, err;
  69. pkt_len = skb->len;
  70. err = ip6_local_out_sk(sk, skb);
  71. if (net_xmit_eval(err) == 0) {
  72. struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
  73. u64_stats_update_begin(&tstats->syncp);
  74. tstats->tx_bytes += pkt_len;
  75. tstats->tx_packets++;
  76. u64_stats_update_end(&tstats->syncp);
  77. } else {
  78. stats->tx_errors++;
  79. stats->tx_aborted_errors++;
  80. }
  81. }
  82. #endif