ip6_tunnel.h 3.0 KB

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